aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc/UTFGrid.java
blob: cf490ec99186d260a8f1b365e261ef0bfdf7c124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cgeo.geocaching.connector.gc;

/**
 *
 * @author blafoo
 *
 * @see https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md
 *
 */
public final class UTFGrid {

    public static final int GRID_MAXX = 63;
    public static final int GRID_MAXY = 63;

    /**
     * Convert a value from a JSON grid object into an id that can be used as an index
     * It's not used at the moment due to optimizations.
     * But maybe we need it some day...
     */
    public static short getUTFGridId(final char value) {
        short result = (short) value;
        if (result >= 93) {
            result--;
        }
        if (result >= 35) {
            result--;
        }
        return (short) (result - 32);
    }

}