mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Compiles, but does not actually seem to clip. Hmm.
This commit is contained in:
@@ -68,16 +68,16 @@ tippecanoe-enumerate: enumerate.o
|
|||||||
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o
|
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
|
||||||
|
|
||||||
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o read_json.o
|
tile-join: tile-join.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o read_json.o clipper2/src/clipper.engine.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
|
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
unit: unit.o text.o sort.o mvt.o projection.o clip.o attribute.o jsonpull/jsonpull.o evaluator.o read_json.o
|
unit: unit.o text.o sort.o mvt.o projection.o clip.o attribute.o jsonpull/jsonpull.o evaluator.o read_json.o clipper2/src/clipper.engine.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o projection.o read_json.o
|
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o projection.o read_json.o clipper2/src/clipper.engine.o
|
||||||
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
|
||||||
|
|
||||||
-include $(wildcard *.d)
|
-include $(wildcard *.d)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <mapbox/geometry/point.hpp>
|
#include <mapbox/geometry/point.hpp>
|
||||||
#include <mapbox/geometry/multi_polygon.hpp>
|
#include <mapbox/geometry/multi_polygon.hpp>
|
||||||
#include <mapbox/geometry/wagyu/wagyu.hpp>
|
#include <mapbox/geometry/wagyu/wagyu.hpp>
|
||||||
|
#include <clipper2/clipper.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "geometry.hpp"
|
#include "geometry.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
@@ -1934,73 +1935,49 @@ mvt_tile assign_to_bins(mvt_tile &features,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawvec clip_lines(drawvec const &geom, drawvec const ®ion) {
|
static Clipper2Lib::Paths64 geom_to_clipper(drawvec const &geom) {
|
||||||
std::vector<index_event> events;
|
Clipper2Lib::Paths64 subject;
|
||||||
|
|
||||||
if (region.size() == 0) {
|
for (size_t i = 0; i < geom.size(); i++) {
|
||||||
return drawvec();
|
if (geom[i].op == VT_MOVETO) {
|
||||||
}
|
Clipper2Lib::Path64 path({{geom[i].x, geom[i].y}});
|
||||||
|
size_t j;
|
||||||
// Index region segments
|
for (j = i + 1; j < geom.size(); j++) {
|
||||||
for (size_t i = 1; i < region.size(); i++) {
|
if (geom[j].op != VT_LINETO) {
|
||||||
if (region[i].op == VT_LINETO) {
|
break;
|
||||||
long long xmin = std::min(region[i - 1].x, region[i].x);
|
|
||||||
long long ymin = std::min(region[i - 1].y, region[i].y);
|
|
||||||
long long xmax = std::max(region[i - 1].x, region[i].x);
|
|
||||||
long long ymax = std::max(region[i - 1].y, region[i].y);
|
|
||||||
unsigned long long start, end;
|
|
||||||
|
|
||||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
|
||||||
events.emplace_back(start, index_event::ENTER, i, 0, xmin, ymin, xmax, ymax);
|
|
||||||
events.emplace_back(end, index_event::EXIT, i, 0, xmin, ymin, xmax, ymax);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Index linestring segments
|
|
||||||
for (size_t i = 1; i < geom.size(); i++) {
|
|
||||||
if (geom[i].op == VT_LINETO) {
|
|
||||||
long long xmin = std::min(geom[i - 1].x, geom[i].x);
|
|
||||||
long long ymin = std::min(geom[i - 1].y, geom[i].y);
|
|
||||||
long long xmax = std::max(geom[i - 1].x, geom[i].x);
|
|
||||||
long long ymax = std::max(geom[i - 1].y, geom[i].y);
|
|
||||||
unsigned long long start, end;
|
|
||||||
|
|
||||||
get_quadkey_bounds(xmin, ymin, xmax, ymax, &start, &end);
|
|
||||||
events.emplace_back(start, index_event::CHECK, i, 0, xmin, ymin, xmax, ymax);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::sort(events.begin(), events.end());
|
|
||||||
std::set<active_bin> active;
|
|
||||||
|
|
||||||
for (auto &e : events) {
|
|
||||||
if (e.kind == index_event::ENTER) {
|
|
||||||
active_bin a(e.layer, e.feature);
|
|
||||||
a.xmin = e.xmin;
|
|
||||||
a.ymin = e.ymin;
|
|
||||||
a.xmax = e.xmax;
|
|
||||||
a.ymax = e.ymax;
|
|
||||||
|
|
||||||
active.insert(std::move(a));
|
|
||||||
} else if (e.kind == index_event::CHECK) {
|
|
||||||
for (auto const &a : active) {
|
|
||||||
if (bbox_intersects(e.xmin, e.ymin, e.xmax, e.ymax,
|
|
||||||
a.xmin, a.ymin, a.xmax, a.ymax)) {
|
|
||||||
// compare
|
|
||||||
}
|
}
|
||||||
|
path.emplace_back(geom[j].x, geom[j].y);
|
||||||
}
|
}
|
||||||
} else /* EXIT */ {
|
subject.push_back(path);
|
||||||
auto const &found = active.find({e.layer, e.feature});
|
|
||||||
if (found != active.end()) {
|
|
||||||
active.erase(found);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "event mismatch: can't happen\n");
|
|
||||||
exit(EXIT_IMPOSSIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return drawvec();
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clipper_to_geom(Clipper2Lib::Paths64 const &geom, drawvec &out) {
|
||||||
|
for (auto const &ring : geom) {
|
||||||
|
for (size_t i = 0; i < ring.size(); i++) {
|
||||||
|
out.emplace_back(i == 0 ? VT_MOVETO : VT_LINETO, ring[i].x, ring[i].y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
drawvec clip_lines(drawvec const &geom, drawvec const ®ion) {
|
||||||
|
Clipper2Lib::Paths64 subject = geom_to_clipper(geom);
|
||||||
|
Clipper2Lib::Paths64 clip = geom_to_clipper(region);
|
||||||
|
|
||||||
|
Clipper2Lib::Clipper64 clipper;
|
||||||
|
clipper.AddOpenSubject(subject);
|
||||||
|
clipper.AddClip(clip);
|
||||||
|
|
||||||
|
Clipper2Lib::Paths64 solution, open_solution;
|
||||||
|
clipper.Execute(Clipper2Lib::ClipType::Intersection, Clipper2Lib::FillRule::Positive, solution, open_solution);
|
||||||
|
|
||||||
|
drawvec out;
|
||||||
|
clipper_to_geom(solution, out);
|
||||||
|
clipper_to_geom(open_solution, out);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int ny,
|
std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int ny,
|
||||||
|
|||||||
Reference in New Issue
Block a user