Package mapnik :: Class PythonDatasource

Class PythonDatasource

object --+
         |
        PythonDatasource

A base class for a Python data source.

Optional arguments:
  envelope -- a mapnik.Box2d (minx, miny, maxx, maxy) envelope of the data source, default (-180,-90,180,90)
  geometry_type -- one of the DataGeometryType enumeration values, default Point
  data_type -- one of the DataType enumerations, default Vector

Instance Methods
 
__init__(self, envelope=None, geometry_type=None, data_type=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
features(self, query)
Return an iterable which yields instances of Feature for features within the passed query.
 
features_at_point(self, point)
Rarely uses.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
wkb_features(cls, keys, features)
A convenience function to wrap an iterator yielding pairs of WKB format geometry and dictionaries of key-value pairs into mapnik features.
 
wkt_features(cls, keys, features)
A convenience function to wrap an iterator yielding pairs of WKT format geometry and dictionaries of key-value pairs into mapnik features.
Properties

Inherited from object: __class__

Method Details

__init__(self, envelope=None, geometry_type=None, data_type=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

features(self, query)

 
Return an iterable which yields instances of Feature for features within the passed query.

Required arguments:
  query -- a Query instance specifying the region for which features should be returned

features_at_point(self, point)

 

Rarely uses. Return an iterable which yields instances of Feature for the specified point.

wkb_features(cls, keys, features)
Class Method

 
A convenience function to wrap an iterator yielding pairs of WKB format geometry and dictionaries of
key-value pairs into mapnik features. Return this from PythonDatasource.features() passing it a sequence of keys
to appear in the output and an iterator yielding features.

For example. One might have a features() method in a derived class like the following:

def features(self, query):
    # ... create WKB features feat1 and feat2

    return mapnik.PythonDatasource.wkb_features(
        keys = ( 'name', 'author' ),
        features = [
            (feat1, { 'name': 'feat1', 'author': 'alice' }),
            (feat2, { 'name': 'feat2', 'author': 'bob' }),
        ]
    )

wkt_features(cls, keys, features)
Class Method

 
A convenience function to wrap an iterator yielding pairs of WKT format geometry and dictionaries of
key-value pairs into mapnik features. Return this from PythonDatasource.features() passing it a sequence of keys
to appear in the output and an iterator yielding features.

For example. One might have a features() method in a derived class like the following:

def features(self, query):
    # ... create WKT features feat1 and feat2

    return mapnik.PythonDatasource.wkt_features(
        keys = ( 'name', 'author' ),
        features = [
            (feat1, { 'name': 'feat1', 'author': 'alice' }),
            (feat2, { 'name': 'feat2', 'author': 'bob' }),
        ]
    )