Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Geometry Question

I'm not sure where to put this in the forum, so I figured Theory and Questions would be fine. I have a Geometry Question that is related to a JAVA program I am making.

Ok, I am pulling a Map from online (OpenStreetMap). The query to get the online image of the map I want accepts the following parameters:
Longitiude -> Map Coordinate of Center Point
Latitude -> Map Coordinate of Center Point
Zoom -> Closeness of Image
Width -> Width (in pixels) of Desired Image
Height -> Height (int pixels) of Desired Image

Now, the user will provide the program with 2 or more coordinates. The goal of the geometry question is to retrieve a map where all of the provided coordinates are shown.

For example, the user provides:
Coordinate 1:
Longitude: 33.38
Latitude: -84.25

Coordinate 2:
Longitude: 28.25
Latitude: -81.18

The Width and Height of the Desired Map is constant. My problem is figuring out the Zoom Factor. To get the Center Coordinate, I figure I will get the largest and smallest Longitude, and the largest and smallest Latitude and average each together respectfully to get a Center Coordinate. But that doesn't help me if the zoom is wrong.

I'm unsure of too much with the zoom, but here is what I know:
Zoom Factor of 11: ~1 inch = 5km
Zoom Factor of 10: ~1 inch = 10km
Zoom Factor of 9: ~1 inch = 20km
Zoom Factor of 8: ~1 inch = 50km
Zoom Factor of 7: ~1 inch = 100km
Zoom Factor of 6: ~1 inch = 200km

Is anyone able to help me figure out some sort of formula to determine the Zoom Factor based the distance between the two Coordinates? I suspect that 1 inch on my screen is around 100 pixels, but I don't really know right now. Also, the Zoom Factor can be a double. So I guess I need to be able to do two things. 1) Turn Coordinates into Distance (miles or km) and 2) Calculate the Zoom accordingly.

Any help is appreciated. I'll provide what additional information is necessary.

2. ## Re: Geometry Question

First, calculate the center point, this is the point to feed to the query. Second, calculate the distance in miles between the two points (see Distance Calculations). Round this value up and to the nearest zoom factor in km, then translate into the actual zoom factor value for the query..