Revision 400
org.gvsig.scripting.app/trunk/org.gvsig.scripting.app/org.gvsig.scripting.app.extension/src/main/resources/scripting/lib/geom.py | ||
---|---|---|
26 | 26 |
__author__ = """Antonio Carrasco Valero |
27 | 27 |
Model Driven Development sl and Antonio Carrasco Valero |
28 | 28 |
<carrasco@modeldd.org> |
29 |
Victor Acevedo Royer <vacevedor@gmail.com> |
|
29 |
Victor Acevedo Royer <vacevedo@gvsig.com> <vacevedor@gmail.com>
|
|
30 | 30 |
""" |
31 | 31 |
|
32 | 32 |
__docformat__ = 'plaintext' |
... | ... | |
60 | 60 |
SURFACE = Geometry.TYPES.SURFACE |
61 | 61 |
|
62 | 62 |
# Common named geometry types |
63 |
POLIGON = Geometry.TYPES.SURFACE
|
|
63 |
POLYGON = Geometry.TYPES.SURFACE
|
|
64 | 64 |
LINE = Geometry.TYPES.CURVE |
65 | 65 |
MULTILINE = Geometry.TYPES.MULTICURVE |
66 |
MULTIPOLIGON = Geometry.TYPES.MULTISURFACE
|
|
66 |
MULTIPOLYGON = Geometry.TYPES.MULTISURFACE
|
|
67 | 67 |
|
68 | 68 |
# geometrySubTypes |
69 | 69 |
D2= Geometry.SUBTYPES.GEOM2D |
... | ... | |
111 | 111 |
|
112 | 112 |
def createMultiPoint(points=None, subtype=D2): |
113 | 113 |
""" |
114 |
Create a new multipoint with a subtype from a list of Points. Also values of |
|
115 |
X and Y tuples like ([x1, y1], [x2, y2], ...., [xn, yn]) are allowed |
|
114 |
Create a new multipoint with a subtype from a list of Points instances. Also |
|
115 |
values of X and Y tuples like ([x1, y1], [x2, y2], ...., [xn, yn]) are |
|
116 |
allowed. If not points returns empty multipoint geometry. |
|
116 | 117 |
|
117 | 118 |
:param points: list of points |
118 | 119 |
:type points: list |
... | ... | |
127 | 128 |
if not isinstance(point, Point): |
128 | 129 |
point = createPoint(point[0], point[1], subtype) |
129 | 130 |
|
130 |
multipoint.add(point) |
|
131 |
multipoint.addPoint(point)
|
|
131 | 132 |
|
132 | 133 |
return multipoint |
133 | 134 |
|
135 |
def createPolygon(vertex=None, subtype=D2): |
|
136 |
""" |
|
137 |
Create a new polygon with a subtype. |
|
138 |
:return: polygon |
|
139 |
:rtype: Geometry |
|
140 |
""" |
|
141 |
polygon = createGeometry(SURFACE, subtype) |
|
142 |
return polygon |
|
143 |
|
|
144 |
def createMultiPolygon(vertex=None, subtype=D2): |
|
145 |
""" |
|
146 |
Create a new multipolygon with a subtype. |
|
147 |
:return: multipolygon |
|
148 |
:rtype: Geometry |
|
149 |
""" |
|
150 |
multipolygon = createGeometry(MULTISURFACE, subtype) |
|
151 |
return multipolygon |
|
152 |
|
|
153 |
def createLine(subtype=D2): |
|
154 |
""" |
|
155 |
Create a new line with a subtype. |
|
156 |
:return: polygon |
|
157 |
:rtype: Geometry |
|
158 |
""" |
|
159 |
line = createGeometry(CURVE, subtype) |
|
160 |
return line |
|
161 |
|
|
162 |
def createMultiLine(subtype=D2): |
|
163 |
""" |
|
164 |
Create a new multiline with a subtype. |
|
165 |
:return: multiline |
|
166 |
:rtype: Geometry |
|
167 |
""" |
|
168 |
multiline = createGeometry(MULTICURVECURVE, subtype) |
|
169 |
return multiline |
|
170 |
|
|
134 | 171 |
def createEnvelope(pointMax=None, pointMin=None, dimension=2): |
135 | 172 |
""" |
136 | 173 |
Create envelope as a minimum bounding box or rectangle. This envelope is |
... | ... | |
151 | 188 |
return envelope |
152 | 189 |
|
153 | 190 |
def getCRS(crs): |
191 |
|
|
154 | 192 |
return CRSFactory.getCRS(crs) |
155 | 193 |
|
156 | 194 |
|
Also available in: Unified diff