-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored sqlalchemy-related parsing of geometry (#88)
* Refactored sqlalchemy-related parsing of geometry Geometry is now able to recognize custom CRS definitions * Removed unnecessary import
- Loading branch information
1 parent
f087964
commit 296e8b9
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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,34 @@ | ||
from typing import cast | ||
import pytest | ||
|
||
from pygeofilter.backends.sqlalchemy import filters | ||
|
||
|
||
@pytest.mark.parametrize("geom, expected", [ | ||
pytest.param( | ||
{ | ||
"type": "Point", | ||
"coordinates": [10, 12] | ||
}, | ||
"ST_GeomFromEWKT('SRID=4326;POINT (10 12)')", | ||
id="without-crs" | ||
), | ||
pytest.param( | ||
{ | ||
"type": "Point", | ||
"coordinates": [1, 2], | ||
"crs": { | ||
"type": "name", | ||
"properties": { | ||
"name": "urn:ogc:def:crs:EPSG::3004" | ||
} | ||
} | ||
}, | ||
"ST_GeomFromEWKT('SRID=3004;POINT (1 2)')", | ||
id="with-crs" | ||
), | ||
]) | ||
def test_parse_geometry(geom, expected): | ||
parsed = filters.parse_geometry(cast(dict, geom)) | ||
result = str(parsed.compile(compile_kwargs={"literal_binds": True})) | ||
assert result == expected |