Open Jeromearsene opened 2 years ago
Can you check older versions? I don't think this issue was introduced recently. But in general, self intersecting polygon is not a valid polygon when checking the geojson spec so I would consider fixing the data and not the rendering as an initial solution.
Can you check older versions? I don't think this issue was introduced recently. But in general, self intersecting polygon is not a valid polygon when checking the geojson spec so I would consider fixing the data and not the rendering as an initial solution.
Thanks for you quick answer !
I also think that the problem is not recent.
Geojson is agnostic to coordinates from Features ¹.
I can format Geojson with Turf. By example, I can use unkinkPolygon
to format Geojson features:
But they are some "problems":
Why not use a multipolygon in this case?
Why not use a multipolygon in this case?
Sometimes I've not the choice. If I get a Geojson with this format, I want have possibility to display correctly, without manual changes. With Leaflet, I didn't ask myself the question. Ideally, I wish I didn't have to worry about it 😅
Ideally I agree. You have two options here: fix the geometry, or send a PR to fix the code here. I'll let you decide which is simpler. 😀
Ideally I agree. You have two options here: fix the geometry, or send a PR to fix the code here. I'll let you decide which is simpler. 😀
Yeah, for the moment I will fix the geometry with Turf.
Thanks
First, I thank everyone participating in maplibre developing project.
But in general, self intersecting polygon is not a valid polygon when checking the geojson spec so I would consider fixing the data and not the rendering as an initial solution.
I also consider fixing the self intersecting is the first step towards solution. But I now found the case that
I've also reported this case at the geojson-vt project. Please refer "here" for more information.
In this case, I hope maplibre will display the form that is not self intersecting, becase the original geojson is as well. Is it technologically difficult to fix maplibre and realize it?
The code blow is how I got the self intersecting WKT using the geojson that is not self intersecting. (ZoomLevel=10, Latitude=28.4441, Longitude=129.6784) I attached the WKT I got by this code as well.
A20-070402_46_AmamiIslands_kasari_10_28.4441_129.6784.txt
map.addSource('amami', {
type: 'geojson',
data: './geojson/A20-070402_46_AmamiIslands_kasari.json',
},);
map.addLayer({
id: 'amami_polygon',
type: 'fill',
source: 'amami',
paint: {
'fill-color': "rgb(255,0,0)",
'fill-opacity': 0.5,
'fill-outline-color': "rgb(0,0,255)",
'fill-antialias': true,
},
});
// get WKT
map.on('click', 'amami_polygon', function (e) {
const coordinates = e.features[0].geometry.coordinates[0];
let cood = "POLYGON((";
for (let i = 0; i < coordinates.length; i++) {
cood+= coordinates[i][0] + (' ') + coordinates[i][1] + ',';
}
cood += "))";
console.log(cood);
}
);
maplibre-gl-js version:
2.3.0
Problem description
For self-intersect polygons, we have 2 problems:
Steps to Trigger Behavior
Draw a polygon with self intersection.
Example:
Link to Demonstration
JSfiddle example
Expected Behavior
Actual Behavior