Whole file
geomet/geomet
The author described this change as “esri: Fix geojson to esrijson conversion with custom SRID”. It counts as a record because the check below fails on the code as it stood at f4def9688 and passes on 6c8493d80, with nothing else changed between the two runs.
Projectgeomet/geomet
Fix saved2023-11-12
Sharing licenceApache-2.0 · LICENSE
Change size+8 −4
What the code was meant to do, written into the code itself as a save note
esri: Fix geojson to esrijson conversion with custom SRID
The change
| 111 | 111 | """ | |
| 112 | 112 | coordkey = "coordinates" | |
| 113 | 113 | coords = obj[coordkey] | |
| 114 | - | srid = _extract_geojson_srid(obj) or srid | |
| 114 | + | if srid is None: | |
| 115 | + | srid = _extract_geojson_srid(obj) | |
| 115 | 116 | return {"x": coords[0], "y": coords[1], "spatialReference": {"wkid": srid}} | |
| 116 | 117 | ||
| 117 | 118 | ||
| ⋯ | |||
| 121 | 122 | ||
| 122 | 123 | """ | |
| 123 | 124 | coordkey = "coordinates" | |
| 124 | - | srid = _extract_geojson_srid(obj) or srid | |
| 125 | + | if srid is None: | |
| 126 | + | srid = _extract_geojson_srid(obj) | |
| 125 | 127 | return {"points": obj[coordkey], "spatialReference": {"wkid": srid}} | |
| 126 | 128 | ||
| 127 | 129 | ||
| ⋯ | |||
| 136 | 138 | coordinates = [obj[coordkey]] | |
| 137 | 139 | else: | |
| 138 | 140 | coordinates = obj[coordkey] | |
| 139 | - | srid = _extract_geojson_srid(obj) or srid | |
| 141 | + | if srid is None: | |
| 142 | + | srid = _extract_geojson_srid(obj) | |
| 140 | 143 | return {"paths": coordinates, "spatialReference": {"wkid": srid}} | |
| 141 | 144 | ||
| 142 | 145 | ||
| ⋯ | |||
| 157 | 160 | else: | |
| 158 | 161 | for seg in part: | |
| 159 | 162 | part_list.append([list(coord) for coord in seg]) | |
| 160 | - | srid = _extract_geojson_srid(data) or srid | |
| 163 | + | if srid is None: | |
| 164 | + | srid = _extract_geojson_srid(data) | |
| 161 | 165 | return {"rings": part_list, "spatialReference": {"wkid": srid}} | |
| 162 | 166 | ||
| 163 | 167 | ||
The check that tells the two apart
fail→pass·geomet/tests/esri_test.py::TestGeoJSONtoEsriJSONCustomSRID::test_dumps_to_esrijson_multipoint_custom_srid
Check file geomet/tests/esri_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf4def96884c3c5f36fc9be98bc5e351e4aa5a3a6
Broken version dated2023-11-09
Modulegeomet.esri
Units changed_dump_geojson_multipoint, _dump_geojson_point, _dump_geojson_polygon, _dump_geojson_polyline
Fingerprint880df8b1f59a96a3
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.