|
23 | 23 | from fastapi.dependencies.utils import get_parameterless_sub_dependant |
24 | 24 | from fastapi.params import Depends as DependsFunc |
25 | 25 | from geojson_pydantic.features import Feature, FeatureCollection |
26 | | -from geojson_pydantic.geometries import MultiPolygon, Polygon |
27 | 26 | from morecantile import TileMatrixSet |
28 | 27 | from morecantile import tms as morecantile_tms |
29 | 28 | from morecantile.defaults import TileMatrixSets |
|
85 | 84 | from titiler.core.resources.enums import ImageType |
86 | 85 | from titiler.core.resources.responses import GeoJSONResponse, JSONResponse, XMLResponse |
87 | 86 | from titiler.core.routing import EndpointScope |
88 | | -from titiler.core.utils import render_image |
| 87 | +from titiler.core.utils import bounds_to_geometry, render_image |
89 | 88 |
|
90 | 89 | jinja2_env = jinja2.Environment( |
91 | 90 | loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) |
@@ -398,15 +397,7 @@ def info_geojson( |
398 | 397 | with rasterio.Env(**env): |
399 | 398 | with self.reader(src_path, **reader_params.as_dict()) as src_dst: |
400 | 399 | bounds = src_dst.get_geographic_bounds(crs or WGS84_CRS) |
401 | | - if bounds[0] > bounds[2]: |
402 | | - pl = Polygon.from_bounds(-180, bounds[1], bounds[2], bounds[3]) |
403 | | - pr = Polygon.from_bounds(bounds[0], bounds[1], 180, bounds[3]) |
404 | | - geometry = MultiPolygon( |
405 | | - type="MultiPolygon", |
406 | | - coordinates=[pl.coordinates, pr.coordinates], |
407 | | - ) |
408 | | - else: |
409 | | - geometry = Polygon.from_bounds(*bounds) |
| 400 | + geometry = bounds_to_geometry(bounds) |
410 | 401 |
|
411 | 402 | return Feature( |
412 | 403 | type="Feature", |
@@ -1446,15 +1437,7 @@ def info_geojson( |
1446 | 1437 | with rasterio.Env(**env): |
1447 | 1438 | with self.reader(src_path, **reader_params.as_dict()) as src_dst: |
1448 | 1439 | bounds = src_dst.get_geographic_bounds(crs or WGS84_CRS) |
1449 | | - if bounds[0] > bounds[2]: |
1450 | | - pl = Polygon.from_bounds(-180, bounds[1], bounds[2], bounds[3]) |
1451 | | - pr = Polygon.from_bounds(bounds[0], bounds[1], 180, bounds[3]) |
1452 | | - geometry = MultiPolygon( |
1453 | | - type="MultiPolygon", |
1454 | | - coordinates=[pl.coordinates, pr.coordinates], |
1455 | | - ) |
1456 | | - else: |
1457 | | - geometry = Polygon.from_bounds(*bounds) |
| 1440 | + geometry = bounds_to_geometry(bounds) |
1458 | 1441 |
|
1459 | 1442 | return Feature( |
1460 | 1443 | type="Feature", |
@@ -1699,15 +1682,7 @@ def info_geojson( |
1699 | 1682 | with rasterio.Env(**env): |
1700 | 1683 | with self.reader(src_path, **reader_params.as_dict()) as src_dst: |
1701 | 1684 | bounds = src_dst.get_geographic_bounds(crs or WGS84_CRS) |
1702 | | - if bounds[0] > bounds[2]: |
1703 | | - pl = Polygon.from_bounds(-180, bounds[1], bounds[2], bounds[3]) |
1704 | | - pr = Polygon.from_bounds(bounds[0], bounds[1], 180, bounds[3]) |
1705 | | - geometry = MultiPolygon( |
1706 | | - type="MultiPolygon", |
1707 | | - coordinates=[pl.coordinates, pr.coordinates], |
1708 | | - ) |
1709 | | - else: |
1710 | | - geometry = Polygon.from_bounds(*bounds) |
| 1685 | + geometry = bounds_to_geometry(bounds) |
1711 | 1686 |
|
1712 | 1687 | return Feature( |
1713 | 1688 | type="Feature", |
|
0 commit comments