mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Round coordinates instead of truncating to avoid projection error
This commit is contained in:
+3
-2
@@ -5,6 +5,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <cmath>
|
||||||
#include "mvt.hpp"
|
#include "mvt.hpp"
|
||||||
#include "plugin.hpp"
|
#include "plugin.hpp"
|
||||||
#include "projection.hpp"
|
#include "projection.hpp"
|
||||||
@@ -150,8 +151,8 @@ mvt_layer parse_layer(int fd, unsigned z, unsigned x, unsigned y, mvt_layer cons
|
|||||||
// Scale and offset geometry from global to tile
|
// Scale and offset geometry from global to tile
|
||||||
for (size_t i = 0; i < dv.size(); i++) {
|
for (size_t i = 0; i < dv.size(); i++) {
|
||||||
long long scale = 1LL << (32 - z);
|
long long scale = 1LL << (32 - z);
|
||||||
dv[i].x = (dv[i].x - scale * x) * olayer.extent / scale;
|
dv[i].x = std::round((dv[i].x - scale * x) * olayer.extent / (double) scale);
|
||||||
dv[i].y = (dv[i].y - scale * y) * olayer.extent / scale;
|
dv[i].y = std::round((dv[i].y - scale * y) * olayer.extent / (double) scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb_geometry[t] == VT_POLYGON) {
|
if (mb_geometry[t] == VT_POLYGON) {
|
||||||
|
|||||||
Reference in New Issue
Block a user