geoalchemy.mssql

geoalchemy.mssql.CastDBSpatialElementFunction()

Wrapper required for handling the geoalchemy.base.DBSpatialElement.

This adds the necessary casts so that a geoalchemy.base.DBSpatialElement is recognised as a spatial element by the SQL Server. The reason for this is that in SQL Server the geometry data is a subclass of VARBINARY and the sub-classing information gets lost between queries. The cast provided by this function guarantees that SQL Server knows the data is a geometry.

class geoalchemy.mssql.MSComparator(prop, mapper, adapter=None)

Comparator class used for MS SQL Server 2008

class geoalchemy.mssql.MSPersistentSpatialElement(desc)

Represents a Geometry as loaded from an MS SQL Server 2008 database.

class geoalchemy.mssql.MSSpatialDialect

The SpatialDialect for accessing MS SQL Server 2008 spatial data.

For the standard OGC functions there are a few differences in the SQL Server 2008 implementation that need to be taken into account:

  • g.centroid – Only returns results for Polygon and MultiPolygon. Returns ‘NULL’ for all other Geometry
  • g.envelope – Will always return a Polygon regardless of the type of Geometry it was called on
  • g.buffer – Only supports the buffer distance as a parameter

Some standard functions are not available:

  • g.transform
  • g.within_distance
  • g.covers
  • g.covers_by
  • g.intersection

For SQL Server 2008 specific functions see ms_functions.

geoalchemy.mssql.MS_SPATIAL_NULL

There is a bug causing errors when trying to insert None values into nullable columns. Use this constant instead.

geoalchemy.mssql.compile_varbinary(element, compiler, **kw)

Compiler function to handle VARBINARY(max).

Should be removed when SQLAlchemy supports this natively.

class geoalchemy.mssql.ms_functions

MS SQL Server specific geometry functions.

class buffer_with_tolerance(*arguments, **kwargs)

g.BufferWithTolerance(distance, tolerance, relative)

Creates a buffer with the given tolerance values.

class ms_functions.filter(*arguments, **kwargs)

g1.Filter(g2)

An index-only intersection query. Can return false positives. If no index is defined then behaves like g1.intersection(g2).

class ms_functions.gml(*arguments, **kwargs)

g.AsGML()

GML representation of the geometry. Does not include the SRS.

class ms_functions.instance_of(*arguments, **kwargs)

g.InstanceOf(geometry_type_name)

Tests whether the geometry is of the given geometry type.

class ms_functions.m(*arguments, **kwargs)

p.M

Returns the M value for the given Point. Only valid for Point geometries.

class ms_functions.make_valid(*arguments, **kwargs)

g.MakeValid()

Converts an invalid Geometry into a valid one. This can return a different type of Geometry.

class ms_functions.reduce(*arguments, **kwargs)

g.Reduce(tolerance)

Returns an approximation of the Geometry using the Douglas-Peucker algorithm.

class ms_functions.text_zm(*arguments, **kwargs)

p.AsTextZM()

The Point WKT representation augmented with Z and M values. Only valid for Point geometries.

class ms_functions.to_string(*arguments, **kwargs)

g.ToString()

Equivalent to text_zm except that for NULL geometries it will return the string ‘NULL’.

class ms_functions.z(*arguments, **kwargs)

p.Z

Returns the M value for the given Point. Only valid for Point geometries.

Previous topic

geoalchemy.oracle

This Page