GeoAlchemy2 0.14.7__py3-none-any.whl → 0.15.1__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GeoAlchemy2
3
- Version: 0.14.7
3
+ Version: 0.15.1
4
4
  Summary: Using SQLAlchemy with Spatial Databases
5
5
  Home-page: https://geoalchemy-2.readthedocs.io/en/stable/
6
6
  Author: Eric Lemoine
@@ -0,0 +1,31 @@
1
+ geoalchemy2/__init__.py,sha256=Wb5f11AM_hYn56yrxOAOjCT3z76TCtseqjFo2hKsob4,1971
2
+ geoalchemy2/_functions.py,sha256=e8v584Fx_fmh8XnJvkuYEXrcyPDiWV95Mu2yw6L-LHY,62863
3
+ geoalchemy2/_functions_helpers.py,sha256=hVM9DDTgf-oM27EZu6ycW1y2ENnSxUJixdINetWsu0E,2651
4
+ geoalchemy2/alembic_helpers.py,sha256=WYjKiVVyHtlB4DI22z-G0-x8NnG8othAINUwmxBCMcs,27885
5
+ geoalchemy2/comparator.py,sha256=WUDXn10doDlJVnYiWbVIAhhBu7N5AO9BI8sNf2mhpA4,8100
6
+ geoalchemy2/elements.py,sha256=h3E-Sh3IPPVSlWjtPOYYGRF_UOqNkxsc15EvOiC6mkM,13001
7
+ geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
8
+ geoalchemy2/functions.py,sha256=0he8hy_SAWpXAFPdfg32NMW5G0FaZP7yVl0jn0MRLBQ,10320
9
+ geoalchemy2/functions.pyi,sha256=rKCKdDSVTgeUQHItkOKqJSEuyKmVJ30bpjLpCPwMI5g,108636
10
+ geoalchemy2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ geoalchemy2/shape.py,sha256=TZJIhCN4p4ZVwZMXidxYxTMeeyReAyoFzyYwspJRqSA,2792
12
+ geoalchemy2/utils.py,sha256=OYWYnT64tjp4DWhPdq3KIxHbVti932xPMtGGxajtu-I,488
13
+ geoalchemy2/admin/__init__.py,sha256=s8L5C9pYC5dTxhIp9j-JzWeg9kEJevXUW8Pq4_L4aZ8,3984
14
+ geoalchemy2/admin/dialects/__init__.py,sha256=XodzuBbWKkkSQzM5EL3I33azuE-y_go0nVOlmIyJ13g,367
15
+ geoalchemy2/admin/dialects/common.py,sha256=8OkGa7T2Gxz2vDVnC9nva8Ma0YqBwGxHWfBJoZF1cNQ,2936
16
+ geoalchemy2/admin/dialects/geopackage.py,sha256=UaJignKtlo13oHxq92yescVJtXFEXkm4fy5WzR6sLT8,13469
17
+ geoalchemy2/admin/dialects/mysql.py,sha256=z2gmkTGav60_myDCFxO1yeezDKBcNcMxFvcpH-OqVKw,6867
18
+ geoalchemy2/admin/dialects/postgresql.py,sha256=VwB_h3TC8M5aQ6aKE3UYgxHfbEKav3eIHJeLx534Zzg,6191
19
+ geoalchemy2/admin/dialects/sqlite.py,sha256=UYQuNDDy-1-lsvYlqyKy01UtHgLF4iEN42fE5D-9QQk,13597
20
+ geoalchemy2/types/__init__.py,sha256=dD2-E8rr1nXr_d4CqyiEvRjO1H-dDRQnzr5B1g3_an8,14186
21
+ geoalchemy2/types/dialects/__init__.py,sha256=sw__RqGAFVrUPGrICjsva9SPoYLBNfyAkBHmsJkT7k0,359
22
+ geoalchemy2/types/dialects/common.py,sha256=gxKaRQhIODJhu_yBurlvFNAqGh3LfPNu_DcObEG1wlU,138
23
+ geoalchemy2/types/dialects/geopackage.py,sha256=nRmN_PnF-CWMEHkWhKVdsybnw3SvXZIBXAHIHXJLTqw,147
24
+ geoalchemy2/types/dialects/mysql.py,sha256=zMNi1920v0XlVaCJWSwtq0b0P5YQRn8y3X_rBxC5KEw,1790
25
+ geoalchemy2/types/dialects/postgresql.py,sha256=7NBKEbDJXMwX8Sgs6o_N2bAUHgjUcjbrdmYOA7sDiRw,1117
26
+ geoalchemy2/types/dialects/sqlite.py,sha256=HaRVLvIM9wsyzlSK4-kJJzg1wNrXFWTBkJkFB0Hga3U,1861
27
+ GeoAlchemy2-0.15.1.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
28
+ GeoAlchemy2-0.15.1.dist-info/METADATA,sha256=yPxdSpR7pdJ73P3YI9yjsl_OasWEimMwtvOCKcZSdMo,2087
29
+ GeoAlchemy2-0.15.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
30
+ GeoAlchemy2-0.15.1.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
31
+ GeoAlchemy2-0.15.1.dist-info/RECORD,,
geoalchemy2/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  """GeoAlchemy2 package."""
2
+
2
3
  from geoalchemy2 import admin
