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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Geometry Question

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,699
    Thanks
    25
    Thanked 334 Times in 310 Posts

    Default 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.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,358
    Thanks
    182
    Thanked 834 Times in 777 Posts
    Blog Entries
    5

    Default 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..

Similar Threads

  1. Geometry/Trigonometry Question
    By barrett777 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 30th, 2010, 06:48 AM