petern48 commented on code in PR #2105:
URL: https://github.com/apache/sedona/pull/2105#discussion_r2213801920
##########
python/tests/geopandas/test_geoseries.py:
##########
@@ -328,7 +342,37 @@ def test_estimate_utm_crs(self):
sgpd.GeoSeries([Polygon([(0, 90), (1, 90), (2,
90)])]).estimate_utm_crs()
def test_to_json(self):
- pass
+ s = GeoSeries([Point(1, 1), Point(2, 2), Point(3, 3)])
+
+ # TODO: optimize this away
+ with self.ps_allow_diff_frames():
+ result = s.to_json()
+ expected = '{"type": "FeatureCollection", "features": [{"id": "0",
"type": "Feature", "pr\
+operties": {}, "geometry": {"type": "Point", "coordinates": [1.0, 1.0]},
"bbox": [1.0,\
+ 1.0, 1.0, 1.0]}, {"id": "1", "type": "Feature", "properties": {}, "geometry":
{"type"\
+: "Point", "coordinates": [2.0, 2.0]}, "bbox": [2.0, 2.0, 2.0, 2.0]}, {"id":
"2", "typ\
+e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates":
[3.0, 3.\
+0]}, "bbox": [3.0, 3.0, 3.0, 3.0]}], "bbox": [1.0, 1.0, 3.0, 3.0]}'
+
+ assert result == expected
+
+ with self.ps_allow_diff_frames():
+ result = s.to_json(show_bbox=True)
+ expected = '{"type": "FeatureCollection", "features": [{"id": "0",
"type": "Feature", "properties": {}, "geometry": {"type": "Point",
"coordinates": [1.0, 1.0]}, "bbox": [1.0, 1.0, 1.0, 1.0]}, {"id": "1", "type":
"Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [2.0,
2.0]}, "bbox": [2.0, 2.0, 2.0, 2.0]}, {"id": "2", "type": "Feature",
"properties": {}, "geometry": {"type": "Point", "coordinates": [3.0, 3.0]},
"bbox": [3.0, 3.0, 3.0, 3.0]}], "bbox": [1.0, 1.0, 3.0, 3.0]}'
+ assert result == expected
+
+ with self.ps_allow_diff_frames():
+ result = s.to_json(drop_id=True)
+ expected = '{"type": "FeatureCollection", "features": [{"type":
"Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [1.0,
1.0]}, "bbox": [1.0, 1.0, 1.0, 1.0]}, {"type": "Feature", "properties": {},
"geometry": {"type": "Point", "coordinates": [2.0, 2.0]}, "bbox": [2.0, 2.0,
2.0, 2.0]}, {"type": "Feature", "properties": {}, "geometry": {"type": "Point",
"coordinates": [3.0, 3.0]}, "bbox": [3.0, 3.0, 3.0, 3.0]}], "bbox": [1.0, 1.0,
3.0, 3.0]}'
+ # print(s.to_geopandas().to_json(drop_id=True))
+ # raise
+ # expected = '{"type": "FeatureCollection", "features": [{"type":
"Feature", "geometry": {"type": "Point", "coordinates": [1.0, 1.0]},
"properties": {}}, {"type": "Feature", "geometry": {"type": "Point",
"coordinates": [2.0, 2.0]}, "properties": {}}, {"type": "Feature", "geometry":
{"type": "Point", "coordinates": [3.0, 3.0]}, "properties": {}}]}'
Review Comment:
Copilot just suggested that I delete this 3 times in a row ... ðŸ˜
(see above two resolved comments)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]