def shape2geometry(shape, projection, clip):
 if clip:
  try:
   shape = shape.intersection(clip)
  except TopologicalError:
   raise _InvisibleBike('Clipping shape resulted in a topological error')
  if shape.is_empty:
   raise _InvisibleBike('Clipping shape resulted in a null geometry')
 geom = shape.__geo_interface__
 if (geom['type'] == 'Point'):
  geom['coordinates'] = _p2p(geom['coordinates'], projection)
 elif (geom['type'] in ('MultiPoint', 'LineString')):
  geom['coordinates'] = [_p2p(c, projection) for c in geom['coordinates']]
 elif (geom['type'] in ('MultiLineString', 'Polygon')):
  geom['coordinates'] = [[_p2p(c, projection) for c in cs] for cs in geom['coordinates']]
 elif (geom['type'] == 'MultiPolygon'):
  geom['coordinates'] = [[[_p2p(c, projection) for c in cs] for cs in ccs] for ccs in geom['coordinates']]
 return geom

def shape2geometry ( shape , projection , clip ) : if clip : try : shape = shape . intersection ( clip ) except TopologicalError : raise _InvisibleBike ( 'Clipping shape resulted in a topological error' ) if shape . is_empty : raise _InvisibleBike ( 'Clipping shape resulted in a null geometry' ) geom = shape . __geo_interface__ if ( geom [ 'type' ] == 'Point' ) : geom [ 'coordinates' ] = _p2p ( geom [ 'coordinates' ] , projection ) elif ( geom [ 'type' ] in ( 'MultiPoint' , 'LineString' ) ) : geom [ 'coordinates' ] = [ _p2p ( c , projection ) for c in geom [ 'coordinates' ] ] elif ( geom [ 'type' ] in ( 'MultiLineString' , 'Polygon' ) ) : geom [ 'coordinates' ] = [ [ _p2p ( c , projection ) for c in cs ] for cs in geom [ 'coordinates' ] ] elif ( geom [ 'type' ] == 'MultiPolygon' ) : geom [ 'coordinates' ] = [ [ [ _p2p ( c , projection ) for c in cs ] for cs in ccs ] for ccs in geom [ 'coordinates' ] ] return geom
convert a shapely geometry object to a geojson-suitable geometry dict .