CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.86k stars 3.47k forks source link

Fill Complex Polygons #1209

Open pjcozzi opened 11 years ago

pjcozzi commented 11 years ago

As originally reported in #1121 and started in #1163.

A few test files:

In particular, ne_10m_us_states.json has a complex polygon on the southeast coast of Texas just south of Sweeny.

image

Zoomed out: image

pjcozzi commented 8 years ago

Improved in #3998.

hpinkos commented 5 years ago

See #6238 for overlapping holes example

philpil commented 1 year ago

Any new update for this problem?

I'm having the problem regardless of drawing large complex polygons or loading json list of points into a multipolygon

ggetz commented 1 year ago

Hi @philpil, there hasn't been any activity on this item recently. If you'd like to add more information about your use case, that may help us prioritize.

If you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR. Thanks!

philpil commented 1 year ago

Hi @philpil, there hasn't been any activity on this item recently. If you'd like to add more information about your use case, that may help us prioritize.

If you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR. Thanks!

there are my location points for a polygon

0, 128.72375851502704 4.242602106251088, 128.67732506084047 8.456919747527134, 128.5380812702795 12.615576479246824, 128.30619679046 16.692942667512057, 127.98195413689993 20.66584537869358, 127.56574834932964 24.514106751781497, 127.05808651039511, 26.342429350371596, 126.40794732146703 22.3516235923492, 116.99874632581987 4.184259503714773, 100.10609976396388 1.1756550952217055, 98.31930014250099 -1.5548488526669846, 95.89963576579291 -3.900648594831361, 92.97519142672053 -5.771801794504618, 89.6760051500002 -7.097923054505805, 86.1340076870971 -7.83125053752346, 82.48362229936326 -7.949174573512473, 78.86002718338821 -7.455317589797858, 75.39452053953767 -4.275823517352206, 62.53043561683481 5.485294681371162, 18.12697113336765 5.253505535146889, 17.5363089013921 4.1775045070352315, 13.738018962116234 3.6921955939146742, 9.291657916783336 3.831027135188426, 4.146749537301111 4.614565006495032, -1.8784460028200263 6.058815553852516, -9.378043821260944 8.251044743758685, -22.06809318937966 8.426383279357289, -23.526543002441773 4.242602106251068, -23.677325060838328 0, -23.72375851502705 -4.2426021062510255, -23.677325060838328 -8.456919747526964, -23.538081270274986 -12.615576479247066, -23.306196790464533 -16.692942667512252, -22.98195413690222 -20.665845378693383, -22.565748349327325 -24.51410675178103, -22.0580865103905 -28.220889290888422, -21.459587127829817 -31.772847654264282, -20.77097938095224 -35.160104404098, -19.993102232220423 -38.376079724381654, -19.126903405139917 -41.41721164960406, -18.173438229529584 -44.28260442156096, -17.133868355853902 -46.97363950683433, -16.009460339857487 -49.493578136229054, -14.80158409949587 -51.8471774324188, -13.511711245945932 -54.04033540858186, -12.141413290569856 -56.07977408682845, -10.692359730317076 -57.972765074979655, -9.166316013796491 -59.72689825106578, -7.565141390164691 -61.34989165419052, -5.890786644078719 -62.84943908939205, -4.145291718877158 -64.23309111328213, -2.330783231270379 -65.5081647720746, -0.44947188031030005 -66.68167753913265, 1.4963502458898752 -67.76030120466535, 3.504312462805032 -68.75033190174514, 5.5719683777691165 -69.65767293585729, 7.696798870568606 -70.48782757152505, 9.876215162513416 -71.24589938855344, 12.10756197062808 -71.93659823653155, 14.388120742484649 -72.56425018089254, 16.715112968531106 -73.13281014768657, 19.085703567194685 -73.64587623788682, 21.497004338967177 -74.10670490118966, 23.94607748532926 -74.51822633889317, 26.42993918786633 -74.88305965028268, 28.945563243722788 -75.20352735368225, 31.48988475247592 -75.48166900498978, 34.059803850314296 -75.719253708998, 36.65218948665848 -75.91779137421386, 39.26388323894391 -76.07854260486616, 41.89170316063749 -76.20252715556823, 44.53244765793803 -76.29053089775654, 47.18289939046972 -76.3431112645115, 49.83982919105136 -76.36060115190607, 52.49999999999998 -76.34311126450471, 55.16017080894713 -76.29053089776107, 57.817100609532176 -76.2025271555682, 60.467552342062376 -76.07854260487512, 63.10829683936962 -75.9177913742139, 65.73611676105604 -75.71925370899363, 68.3478105133365 -75.4816690049898, 70.94019614968562 -75.20352735367612, 73.51011524751445 -74.8830596502807, 76.05443675627394 -74.51822633889311, 78.57006081213387 -74.10670490119146, 81.05392251467443 -73.64587623788323, 83.50299566102484 -73.13281014768828, 85.91429643280932 -72.56425018089428, 88.28488703147339 -71.93659823653151, 90.61187925751528 -71.24589938855036, 92.89243802936312 -70.48782757152351, 95.12378483748242 -69.65767293585316, 97.30320112941884 -68.75033190174113, 99.42803162221826 -67.76030120466537, 101.49568753719502 -66.68167753913269, 103.50364975411014 -65.5081647720746, 105.44947188031033 -64.23309111328217, 107.3307832312704 -62.84943908939203, 109.14529171887726 -61.349891654190486, 110.8907866440788 -59.72689825106488, 112.56514139016137 -57.972765074977275, 114.16631601378656 -56.07977408682916, 115.69235973032036 -54.04033540857772, 117.14141329055145 -51.84717743241887, 118.5117112459458 -49.493578136230234, 119.80158409950157 -46.97363950683326, 121.0094603398519 -44.28260442155997, 122.13386835584869 -41.41721164960499, 123.17343822953471 -38.3760797243804, 124.12690340513232 -35.16010440409947, 124.99310223223023 -31.772847654263284, 125.770979380945 -28.22088929088846, 126.45958712782979 -24.51410675178152, 127.05808651039511 -20.66584537869357, 127.56574834932964 -16.692942667512092, 127.98195413689993 -12.615576479246808, 128.30619679046 -8.456919747527147, 128.5380812702795 -4.242602106251067, 128.67732506084047 0, 128.72375851502704

