This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
within expression behaves incorrectly when geometry crosses 180th Meridian #16326
Copy link
Copy link
Closed
Closed
Copy link
Description
Currently, the within expression only supports calculation for geometries that are with longitudes between -180 to 180. The expression will return incorrect value for those geometries that beyond this range.
cc: @chloekraw @tmpsantos @asheemmamoowala @mourner
Taking the following style as example, the correct behavior should be that all the points with red colors.
{
"version": 8,
"metadata": {
"test": {
"width": 150,
"height": 150
}
},
"zoom": 3,
"center": [-1, -27],
"sources": {
"line": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates":
[
-200.0,
83.0
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates":
[
170.0,
81.0
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates":
[
-170.0,
81.0
]
}
}
]
}
},
"polygon": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-205.83984375,
80.44493052181339
],
[
-135,
80.44493052181339
],
[
-135,
84.30218294503882
],
[
-205.83984375,
84.30218294503882
],
[
-205.83984375,
80.44493052181339
]
]
]
}
}
]
}
}
},
"layers": [
{
"id": "border",
"type": "fill",
"source": "polygon",
"paint": {
"fill-color": "white",
"fill-opacity": 0.5
}
},
{
"id": "line",
"type": "circle",
"source": "line",
"paint": {
"circle-color": ["case", ["within", {
"type": "Polygon",
"coordinates": [
[
[
-205.83984375,
80.44493052181339
],
[
-135,
80.44493052181339
],
[
-135,
84.30218294503882
],
[
-205.83984375,
84.30218294503882
],
[
-205.83984375,
80.44493052181339
]
]
]
}], "red", "blue"]
}
}
]
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]`within` expression behaves incorrectly when geometry longitude is beyond [-180, 180][/-][+]`within` expression behaves incorrectly when geometry crosses 180th Meridian[/+]zmiao commentedon Mar 23, 2020
An equivalent ticket in gl js: mapbox/mapbox-gl-js#9442