Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   help mapping latitude, longitude in svg (http://www.programmingforums.org/showthread.php?t=14167)

hardc0d3r Oct 17th, 2007 2:00 PM

help mapping latitude, longitude in svg
 
this is a general programming question but i'm using java so i'm posting it here...

i am trying to map geographical coordinates in a plane. given are 2 geographical points (latitude longitude), the width and height of the svg in pixels and a third geographical point. given the values, i would like to know what will be the coordinates of the third geographical point in the svg... i am having trouble finding a right formula for this one.. what i did is i subtract lat1 from lat2 and given the difference, i divided it with the width of the svg file. i am thinking that this will give me n decimal per pixel... to be able to map the third geographical point in the svg, i subtracted lat1 from the latitude of the third point and divided it with the n decimal per pixel... i think that my math is right but apparently it's not.. please correct me because the coordinates is way off.. :confused: thanks..

http://i163.photobucket.com/albums/t...lustration.png

please help me!!!

andro Oct 17th, 2007 10:32 PM

Re: help mapping latitude, longitude in svg
 
OK, based on that drawing, I've come up with this.

:

latRatio = newLat/(lat2-lat1)
longRatio = newLong/(long1-long2)



This is specialized to those particular coordinates, but you can look at it like this....

If you used the first 2 coordinates to form a rectangle, then it would be:

:

latRatio = newLat/recWidth
longRatio = newLong/recHeight


Basically, just finding a ratio of how far in the 3rd point is in the x direction, how far in the y direction.

Then apply it to the SVG dimensions to find the coordinates.

:

newCoordX = latRatio * svgWidth
newCoordY = longRatio * svgHeight



All times are GMT -5. The time now is 3:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC