mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
Heavy-handedly fix clipping errors at the edges of z0 and z1 tiles
This commit is contained in:
parent
8fec4ef9fc
commit
3bdcc3ca90
27
geojson.c
27
geojson.c
@ -61,8 +61,31 @@ void latlon2tile(double lat, double lon, int zoom, unsigned int *x, unsigned int
|
||||
double lat_rad = lat * M_PI / 180;
|
||||
unsigned long long n = 1LL << zoom;
|
||||
|
||||
*x = n * ((lon + 180) / 360);
|
||||
*y = n * (1 - (log(tan(lat_rad) + 1/cos(lat_rad)) / M_PI)) / 2;
|
||||
long long llx = n * ((lon + 180) / 360);
|
||||
long long lly = n * (1 - (log(tan(lat_rad) + 1/cos(lat_rad)) / M_PI)) / 2;
|
||||
|
||||
if (lat >= 85.0511) {
|
||||
lly = 0;
|
||||
}
|
||||
if (lat <= -85.0511) {
|
||||
lly = n - 1;
|
||||
}
|
||||
|
||||
if (llx < 0) {
|
||||
llx = 0;
|
||||
}
|
||||
if (lly < 0) {
|
||||
lly = 0;
|
||||
}
|
||||
if (llx >= n) {
|
||||
llx = n - 1;
|
||||
}
|
||||
if (lly >= n) {
|
||||
lly = n - 1;
|
||||
}
|
||||
|
||||
*x = llx;
|
||||
*y = lly;
|
||||
}
|
||||
|
||||
// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
|
||||
|
12
tile.cc
12
tile.cc
@ -373,8 +373,8 @@ void douglas_peucker(drawvec &geom, int start, int n, double e) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool inside(draw d, int edge, int area) {
|
||||
int clip_buffer = area / 64;
|
||||
static bool inside(draw d, int edge, long long area) {
|
||||
long long clip_buffer = area / 64;
|
||||
|
||||
switch (edge) {
|
||||
case 0: // top
|
||||
@ -408,8 +408,8 @@ static draw get_line_intersection(draw p0, draw p1, draw p2, draw p3) {
|
||||
return draw(VT_LINETO, p0.x + (t * s1_x), p0.y + (t * s1_y));
|
||||
}
|
||||
|
||||
static draw intersect(draw a, draw b, int edge, int area) {
|
||||
int clip_buffer = area / 64;
|
||||
static draw intersect(draw a, draw b, int edge, long long area) {
|
||||
long long clip_buffer = area / 64;
|
||||
|
||||
switch (edge) {
|
||||
case 0: // top
|
||||
@ -437,9 +437,9 @@ static draw intersect(draw a, draw b, int edge, int area) {
|
||||
static drawvec clip_poly1(drawvec &geom, int z, int detail) {
|
||||
drawvec out = geom;
|
||||
|
||||
unsigned area = 0xFFFFFFFF;
|
||||
long long area = 0xFFFFFFFF;
|
||||
if (z != 0) {
|
||||
area = 1 << (32 - z);
|
||||
area = 1LL << (32 - z);
|
||||
}
|
||||
|
||||
for (int edge = 0; edge < 4; edge++) {
|
||||
|
Loading…
Reference in New Issue
Block a user