~ubuntu-branches/ubuntu/trusty/mapnik/trusty-proposed

« back to all changes in this revision

Viewing changes to bindings/python/mapnik/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2009-08-27 00:28:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090827002837-ztqzfg2rmclfh4i9
Tags: 0.6.1-0ubuntu1
* New upstream release.
* Change usr/lib to usr/lib* to enable build on 64 bits systems due to new
  configuration in SConstruct in :
  - debian/libmapnik-dev.install
  - debian/libmapnik0.6.install
  - debian/mapnik-plugin-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 2) The paths to the input plugins and font directories are imported from the 'paths.py'
32
32
    file which was constructed and installed during SCons installation.
33
33
 
34
 
 3) All available input plugins and and TrueType fonts are automatically registered.
 
34
 3) All available input plugins and TrueType fonts are automatically registered.
35
35
 
36
36
 4) Boost Python metaclass injectors are used in the '__init__.py' to wrap/extend several
37
37
    objects adding extra convenience when accessed via Python.
90
90
        return forward_(obj,self)
91
91
    def inverse(self,obj):
92
92
        return inverse_(obj,self)
93
 
  
 
93
 
 
94
def get_types(num):
 
95
    if num == 1:
 
96
        return int
 
97
    elif num == 2:
 
98
        return float
 
99
    elif num == 3:
 
100
        return float
 
101
    elif num == 4:
 
102
        return str
 
103
    elif num == 5:
 
104
        return Geometry2d
 
105
    elif num == 6:
 
106
        return object
 
107
 
94
108
class _Datasource(Datasource,_injector):
95
109
    def describe(self):
96
110
        return Describe(self)
 
111
    def field_types(self):
 
112
        return map(get_types,self._field_types())        
 
113
    def all_features(self):
 
114
        query = Query(self.envelope(),1.0)
 
115
        for fld in self.fields():
 
116
            query.add_property_name(fld)
 
117
        return self.features(query).features
 
118
 
 
119
class _Feature(Feature,_injector):
 
120
    @property
 
121
    def attributes(self):
 
122
        attr = {}
 
123
        for prop in self.properties:
 
124
            attr[prop[0]] = prop[1]
 
125
        return attr
97
126
 
98
127
#class _Filter(Filter,_injector):
99
128
#    """Mapnik Filter expression.
320
349
    keywords['type'] = 'osm'
321
350
    return CreateDatasource(keywords)
322
351
 
 
352
def Kismet(**keywords):
 
353
    """Create a Kismet Datasource.
 
354
  
 
355
    Required keyword arguments:
 
356
      host -- kismet hostname
 
357
      port -- kismet port
 
358
 
 
359
    Optional keyword arguments:
 
360
      encoding -- file encoding (default 'utf-8')
 
361
      extent -- manually specified data extent (comma delimited string, default None)
 
362
    
 
363
    >>> from mapnik import Kismet, Layer
 
364
    >>> datasource = Kismet(host='localhost',port=2501,extent='-179,-85,179,85') 
 
365
    >>> lyr = Layer('Kismet Server Layer')
 
366
    >>> lyr.datasource = datasource
 
367
    
 
368
    """
 
369
    keywords['type'] = 'kismet'
 
370
    return CreateDatasource(keywords)
 
371
    
323
372
def mapnik_version_string():
324
373
    """Return the Mapnik version as a string."""
325
374
    version = mapnik_version()