[Doc] pydeck.Layer modifies data. Documentation should make this clear!
@Jesus89 is already working on this.
Since Dec 14, 2023.
- Dominant language
- TypeScript
- Stars
- 14.6k
- Forks
- 2.3k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 42
Description
Link
https://deckgl.readthedocs.io/en/latest/layer.html
Description
When using 'GeoJsonLayer' and passing a python-geojson object to the data attribute the geojson object gets modified. This sideeffect is not documented.
I spent a while trying to figure out why the geojson geometry suddenly appeared in the properties of a feature as well as in the feature itself. This was due to me using the geojson object after passing it to a Layer. So the layer seems to modify the object.
import geojson
from pydeck import Layer
gj_obj = geojson.FeatureCollection([geojson.Feature(geometry=geojson.Point((0, 0)))])
before = geojson.dumps(gj_obj)
print(before)
layer = Layer('GeoJsonLayer', gj_obj)
after = geojson.dumps(gj_obj)
print(after)
print(before == after)
{"features": [{
"geometry": {"coordinates": [0, 0], "type": "Point"},
"properties": {"geometry": {"coordinates": [0, 0], "type": "Point"}},
"type": "Feature"
}], "type": "FeatureCollection"}
I don't really know why adding the geometry to the properties is neccessary as it is present in the feature anyway, but if it is required it should at least be documented that this is happening.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.