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 []
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 []
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}
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}
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}
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}