outer.append(tmp) items += 1 else: print('Object is not a way!') for item in iter_osm_file(input_file): if item.id in nodes: if isinstance(item, Node): nodes[item.id] = (item.lon, item.lat) items += 1 else: print('Object is not a node!') print('{0} items processed'.format(items)) polygons = glue_together(*outer, unconnected=True) shapes = list() for polygon in polygons: points = [nodes[p] for p in polygon] shapes.append(Polygon(points)) print('Found {0} polygons'.format(len(shapes))) # Define a polygon feature geometry with on e attribute schema = { 'geometry': 'Polygon', 'properties': {'id': 'int'}, }
def test_glue_together(self): input = [[1, 2, 3], [3, 4, 5]] self.assertEqual(lists.glue_together(*input), [1, 2, 3, 4, 5])