Commit ec5784f9 authored by PIOLLE's avatar PIOLLE

added geojson method to GeoShape

parent 229c19f0
......@@ -110,6 +110,15 @@ class GeoShape(object):
shape_union = shapely.ops.unary_union(shapes)
return GeoShape.orient(shape_union)
def geojson(self):
"""return a shape as a geojson string"""
geojson_area = shapely.geometry.mapping(self.shape)
geojson_area['type'] = geojson_area['type'].lower()
if (geojson_area['type'] in ['linestring', 'multilinestring'] and
'orientation' in geojson_area):
del geojson_area['orientation']
return geojson_area
@staticmethod
def make2d(lons, lats, offsets,
tiling_method="corners",
......
......@@ -109,12 +109,7 @@ class Tile(object):
def geojson(self):
"""return the tile shape as a geojson string"""
geojson_area = shapely.geometry.mapping(self.shape)
geojson_area['type'] = geojson_area['type'].lower()
if (geojson_area['type'] in ['linestring', 'multilinestring'] and
'orientation' in geojson_area):
del geojson_area['orientation']
geojson_area = self.shape.geojson()
geojson = {
'time_coverage_end': self.end,
'geometry': geojson_area,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment