From b7e8bf53d467e4698f7dbec23a4a7ec9ebf55a1e Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Sat, 18 Jan 2025 00:27:20 +0900 Subject: [PATCH 1/2] feat(server): add skip_code_list_fetch option to CityGML SpatialID Attributes API --- server/citygml/echo.go | 3 ++- server/citygml/spatialid_attributes.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/citygml/echo.go b/server/citygml/echo.go index 1eea9d0f..7c1e41ab 100644 --- a/server/citygml/echo.go +++ b/server/citygml/echo.go @@ -136,6 +136,7 @@ func spatialIDAttributesHandler(dc *dataCatalogAPI) echo.HandlerFunc { ctx := c.Request().Context() sids := strings.Split(c.QueryParam("sid"), ",") types := strings.Split(c.QueryParam("type"), ",") + skipCodeListFetch := c.QueryParam("skip_code_list_fetch") != "" if len(sids) == 0 || (len(sids) == 1 && sids[0] == "") { return c.JSON(http.StatusBadRequest, map[string]any{ "error": "sid parameter is required", @@ -185,7 +186,7 @@ func spatialIDAttributesHandler(dc *dataCatalogAPI) echo.HandlerFunc { rs := make([]Reader, 0, len(urls)) etagCache := make(map[string]string) for _, u := range urls { - rs = append(rs, &urlReader{URL: u, client: httpClient, etagCache: etagCache}) + rs = append(rs, &urlReader{url: u, client: httpClient, etagCache: etagCache, skipCodeListFetch: skipCodeListFetch}) } attributes, err := SpatialIDAttributes(ctx, rs, sids) diff --git a/server/citygml/spatialid_attributes.go b/server/citygml/spatialid_attributes.go index 3b953a10..7831dfc8 100644 --- a/server/citygml/spatialid_attributes.go +++ b/server/citygml/spatialid_attributes.go @@ -22,7 +22,8 @@ type urlReader struct { URL string client *http.Client - etagCache map[string]string + skipCodeListFetch bool + etagCache map[string]string } func (r *urlReader) Open(ctx context.Context) (io.Reader, func() error, error) { @@ -66,6 +67,9 @@ func (r *urlReader) Open(ctx context.Context) (io.Reader, func() error, error) { } func (r *urlReader) Resolver() codeResolver { + if r.skipCodeListFetch { + return nil + } return &fetchCodeResolver{ client: r.client, url: r.URL, From 3d39af3504c9b759f2d90b8ea47da52748dc5258 Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Sat, 18 Jan 2025 00:32:27 +0900 Subject: [PATCH 2/2] chore: fix build error --- server/citygml/echo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/citygml/echo.go b/server/citygml/echo.go index 7c1e41ab..57b064cc 100644 --- a/server/citygml/echo.go +++ b/server/citygml/echo.go @@ -186,7 +186,7 @@ func spatialIDAttributesHandler(dc *dataCatalogAPI) echo.HandlerFunc { rs := make([]Reader, 0, len(urls)) etagCache := make(map[string]string) for _, u := range urls { - rs = append(rs, &urlReader{url: u, client: httpClient, etagCache: etagCache, skipCodeListFetch: skipCodeListFetch}) + rs = append(rs, &urlReader{URL: u, client: httpClient, etagCache: etagCache, skipCodeListFetch: skipCodeListFetch}) } attributes, err := SpatialIDAttributes(ctx, rs, sids)