deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] GeoJsonLayer accessors receive different payloads when data is binary

Open aethr opened this issue 1 year ago • 2 comments

Description

When using GeoJsonLayer with binary data, layer accessors receive a feature object which is missing important fields such as id. When creating a GeoJsonLayer with the same feature in GeoJSON format, the id field is present.

Example feature:

{
  "type": "Feature",
  "id": 1,
  "properties": {
    "foo": "bar"
  },
  "geometry": { "type": "Point", "coordinates": [0.60888671875, 0.556884765625] }
}

Creating a GeoJsonLayer from this feature, and providing it as a normal GeoJSON object, accessors such as getText will receive the object:

{
    "type": "Feature",
    "id": 1,
    "properties": {
        "foo": "bar"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [
            0.60888671875,
            0.556884765625
        ]
    }
}

With no other changes, but supplying data to the layer as binary, the same accessor receives the object:

{
    "properties": {
        "foo": "bar"
    }
}

Flavors

  • [ ] Script tag
  • [ ] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxOverlay
  • [ ] GoogleMapsOverlay
  • [ ] CartoLayer
  • [ ] ArcGIS

Expected Behavior

Although it may not be feasible to reconstruct the entire feature object for performance reasons, it would be really useful to still have access to the id field within accessors. This is useful for features like having a highlighted feature (not using autoHighlight) which is based on the feature's id.

Steps to Reproduce

https://codepen.io/aethrXor/pen/gOVbrGv?editors=0010

Environment

Logs

No response

aethr avatar Sep 25 '24 03:09 aethr

As a workaround I am currently duplicating the id in the properties object as well, but it means I'm sending some unnecessary data in my MVT responses that I'd like to avoid.

aethr avatar Sep 25 '24 03:09 aethr

@felixpalmer It should be trivial to add the id here? https://github.com/visgl/deck.gl/blob/aa2537bbb1b01392aa053ba1f413eea1b689327a/modules/layers/src/geojson-layer/geojson-binary.ts#L45

Pessimistress avatar Sep 25 '24 19:09 Pessimistress