Permalink
Browse files
clean up topology and clockwise
- Loading branch information...
|
@@ -9,19 +9,17 @@ def clock(self,feature): |
|
|
return feature
|
|
|
def clock_geometry(self,geo):
|
|
|
if 'type' in geo:
|
|
|
- if geo['type']=='Polygon':
|
|
|
+ if geo['type']=='Polygon' or geo['type']=='MultiLineString':
|
|
|
geo['coordinates'] = self.clockwise_polygon(geo['coordinates'])
|
|
|
elif geo['type']=='MultiPolygon':
|
|
|
geo['coordinates'] = map(lambda x:self.clockwise_polygon(x),geo['coordinates'])
|
|
|
+ elif geo['type']=='LineString':
|
|
|
+ geo['coordinates'] = self.clockwise_ring(geo['coordinates'])
|
|
|
return geo
|
|
|
def clockwise_polygon(self,rings):
|
|
|
- i=0
|
|
|
- r = rings[i]
|
|
|
- if len(rings):
|
|
|
- n=len(rings)
|
|
|
- while i<n:
|
|
|
- r=rings[i]
|
|
|
- if self.area(rings[i]) > 0:
|
|
|
- r=list(reversed(r))
|
|
|
- i+=1
|
|
|
- return rings
|
|
|
+ return map(lambda x:self.clockwise_ring(x),rings)
|
|
|
+ def clockwise_ring(self,ring):
|
|
|
+ if self.area(ring) > 0:
|
|
|
+ return list(reversed(ring))
|
|
|
+ else:
|
|
|
+ return ring
|
|
@@ -100,7 +100,7 @@ def FeatureCollection(self,collection): |
|
|
def GeometryCollection(self,collection):
|
|
|
collection['geometries'] = map(self.geometry,collection['geometries'])
|
|
|
def MultiPolygon(self,multiPolygon):
|
|
|
- multiPolygon['arcs'] = map(poly:map(self.ln.line_closed,poly),multiPolygon['coordinates'])
|
|
|
+ multiPolygon['arcs'] = map(lambda poly:map(self.ln.line_closed,poly),multiPolygon['coordinates'])
|
|
|
def Polygon(self,polygon):
|
|
|
polygon['arcs'] = map(self.ln.line_closed,polygon['coordinates'])
|
|
|
def MultiLineString(self,multiLineString):
|
|
|
0 comments on commit
75caa45