Results 1 to 6 of 6

Thread: GPSFS, Java and some troubles

                  
   
  1. #1
    DCEmu Newbie
    Join Date
    Jun 2007
    Posts
    9
    Rep Power
    0

    Default GPSFS, Java and some troubles

    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:
    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]; 
    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.

    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.

  2. #2
    DCEmu Regular
    Join Date
    Feb 2007
    Posts
    448
    Rep Power
    29

    Default

    Your stud.tuwien.at image isn't working.

  3. #3
    PSP Coder deniska's Avatar
    Join Date
    Jul 2005
    Posts
    1,557
    Rep Power
    40

    Default

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

  4. #4
    PSP Coder deniska's Avatar
    Join Date
    Jul 2005
    Posts
    1,557
    Rep Power
    40

    Default

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

  5. #5
    DCEmu Newbie
    Join Date
    Jun 2007
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by deniska View Post
    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.
    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 latdouble lonint zoomLl ) {
        
    int x,y;
        
    int zoomLevel=zoomLl;
        if (
    zoomLevel<0zoomLevel=zoomLevel*(-1)+17;
         
    x= (int)(bitmapOrigo[zoomLevel] + lon pixelsPerLonDegree[zoomLevel]);
         
    x/=256;
                    
    double e sin(lat Wa);

                    if (
    0.9999) {
                            
    0.9999;
                    }

                    if (
    < -0.9999) {
                            
    = -0.9999;
                    }

                    
    = (int)(bitmapOrigo[zoomLevel] + 0.5
                                    
    log((e) / (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 latdouble lonint zoom) {
        
    Coord c;
        
    long x,y;
        
    int zoomLevel=zoom;
            if (
    zoomLevel<0zoomLevel=zoomLevel*(-1)+17;

         
    x= (long)(bitmapOrigo[zoomLevel] + lon pixelsPerLonDegree[zoomLevel]);
         
    x/=256;
                    
    double e sin(lat Wa);

                    if (
    0.9999) {
                            
    0.9999;
                    }

                    if (
    < -0.9999) {
                            
    = -0.9999;
                    }

                    
    = (long)(bitmapOrigo[zoomLevel] + 0.5
                                    
    log((e) / (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;



  6. #6
    PSP Coder deniska's Avatar
    Join Date
    Jul 2005
    Posts
    1,557
    Rep Power
    40

    Default

    check out this page: http://mapki.com/wiki/Knowledge_Base

    They should have some java api samples already

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •