diff --git a/plugin.cpp b/plugin.cpp index ebb24889..c6a87617 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -400,7 +400,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: sf.index = 0; sf.bbox[0] = sf.bbox[1] = LLONG_MAX; sf.bbox[2] = sf.bbox[3] = LLONG_MIN; - sf.extent = 0; + sf.area = 0; sf.metapos = 0; sf.has_id = false; @@ -422,9 +422,9 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: sf.seq = sequence->value.number.number; } - json_object *extent = json_hash_get(tippecanoe, "extent"); - if (extent != NULL && extent->type == JSON_NUMBER) { - sf.extent = extent->value.number.number; + json_object *area = json_hash_get(tippecanoe, "extent"); + if (area != NULL && area->type == JSON_NUMBER) { + sf.area = area->value.number.number; } json_object *dropped = json_hash_get(tippecanoe, "dropped"); diff --git a/serial.cpp b/serial.cpp index 27db34d0..f8d89e82 100644 --- a/serial.cpp +++ b/serial.cpp @@ -196,7 +196,7 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomiclayer << 6; layer |= (sf->seq != 0) << 5; layer |= (sf->index != 0) << 4; - layer |= (sf->extent != 0) << 3; + layer |= (sf->area != 0) << 3; layer |= sf->has_id << 2; layer |= sf->has_tippecanoe_minzoom << 1; layer |= sf->has_tippecanoe_maxzoom << 0; @@ -222,8 +222,8 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomicindex != 0) { serialize_ulong_long(geomfile, sf->index, geompos, fname); } - if (sf->extent != 0) { - serialize_long_long(geomfile, sf->extent, geompos, fname); + if (sf->area != 0) { + serialize_long_long(geomfile, sf->area, geompos, fname); } serialize_long_long(geomfile, sf->metapos, geompos, fname); @@ -275,14 +275,14 @@ serial_feature deserialize_feature(FILE *geoms, std::atomic *geompos_ deserialize_int_io(geoms, &sf.segment, geompos_in); sf.index = 0; - sf.extent = 0; + sf.area = 0; sf.geometry = decode_geometry(geoms, geompos_in, z, tx, ty, sf.bbox, initial_x[sf.segment], initial_y[sf.segment]); if (sf.layer & (1 << 4)) { deserialize_ulong_long_io(geoms, &sf.index, geompos_in); } if (sf.layer & (1 << 3)) { - deserialize_long_long_io(geoms, &sf.extent, geompos_in); + deserialize_long_long_io(geoms, &sf.area, geompos_in); } sf.layer >>= 6; @@ -503,12 +503,12 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) { if (prevent[P_CLIPPING]) { static std::atomic warned(0); - long long extent = ((sf.bbox[2] - sf.bbox[0]) / ((1LL << (32 - sst->maxzoom)) + 1)) * ((sf.bbox[3] - sf.bbox[1]) / ((1LL << (32 - sst->maxzoom)) + 1)); - if (extent > warned) { - fprintf(stderr, "Warning: %s:%d: Large unclipped (-pc) feature may be duplicated across %lld tiles\n", sst->fname, sst->line, extent); - warned = extent; + long long area = ((sf.bbox[2] - sf.bbox[0]) / ((1LL << (32 - sst->maxzoom)) + 1)) * ((sf.bbox[3] - sf.bbox[1]) / ((1LL << (32 - sst->maxzoom)) + 1)); + if (area > warned) { + fprintf(stderr, "Warning: %s:%d: Large unclipped (-pc) feature may be duplicated across %lld tiles\n", sst->fname, sst->line, area); + warned = area; - if (extent > 10000) { + if (area > 10000) { fprintf(stderr, "Exiting because this can't be right.\n"); exit(EXIT_IMPOSSIBLE); } @@ -516,7 +516,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) { } } - double extent = 0; + double area = 0; if (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) { if (sf.t == VT_POLYGON) { for (size_t i = 0; i < sf.geometry.size(); i++) { @@ -528,7 +528,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) { } } - extent += get_area(sf.geometry, i, j); + area += get_area(sf.geometry, i, j); i = j - 1; } } @@ -542,16 +542,16 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) { } } // treat lines as having the area of a circle with the line as diameter - extent = M_PI * (dist / 2) * (dist / 2); + area = M_PI * (dist / 2) * (dist / 2); } - // VT_POINT extent will be calculated in write_tile from the distance between adjacent features. + // VT_POINT area will be calculated in write_tile from the distance between adjacent features. } - if (extent <= LLONG_MAX) { - sf.extent = (long long) extent; + if (area <= LLONG_MAX) { + sf.area = (long long) area; } else { - sf.extent = LLONG_MAX; + sf.area = LLONG_MAX; } if (!prevent[P_INPUT_ORDER]) { diff --git a/serial.hpp b/serial.hpp index a662d497..dfa506d2 100644 --- a/serial.hpp +++ b/serial.hpp @@ -56,7 +56,7 @@ struct serial_feature { drawvec geometry = drawvec(); unsigned long long index = 0; - long long extent = 0; + long long area = 0; std::vector keys{}; std::vector values{}; diff --git a/tile.cpp b/tile.cpp index 0f9f81b4..29e1a59e 100644 --- a/tile.cpp +++ b/tile.cpp @@ -316,7 +316,7 @@ struct ordercmp { } } ordercmp; -void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int *within, std::atomic *geompos, FILE **geomfile, const char *fname, signed char t, int layer, long long metastart, signed char feature_minzoom, int child_shards, int max_zoom_increment, long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, std::vector &metakeys, std::vector &metavals, bool has_id, unsigned long long id, unsigned long long index, long long extent) { +void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int *within, std::atomic *geompos, FILE **geomfile, const char *fname, signed char t, int layer, long long metastart, signed char feature_minzoom, int child_shards, int max_zoom_increment, long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, std::vector &metakeys, std::vector &metavals, bool has_id, unsigned long long id, unsigned long long index, long long area) { if (geom.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS])) { int xo, yo; int span = 1 << (nextzoom - z); @@ -406,7 +406,7 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u sf.metapos = metastart; sf.geometry = geom2; sf.index = index; - sf.extent = extent; + sf.area = area; sf.feature_minzoom = feature_minzoom; if (metastart < 0) { @@ -450,7 +450,7 @@ struct partial { unsigned long long id = 0; bool has_id = 0; ssize_t renamed = 0; - long long extent = 0; + long long area = 0; long long clustered = 0; std::set need_tilestats; std::map attribute_accum_state; @@ -1422,7 +1422,7 @@ serial_feature next_feature(FILE *geoms, std::atomic *geompos_in, cha if (*first_time && pass == 1) { /* only write out the next zoom once, even if we retry */ if (sf.tippecanoe_maxzoom == -1 || sf.tippecanoe_maxzoom >= nextzoom) { - rewrite(sf.geometry, z, nextzoom, maxzoom, sf.bbox, tx, ty, buffer, within, geompos, geomfile, fname, sf.t, sf.layer, sf.metapos, sf.feature_minzoom, child_shards, max_zoom_increment, sf.seq, sf.tippecanoe_minzoom, sf.tippecanoe_maxzoom, sf.segment, initial_x, initial_y, sf.keys, sf.values, sf.has_id, sf.id, sf.index, sf.extent); + rewrite(sf.geometry, z, nextzoom, maxzoom, sf.bbox, tx, ty, buffer, within, geompos, geomfile, fname, sf.t, sf.layer, sf.metapos, sf.feature_minzoom, child_shards, max_zoom_increment, sf.seq, sf.tippecanoe_minzoom, sf.tippecanoe_maxzoom, sf.segment, initial_x, initial_y, sf.keys, sf.values, sf.has_id, sf.id, sf.index, sf.area); } } @@ -1597,7 +1597,7 @@ void *run_prefilter(void *v) { decode_meta(sf.keys, sf.values, rpa->stringpool + rpa->pool_off[sf.segment], tmp_layer, tmp_feature); tmp_layer.features.push_back(tmp_feature); - layer_to_geojson(tmp_layer, 0, 0, 0, false, true, false, true, sf.index, sf.seq, sf.extent, true, state, 0); + layer_to_geojson(tmp_layer, 0, 0, 0, false, true, false, true, sf.index, sf.seq, sf.area, true, state, 0); } if (fclose(rpa->prefilter_fp) != 0) { @@ -1951,12 +1951,12 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta if (sf.t == VT_POINT) { if (extent_previndex >= sf.index) { - sf.extent = 1; + sf.area = 1; } else { double radius = sqrt(sf.index - extent_previndex) / 4.0; - sf.extent = M_PI * radius * radius; - if (sf.extent < 1) { - sf.extent = 1; + sf.area = M_PI * radius * radius; + if (sf.area < 1) { + sf.area = 1; } } @@ -2011,23 +2011,23 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta indices.push_back(sf.index); if (sf.index - merge_previndex < mingap && find_partial(partials, sf, which_partial, layer_unmaps)) { partials[which_partial].geoms.push_back(sf.geometry); - coalesced_area += sf.extent; + coalesced_area += sf.area; preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]); strategy->coalesced_as_needed++; continue; } } else if (additional[A_DROP_SMALLEST_AS_NEEDED]) { - extents.push_back(sf.extent); - if (sf.extent + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { + extents.push_back(sf.area); + if (sf.area + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]); strategy->dropped_as_needed++; continue; } } else if (additional[A_COALESCE_SMALLEST_AS_NEEDED]) { - extents.push_back(sf.extent); - if (sf.extent + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { + extents.push_back(sf.area); + if (sf.area + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { partials[which_partial].geoms.push_back(sf.geometry); - coalesced_area += sf.extent; + coalesced_area += sf.area; preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]); strategy->coalesced_as_needed++; continue; @@ -2050,7 +2050,7 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta if (fraction_accum < 1 && find_partial(partials, sf, which_partial, layer_unmaps)) { if (additional[A_COALESCE_FRACTION_AS_NEEDED]) { partials[which_partial].geoms.push_back(sf.geometry); - coalesced_area += sf.extent; + coalesced_area += sf.area; strategy->coalesced_as_needed++; } else { strategy->dropped_as_needed++; @@ -2116,7 +2116,7 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta p.has_id = sf.has_id; p.index = sf.index; p.renamed = -1; - p.extent = sf.extent; + p.area = sf.area; p.clustered = 0; if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {