mapillary / mapillary/mapillary-python-sdk

[Bug Report] Detections with map feature ID decoding error

未关闭
#176 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug
主要语言
Python
星标
66
派生
23
平均合并
1 天 20 小时
30 天内合并 PR
11

描述

Describe the bug
Running interface.get_detections_with_map_feature_id under select map feature IDs throws a KeyError within the models/geojson file.

To Reproduce
mapillary.interface.get_detections_with_map_feature_id(1852672618623383, fields=[])

Returns KeyError as following:


Traceback (most recent call last):
  File "x.py", line 703, in <module>
    mapillary.interface.get_detections_with_map_feature_id(1852672618623383, fields=[])
  File "..\mapillary\utils\auth.py", line 59, in wrapper
    return f(*args, **kwargs)
  File "..\mapillary\interface.py", line 330, in get_detections_with_map_feature_id
    return detection.get_map_feature_detections_controller(
  File "..\mapillary\controller\detection.py", line 83, in get_map_feature_detections_controller
    return GeoJSON(
  File "..\mapillary\models\geojson.py", line 398, in __init__
    [Feature(feature=feature) for feature in geojson["features"]]
  File "..\mapillary\models\geojson.py", line 398, in <listcomp>
    [Feature(feature=feature) for feature in geojson["features"]]
  File "..\mapillary\models\geojson.py", line 270, in __init__
    self.geometry = Geometry(feature["geometry"])
  File "..\mapillary\models\geojson.py", line 211, in __init__
    self.type: str = geometry["type"]
KeyError: 'type'

The returned GeoJSON from the API is in the form:

[{'geometry': {'coordinates': [-0.12497729285872, 51.537085937084],
               'type': 'Point'},
  'properties': {'created_at': '2025-08-02T16:21:25+0000',
                 'id': '1724058414915752',
                 'pixel_geometry': 'Gjp4AgoGbXB5LW9yKIAgEisYAwgBIiUJqiuWInoIDxAABAcIAAQHBgAcAAgIBAgACAMQCwAPCCkKBxEP',
                 'value': 'object--catch-basin'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [-0.12498136837391, 51.537059028201],
               'type': 'Point'},
  'properties': {'created_at': '2025-08-02T16:20:30+0000',
                 'id': '1807913776455018',
                 'pixel_geometry': 'Gld4AgoGbXB5LW9yKIAgEkgYAwgBIkIJ2inOJ+oBKDcEAAgHLiEkEAgKBAAECAQACAgKCAwICAgIEAsaGRALGAcIAwgHCAcIAwADCAsAGQ8DBy8fAwcTBw8=',
                 'value': 'object--catch-basin'},
  'type': 'Feature'},
 {'geometry': {},
  'properties': {'created_at': '2025-08-02T16:20:20+0000',
                 'id': '685612757857124',
                 'pixel_geometry': 'GosBeAIKBm1weS1vciiAIBJ8GAMIASJ2Cd44jCy6AwQHCAAIBwgABAcGAAgHBAAIBwgABAcUCQQHCAAEBwgABAcOAAgAFAgECAgACAgICgQABAgEAAoIBAgECAgQABADEgcAAwgNAA8YBwgHCAcIAwAHCA8QFQoDACchAw8LAAMHAwAJBwsXBwADCQMHDw==',
                 'value': 'object--catch-basin'},
  'type': 'Feature'},
 {'geometry': {'coordinates': [-0.12497321734354, 51.537112845968],
               'type': 'Point'},
  'properties': {'created_at': '2025-08-02T16:21:33+0000',
                 'id': '1777805250267304',
                 'pixel_geometry': 'GiR4AgoGbXB5LW9yKIAgEhUYAwgBIg8JtCWiIyIyAAQYMQADBw8=',
                 'value': 'object--catch-basin'},
  'type': 'Feature'}]

Clearly we see features in Mapillary without attached geometry, but still picked up by the map feature API.
It's unclear what the expected behaviour is here, otherwise I would have submitted a PR. 😥

Expected behavior
Detections returned as usual.
Unclear how to handle detections without any geometry.

Screenshots

Additional context

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

复现使用 fields=[] 对 mapillary.interface.get_detections_with_map_feature_id 的调用,并通过 interface.py、controller/detection.py 和 models/geojson.py 跟踪它。检查 Geometry 如何处理空的 geometry 对象,明确预期的返回表示形式,并在此响应不再引发 KeyError 且预期行为得到覆盖时,认为该 issue 已完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。