Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.

Get a Professional Answer

Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.

100% Satisfaction Guarantee

Rate the answer you receive.

Ask Russell H. Your Own Question

Russell H., Programmer & Coder

Category: Programming

Satisfied Customers: 9547

Experience: Programmer & Coder

13568747

Type Your Programming Question Here...

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

Share this conversation

Customer:replied 1 year ago.

SELECT top 6 locnum, hbr, lat, long, distance FROM ( SELECT z.locnum, z.hbr, z.lat, z.long, p.radius, p.distance_unit * DEGREES(ACOS(COS(RADIANS(p.latpoint)) * COS(RADIANS(z.lat)) * COS(RADIANS(p.longpoint - z.long)) + SIN(RADIANS(p.latpoint)) * SIN(RADIANS(z.lat)))) AS distance 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 BETWEEN p.longpoint - (p.radius / (p.distance_unit * COS(RADIANS(p.latpoint)))) AND p.longpoint + (p.radius / (p.distance_unit * COS(RADIANS(p.latpoint)))) ) 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

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.