blob: 89a3de827b7d48cbc7f36ad3dc04f1d4b40140c6 (
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
|
package cgeo.geocaching.connector.gc;
import java.util.List;
/**
*
* @see <a href="https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md">Mapbox</a>
*
*/
public final class UTFGrid {
public static final int GRID_MAXX = 63;
public static final int GRID_MAXY = 63;
/** Calculate from a list of positions (x/y) the coords */
public static UTFGridPosition getPositionInGrid(List<UTFGridPosition> positions) {
int minX = GRID_MAXX;
int maxX = 0;
int minY = GRID_MAXY;
int maxY = 0;
for (UTFGridPosition pos : positions) {
minX = Math.min(minX, pos.x);
maxX = Math.max(maxX, pos.x);
minY = Math.min(minY, pos.y);
maxY = Math.max(maxY, pos.y);
}
return new UTFGridPosition((minX + maxX) / 2, (minY + maxY) / 2);
}
}
|