类型¶
此模块定义 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'AddGeometryColumnZM几何类型失败。相反,“简单”几何类型(例如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语句中定义主地理类型(几何或地理)的名称。在子类中设置。