Ignore:
Timestamp:
2009-11-09T21:32:12+01:00 (14 years ago)
Author:
jttt
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java

    r2263 r2422  
    22package org.openstreetmap.josm.data.coor;
    33
    4 import org.openstreetmap.josm.data.osm.Node;
    5 
    6 import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.projection.Projection;
    84
    95public class QuadTiling
     
    4137            //    out("shift: " + shift + " bits: " + bits);
    4238            // remember x is the MSB
    43             if ((bits & 0x2) != 0)
     39            if ((bits & 0x2) != 0) {
    4440                x += x_unit;
    45             if ((bits & 0x1) != 0)
     41            }
     42            if ((bits & 0x1) != 0) {
    4643                y += y_unit;
     44            }
    4745            x_unit /= 2;
    4846            y_unit /= 2;
     
    5553    static long xy2tile(long x, long y)
    5654    {
    57        long tile = 0;
    58        int i;
    59        for (i = NR_LEVELS-1; i >= 0; i--)
    60        {
     55        long tile = 0;
     56        int i;
     57        for (i = NR_LEVELS-1; i >= 0; i--)
     58        {
    6159            long xbit = ((x >> i) & 1);
    6260            long ybit = ((y >> i) & 1);
     
    6462            // Note that x is the MSB
    6563            tile |= (xbit<<1) | ybit;
    66        }
    67        return tile;
     64        }
     65        return tile;
    6866    }
    6967    static long coorToTile(LatLon coor)
     
    7371    static long lon2x(double lon)
    7472    {
    75        //return Math.round((lon + 180.0) * QuadBuckets.WORLD_PARTS / 360.0)-1;
    76        long ret = (long)Math.floor((lon + 180.0) * WORLD_PARTS / 360.0);
    77        if (ret == WORLD_PARTS)
    78            ret--;
    79        return ret;
     73        //return Math.round((lon + 180.0) * QuadBuckets.WORLD_PARTS / 360.0)-1;
     74        long ret = (long)Math.floor((lon + 180.0) * WORLD_PARTS / 360.0);
     75        if (ret == WORLD_PARTS) {
     76            ret--;
     77        }
     78        return ret;
    8079    }
    8180    static long lat2y(double lat)
    8281    {
    83        //return Math.round((lat + 90.0) * QuadBuckets.WORLD_PARTS / 180.0)-1;
    84        long ret = (long)Math.floor((lat + 90.0) * WORLD_PARTS / 180.0);
    85        if (ret == WORLD_PARTS)
    86            ret--;
    87        return ret;
     82        //return Math.round((lat + 90.0) * QuadBuckets.WORLD_PARTS / 180.0)-1;
     83        long ret = (long)Math.floor((lat + 90.0) * WORLD_PARTS / 180.0);
     84        if (ret == WORLD_PARTS) {
     85            ret--;
     86        }
     87        return ret;
    8888    }
    8989    static public long quadTile(LatLon coor)
    9090    {
    9191        return xy2tile(lon2x(coor.lon()),
    92                        lat2y(coor.lat()));
     92                lat2y(coor.lat()));
    9393    }
    9494    static public int index(int level, long quad)
Note: See TracChangeset for help on using the changeset viewer.