コード例 #1
0
ファイル: geojson.py プロジェクト: craws/OpenAtlas
 def get_geom(entity: Entity) -> Union[list[dict[str, Any]], list[Any]]:
     if entity.class_.view == 'place' or entity.class_.name == 'artifact':
         return Gis.get_by_id(
             Link.get_linked_entity_safe(entity.id, 'P53').id)
     if entity.class_.name == 'object_location':
         return Gis.get_by_id(entity.id)
     return []
コード例 #2
0
 def get_geom(entity: Entity) -> Union[List[Dict[str, Any]], List[Any]]:
     if entity.class_.view == 'place' or entity.class_.name in [
             'find', 'artifact'
     ]:
         return Gis.get_by_id(Link.get_linked_entity(entity.id, 'P53').id)
     if entity.class_.name == 'object_location':
         print("here")
         return Gis.get_by_id(entity.id)
     return []
コード例 #3
0
def get_csv_geometry(entity: Entity) -> dict[str, Any]:
    if entity.cidoc_class.code != 'E53':
        return {'type': None, 'coordinates': None}  # pragma: no cover
    geoms = Gis.get_by_id(entity.id)
    if geoms:
        return {key: [geom[key] for geom in geoms] for key in geoms[0]}
    return {'type': None, 'coordinates': None}
コード例 #4
0
 def get_geometry(entity: Entity) -> Dict[str, None]:
     if entity.cidoc_class.code != 'E53':  # pragma: nocover
         return {'type': None, 'coordinates': None}
     geoms = Gis.get_by_id(entity.id)
     if geoms:
         return {key: [d[key] for d in geoms] for key in geoms[0]}
     return {'type': None, 'coordinates': None}
コード例 #5
0
 def get_geoms_by_entity(entity_id: int) -> Dict[str, Any]:
     geoms = Gis.get_by_id(entity_id)
     if len(geoms) == 1:
         return geoms[0]
     return {'type': 'GeometryCollection', 'geometries': geoms}
コード例 #6
0
 def get_geoms_by_entity(entity: Entity) -> Union[str, Dict[str, Any]]:
     geoms = Gis.get_by_id(entity.id)
     if len(geoms) == 1:
         return geoms[0]
     return {'type': 'GeometryCollection', 'geometries': geoms}