• 100% Satisfaction Guarantee
Russell H., Programmer & Coder
Category: Programming
Satisfied Customers: 10642
Experience:  Programmer & Coder
13568747
Russell H. is online now

# I need to find the 4 coordinates that are a bounding box

### Customer Question

I need to find the 4 coordinates that are a bounding box around a lat,long point I give the sql query and the first point must be the closest within .005 degrees or greater. The bounding box is based on a grid table. I need to find 4 points that are equal in distance on the latitude line and longitude.
Submitted: 1 year ago.
Category: Programming
Customer: replied 1 year ago.
SELECT top 6 locnum, hbr,
lat, long, distance
FROM (
SELECT z.locnum,
z.hbr,
z.lat, z.long,
p.distance_unit
FROM MyGRID AS z
JOIN ( /* these are the query parameters 28.03732, -97.51765 */
SELECT 28.03732 AS latpoint, -97.51765 AS longpoint,
50 AS radius, 111.045 AS distance_unit
) AS p ON 1=1
WHERE z.lat
BETWEEN p.latpoint - (p.radius / p.distance_unit)
AND p.latpoint + (p.radius / p.distance_unit)
AND z.long
) AS d
WHERE distance >= .005
ORDER BY distanceResult set:
28.0375 -97.5175
28.0375 -97.5225
28.0375 -97.5125
28.0325 -97.5175
28.0425 -97.5175
28.0325 -97.5225
Expert:  Russell H. replied 1 year ago.

Hi, thank you for contacting JustAnswer.com. My name is Russell. I will do what I can to provide the right answer to your question.

I think that the basics of what you are asking about is

1: given a coordinate set 'a' and 'b' for lat. and long., your bounding box would be roughly

a+x, b+x

a+x, b-x

a-x, b+x

a-x, b-x

where 'x' is about .005 degrees.

and

2. use of the 'NEAR' keyword might provide a match-up of specific coordinate values, once you have the values mentioned in (1) to 'NEAR'-match to them.