类型¶
此模块定义 geoalchemy2.types.Geometry
, geoalchemy2.types.Geography
和 geoalchemy2.types.Raster
类,在模型中定义几何图形、地理和栅格列/特性时使用。
参考文献¶
- class geoalchemy2.types.CompositeType[源代码]¶
基类:
sqlalchemy.sql.type_api.UserDefinedType
包装纸
geoalchemy2.elements.CompositeElement
,可在返回复合值的PostgreSQL函数中用作返回类型。它用作
geoalchemy2.types.GeometryDump
.- typemap = {}¶
用于定义内容类型及其对应键的字典。在子类中设置。
- class geoalchemy2.types.Geography(geometry_type='GEOMETRY', srid=- 1, dimension=2, spatial_index=True, use_N_D_index=False, management=False, use_typmod=None, from_text=None, name=None, nullable=True)[源代码]¶
-
地理类型。
创建地理列的操作如下:
Column(Geography(geometry_type='POINT', srid=4326))
见
geoalchemy2.types._GISType
可传递给构造函数的参数列表。- ElementType¶
alias of
geoalchemy2.elements.WKBElement
- as_binary = 'ST_AsBinary'¶
要使用的“作为二进制”函数。由父类使用'
column_expression
方法。
- from_text = 'ST_GeogFromText'¶
这个
FromText
地理构造器。由父类使用'bind_expression
方法。
- name = 'geography'¶
用于在中定义地理列的类型名
CREATE TABLE
.
- class geoalchemy2.types.Geometry(geometry_type='GEOMETRY', srid=- 1, dimension=2, spatial_index=True, use_N_D_index=False, management=False, use_typmod=None, from_text=None, name=None, nullable=True)[源代码]¶
-
几何类型。
创建几何列的操作如下:
Column(Geometry(geometry_type='POINT', srid=4326))
见
geoalchemy2.types._GISType
可传递给构造函数的参数列表。如果
srid
设置好后WKBElement
查询产生的对象将具有该SRID,并且在构造WKBElement
对象,则不会从数据库返回的数据中读取SRID。如果srid
未设置(意味着-1
)然后SRID设置为WKBElement
对象将从数据库返回的数据中读取。- ElementType¶
alias of
geoalchemy2.elements.WKBElement
- as_binary = 'ST_AsEWKB'¶
要使用的“作为二进制”函数。由父类使用'
column_expression
方法。
- from_text = 'ST_GeomFromEWKT'¶
“from text”几何构造函数。由父类使用'
bind_expression
方法。
- name = 'geometry'¶
用于在中定义几何列的类型名
CREATE TABLE
.
- class geoalchemy2.types.GeometryDump[源代码]¶
基类:
geoalchemy2.types.CompositeType
函数的返回类型,如
ST_Dump
,由路径和几何场组成。你通常不应该直接使用这个类。- typemap = {'geom': <class 'geoalchemy2.types.Geometry'>, 'path': ARRAY(Integer())}¶
定义
geometry_dump
.
- class geoalchemy2.types.Raster(*args, **kwargs)[源代码]¶
-
栅格列类型。
创建栅格列的操作如下:
Column(Raster)
这个类定义
result_processor
方法,以便将从数据库接收的栅格值转换为geoalchemy2.elements.RasterElement
物体。构造函数参数:
spatial_index
指示是否应创建空间索引。默认为
True
.- ElementType¶
alias of
geoalchemy2.elements.RasterElement
- as_binary = 'raster'¶
要使用的“作为二进制”函数。由父类使用'
column_expression
方法。
- comparator_factory¶
- from_text = 'raster'¶
“从文本”栅格构造函数。由父类使用'
bind_expression
方法。
- name = 'raster'¶
用于在中定义栅格列的类型名
CREATE TABLE
.
- class geoalchemy2.types._GISType(geometry_type='GEOMETRY', srid=- 1, dimension=2, spatial_index=True, use_N_D_index=False, management=False, use_typmod=None, from_text=None, name=None, nullable=True)[源代码]¶
基类:
sqlalchemy.sql.type_api.UserDefinedType
的基类
geoalchemy2.types.Geometry
和geoalchemy2.types.Geography
.这个类定义
bind_expression
和column_expression
在中包装列表达式的方法ST_GeomFromEWKT
,ST_GeogFromText
或ST_AsEWKB
电话。这个类还定义
result_processor
和bind_processor
方法。返回的函数result_processor
将从数据库接收的WKB值转换为geoalchemy2.elements.WKBElement
物体。返回的函数bind_processor
皈依者geoalchemy2.elements.WKTElement
对象到EWKT字符串。构造函数参数:
geometry_type
几何类型。
可能的值是:
"GEOMETRY"
,"POINT"
,"LINESTRING"
,"POLYGON"
,"MULTIPOINT"
,"MULTILINESTRING"
,"MULTIPOLYGON"
,"GEOMETRYCOLLECTION"
,"CURVE"
,None
.
后者实际上不支持
geoalchemy2.types.Geography
.当设置为
None
则“几何类型”约束不会附加到几何类型声明。使用None
此处与设置不兼容management
到True
.默认值为
"GEOMETRY"
。srid
此列的SRID。E、 克4326。默认为
-1
.dimension
几何体的尺寸。默认为
2
.用
management
设置为True
,那是什么时候AddGeometryColumn
用于添加几何图形列,有两个约束:这个
geometry_type
不能以结束"ZM"
. 这是因为PostGIS'AddGeometryColumn
ZM几何类型失败。相反,“简单”几何类型(例如POINT而不是POINTZM)应与dimension
设置为4
.当
geometry_type
以结束"Z"
或"M"
然后dimension
必须设置为3
.
用
management
设置为False
(默认)dimension
不考虑,实际尺寸完全用geometry_type
.spatial_index
指示是否应创建空间索引。默认为
True
.use_N_D_index
使用N-D索引而不是标准的2-D索引。
management
指示是否
AddGeometryColumn
和DropGeometryColumn
添加和删除几何列时应调用managements函数。应该设置为True
对于PostGIS 1.x,默认值为False
. 请注意,此选项对geoalchemy2.types.Geography
.use_typmod
默认情况下,PostgreSQL类型修饰符用于创建几何列。改为使用检查约束集
use_typmod
到False
. 默认情况下,此选项不包括在调用AddGeometryColumn
. 注意,只有在management
设置为True
仅适用于PostGIS 2.x。- as_binary = None¶
此类型的“作为二进制”函数的名称。在子类中设置。
- bind_processor(dialect)[源代码]¶
返回用于处理绑定值的转换函数。
返回一个callable,该callable将接收一个bind参数值作为唯一的位置参数,并返回一个要发送到db-api的值。
如果不需要处理,则该方法应返回
None
.- 参数
dialect -- 方言实例正在使用中。
- comparator_factory¶
alias of
geoalchemy2.comparator.Comparator
- from_text = None¶
此类型的“from text”函数的名称。在子类中设置。
- name = None¶
用于在CREATE TABLE语句中定义主地理类型(几何或地理)的名称。在子类中设置。