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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/GeoTypes/_OGGeoTypeFactory.py@2194
Revision 2194, 3.8 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
8from _OGMultiPolygon import OGMultiPolygon
9from _OGPoint import OGPoint
10from _OGLineString import OGLineString
11from _OGLinearRing import OGLinearRing
12from _OGPolygon import OGPolygon
13from _OGMultiPoint import OGMultiPoint
14from _OGMultiLineString import OGMultiLineString
15from _OGGeometryCollection import OGGeometryCollection
16
17from _OGLoggingFactory import OGLoggingFactory
18from _OGAbstractFactory import OGAbstractFactory
19
20#class OGGeoTypeFactory(OGLoggingFactory):
21class OGGeoTypeFactory(OGAbstractFactory):
22
23    def __init__(self):
24        self._top = None
25        self._current_node = None
26
27    def getGeometry(self):
28        return self._top
29   
30    def abortGeometryCollection(self):
31        pass
32   
33    def abortLinearRing(self):
34        pass
35
36    def abortLineString(self):
37        pass
38   
39    def abortMultiLineString(self):
40        pass
41   
42    def abortMultiPoint(self):
43        pass
44   
45    def abortMultiPolygon(self):
46        pass
47   
48    def abortPoint(self):
49        pass
50   
51    def abortPolygon(self):
52        pass
53   
54##    def abortUnit(self):
55##        pass
56   
57##    def abortWork(self):
58##        pass
59   
60    def addPoints(self,x,y):
61##        print "addPoint"
62        self._current_node.setX(x)
63        self._current_node.setY(y)       
64   
65    def addPoints3D(self,x,y,z):
66##        print "addPoint3D"
67        self._current_node.setX(x)
68        self._current_node.setY(y)       
69        self._current_node.setZ(z)       
70
71    def beginGeometryCollection(self, srid=None):
72        self._beginNode(OGGeometryCollection, srid)
73
74    def _beginNode(self, node_type, srid=None):
75        self._printState()
76
77        parent = self._current_node
78        self._current_node = node_type(srid=srid or self._srid)
79        self._current_node.setParent(parent)
80
81        if self._top == None:
82            self._top = self._current_node
83
84        self._printState()
85       
86    def beginLinearRing(self, srid=None):
87        self._beginNode(OGLinearRing, srid)
88   
89    def beginLineString(self, srid=None):
90        self._beginNode(OGLineString, srid)
91   
92    def beginMultiLineString(self, srid=None):
93        self._beginNode(OGMultiLineString, srid)
94   
95    def beginMultiPoint(self, srid=None):
96        self._beginNode(OGMultiPoint, srid)
97   
98    def beginMultiPolygon(self, srid=None):
99        self._beginNode(OGMultiPolygon, srid)
100   
101    def beginPoint(self,srid=None):
102        self._beginNode(OGPoint, srid)
103   
104    def beginPolygon(self, srid=None):
105        self._beginNode(OGPolygon, srid)
106
107    def beginUnit(self, srid):
108        self._srid = srid
109   
110##    def beginUnit(java.lang.String[] words, int[] values):
111##        pass
112   
113##    def beginWork(self):
114##        pass
115
116    def endGeometryCollection(self):
117        self._endNode()
118
119    def _endNode(self):
120        self._printState()
121
122        parent = self._current_node.getParent()
123        if parent != None:
124            parent.append(self._current_node)
125        self._current_node = parent
126       
127    def endLinearRing(self):
128        self._endNode()
129       
130    def endLineString(self):
131        self._endNode()
132   
133    def endMultiLineString(self):
134        self._endNode()
135       
136    def endMultiPoint(self):
137        self._endNode()
138   
139    def endMultiPolygon(self):
140        self._endNode()
141   
142    def endPoint(self):
143        self._endNode()
144   
145    def endPolygon(self):
146        self._endNode()
147   
148##    def endUnit(self):
149##        pass
150   
151##    def endWork(self):
152##        pass
153
154##    def reset(self):
155##        pass
156
157    def _printState(self):
158        #print "_current_node = ", self._current_node, " _top = ", self._top
159        pass
Note: See TracBrowser for help on using the repository browser.