Previous topic

API References

Next topic

mapfish.lib.protocol

This Page

mapfish.sqlalchemygeom

class mapfish.sqlalchemygeom.Geometry(srid=-1, dims=2)

The SQLAlchemy Geometry type.

Use a Geometry instance when defining a geometry column in an sqlalchemy.schema.Table object of the model.

Example:

wifi_table = Table('wifi', metadata,
    Column('gid', Integer, primary_key=True),
    Column('the_geom', Geometry(4326))
)
srid
The SRID of the geometry column, defaults to -1 (no SRID).
dims
The number of dimensions of the geometry column, defaults to 2.
class mapfish.sqlalchemygeom.GeometryTableMixIn

Class to be mixed in mapped classes.

When used the mapped class exposes

geometry_column()
Class method returning the Column object corresponding to the geometry column.
primary_key_column()
Class method returning the Column object corresponding to the primary key.

When used the mapped object exposes

geometry
The Shapely geometry object representing the geometry value in the database.
fid
The value of the primary key.
toFeature()
Method returning a geojson.Feature object that corresponds to this object.

Example:

lines_table = Table(
    "lines", metadata,
    Column('the_geom', Geometry(4326)),
    autoload=True, autoload_with=engine)

class Line(GeometryTableMixIn):
    # for GeometryTableMixIn to do its job the __table__ property
    # must be set here
    __table__ = lines_table

mapper(Line, lines_table)
fid
The value of the primary key.
geometry
The Shapely geometry object associated to the geometry value.
classmethod geometry_column()
Returns the table’s geometry column or None if the table has no geometry column.
classmethod primary_key_column()
Returns the table’s primary key column
toFeature()
Create and return a geojson.Feature object from this mapped object.