Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Mar 29, 2024
1 parent 73ad49f commit f93d777
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions tipg/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@

from fastapi import APIRouter, Depends, Path, Query
from fastapi.responses import ORJSONResponse
from fastapi.routing import APIRoute

from starlette.datastructures import QueryParams
from starlette.requests import Request
from starlette.responses import HTMLResponse, Response, StreamingResponse
from starlette.routing import Match, compile_path, replace_params
from starlette.routing import compile_path, replace_params
from starlette.templating import Jinja2Templates, _TemplateResponse

tms_settings = TMSSettings()
Expand Down Expand Up @@ -211,17 +210,6 @@ def url_for(self, request: Request, name: str, **path_params: Any) -> str:

return str(url_path.make_absolute_url(base_url=base_url))

def find_route(self, path: str, method: str = "GET") -> Optional[APIRoute]:
"""find route from scope."""
for route in self.router.routes:
match, _ = route.matches({"type": "http", "path": path, "method": method})
if match != Match.FULL:
continue

return route

return None

def _create_html_response(
self,
request: Request,
Expand Down Expand Up @@ -1500,14 +1488,12 @@ async def collection_tileset(
},
]

if route := self.find_route(
f"/collections/{collection.id}/tiles/{tileMatrixSetId}/viewer"
):
if self.with_viewer:
links.append(
{
"href": self.url_for(
request,
route.name,
"viewer_endpoint",
tileMatrixSetId=tileMatrixSetId,
collectionId=collection.id,
),
Expand Down Expand Up @@ -1925,6 +1911,7 @@ def viewer_endpoint(
"resolutions": [matrix.cellSize for matrix in tms],
},
template_name="map",
title=f"{collection.id} viewer",
)


Expand Down

0 comments on commit f93d777

Please sign in to comment.