Adding optional clipping to tippecanoe-overzoom (#298)

* Plumb a clip bounding box around through overzoom

* Actually do some clipping

* Add a test

* Fix post-binning clipping

* Factoring out geometry parsing from feature parsing

* Accept a clip polygon argument to tippecanoe-overzoom

* Progress in the direction of polygon clipping

* Fix the wagyu flags. We need intersection, not union

* Remove debug spew

* Clip points to polygon bounds too

* Copy the geometric binning code to serve as intersection-finding code

* Add clipper2 for linestring clipping

* Compiles, but does not actually seem to clip. Hmm.

* Oh, it helps if I actually call the function

* Add clipping tests

* Add missing fixture, and don't crash if it is missing

* Remember to do polygon clipping after binning too

* Fix scaling before post-binning clipping. Add test.

* Remove unused parts of clipper

* Rename for consistency

* Revert accidentally added line

* Clip the clip regions to the tile bounds to reduce their complexity

* Add a test of clipping the clip region down to the tile boundary

* Update version and changelog
This commit is contained in:
Erica Fischer
2024-11-27 13:43:40 -08:00
committed by GitHub
parent 11e3196c9a
commit dcc616d3d4
31 changed files with 9458 additions and 163 deletions
+25 -2
View File
@@ -99,8 +99,13 @@ drawvec clip_lines(drawvec &geom, long long x1, long long y1, long long x2, long
drawvec clip_point(drawvec &geom, long long x1, long long y1, long long x2, long long y2);
void visvalingam(drawvec &ls, size_t start, size_t end, double threshold, size_t retain);
int pnpoly(const drawvec &vert, size_t start, size_t nvert, long long testx, long long testy);
bool pnpoly_mp(drawvec const &geom, long long x, long long y);
double distance_from_line(long long point_x, long long point_y, long long segA_x, long long segA_y, long long segB_x, long long segB_y);
drawvec clip_poly_poly(drawvec const &geom, drawvec const &bounds);
drawvec clip_lines_poly(drawvec const &geom, drawvec const &bounds);
drawvec clip_point_poly(drawvec const &geom, drawvec const &bounds);
struct input_tile {
std::string tile;
int z;
@@ -115,6 +120,20 @@ struct source_tile {
int y;
};
struct clipbbox {
double lon1;
double lat1;
double lon2;
double lat2;
long long minx;
long long miny;
long long maxx;
long long maxy;
drawvec dv; // empty, or arbitrary clipping polygon
};
std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int ny,
int detail, int buffer,
std::set<std::string> const &keep,
@@ -127,7 +146,8 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
std::vector<std::string> const &unidecode_data, double simplification,
double tiny_polygon_size,
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
std::string const &accumulate_numeric, size_t feature_limit);
std::string const &accumulate_numeric, size_t feature_limit,
std::vector<clipbbox> const &clipbboxes);
std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int ny,
int detail, int buffer,
@@ -141,11 +161,14 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
std::vector<std::string> const &unidecode_data, double simplification,
double tiny_polygon_size,
std::vector<mvt_layer> const &bins, std::string const &bin_by_id_list,
std::string const &accumulate_numeric, size_t feature_limit);
std::string const &accumulate_numeric, size_t feature_limit,
std::vector<clipbbox> const &clipbboxes);
draw center_of_mass_mp(const drawvec &dv);
void get_quadkey_bounds(long long xmin, long long ymin, long long xmax, long long ymax,
unsigned long long *start, unsigned long long *end);
clipbbox parse_clip_poly(std::string arg);
#endif