source: TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/GeoTypes/_OGMultiPolygon.py @ 2194

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/GeoTypes/_OGMultiPolygon.py@2194
Revision 2194, 1.4 KB checked in by lawrence, 13 years ago (diff)

Adding various specs and 3rd party code of interest for the CSML
services development.

Line 
1
2################################################################################
3# Copyright (c) QinetiQ Plc 2003
4#
5# Licensed under the LGPL. For full license details see the LICENSE file.
6################################################################################
7
8import string
9
10from _OGMultiSurface import OGMultiSurface
11from _OGPolygon import OGpolygonFromSequence
12
13class OGMultiPolygon(OGMultiSurface):
14
15    def _og_str(self):
16        s = string.join([ point.__repr__() for point in self.getGeometries() ],',')
17        return 'MULTIPOLYGON (%s)' % (s,)
18   
19    def __repr__(self):
20        s = string.join([ point.__repr__() for point in self.getGeometries() ],',')
21           
22        return "(%s)" % (s,)
23
24
25# factory methods
26
27def OGmultiPolygonFromOGPolygons(*polygons):
28    """
29    Return a OGMultipolygon.
30
31    (arg *points) any number of OGPolygons that make up the OGMultiPolygon.
32
33    """
34    multipolygon = OGMultiPolygon()
35    for polygon in polygons:
36        multipolygon.append(polygon)
37       
38    return multipolygon
39
40def OGmultiPolygonFromSequence(seq):
41    """
42    Return a OGMultiPolygon.
43
44    (arg *seq) a sequence of the form ((x,y),...,(x,y)) that make up the OGMultiPolygon,
45    where x and y are floats.
46
47    """
48
49    multipolygon = OGMultiPolygon()
50    for polygon in seq:
51        multipolygon.append(OGpolygonFromSequence(polygon))
52       
53    return multipolygon
Note: See TracBrowser for help on using the repository browser.