i set my polygons to all have the height of 0 and i'm setting the outline, outlinecolor and material to a default for all polygon points

ggetz commented 1 year ago

Also reported in https://github.com/CesiumGS/cesium/issues/11502.

pvocat commented 12 months ago

Hi,

I'm not sure if my problem is related to this issue, since I have a pretty complex polygon (157 holes in it), so I can't really see if what's happening is a filling problem, or something else. Here's a visual and the polygon in question :

The polygon in FME : polygonorigin

The polygon rendered in Cesium : polygonrendered

The base geoJSON : rewound-geojson.json

ggetz commented 12 months ago

Hi, CesiumJS should handle the holes correctly assuming they are all within the outermost polygon. In other words, the polygon can't self-intersect.

We did fix an issue with holes in https://github.com/CesiumGS/cesium/pull/11577.

You can use a tool like Turf.js kinks to check if there are any self-intersections.

pvocat commented 12 months ago

Hi, CesiumJS should handle the holes correctly assuming they are all within the outermost polygon. In other words, the polygon can't self-intersect.

We did fix an issue with holes in #11577.

You can use a tool like Turf.js kinks to check if there are any self-intersections.

So my current problem is about self-intersections and not holes if I understand correctly? The turf kinks function returned 12 features. turf_kinks.json

Is my current issue linked to this one, or isn't it?

ggetz commented 12 months ago

Yes, based on the results of the turf.js kinks function, you have a complex polygons. That is the issue documented here.

As a workaround, you can split the polygon into multiple simple polygons. Turf.js unkinkPolygon can do this.