Skip to content

Commit 2cda72b

Browse files
authored
docs: add notes about mutation (#192)
* docs: add notes about mutation * docs: try gfm
1 parent 58d01aa commit 2cda72b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ import antimeridian
4141
fixed = antimeridian.fix_geojson(geojson)
4242
```
4343

44+
> [!NOTE]
45+
> `fix_geojson` mutates the input dictionary in-place. If you need to preserve the original GeoJSON, make a copy first:
46+
>
47+
> ```python
48+
> import copy
49+
> fixed = antimeridian.fix_geojson(copy.deepcopy(geojson))
50+
> ```
51+
4452
We also have some utilities to create [bounding boxes](https://antimeridian.readthedocs.io/en/latest/api.html#antimeridian.bbox) and [centroids](https://antimeridian.readthedocs.io/en/latest/api.html#antimeridian.centroid) from antimeridian-crossing polygons and multipolygons.
4553
See [the documentation](https://www.gadom.ski/antimeridian/) for a complete API reference.
4654

src/antimeridian/_implementation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ def fix_geojson(
8585
See [antimeridian.fix_polygon][] for a description of the `force_north_pole`
8686
`force_south_pole` and `fix_winding` arguments.
8787
88+
Warning:
89+
This function mutates the input dictionary in-place. If you need to
90+
preserve the original GeoJSON, make a copy before calling this function
91+
(e.g., using `copy.deepcopy(geojson)`).
92+
8893
Args:
8994
geojson: A GeoJSON object as a dictionary
9095
force_north_pole: If the polygon crosses the antimeridian, force the
@@ -190,6 +195,11 @@ def fix_shape(
190195
See [antimeridian.fix_polygon][] for a description of the `force_north_pole`
191196
`force_south_pole` and `fix_winding` arguments.
192197
198+
Note:
199+
When `shape` is a dictionary, this function does not mutate it directly,
200+
but converts it to a Shapely geometry first. However, if called via
201+
[antimeridian.fix_geojson][], the input dictionary will be mutated.
202+
193203
Args:
194204
shape: A polygon, multi-polygon, line string, or multi-line string,
195205
either as a dictionary or as a [antimeridian.GeoInterface][]. Uses

0 commit comments

Comments
 (0)