(target: str, geolocation: str)
| 130 | |
| 131 | |
| 132 | async def process_geolocation(target: str, geolocation: str): |
| 133 | try: |
| 134 | geo_long_str, geo_lat_str, geo_radius_str = geolocation.split(",") |
| 135 | geo_long = float(geo_long_str) |
| 136 | geo_lat = float(geo_lat_str) |
| 137 | geo_radius = float(geo_radius_str) |
| 138 | target_field = "" |
| 139 | if target == "captures": |
| 140 | target_field = "captures.core:geolocation" |
| 141 | if target == "annotations": |
| 142 | target_field = "annotations.core:geolocation" |
| 143 | |
| 144 | return { |
| 145 | target_field: { |
| 146 | "$near": { |
| 147 | "$geometry": { |
| 148 | "type": "Point", |
| 149 | "coordinates": [geo_long, geo_lat], |
| 150 | }, |
| 151 | "$maxDistance": geo_radius, |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | except Exception: |
| 157 | raise InvalidGeolocationFormat() |
| 158 | |
| 159 | |
| 160 | async def query_metadata( |
no test coverage detected