Change all these places where I said "extent" but really meant "area"

This commit is contained in:
Erica Fischer
2022-10-04 16:12:33 -07:00
parent 1885f989bf
commit 403828d2f7
4 changed files with 39 additions and 39 deletions
+4 -4
View File
@@ -400,7 +400,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
sf.index = 0; sf.index = 0;
sf.bbox[0] = sf.bbox[1] = LLONG_MAX; sf.bbox[0] = sf.bbox[1] = LLONG_MAX;
sf.bbox[2] = sf.bbox[3] = LLONG_MIN; sf.bbox[2] = sf.bbox[3] = LLONG_MIN;
sf.extent = 0; sf.area = 0;
sf.metapos = 0; sf.metapos = 0;
sf.has_id = false; 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; sf.seq = sequence->value.number.number;
} }
json_object *extent = json_hash_get(tippecanoe, "extent"); json_object *area = json_hash_get(tippecanoe, "extent");
if (extent != NULL && extent->type == JSON_NUMBER) { if (area != NULL && area->type == JSON_NUMBER) {
sf.extent = extent->value.number.number; sf.area = area->value.number.number;
} }
json_object *dropped = json_hash_get(tippecanoe, "dropped"); json_object *dropped = json_hash_get(tippecanoe, "dropped");
+17 -17
View File
@@ -196,7 +196,7 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
layer |= sf->layer << 6; layer |= sf->layer << 6;
layer |= (sf->seq != 0) << 5; layer |= (sf->seq != 0) << 5;
layer |= (sf->index != 0) << 4; layer |= (sf->index != 0) << 4;
layer |= (sf->extent != 0) << 3; layer |= (sf->area != 0) << 3;
layer |= sf->has_id << 2; layer |= sf->has_id << 2;
layer |= sf->has_tippecanoe_minzoom << 1; layer |= sf->has_tippecanoe_minzoom << 1;
layer |= sf->has_tippecanoe_maxzoom << 0; layer |= sf->has_tippecanoe_maxzoom << 0;
@@ -222,8 +222,8 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
if (sf->index != 0) { if (sf->index != 0) {
serialize_ulong_long(geomfile, sf->index, geompos, fname); serialize_ulong_long(geomfile, sf->index, geompos, fname);
} }
if (sf->extent != 0) { if (sf->area != 0) {
serialize_long_long(geomfile, sf->extent, geompos, fname); serialize_long_long(geomfile, sf->area, geompos, fname);
} }
serialize_long_long(geomfile, sf->metapos, geompos, fname); serialize_long_long(geomfile, sf->metapos, geompos, fname);
@@ -275,14 +275,14 @@ serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_
deserialize_int_io(geoms, &sf.segment, geompos_in); deserialize_int_io(geoms, &sf.segment, geompos_in);
sf.index = 0; 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]); 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)) { if (sf.layer & (1 << 4)) {
deserialize_ulong_long_io(geoms, &sf.index, geompos_in); deserialize_ulong_long_io(geoms, &sf.index, geompos_in);
} }
if (sf.layer & (1 << 3)) { 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; sf.layer >>= 6;
@@ -503,12 +503,12 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
if (prevent[P_CLIPPING]) { if (prevent[P_CLIPPING]) {
static std::atomic<long long> warned(0); static std::atomic<long long> 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)); 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 (extent > warned) { if (area > warned) {
fprintf(stderr, "Warning: %s:%d: Large unclipped (-pc) feature may be duplicated across %lld tiles\n", sst->fname, sst->line, extent); fprintf(stderr, "Warning: %s:%d: Large unclipped (-pc) feature may be duplicated across %lld tiles\n", sst->fname, sst->line, area);
warned = extent; warned = area;
if (extent > 10000) { if (area > 10000) {
fprintf(stderr, "Exiting because this can't be right.\n"); fprintf(stderr, "Exiting because this can't be right.\n");
exit(EXIT_IMPOSSIBLE); 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 (additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
if (sf.t == VT_POLYGON) { if (sf.t == VT_POLYGON) {
for (size_t i = 0; i < sf.geometry.size(); i++) { 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; 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 // 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) { if (area <= LLONG_MAX) {
sf.extent = (long long) extent; sf.area = (long long) area;
} else { } else {
sf.extent = LLONG_MAX; sf.area = LLONG_MAX;
} }
if (!prevent[P_INPUT_ORDER]) { if (!prevent[P_INPUT_ORDER]) {
+1 -1
View File
@@ -56,7 +56,7 @@ struct serial_feature {
drawvec geometry = drawvec(); drawvec geometry = drawvec();
unsigned long long index = 0; unsigned long long index = 0;
long long extent = 0; long long area = 0;
std::vector<long long> keys{}; std::vector<long long> keys{};
std::vector<long long> values{}; std::vector<long long> values{};
+17 -17
View File
@@ -316,7 +316,7 @@ struct ordercmp {
} }
} 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<long long> *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<long long> &metakeys, std::vector<long long> &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<long long> *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<long long> &metakeys, std::vector<long long> &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])) { if (geom.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS])) {
int xo, yo; int xo, yo;
int span = 1 << (nextzoom - z); 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.metapos = metastart;
sf.geometry = geom2; sf.geometry = geom2;
sf.index = index; sf.index = index;
sf.extent = extent; sf.area = area;
sf.feature_minzoom = feature_minzoom; sf.feature_minzoom = feature_minzoom;
if (metastart < 0) { if (metastart < 0) {
@@ -450,7 +450,7 @@ struct partial {
unsigned long long id = 0; unsigned long long id = 0;
bool has_id = 0; bool has_id = 0;
ssize_t renamed = 0; ssize_t renamed = 0;
long long extent = 0; long long area = 0;
long long clustered = 0; long long clustered = 0;
std::set<std::string> need_tilestats; std::set<std::string> need_tilestats;
std::map<std::string, accum_state> attribute_accum_state; std::map<std::string, accum_state> attribute_accum_state;
@@ -1422,7 +1422,7 @@ serial_feature next_feature(FILE *geoms, std::atomic<long long> *geompos_in, cha
if (*first_time && pass == 1) { /* only write out the next zoom once, even if we retry */ 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) { 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); decode_meta(sf.keys, sf.values, rpa->stringpool + rpa->pool_off[sf.segment], tmp_layer, tmp_feature);
tmp_layer.features.push_back(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) { if (fclose(rpa->prefilter_fp) != 0) {
@@ -1951,12 +1951,12 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
if (sf.t == VT_POINT) { if (sf.t == VT_POINT) {
if (extent_previndex >= sf.index) { if (extent_previndex >= sf.index) {
sf.extent = 1; sf.area = 1;
} else { } else {
double radius = sqrt(sf.index - extent_previndex) / 4.0; double radius = sqrt(sf.index - extent_previndex) / 4.0;
sf.extent = M_PI * radius * radius; sf.area = M_PI * radius * radius;
if (sf.extent < 1) { if (sf.area < 1) {
sf.extent = 1; sf.area = 1;
} }
} }
@@ -2011,23 +2011,23 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
indices.push_back(sf.index); indices.push_back(sf.index);
if (sf.index - merge_previndex < mingap && find_partial(partials, sf, which_partial, layer_unmaps)) { if (sf.index - merge_previndex < mingap && find_partial(partials, sf, which_partial, layer_unmaps)) {
partials[which_partial].geoms.push_back(sf.geometry); 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]); preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]);
strategy->coalesced_as_needed++; strategy->coalesced_as_needed++;
continue; continue;
} }
} else if (additional[A_DROP_SMALLEST_AS_NEEDED]) { } else if (additional[A_DROP_SMALLEST_AS_NEEDED]) {
extents.push_back(sf.extent); extents.push_back(sf.area);
if (sf.extent + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { 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]); preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]);
strategy->dropped_as_needed++; strategy->dropped_as_needed++;
continue; continue;
} }
} else if (additional[A_COALESCE_SMALLEST_AS_NEEDED]) { } else if (additional[A_COALESCE_SMALLEST_AS_NEEDED]) {
extents.push_back(sf.extent); extents.push_back(sf.area);
if (sf.extent + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) { if (sf.area + coalesced_area <= minextent && find_partial(partials, sf, which_partial, layer_unmaps)) {
partials[which_partial].geoms.push_back(sf.geometry); 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]); preserve_attributes(arg->attribute_accum, sf, stringpool, pool_off, partials[which_partial]);
strategy->coalesced_as_needed++; strategy->coalesced_as_needed++;
continue; continue;
@@ -2050,7 +2050,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
if (fraction_accum < 1 && find_partial(partials, sf, which_partial, layer_unmaps)) { if (fraction_accum < 1 && find_partial(partials, sf, which_partial, layer_unmaps)) {
if (additional[A_COALESCE_FRACTION_AS_NEEDED]) { if (additional[A_COALESCE_FRACTION_AS_NEEDED]) {
partials[which_partial].geoms.push_back(sf.geometry); partials[which_partial].geoms.push_back(sf.geometry);
coalesced_area += sf.extent; coalesced_area += sf.area;
strategy->coalesced_as_needed++; strategy->coalesced_as_needed++;
} else { } else {
strategy->dropped_as_needed++; strategy->dropped_as_needed++;
@@ -2116,7 +2116,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *meta
p.has_id = sf.has_id; p.has_id = sf.has_id;
p.index = sf.index; p.index = sf.index;
p.renamed = -1; p.renamed = -1;
p.extent = sf.extent; p.area = sf.area;
p.clustered = 0; p.clustered = 0;
if (line_detail == detail && extra_detail >= 0 && z == maxzoom) { if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {