Permalink
Browse files

clean up topology and clockwise

  • Loading branch information...
1 parent 3da6aca commit 75caa45b4df6e4e173c0020f411bb40b6054359c Calvin Metcalf committed Oct 29, 2013
Showing with 10 additions and 12 deletions.
  1. +9 −11 Install/esri2open/topojson/clockwise.py
  2. +1 −1 Install/esri2open/topojson/topology.py
@@ -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

Please sign in to comment.