-
Notifications
You must be signed in to change notification settings - Fork 42
feat(rust/sedona-functions): Implement ST_AsEWKB with item CRS support #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fbd5cfc
first go
paleolimbot 64b45e1
in theory work
paleolimbot 7b0fa5b
passing tests
paleolimbot 5f699da
working!
paleolimbot ba80f16
typo
paleolimbot 41e758c
move ewkb to sedona-geometry
paleolimbot fa9272a
add roundtrip test
paleolimbot 215347c
fix test
paleolimbot 559439f
test empties
paleolimbot 14894ee
better order
paleolimbot da872d6
function tests
paleolimbot 9069645
pin pandas
paleolimbot e0a569d
Update rust/sedona-functions/src/st_asewkb.rs
paleolimbot 44de999
remove test dep change
paleolimbot 36c7846
add nested geometry collection test
paleolimbot 1c6501f
test questionable crs values
paleolimbot 1d4a9e1
Merge remote-tracking branch 'upstream/main' into st-ewkb-fns
paleolimbot a2ebf98
Merge remote-tracking branch 'upstream/main' into st-ewkb-fns
paleolimbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| import pytest | ||
| import shapely | ||
| from sedonadb.testing import PostGIS, SedonaDB, geom_or_null | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) | ||
| @pytest.mark.parametrize("srid", [None, 4326]) | ||
| @pytest.mark.parametrize( | ||
| "geom", | ||
| [ | ||
| # XY dimensions | ||
| "POINT (1 2)", | ||
| "LINESTRING (1 2, 3 4, 5 6)", | ||
| "POLYGON ((0 1, 2 0, 2 3, 0 3, 0 1))", | ||
| "MULTIPOINT ((1 2), (3 4))", | ||
| "MULTILINESTRING ((1 2, 3 4), (5 6, 7 8))", | ||
| "MULTIPOLYGON (((0 1, 2 0, 2 3, 0 3, 0 1)))", | ||
| "GEOMETRYCOLLECTION (POINT (1 2), LINESTRING (3 4, 5 6))", | ||
| # XYZ dimensions | ||
| "POINT Z (1 2 3)", | ||
| "LINESTRING Z (1 2 3, 4 5 6)", | ||
| "POLYGON Z ((0 1 2, 3 0 2, 3 4 2, 0 4 2, 0 1 2))", | ||
| "MULTIPOINT Z ((1 2 3), (4 5 6))", | ||
| "MULTILINESTRING Z ((1 2 3, 4 5 6), (7 8 9, 10 11 12))", | ||
| "MULTIPOLYGON Z (((0 1 2, 3 0 2, 3 4 2, 0 4 2, 0 1 2)))", | ||
| "GEOMETRYCOLLECTION Z (POINT Z (1 2 3))", | ||
| # XYM dimensions | ||
| "POINT M (1 2 3)", | ||
| "LINESTRING M (1 2 3, 4 5 6)", | ||
| "POLYGON M ((0 1 2, 3 0 2, 3 4 2, 0 4 2, 0 1 2))", | ||
| "MULTIPOINT M ((1 2 3), (4 5 6))", | ||
| "MULTILINESTRING M ((1 2 3, 4 5 6), (7 8 9, 10 11 12))", | ||
| "MULTIPOLYGON M (((0 1 2, 3 0 2, 3 4 2, 0 4 2, 0 1 2)))", | ||
| "GEOMETRYCOLLECTION M (POINT M (1 2 3))", | ||
| # XYZM dimensions | ||
| "POINT ZM (1 2 3 4)", | ||
| "LINESTRING ZM (1 2 3 4, 5 6 7 8)", | ||
| "POLYGON ZM ((0 1 2 3, 4 0 2 3, 4 5 2 3, 0 5 2 3, 0 1 2 3))", | ||
| "MULTIPOINT ZM ((1 2 3 4), (5 6 7 8))", | ||
| "MULTILINESTRING ZM ((1 2 3 4, 5 6 7 8), (9 10 11 12, 13 14 15 16))", | ||
| "MULTIPOLYGON ZM (((0 1 2 3, 4 0 2 3, 4 5 2 3, 0 5 2 3, 0 1 2 3)))", | ||
| "GEOMETRYCOLLECTION ZM (POINT ZM (1 2 3 4))", | ||
| # Empty geometries | ||
| "POINT EMPTY", | ||
| "LINESTRING EMPTY", | ||
| "POLYGON EMPTY", | ||
| "MULTIPOINT EMPTY", | ||
| "MULTILINESTRING EMPTY", | ||
| "MULTIPOLYGON EMPTY", | ||
| "GEOMETRYCOLLECTION EMPTY", | ||
| # NULL | ||
| None, | ||
| ], | ||
| ) | ||
| def test_st_asewkb(eng, srid, geom): | ||
| eng = eng.create_or_skip() | ||
|
|
||
| if geom is not None: | ||
| shapely_geom = shapely.from_wkt(geom) | ||
| if srid is not None: | ||
| shapely_geom = shapely.set_srid(shapely_geom, srid) | ||
| write_srid = True | ||
| else: | ||
| write_srid = False | ||
|
|
||
| expected = shapely.to_wkb( | ||
| shapely_geom, | ||
| output_dimension=4, | ||
| byte_order=1, | ||
| flavor="extended", | ||
| include_srid=write_srid, | ||
| ) | ||
| else: | ||
| expected = None | ||
|
|
||
| eng.assert_query_result(f"SELECT ST_AsEWKB({geom_or_null(geom, srid)})", expected) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember it correctly, this pattern for decomposing fields in struct type representing item with crs has appeared many times in the code base. Maybe we can define a helper method for doing this.