Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

within expression returns inconsistent value when point is on the boundary #16301

Closed
zmiao opened this issue Mar 11, 2020 · 1 comment · Fixed by #16319
Closed

within expression returns inconsistent value when point is on the boundary #16301

zmiao opened this issue Mar 11, 2020 · 1 comment · Fixed by #16319
Assignees

Comments

@zmiao
Copy link
Contributor

zmiao commented Mar 11, 2020

When feature is on the polygon boundary, within returns inconsistent value, which will cause flickering styling for the feature.

Reproducable with style:

{
  "version": 8,
  "sources": {
    "points": {
      "type": "geojson",
      "data": {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "geometry": {
              "type": "Point",
              "coordinates": [ 5, 5]
            }
          }
        ]
      }
    },
    "polygon": {
      "type": "geojson",
      "data": {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "Polygon",
              "coordinates": [
                [
                  [-5, -5],
                  [5, -5],
                  [5, 5],
                  [-5, 5],
                  [-5,-5]
                ]
              ]
            }
          }
        ]
      }
    }
  },
  "layers": [
    {
      "id": "border",
      "type": "fill",
      "source": "polygon",
      "paint": {
        "fill-color": "black",
        "fill-opacity": 0.5
      }
    },
    {
      "id": "points",
      "type": "circle",
      "source": "points",
      "paint": {
        "circle-color": [
          "case",
          [
            "within",
            {
              "type": "Polygon",
              "coordinates": [
                [
                  [-5, -5],
                  [5, -5],
                  [5, 5],
                  [-5, 5],
                  [-5,-5]
                ]
              ]
            }
          ],
          "red",
          "blue"
        ],
      }
    }
  ]
}
@zmiao zmiao self-assigned this Mar 11, 2020
@1ec5
Copy link
Contributor

1ec5 commented Mar 12, 2020

mapbox/mapbox-gl-js#9411 tracks the same issue on the GL JS side.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants