root/pleiades.keytree/trunk/keytree/model.py

Revision 1293, 0.8 kB (checked in by sgillies, 8 months ago)

line strings and polygons

Line 
1 """
2 Geometry classes
3 """
4
5 GEOM_TYPES = [
6     'Point',
7     'LineString',
8     'LinearRing',
9     'Polygon',
10     'MultiGeometry'
11     ]
12
13 class Geometry(object):
14
15     def __init__(self, type, coordinates):
16         self.type = type
17         self.coordinates = coordinates
18    
19     @property
20     def __geo_interface__(self):
21         return dict(type=self.type, coordinates=self.coordinates)
22
23
24 class Feature(object):
25
26     def __init__(self, kid=None, geometry=None, properties=None, **kw):
27         self.id = kid
28         self.geometry = geometry
29         self.properties = properties or {}
30         self.properties.update(kw)
31
32     @property
33     def __geo_interface__(self):
34         return dict(
35             id=self.id,
36             geometry=self.geometry.__geo_interface__,
37             properties=dict(self.properties)
38             )
Note: See TracBrowser for help on using the browser.