Shri Sawarkar

Shri Sawarkar

  • NA
  • 9
  • 48.4k

finding the city by Easting/Nothing

Jan 19 2011 8:10 AM
Hi all...
I am having a question for finding the city by x/y i.e. Easting/Nothing coordinates.
I have a database table for city,easting,northing,zipcode columns.
I want to search the city within particular radius from given city. I got the solution for finding by longitude/latitude as
creating a function in database :-

ALTER FUNCTION [dbo].[GetCityByRadius](@Radius INT,@CityID INT)
RETURNS @RTN TABLE (SVALUE  INT)
AS
BEGIN
    INSERT INTO @RTN
    SELECT t1.ID AS ID
    FROM tbl_City t1
    JOIN tbl_City t2 ON (3963.0*acos(sin(t1.Latitude/(180/PI())) * sin(t2.Latitude/(180/PI())) + cos(t1.Latitude/(180/PI())) * cos(t2.Latitude/(180/PI())) *  cos(t2.Longitude/(180/PI())-t1.Longitude/(180/PI())))<@Radius)
    WHERE t2.City= (SELECT City FROM tbl_City WHERE ID = @CityID)
RETURN
END

 this is for longitude/latitude......the same I want for easting/northing.....Please suggest me for the solution.
Thanks in advance.