3
4
  from geoalchemy2 import elements # noqa
4
5
  from geoalchemy2 import exc # noqa
@@ -60,8 +60,8 @@ class TableRowElement(ColumnElement):
60
60
  """The cache is disabled for this class."""
61
61
 
62
62
  def __init__(self, selectable: bool) -> None: ...
63
- @property
64
- def _from_objects(self) -> List[bool]: ... # type: ignore[override]
63
+ @property # type: ignore[override]
64
+ def _from_objects(self) -> List[bool]: ...
65
65
  '''
66
66
  stub_file_parts = [header]
67
67
 
@@ -1,4 +1,5 @@
1
1
  """This module defines the functions used for administration tasks."""
2
+
2
3
  from sqlalchemy import Column
3
4
  from sqlalchemy import Index
4
5
  from sqlalchemy import Table
@@ -1,4 +1,5 @@
1
1
  """This module defines some dialect-specific functions used for administration tasks."""
2
+
2
3
  from geoalchemy2.admin.dialects import common # noqa
3
4
  from geoalchemy2.admin.dialects import geopackage # noqa
4
5
  from geoalchemy2.admin.dialects import mysql # noqa
@@ -1,4 +1,5 @@
1
1
  """This module defines functions used by several dialects."""
2
+
2
3
  import sqlalchemy
3
4
  from packaging import version
4
5
  from sqlalchemy import Column
@@ -2,6 +2,7 @@
2
2
 
3
3
  See GeoPackage specifications here: http://www.geopackage.org/spec/
4
4
  """
5
+
5
6
  import re
6
7
 
7
8
  from sqlalchemy import text
@@ -1,4 +1,5 @@
1
1
  """This module defines specific functions for MySQL dialect."""
2
+
2
3
  from sqlalchemy import text
3
4
  from sqlalchemy.ext.compiler import compiles
4
5
  from sqlalchemy.sql.sqltypes import NullType
@@ -1,4 +1,5 @@
1
1
  """This module defines specific functions for Postgresql dialect."""
2
+
2
3
  from sqlalchemy import Index
3
4
  from sqlalchemy import text
4
5
  from sqlalchemy.sql import func
@@ -1,4 +1,5 @@
1
1
  """This module defines specific functions for SQLite dialect."""
2
+
2
3
  import os
3
4
  from typing import Optional
4
5
 
@@ -1,4 +1,5 @@
1
1
  """Some helpers to use with Alembic migration tool."""
2
+
2
3
  from alembic.autogenerate import renderers
3
4
  from alembic.autogenerate import rewriter
4
5
  from alembic.autogenerate.render import _add_column
geoalchemy2/comparator.py CHANGED
@@ -36,6 +36,7 @@ Using the ORM::
36
36
 
37
37
  Session.query(Cls).order_by(Cls.geom.distance_box('POINT(0 0)')).limit(10)
38
38
  """
39
+
39
40
  from typing import Union
40
41
 
41
42
  from sqlalchemy import types as sqltypes
geoalchemy2/elements.py CHANGED
@@ -117,6 +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 ]+) *(\([\d\. ,\(\)]+\))")
120
121
 
121
122
  geom_from: str = "ST_GeomFromText"
122
123
  geom_from_extended_version: str = "ST_GeomFromEWKT"
geoalchemy2/functions.py CHANGED
@@ -66,6 +66,7 @@ Reference
66
66
  ---------
67
67
 
68
68
  """
69
+
69
70
  import re
70
71
  from typing import List
71
72
  from typing import Type
geoalchemy2/functions.pyi CHANGED
@@ -13,8 +13,8 @@ class TableRowElement(ColumnElement):
13
13
  """The cache is disabled for this class."""
14
14
 
15
15
  def __init__(self, selectable: bool) -> None: ...
16
- @property
17
- def _from_objects(self) -> List[bool]: ... # type: ignore[override]
16
+ @property # type: ignore[override]
17
+ def _from_objects(self) -> List[bool]: ...
18
18
 
19
19
  class ST_AsGeoJSON(GenericFunction):
20
20
  """
geoalchemy2/shape.py CHANGED
@@ -5,6 +5,7 @@
5
5
  As GeoAlchemy 2 itself has no dependency on `Shapely`, applications using
6
6
  functions of this module have to ensure that `Shapely` is available.
7
7
  """
8
+
8
9
  from contextlib import contextmanager
9
10
  from typing import List
10
11
  from typing import Optional
@@ -4,6 +4,7 @@ The :class:`geoalchemy2.types.Geometry`, :class:`geoalchemy2.types.Geography`, a
4
4
  :class:`geoalchemy2.types.Raster` classes are used when defining geometry, geography and raster
5
5
  columns/properties in models.
6
6
  """
7
+
7
8
  import warnings
8
9
  from typing import Any
9
10
  from typing import Dict
@@ -1,4 +1,5 @@
1
1
  """This module defines some dialect-specific functions used for Column types."""
2
+
2
3
  from geoalchemy2.types.dialects import common # noqa
3
4
  from geoalchemy2.types.dialects import geopackage # noqa
4
5
  from geoalchemy2.types.dialects import mysql # noqa
@@ -1,2 +1,3 @@
1
1
  """This module defines specific functions for GeoPackage dialect."""
2
+
2
3
  from geoalchemy2.types.dialects.sqlite import bind_processor_process # noqa
@@ -1,4 +1,5 @@
1
1
  """This module defines specific functions for MySQL dialect."""
2
+
2
3
  from geoalchemy2.elements import WKBElement
3
4
  from geoalchemy2.elements import WKTElement
4
5
  from geoalchemy2.elements import _SpatialElement
@@ -1,4 +1,5 @@
1
1
  """This module defines specific functions for Postgresql dialect."""
2
+
2
3
  from geoalchemy2.elements import RasterElement
3
4
  from geoalchemy2.elements import WKBElement
4
5
  from geoalchemy2.elements import WKTElement
@@ -1,21 +1,50 @@
1
1
  """This module defines specific functions for SQLite dialect."""
2
+
3
+ import re
4
+
2
5
  from geoalchemy2.elements import RasterElement
3
6
  from geoalchemy2.elements import WKBElement
4
7
  from geoalchemy2.elements import WKTElement
5
8
  from geoalchemy2.shape import to_shape
6
9
 
7
10
 
11
+ def format_geom_type(wkt, default_srid=None):
12
+ """Format the Geometry type for SQLite."""
13
+ match = re.match(WKTElement.SPLIT_WKT_PATTERN, wkt)
14
+ if match is None:
15
+ return wkt
16
+ _, srid, geom_type, coords = match.groups()
17
+ geom_type = geom_type.replace(" ", "")
18
+ if geom_type.endswith("ZM"):
19
+ geom_type = geom_type[:-2]
20
+ elif geom_type.endswith("Z"):
21
+ geom_type = geom_type[:-1]
22
+ if srid is None and default_srid is not None:
23
+ srid = f"SRID={default_srid}"
24
+ if srid is not None:
25
+ return "%s;%s%s" % (srid, geom_type, coords)
26
+ else:
27
+ return "%s%s" % (geom_type, coords)
28
+
29
+
8
30
  def bind_processor_process(spatial_type, bindvalue):
9
31
  if isinstance(bindvalue, WKTElement):
10
- if bindvalue.extended:
11
- return "%s" % (bindvalue.data)
12
- else:
13
- return "SRID=%d;%s" % (bindvalue.srid, bindvalue.data)
32
+ return format_geom_type(
33
+ bindvalue.data,
34
+ default_srid=bindvalue.srid if bindvalue.srid >= 0 else spatial_type.srid,
35
+ )
14
36
  elif isinstance(bindvalue, WKBElement):
15
37
  # With SpatiaLite we use Shapely to convert the WKBElement to an EWKT string
16
38
  shape = to_shape(bindvalue)
17
- return "SRID=%d;%s" % (bindvalue.srid, shape.wkt)
39
+ # shapely.wkb.loads returns geom_type with a 'Z', for example, 'LINESTRING Z'
40
+ # which is a limitation with SpatiaLite. Hence, a temporary fix.
41
+ res = format_geom_type(
42
+ shape.wkt, default_srid=bindvalue.srid if bindvalue.srid >= 0 else spatial_type.srid
43
+ )
44
+ return res
18
45
  elif isinstance(bindvalue, RasterElement):
19
46
  return "%s" % (bindvalue.data)
47
+ elif isinstance(bindvalue, str):
48
+ return format_geom_type(bindvalue, default_srid=spatial_type.srid)
20
49
  else:
21
50
  return bindvalue
@@ -1,31 +0,0 @@
1
- geoalchemy2/__init__.py,sha256=N1HOMPNSrNa6oIpo7CBGnUOt-Fu5SzdqngDEoqyvmOo,1970
2
- geoalchemy2/_functions.py,sha256=e8v584Fx_fmh8XnJvkuYEXrcyPDiWV95Mu2yw6L-LHY,62863
3
- geoalchemy2/_functions_helpers.py,sha256=bINko9ivqpbG-mdwoYx2mQcSs8ygiiIWik3zs-RPmUQ,2651
4
- geoalchemy2/alembic_helpers.py,sha256=canBGpmeaTMMQR0u55C2xW-A31L1-CVVC2ZymRrew0A,27884
5
- geoalchemy2/comparator.py,sha256=ZWQyPJnT0IgiG3NvPLqBcEFqu2ae17QKRc5LZk1ozRU,8099
6
- geoalchemy2/elements.py,sha256=-FSSixQbAS_jO5TysMGxRDdbq5VZ9ZHQOk1YdHqs1nc,12914
7
- geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
8
- geoalchemy2/functions.py,sha256=PvnwjZfmvDCRrbOxdje0xK5gZ0PJZcIyBaeIrXBPNP4,10319
9
- geoalchemy2/functions.pyi,sha256=sGnrJh5Oae2UuPnrom_pAfT-IWXvTnKwHi6N3cjnN1M,108636
10
- geoalchemy2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- geoalchemy2/shape.py,sha256=1c6oVhAGJHKgFfYzHMpw9HcFicLjSV1Bb3JWol01TjM,2791
12
- geoalchemy2/utils.py,sha256=OYWYnT64tjp4DWhPdq3KIxHbVti932xPMtGGxajtu-I,488
13
- geoalchemy2/admin/__init__.py,sha256=QwqC-IaQRm_vXV4ZBOuPk3C2byeno65IGzkAdQ5URDc,3983
14
- geoalchemy2/admin/dialects/__init__.py,sha256=1QYO2ET6emC-uB30CC97_4_td-O6SOudoEPsJOfo4IE,366
15
- geoalchemy2/admin/dialects/common.py,sha256=bIAkd1TUnn24XEaJU6_OZ_eSHOOlMKthOEkBJ4p6Z4k,2935
16
- geoalchemy2/admin/dialects/geopackage.py,sha256=AX3Jq2-yJW5SzZJDLUytNGsqs05x4NwxHifPirO500o,13468
17
- geoalchemy2/admin/dialects/mysql.py,sha256=p4GSudDUMRDc2usyPCJ--JWQkyV08yuitxhrNKJPGXE,6866
18
- geoalchemy2/admin/dialects/postgresql.py,sha256=GTUoWKGEhkNiC0tVHkfIcXpNwd-JumY9kaqoBivKXLo,6190
19
- geoalchemy2/admin/dialects/sqlite.py,sha256=oAx6_XFVqAcL82IyUl19QM4XjMrt-Ofc-OmMsAbjfyI,13596
20
- geoalchemy2/types/__init__.py,sha256=T4Ph7Zr02PMe7drqtquIdzEPKBBEXUybQIDPuhWSoRM,14185
21
- geoalchemy2/types/dialects/__init__.py,sha256=Z9GgQc7pEbOMnPglXnU0tBSY7DynB5uszCwfw2CGT_k,358
22
- geoalchemy2/types/dialects/common.py,sha256=gxKaRQhIODJhu_yBurlvFNAqGh3LfPNu_DcObEG1wlU,138
23
- geoalchemy2/types/dialects/geopackage.py,sha256=V7XFYNQrSukCj1mIaPIDYuMZRcXolj0CWMEy057t2VY,146
24
- geoalchemy2/types/dialects/mysql.py,sha256=I37iC1Gl78p9BF3f3RB-zBjmQcT64bN60RFXitvVsiI,1789
25
- geoalchemy2/types/dialects/postgresql.py,sha256=4B2IPoZfV99w7KUYkazSJs7c6LjF1cALVhFgB7atKCk,1116
26
- geoalchemy2/types/dialects/sqlite.py,sha256=e3gj-JuxVP7bHU9BjsKRjjYJK_6OYJlwGaFA3VumamM,835
27
- GeoAlchemy2-0.14.7.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
28
- GeoAlchemy2-0.14.7.dist-info/METADATA,sha256=R_-087iq69pLYKswY-c3IRIGfybISvtPDHW6xhAtPDw,2087
29
- GeoAlchemy2-0.14.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
30
- GeoAlchemy2-0.14.7.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
31
- GeoAlchemy2-0.14.7.dist-info/RECORD,,