Skip to content

Commit fab9a64

Browse files
authored
Merge pull request #133 from mapillary/Rubix982/132-Bug-Request-Detection-With-Image-Key-Fix
Rubix982/132 bug request detection with image key fix
2 parents 3a6ea84 + 75874a1 commit fab9a64

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# Setup variables. Change as needed
2525
NAME = "mapillary"
26-
VERSION = "0.0.32"
26+
VERSION = "1.0.0"
2727
AUTHOR = "Christopher Beddow"
2828
AUTHOR_EMAIL = "[email protected]"
2929
LICENSE = "MIT"

src/mapillary/controller/detection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
def get_image_detections_controller(
33-
image_id: typing.Union[str, int], fields: list = None
33+
image_id: typing.Union[str, int], fields: list = []
3434
) -> GeoJSON:
3535
"""
3636
Get image detections with given (image) key
@@ -60,7 +60,7 @@ def get_image_detections_controller(
6060

6161

6262
def get_map_feature_detections_controller(
63-
map_feature_id: typing.Union[str, int], fields: list = None
63+
map_feature_id: typing.Union[str, int], fields: list = []
6464
) -> GeoJSON:
6565
"""
6666
Get image detections with given (map feature) key

src/mapillary/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def get_image_looking_at(
195195

196196

197197
@auth()
198-
def get_detections_with_image_id(image_id: int, fields: list = None):
198+
def get_detections_with_image_id(image_id: int, fields: list = []):
199199
"""
200200
Extracting all the detections within an image using an image key
201201

src/mapillary/models/api/entities.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def fetch_map_feature(
144144
).content.decode("utf-8")
145145
)
146146

147-
def fetch_detections(
148-
self, identity: int, id_type: bool = True, fields: list = None
149-
):
147+
def fetch_detections(self, identity: int, id_type: bool = True, fields: list = []):
150148
"""
151149
Fetches detections depending on the id, detections for either map_features or
152150
images and the fields provided

src/mapillary/utils/format.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def detection_features_to_geojson(feature_list: list) -> dict:
231231
if "image" in feature
232232
else {},
233233
# Property list
234-
"properties": {
234+
"possible_none_properties": {
235235
# Only if "image" was specified in the `fields` of the endpoint, else None
236236
"image_id": feature["image"]["id"]
237237
if "image" in "feature"
@@ -249,6 +249,7 @@ def detection_features_to_geojson(feature_list: list) -> dict:
249249
# "id" is always available in the response
250250
"id": feature["id"],
251251
},
252+
"properties": {},
252253
}
253254
# Going through the given of features
254255
for feature in feature_list
@@ -261,13 +262,17 @@ def detection_features_to_geojson(feature_list: list) -> dict:
261262
for _feature in resulting_geojson["features"]:
262263

263264
# Going through each property in the feature
264-
for key, value in _feature["properties"].items():
265+
for key, value in _feature["possible_none_properties"].items():
265266

266-
# If the _property has defaulted to None
267-
if value is None:
267+
# If the _property is not None
268+
if value is not None:
268269

269-
# Delete the _property from the feature
270-
del _feature["properties"][key]
270+
# Add that property to the _feature
271+
_feature["properties"][key] = value
272+
273+
for _feature in resulting_geojson["features"]:
274+
275+
del _feature["possible_none_properties"]
271276

272277
# Finally return the output
273278
return resulting_geojson

0 commit comments

Comments
 (0)