Fix area of placeholders for degenerate multipolygons

This commit is contained in:
Eric Fischer 2017-02-06 14:14:34 -08:00
parent 4517bd6e90
commit 62e1018c87
6 changed files with 30 additions and 4 deletions

View File

@ -1,3 +1,7 @@
## 1.16.7
* Fix area of placeholders for degenerate multipolygons
## 1.16.6
* Upgrade Wagyu to 0.3.0; downgrade C++ requirement to C++ 11

View File

@ -166,6 +166,27 @@ double get_area(drawvec &geom, size_t i, size_t j) {
return area;
}
double get_mp_area(drawvec &geom) {
double ret = 0;
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[j].op != VT_LINETO) {
break;
}
}
ret += get_area(geom, i, j);
i = j - 1;
}
}
return ret;
}
static void decode_clipped(mapbox::geometry::multi_polygon<long long> &t, drawvec &out) {
out.clear();

View File

@ -71,3 +71,4 @@ drawvec fix_polygon(drawvec &geom);
std::vector<drawvec> chop_polygon(std::vector<drawvec> &geoms);
void check_polygon(drawvec &geom, drawvec &before);
double get_area(drawvec &geom, size_t i, size_t j);
double get_mp_area(drawvec &geom);

View File

@ -12,9 +12,9 @@
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { "adm1_code": "KIR+99?", "OBJECTID_1": 3643, "diss_me": 10097, "adm1_cod_1": "KIR+99?", "iso_3166_2": "KI-", "iso_a2": "KI", "adm0_sr": 5, "code_hasc": "-99", "note": "KIR-99 (Kiribati minor island)", "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 11, "datarank": 11, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 minor island", "name_len": 0, "mapcolor9": 6, "mapcolor13": 12, "woe_id": -99, "latitude": -4.68967, "longitude": -174.511, "sov_a3": "KIR", "adm0_a3": "KIR", "adm0_label": 7, "admin": "Kiribati", "geonunit": "Kiribati", "gu_a3": "KIR", "gn_id": 0, "gns_id": 0, "gn_level": 0, "gn_a1_code": "KI.", "gns_level": 0 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -59.589844, 12.297068 ], [ -26.894531, 12.297068 ], [ -26.894531, -19.890723 ], [ -59.589844, -19.890723 ], [ -59.589844, 12.297068 ] ] ] } }
{ "type": "Feature", "properties": { "adm1_code": "KIR+99?", "OBJECTID_1": 3643, "diss_me": 10097, "adm1_cod_1": "KIR+99?", "iso_3166_2": "KI-", "iso_a2": "KI", "adm0_sr": 5, "code_hasc": "-99", "note": "KIR-99 (Kiribati minor island)", "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 11, "datarank": 11, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 minor island", "name_len": 0, "mapcolor9": 6, "mapcolor13": 12, "woe_id": -99, "latitude": -4.68967, "longitude": -174.511, "sov_a3": "KIR", "adm0_a3": "KIR", "adm0_label": 7, "admin": "Kiribati", "geonunit": "Kiribati", "gu_a3": "KIR", "gn_id": 0, "gns_id": 0, "gn_level": 0, "gn_a1_code": "KI.", "gns_level": 0 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -43.242188, -3.951941 ], [ -43.154297, -3.951941 ], [ -43.154297, -4.039618 ], [ -43.242188, -4.039618 ], [ -43.242188, -3.951941 ] ] ] } }
,
{ "type": "Feature", "properties": { "adm1_code": "FSM-4943", "OBJECTID_1": 6464, "diss_me": 4943, "adm1_cod_1": "FSM-4943", "iso_3166_2": "FM-YAP", "wikipedia": "http://en.wikipedia.org/wiki/Yap_State", "iso_a2": "FM", "adm0_sr": 5, "name": "Yap", "code_hasc": "FM.YA", "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 10, "datarank": 10, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 scale rank", "name_len": 3, "mapcolor9": 4, "mapcolor13": 13, "fips": "FM04", "woe_id": 2345343, "woe_label": "Yap, FM, Federated States of Micronesia", "woe_name": "Yap", "latitude": 9.58101, "longitude": 138.114, "sov_a3": "FSM", "adm0_a3": "FSM", "adm0_label": 5, "admin": "Federated States of Micronesia", "geonunit": "Federated States of Micronesia", "gu_a3": "FSM", "gn_id": 2081175, "gn_name": "State of Yap", "gns_id": -3741502, "gns_name": "Yap, State of", "gn_level": 1, "gn_a1_code": "FM.04", "gns_level": 1, "gns_adm1": "FM04" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 141.416016, 9.102097 ], [ 143.173828, 9.102097 ], [ 143.173828, 7.275292 ], [ 141.416016, 7.275292 ], [ 141.416016, 9.102097 ] ] ] } }
{ "type": "Feature", "properties": { "adm1_code": "FSM-4943", "OBJECTID_1": 6464, "diss_me": 4943, "adm1_cod_1": "FSM-4943", "iso_3166_2": "FM-YAP", "wikipedia": "http://en.wikipedia.org/wiki/Yap_State", "iso_a2": "FM", "adm0_sr": 5, "name": "Yap", "code_hasc": "FM.YA", "provnum_ne": 0, "gadm_level": 0, "check_me": 0, "scalerank": 10, "datarank": 10, "area_sqkm": 0, "sameascity": -99, "labelrank": 20, "featurecla": "Admin-1 scale rank", "name_len": 3, "mapcolor9": 4, "mapcolor13": 13, "fips": "FM04", "woe_id": 2345343, "woe_label": "Yap, FM, Federated States of Micronesia", "woe_name": "Yap", "latitude": 9.58101, "longitude": 138.114, "sov_a3": "FSM", "adm0_a3": "FSM", "adm0_label": 5, "admin": "Federated States of Micronesia", "geonunit": "Federated States of Micronesia", "gu_a3": "FSM", "gn_id": 2081175, "gn_name": "State of Yap", "gns_id": -3741502, "gns_name": "Yap, State of", "gn_level": 1, "gn_a1_code": "FM.04", "gns_level": 1, "gns_adm1": "FM04" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 142.294922, 8.320212 ], [ 142.382812, 8.320212 ], [ 142.382812, 8.146243 ], [ 142.294922, 8.146243 ], [ 142.294922, 8.320212 ] ] ] } }
] }
] }
,

View File

@ -449,7 +449,7 @@ void *partial_feature_worker(void *v) {
double area = 0;
if (t == VT_POLYGON) {
area = get_area(geom, 0, geom.size());
area = get_mp_area(geom);
}
if ((t == VT_LINE || t == VT_POLYGON) && !(prevent[P_SIMPLIFY] || (z == maxzoom && prevent[P_SIMPLIFY_LOW]) || (z < maxzoom && additional[A_GRID_LOW_ZOOMS]))) {

View File

@ -1 +1 @@
#define VERSION "tippecanoe v1.16.6\n"
#define VERSION "tippecanoe v1.16.7\n"