Skip to content

Commit cddee9f

Browse files
authored
Merge pull request #149 from ducksoup/polygon_creating_fix
Fix Polygon creation in {shape,geojson}_features_controller
2 parents 323290f + 08936fe commit cddee9f

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/mapillary/controller/image.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,8 @@ def geojson_features_controller(
582582
# Extracting polygon from geojson, converting to dict
583583
polygon = geojson_to_polygon(geojson).to_dict()
584584

585-
# Generating a coordinates list to extract from polygon
586-
coordinates_list = []
587-
588-
# Going through each feature
589-
for feature in polygon["features"]:
590-
591-
# Going through the coordinate's nested list
592-
for coordinates in feature["geometry"]["coordinates"][0]:
593-
# Appending a tuple of coordinates
594-
coordinates_list.append((coordinates[0], coordinates[1]))
595-
596-
# Sending coordinates_list a input to form a Polygon
597-
polygon = Polygon(coordinates_list)
585+
# Wrapping in Polygon object
586+
polygon = Polygon(polygon["features"][0]["geometry"]["coordinates"])
598587

599588
# Getting the boundary parameters from polygon
600589
boundary = shapely.geometry.shape(polygon)
@@ -765,19 +754,8 @@ def shape_features_controller(
765754

766755
image_bbox_check(filters)
767756

768-
# Generating a coordinates list to extract from polygon
769-
coordinates_list = []
770-
771-
# Going through each feature
772-
for feature in shape["features"]:
773-
774-
# Going through the coordinate's nested list
775-
for coordinates in feature["geometry"]["coordinates"][0]:
776-
# Appending a tuple of coordinates
777-
coordinates_list.append((coordinates[0], coordinates[1]))
778-
779-
# Sending coordinates_list a input to form a Polygon
780-
polygon = Polygon(coordinates_list)
757+
# Wrapping the shape in a Polygon object
758+
polygon = Polygon(shape["features"][0]["geometry"]["coordinates"])
781759

782760
# Getting the boundary parameters from polygon
783761
boundary = shapely.geometry.shape(polygon)

0 commit comments

Comments
 (0)