MultiPolygon Support
jguthmiller opened this issue · 4 comments
If more than one polygon exists for a unique feature in a given tile, the parseVectorTileLayer method will end up overwriting the existing references to that feature, and add a copy of itself to the features list for that tile.
For example, the islands off the coast of California should be visible; Instead the last California
polygon in the list of polygons for that tile was effectively duplicated.
Here's the decoded json of the tile for reference. I used Tilestache to generate the tiles, and Mapzen's mapbox vector tile library to encode them.
{
"states": [
{
"geometry": [
[
4096,
2231
],
[
3532,
2232
],
[
3534,
4096
],
[
4096,
4096
],
[
4096,
2231
]
],
"properties": {
"label": "Utah"
},
"id": 24
},
{
"geometry": [
[
3898,
0
],
[
3252,
240
],
[
3294,
342
],
[
3355,
346
],
[
3379,
386
],
[
3362,
464
],
[
3308,
467
],
[
3292,
491
],
[
3305,
565
],
[
3283,
584
],
[
3285,
629
],
[
3358,
693
],
[
3354,
861
],
[
3396,
931
],
[
3502,
1005
],
[
3485,
1043
],
[
3409,
1091
],
[
3378,
1203
],
[
3318,
1275
],
[
3314,
1376
],
[
3342,
1413
],
[
3302,
1554
],
[
3290,
1691
],
[
3308,
1720
],
[
3274,
1818
],
[
3319,
1843
],
[
3406,
1842
],
[
3457,
1787
],
[
3494,
1790
],
[
3533,
1866
],
[
3532,
2232
],
[
4096,
2231
],
[
4096,
0
],
[
3898,
0
]
],
"properties": {
"label": "Arizona"
},
"id": 1
},
{
"geometry": [
[
3532,
2232
],
[
3533,
1866
],
[
3494,
1790
],
[
3457,
1787
],
[
3406,
1842
],
[
3319,
1843
],
[
3274,
1818
],
[
3308,
1720
],
[
3290,
1691
],
[
3302,
1554
],
[
3342,
1413
],
[
3314,
1376
],
[
3322,
1332
],
[
2275,
2332
],
[
1364,
3155
],
[
1365,
4096
],
[
3534,
4096
],
[
3532,
2232
]
],
"properties": {
"label": "Nevada"
},
"id": 19
},
{
"geometry": [
[
1231,
923
],
[
1253,
899
],
[
1201,
904
],
[
1231,
923
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1964,
375
],
[
1909,
389
],
[
1871,
467
],
[
1964,
375
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1519,
574
],
[
1571,
551
],
[
1530,
554
],
[
1519,
574
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1958,
631
],
[
1982,
588
],
[
1924,
595
],
[
1915,
635
],
[
1873,
661
],
[
1958,
631
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1376,
864
],
[
1323,
843
],
[
1274,
890
],
[
1349,
905
],
[
1376,
864
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1390,
916
],
[
1497,
895
],
[
1539,
904
],
[
1431,
872
],
[
1390,
916
]
],
"properties": {
"label": "California"
},
"id": 35
},
{
"geometry": [
[
1364,
3155
],
[
2275,
2332
],
[
3322,
1332
],
[
3318,
1275
],
[
3378,
1203
],
[
3409,
1091
],
[
3485,
1043
],
[
3502,
1005
],
[
3396,
931
],
[
3354,
861
],
[
3358,
693
],
[
3285,
629
],
[
3305,
565
],
[
3292,
491
],
[
3379,
441
],
[
3355,
346
],
[
2412,
251
],
[
2396,
311
],
[
2368,
309
],
[
2338,
506
],
[
2286,
582
],
[
2045,
781
],
[
1995,
760
],
[
1943,
776
],
[
1951,
819
],
[
1904,
901
],
[
1799,
889
],
[
1682,
934
],
[
1627,
1007
],
[
1524,
1072
],
[
1409,
1069
],
[
1313,
1098
],
[
1200,
1084
],
[
1133,
1137
],
[
1130,
1393
],
[
1053,
1423
],
[
1043,
1523
],
[
896,
1628
],
[
818,
1779
],
[
672,
1917
],
[
644,
2041
],
[
704,
2087
],
[
714,
2142
],
[
687,
2200
],
[
662,
2221
],
[
587,
2217
],
[
489,
2321
],
[
491,
2395
],
[
447,
2477
],
[
447,
2597
],
[
325,
2698
],
[
264,
2688
],
[
291,
2762
],
[
281,
2814
],
[
8,
3118
],
[
0,
4096
],
[
1365,
4096
],
[
1364,
3155
]
],
"properties": {
"label": "California"
},
"id": 35
}
]
}
Ah, yes. Our ID dictionary should then refer to an array of features rather than just one.
I wonder if the Mapbox folks have any insight on how multi-polygons should be thought about in regards to the vector tile spec.
+1 on seeing this fixed. Took me ages to realize what was going on when using the gs-mvt plugin for geoserver and trying to see if it is actually doing its job right...
I hacked together a fix a while back, but wasn't sure about submitting a PR since version 2 of the vector tile spec addresses multipolygons.
Here's a copy of the patch if anyone's interested.
hi @jguthmiller !
the patch is perfect.
thanks !