mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Starting on my own polygon cleaner
This commit is contained in:
@@ -58,7 +58,7 @@ C = $(wildcard *.c) $(wildcard *.cpp)
|
||||
INCLUDES = -I/usr/local/include -I.
|
||||
LIBS = -L/usr/local/lib
|
||||
|
||||
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o
|
||||
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o polygon.o
|
||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||
|
||||
tippecanoe-enumerate: enumerate.o
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#include "geometry.hpp"
|
||||
|
||||
struct point {
|
||||
double x;
|
||||
double y;
|
||||
|
||||
point(double x_, double y_)
|
||||
: x(x_), y(y_) {
|
||||
}
|
||||
};
|
||||
|
||||
drawvec clean_polygon(drawvec const &geom, int z, int detail) {
|
||||
double scale = 1LL << (-(32 - detail - z));
|
||||
|
||||
// decompose polygon rings into segments
|
||||
|
||||
std::vector<std::pair<point, point>> segments;
|
||||
|
||||
for (size_t i = 0; i < geom.size(); i++) {
|
||||
if (geom[i].op == VT_MOVETO) {
|
||||
size_t j;
|
||||
|
||||
for (j = i + 1; j < geom.size(); j++) {
|
||||
if (geom[i].op != VT_LINETO) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t k = i; k + 1 < j; k++) {
|
||||
std::pair<point, point> segment = std::make_pair(
|
||||
point(geom[k].x / scale, geom[k].y / scale),
|
||||
point(geom[k + 1].x / scale, geom[k + 1].y / scale));
|
||||
|
||||
segments.push_back(segment);
|
||||
}
|
||||
|
||||
i = j - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// snap-round intersecting segments
|
||||
|
||||
// remove duplicate segments with opposite windings
|
||||
|
||||
// reassemble segments into rings
|
||||
|
||||
// remove collinear points?
|
||||
|
||||
// determine ring nesting
|
||||
|
||||
return drawvec();
|
||||
}
|
||||
Reference in New Issue
Block a user