GeoAlchemy2 0.15.0__tar.gz → 0.15.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.pre-commit-config.yaml +4 -4
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/CHANGES.txt +11 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2/GeoAlchemy2.egg-info}/PKG-INFO +1 -1
- {geoalchemy2-0.15.0/GeoAlchemy2.egg-info → geoalchemy2-0.15.2}/PKG-INFO +1 -1
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/elements.py +1 -1
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/sqlite.py +5 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/__init__.py +4 -5
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/conftest.py +13 -8
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functional.py +40 -2
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functional_sqlite.py +48 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.codespellrc +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.coveragerc +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.flake8 +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/ISSUE_TEMPLATE/how_to_use.yaml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/dependabot.yml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/pull_request_template.md +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.github/workflows/test_and_publish.yml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.gitignore +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/.readthedocs.yaml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/COPYING.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2.egg-info/SOURCES.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2.egg-info/dependency_links.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2.egg-info/not-zip-safe +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2.egg-info/requires.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2.egg-info/top_level.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/GeoAlchemy2_dev.yml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/MANIFEST.in +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/README.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/RELEASE.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/TEST.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/Makefile +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_static/geoalchemy.png +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_static/geoalchemy.svg +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_static/geoalchemy_small.png +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_static/geoalchemy_small.svg +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_templates/sidebar-about.html +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_templates/sidebar-links.html +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_templates/sidebar-logo.html +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/LICENSE +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/README +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/flask/layout.html +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/flask/relations.html +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/flask/static/flasky.css_t +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/flask/static/small_flask.css +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/_themes/flask/theme.conf +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/admin.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/alembic.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/alembic_helpers.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/changelog.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/conf.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/core_tutorial.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/elements.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/index.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/make.bat +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/migrate.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/orm_tutorial.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/shape.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/spatial_functions.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/spatial_operators.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/spatialite_tutorial.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/doc/types.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/generate_type_stubs.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/_functions.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/_functions_helpers.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/common.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/geopackage.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/mysql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/postgresql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/admin/dialects/sqlite.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/alembic_helpers.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/comparator.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/exc.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/functions.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/functions.pyi +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/py.typed +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/shape.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/common.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/geopackage.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/mysql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/types/dialects/postgresql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/geoalchemy2/utils.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/pyproject.toml +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/requirements-doc.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/requirements-mypy.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/requirements-rtd.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/requirements.txt +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/setup.cfg +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/setup.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/.dockerignore +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/.gitignore +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/Dockerfile +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/build.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/helpers/entrypoint.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/helpers/init_mysql.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/helpers/init_postgres.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/helpers/install_requirements.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/test_container/run.sh +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/alembic_config/alembic.ini +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/data/spatialite_ge_4.sqlite +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/data/spatialite_geopackage.gpkg +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/data/spatialite_lt_4.sqlite +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/README.rst +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/__init__.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_decipher_raster.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_disable_wrapping.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_insert_raster.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_length_at_insert.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_orm_mapped_v2.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_raster_transform.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_specific_compilation.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_summarystatsagg.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/gallery/test_type_decorator.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/schema_fixtures.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_alembic_migrations.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_comparator.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_elements.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functional_geopackage.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functional_mysql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functional_postgresql.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_functions.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_pickle.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_shape.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tests/test_types.py +0 -0
- {geoalchemy2-0.15.0 → geoalchemy2-0.15.2}/tox.ini +0 -0
@@ -2,7 +2,7 @@ default_language_version:
|
|
2
2
|
python: python3.8
|
3
3
|
repos:
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
5
|
-
rev: v4.
|
5
|
+
rev: v4.6.0
|
6
6
|
hooks:
|
7
7
|
- id: check-added-large-files
|
8
8
|
- id: check-case-conflict
|
@@ -17,11 +17,11 @@ repos:
|
|
17
17
|
hooks:
|
18
18
|
- id: isort
|
19
19
|
- repo: https://github.com/psf/black
|
20
|
-
rev: 24.
|
20
|
+
rev: 24.4.2
|
21
21
|
hooks:
|
22
22
|
- id: black
|
23
23
|
- repo: https://github.com/codespell-project/codespell
|
24
|
-
rev: v2.
|
24
|
+
rev: v2.3.0
|
25
25
|
hooks:
|
26
26
|
- id: codespell
|
27
27
|
- repo: https://github.com/PyCQA/pydocstyle
|
@@ -31,7 +31,7 @@ repos:
|
|
31
31
|
additional_dependencies: ["tomli"]
|
32
32
|
exclude: "tests"
|
33
33
|
- repo: https://github.com/PyCQA/flake8
|
34
|
-
rev: 7.
|
34
|
+
rev: 7.1.0
|
35
35
|
hooks:
|
36
36
|
- id: flake8
|
37
37
|
ci:
|
@@ -1,6 +1,17 @@
|
|
1
1
|
GeoAlchemy 2 Changelog
|
2
2
|
======================
|
3
3
|
|
4
|
+
0.15.2
|
5
|
+
------
|
6
|
+
|
7
|
+
* Fix: Can handle negative coordinates with Spatialite @adrien-berchet (#517)
|
8
|
+
|
9
|
+
0.15.1
|
10
|
+
------
|
11
|
+
|
12
|
+
* Fix: Default SRID is bypassed when using floating point coordinates @aballet (#509)
|
13
|
+
* Test: Dispose of the connection pools of the test engines @adrien-berchet (#511)
|
14
|
+
|
4
15
|
0.15.0
|
5
16
|
------
|
6
17
|
|
@@ -117,7 +117,7 @@ class WKTElement(_SpatialElement):
|
|
117
117
|
"""
|
118
118
|
|
119
119
|
_REMOVE_SRID = re.compile("(SRID=([0-9]+); ?)?(.*)")
|
120
|
-
SPLIT_WKT_PATTERN = re.compile(r"((SRID=\d+) *; *)?([\w ]+) *(\([
|
120
|
+
SPLIT_WKT_PATTERN = re.compile(r"((SRID=\d+) *; *)?([\w ]+) *(\([-\d\. ,\(\)]+\))")
|
121
121
|
|
122
122
|
geom_from: str = "ST_GeomFromText"
|
123
123
|
geom_from_extended_version: str = "ST_GeomFromEWKT"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""This module defines specific functions for SQLite dialect."""
|
2
2
|
|
3
3
|
import re
|
4
|
+
import warnings
|
4
5
|
|
5
6
|
from geoalchemy2.elements import RasterElement
|
6
7
|
from geoalchemy2.elements import WKBElement
|
@@ -12,6 +13,10 @@ def format_geom_type(wkt, default_srid=None):
|
|
12
13
|
"""Format the Geometry type for SQLite."""
|
13
14
|
match = re.match(WKTElement.SPLIT_WKT_PATTERN, wkt)
|
14
15
|
if match is None:
|
16
|
+
warnings.warn(
|
17
|
+
"The given WKT could not be parsed by GeoAlchemy2, this could lead to undefined "
|
18
|
+
f"behavior with Z, M or ZM geometries or with incorrect SRID. The WKT string is: {wkt}"
|
19
|
+
)
|
15
20
|
return wkt
|
16
21
|
_, srid, geom_type, coords = match.groups()
|
17
22
|
geom_type = geom_type.replace(" ", "")
|
@@ -5,8 +5,7 @@ import shutil
|
|
5
5
|
import sys
|
6
6
|
|
7
7
|
import pytest
|
8
|
-
from packaging import
|
9
|
-
from pkg_resources import parse_version
|
8
|
+
from packaging.version import parse as parse_version
|
10
9
|
from sqlalchemy import __version__ as SA_VERSION
|
11
10
|
from sqlalchemy import create_engine
|
12
11
|
from sqlalchemy import select as raw_select
|
@@ -30,9 +29,9 @@ class test_only_with_dialects:
|
|
30
29
|
|
31
30
|
def get_postgis_major_version(bind):
|
32
31
|
try:
|
33
|
-
return
|
32
|
+
return parse_version(bind.execute(func.postgis_lib_version()).scalar()).major
|
34
33
|
except OperationalError:
|
35
|
-
return
|
34
|
+
return parse_version("0").major
|
36
35
|
|
37
36
|
|
38
37
|
def get_postgres_major_version(bind):
|
@@ -81,7 +80,7 @@ def skip_pypy(msg=None):
|
|
81
80
|
|
82
81
|
|
83
82
|
def select(args):
|
84
|
-
if
|
83
|
+
if parse_version(SA_VERSION) < parse_version("1.4"):
|
85
84
|
return raw_select(args)
|
86
85
|
else:
|
87
86
|
return raw_select(*args)
|
@@ -161,18 +161,23 @@ def engine(tmpdir, db_url, _engine_echo):
|
|
161
161
|
# Copy the input SQLite DB to a temporary file and return an engine to it
|
162
162
|
input_url = str(db_url)[10:]
|
163
163
|
output_file = "test_spatial_db.sqlite"
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
current_engine = copy_and_connect_sqlite_db(
|
165
|
+
input_url, tmpdir / output_file, _engine_echo, "sqlite"
|
166
|
+
)
|
167
|
+
elif db_url.startswith("gpkg:///"):
|
167
168
|
# Copy the input SQLite DB to a temporary file and return an engine to it
|
168
169
|
input_url = str(db_url)[8:]
|
169
170
|
output_file = "test_spatial_db.gpkg"
|
170
|
-
|
171
|
+
current_engine = copy_and_connect_sqlite_db(
|
172
|
+
input_url, tmpdir / output_file, _engine_echo, "gpkg"
|
173
|
+
)
|
174
|
+
else:
|
175
|
+
# For other dialects the engine is directly returned
|
176
|
+
current_engine = create_engine(db_url, echo=_engine_echo)
|
177
|
+
current_engine.update_execution_options(search_path=["gis", "public"])
|
171
178
|
|
172
|
-
|
173
|
-
|
174
|
-
engine.update_execution_options(search_path=["gis", "public"])
|
175
|
-
return engine
|
179
|
+
yield current_engine
|
180
|
+
current_engine.dispose()
|
176
181
|
|
177
182
|
|
178
183
|
@pytest.fixture
|
@@ -335,7 +335,16 @@ class TestInsertionCore:
|
|
335
335
|
),
|
336
336
|
],
|
337
337
|
)
|
338
|
-
|
338
|
+
@pytest.mark.parametrize(
|
339
|
+
"use_floating_point",
|
340
|
+
[
|
341
|
+
pytest.param(True, id="Use floating point"),
|
342
|
+
pytest.param(False, id="Do not use floating point"),
|
343
|
+
],
|
344
|
+
)
|
345
|
+
def test_insert_all_geom_types(
|
346
|
+
self, dialect_name, base, conn, metadata, geom_type, wkt, use_floating_point
|
347
|
+
):
|
339
348
|
"""Test insertion and selection of all geometry types."""
|
340
349
|
ndims = 2
|
341
350
|
if "Z" in geom_type[-2:]:
|
@@ -358,6 +367,9 @@ class TestInsertionCore:
|
|
358
367
|
metadata.drop_all(bind=conn, checkfirst=True)
|
359
368
|
metadata.create_all(bind=conn)
|
360
369
|
|
370
|
+
if use_floating_point:
|
371
|
+
wkt = wkt.replace("1 2", "1.5 2.5")
|
372
|
+
|
361
373
|
inserted_wkt = f"{geom_type}{wkt}"
|
362
374
|
|
363
375
|
# Use the DB to generate the corresponding raw WKB
|
@@ -401,7 +413,7 @@ class TestInsertionCore:
|
|
401
413
|
if "MULTIPOINT" in geom_type:
|
402
414
|
# Some dialects return MULTIPOINT geometries with nested parenthesis and others
|
403
415
|
# do not so we remove them before checking the results
|
404
|
-
checked_wkt = re.sub(r"\(([0-9]+)\)", "\\1", checked_wkt)
|
416
|
+
checked_wkt = re.sub(r"\(([0-9\.]+)\)", "\\1", checked_wkt)
|
405
417
|
if row_id >= 5 and dialect_name in ["geopackage"] and has_m:
|
406
418
|
# Currently Shapely does not support geometry types with M dimension
|
407
419
|
assert checked_wkt != expected_wkt
|
@@ -433,6 +445,32 @@ class TestInsertionCore:
|
|
433
445
|
assert srid == 4326
|
434
446
|
assert row[1] == from_shape(Point(1, 1), srid=4326, extended=True)
|
435
447
|
|
448
|
+
def test_insert_negative_coords(self, conn, Poi, setup_tables, dialect_name):
|
449
|
+
conn.execute(
|
450
|
+
Poi.__table__.insert(),
|
451
|
+
[
|
452
|
+
{"geom": "SRID=4326;POINT(-1 1)"},
|
453
|
+
{"geom": WKTElement("POINT(-1 1)", srid=4326)},
|
454
|
+
{"geom": WKTElement("SRID=4326;POINT(-1 1)", extended=True)},
|
455
|
+
{"geom": from_shape(Point(-1, 1), srid=4326)},
|
456
|
+
{"geom": from_shape(Point(-1, 1), srid=4326, extended=True)},
|
457
|
+
],
|
458
|
+
)
|
459
|
+
|
460
|
+
results = conn.execute(Poi.__table__.select())
|
461
|
+
rows = results.fetchall()
|
462
|
+
|
463
|
+
for row in rows:
|
464
|
+
assert isinstance(row[1], WKBElement)
|
465
|
+
wkt = conn.execute(row[1].ST_AsText()).scalar()
|
466
|
+
assert format_wkt(wkt) == "POINT(-1 1)"
|
467
|
+
srid = conn.execute(row[1].ST_SRID()).scalar()
|
468
|
+
assert srid == 4326
|
469
|
+
if dialect_name == "mysql":
|
470
|
+
assert row[1] == from_shape(Point(-1, 1), srid=4326)
|
471
|
+
else:
|
472
|
+
assert row[1] == from_shape(Point(-1, 1), srid=4326, extended=True)
|
473
|
+
|
436
474
|
|
437
475
|
class TestSelectBindParam:
|
438
476
|
@pytest.fixture
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import re
|
2
2
|
|
3
3
|
import pytest
|
4
|
+
from shapely.geometry import GeometryCollection
|
4
5
|
from shapely.geometry import LineString
|
6
|
+
from shapely.geometry import Point
|
5
7
|
from sqlalchemy import CheckConstraint
|
6
8
|
from sqlalchemy import Column
|
7
9
|
from sqlalchemy import Integer
|
@@ -22,6 +24,7 @@ from geoalchemy2.elements import WKTElement
|
|
22
24
|
from geoalchemy2.shape import from_shape
|
23
25
|
from geoalchemy2.shape import to_shape
|
24
26
|
|
27
|
+
from . import format_wkt
|
25
28
|
from . import select
|
26
29
|
from . import skip_case_insensitivity
|
27
30
|
from . import skip_pypy
|
@@ -310,6 +313,51 @@ class TestMiscellaneous:
|
|
310
313
|
load_spatialite(conn.connection.dbapi_connection)
|
311
314
|
|
312
315
|
|
316
|
+
class TestInsertionCore:
|
317
|
+
@pytest.fixture
|
318
|
+
def GeomObject(self, base):
|
319
|
+
class GeomObject(base):
|
320
|
+
__tablename__ = "any_geom_object"
|
321
|
+
id = Column(Integer, primary_key=True)
|
322
|
+
geom = Column(Geometry(srid=4326))
|
323
|
+
|
324
|
+
return GeomObject
|
325
|
+
|
326
|
+
def test_insert_unparsable_WKT(self, conn, GeomObject, setup_tables, dialect_name):
|
327
|
+
with pytest.warns(
|
328
|
+
UserWarning,
|
329
|
+
match=(
|
330
|
+
"The given WKT could not be parsed by GeoAlchemy2, this could lead to undefined "
|
331
|
+
"behavior"
|
332
|
+
),
|
333
|
+
):
|
334
|
+
conn.execute(
|
335
|
+
GeomObject.__table__.insert(),
|
336
|
+
[
|
337
|
+
{"geom": "SRID=4326;GeometryCollection(POINT (-1 1),LINESTRING (2 2, 3 3))"},
|
338
|
+
],
|
339
|
+
)
|
340
|
+
|
341
|
+
results = conn.execute(GeomObject.__table__.select())
|
342
|
+
rows = results.fetchall()
|
343
|
+
|
344
|
+
for row in rows:
|
345
|
+
assert isinstance(row[1], WKBElement)
|
346
|
+
wkt = conn.execute(row[1].ST_AsText()).scalar()
|
347
|
+
assert format_wkt(wkt) == "GEOMETRYCOLLECTION(POINT(-1 1),LINESTRING(2 2,3 3))"
|
348
|
+
srid = conn.execute(row[1].ST_SRID()).scalar()
|
349
|
+
assert srid == 4326
|
350
|
+
if dialect_name == "mysql":
|
351
|
+
extended = None
|
352
|
+
else:
|
353
|
+
extended = True
|
354
|
+
assert row[1] == from_shape(
|
355
|
+
GeometryCollection([Point(-1, 1), LineString([[2, 2], [3, 3]])]),
|
356
|
+
srid=4326,
|
357
|
+
extended=extended,
|
358
|
+
)
|
359
|
+
|
360
|
+
|
313
361
|
class TestInsertionORM:
|
314
362
|
@pytest.fixture
|
315
363
|
def LocalPoint(self, base):
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|