Your stud.tuwien.at image isn't working.
Hello,
im writing a little programm with java, where i want to see my position on a map.
so i decide to use GMDL.
first i have to thank for this great tool :thumbup:
i also have to thank for the detailed description of GPSFS at the end of the sourcefile
(but there seems to be a little error. there says, that the IDX begins with the highest zoom level, but it begins with the lowest zoomlevel )
however, i now can draw the map at my current position. but i have trouble with the exact positioning on the drawed map.
for better understanding a little example:
My GPS-Position is: 48.3767 16.2426
if i search this coordinates on maps.google.com i get the exact position on the freeway:
http://maps.google.com/maps?f=q&hl=e...wloc=addr&om=1
but if i draw the map on my own, im a little bit outside or on the border of the freeway:
http://stud3.tuwien.ac.at/~e0025170/...s_position.jpg
i don't know much thing about the projection. i just 'translate' the code to get the gps-position of the downloaded map from the X-Y pair from the sourcecode of mapthis.
(getLatLong, getTileCoord, initLatLong)
Any idea, why the position could be not exact?
I do following to compute the position on the map:
1) i compute the coordinates of the upper-left and the lower-right corner of the image:
2) i find the 256*256 part, where my incoming GPS-Position is and draw it, with the surrounding parts in a 768*768 image.PHP Code:
xLeft = getLatLong( (int)X, (int)(Y-1), 0)[1];
xRight = getLatLong( (int)(X+filesPerLine[zoomlevel]), (int)(Y+filesPerLine[zoomlevel]-1), 0)[1];
yTop = getLatLong( (int)X, (int)(Y-1), 0)[0];
yBottom = getLatLong( (int)(X+filesPerLine[zoomlevel]), (int)(Y+filesPerLine[zoomlevel]-1), 0)[0];
3) i compute the position in this little image, and get a 300*300 pixel part of it.
4) my position should now be exact at the center of this 300*300 pixel, but it's not
sorry for my bad english and thanks in advance,
Ahmet Y.
Your stud.tuwien.at image isn't working.
It's hard to speculate on what's going on without seeing the actual code.. Perhaps that little error comes from assumtion of linear dependency between lon/lat and the coordinates inside that tile.
Or perhaps, some error kicks in when the JRE rounds things up..
MapThis! seems to render the coordinates just like google maps (see below).. so you error comes from either different round up algorithm or some faulty logic..
well, i really assume that lon/lat are linear in a tile.
do you have any helpfull links for me, where i can "easily" learn how to compute the exact position on the mercator projection?
(or a good introduction into this area)
do i have to use these two methods from your main.c ?
PHP Code:
//puts x value in Coord.lon and y value in Coord.lat
Coord getTileCoord(double lat, double lon, int zoomLl ) {
int x,y;
int zoomLevel=zoomLl;
if (zoomLevel<0) zoomLevel=zoomLevel*(-1)+17;
x= (int)(bitmapOrigo[zoomLevel] + lon * pixelsPerLonDegree[zoomLevel]);
x/=256;
double e = sin(lat * Wa);
if (e > 0.9999) {
e = 0.9999;
}
if (e < -0.9999) {
e = -0.9999;
}
y = (int)(bitmapOrigo[zoomLevel] + 0.5
* log((1 + e) / (1 - e)) * -1
* (pixelsPerLonRadian[zoomLevel]));
y/=256;
Coord cc;
cc.lon=x;
cc.lat=y;
return cc;
}
//puts x value in Coord.lon and y value in Coord.lat
Coord getXY(double lat, double lon, int zoom) {
Coord c;
long x,y;
int zoomLevel=zoom;
if (zoomLevel<0) zoomLevel=zoomLevel*(-1)+17;
x= (long)(bitmapOrigo[zoomLevel] + lon * pixelsPerLonDegree[zoomLevel]);
x/=256;
double e = sin(lat * Wa);
if (e > 0.9999) {
e = 0.9999;
}
if (e < -0.9999) {
e = -0.9999;
}
y = (long)(bitmapOrigo[zoomLevel] + 0.5
* log((1 + e) / (1 - e)) * -1
* (pixelsPerLonRadian[zoomLevel]));
y/=256;
c=getLatLong(x,y,basezoom);
c.lon=(x-ftx)*TILE_SIZE+(lon-c.lon)*TILE_SIZE/c.lonWidth;
c.lat=(y-fty)*TILE_SIZE+(c.lat-lat)*TILE_SIZE/c.latHeight+TILE_SIZE;
return c;
}
check out this page: http://mapki.com/wiki/Knowledge_Base
They should have some java api samples already
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks