diff --git a/CHANGELOG.md b/CHANGELOG.md index 397fd8ad..571b1a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ - New community module `hakunapi-tiles-source-gpkg`: a `MapTileSource` and a `VectorTileSource` serving the tiles stored in a GeoPackage tile pyramid, read through `sqlite-jdbc`. Not part of the reference webapp. - New community module `hakunapi-tiles-source-pmtiles`: a `MapTileSource` and a `VectorTileSource` serving the tiles of a PMTiles v3 archive, read in place from a local file or over HTTP range requests. Not part of the reference webapp. - New community module `hakunapi-tiles-generator`: the seed tool `TilesGenerator` writes a vector tile pyramid into a GeoPackage (`hakunapi-tiles-source-gpkg` can serve it), and `PMTilesConvert` converts such a pyramid into a PMTiles v3 archive. Not part of the reference webapp. +- HTML items and item pages: the Leaflet map shows a background tile layer only for CRSs an open tile service fits. The default OpenStreetMap layer is used for geographic CRSs and EPSG:3857 (which is now plotted correctly); for other CRSs, such as EPSG:3067 or ETRS-GKnn, only the feature geometries are drawn unless `formats.html..tileUrl` is configured. - `collectionInfo.ftl` shows the collection id alongside its title and description, and links to the collection's schema. `collections.ftl` lists entries as `collection_id (Title)`. diff --git a/docker/cfg/addresses.properties b/docker/cfg/addresses.properties index e1d99dbb..603a1ae2 100644 --- a/docker/cfg/addresses.properties +++ b/docker/cfg/addresses.properties @@ -23,6 +23,8 @@ formats.geojson.type=json # formats.geojson.forceLonLat=true formats.html.type=html # HTML tile layer configuration per SRID +formats.html.4258.tileUrl=https://avoin-karttakuva.maanmittauslaitos.fi/avoin/wmts/1.0.0/taustakartta/default/WGS84_Pseudo-Mercator/{z}/{y}/{x}.png?api-key=7cd2ddae-9f2e-481c-99d0-404e7bc7a0b2 +formats.html.4258.tileAttribution=© National Land Survey of Finland formats.html.3067.tileUrl=https://avoin-karttakuva.maanmittauslaitos.fi/avoin/wmts/1.0.0/taustakartta/default/ETRS-TM35FIN/{z}/{y}/{x}.png?api-key=7cd2ddae-9f2e-481c-99d0-404e7bc7a0b2 formats.html.3067.tileAttribution=© National Land Survey of Finland formats.html.3067.tileOriginX=-548576 @@ -41,7 +43,7 @@ getfeatures.limit.default=10 getfeatures.limit.max=10000 # Configure known srids (hakunapi will always add 84 (lon, lat) and 4326 (lat, lon)) -srid=3067,4258,3903,10774 +srid=3067,4258,3903,10774,3879 # Let hakunapi know that EPSG:4258 is lat,lon order (+ degrees) srid.4258.latLon=true srid.4258.degrees=true @@ -56,6 +58,9 @@ srid.3903.proj4=+proj=utm +zone=35 +ellps=GRS80 +units=m +vunits=m +no_defs +typ srid.10774.latLon=false srid.10774.geometryDimension=XYZ srid.10774.proj4=+proj=utm +zone=35 +ellps=GRS80 +units=m +vunits=m +no_defs +type=crs +# EPSG:3879 ETRS-GK25 (north,east axis order); no open tile service, so the HTML map draws only the geometries +srid.3879.latLon=true +srid.3879.proj4=+proj=tmerc +lat_0=0 +lon_0=25 +k=1 +x_0=25500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs # JSON Schema for additional metadata (titles, descriptions, codelist URIs) # schema names imply the language tag (overridable with schema..lang=) @@ -129,7 +134,7 @@ collections.addresses.table=simple_addresses collections.addresses.extent.spatial.crs84=15.0537852,58.6074565,33.9935374,70.2641566 ### Supported Coordinate Reference Systems (CRS:84 is always and automatically included) -collections.addresses.srid=3067,4258,3903,10774 +collections.addresses.srid=3067,4258,3903,10774,3879 ### Required, mapping for primary id property diff --git a/docs/overview/modules.md b/docs/overview/modules.md index 10cb7c36..b51d8d9b 100644 --- a/docs/overview/modules.md +++ b/docs/overview/modules.md @@ -319,6 +319,8 @@ This support is implemented by the `hakunapi-html` module and it can be enabled The HTML content produced includes an interactive Leaflet map by default, with features visualized on a configurable tile layer and displayed in a data table. Maps work with any coordinate system configured via proj4 definitions and per-SRID tile settings, handling both geographic and projected CRS transparently. The HTML templates are customizable and can be extended or replaced for application-specific needs. +The map on the items and item pages is a demo feature. A background tile layer is shown only when an open tile service fits the CRS of the page: OpenStreetMap by default for geographic CRSs and EPSG:3857, or the service configured for the CRS with `formats.html..tileUrl` (also `tileAttribution`, `tileOriginX`, `tileOriginY`; `formats.html.tileUrl` applies to all CRSs). For any other CRS, such as EPSG:3067 or ETRS-GKnn without configuration, only the feature geometries are drawn. For example, the National Land Survey of Finland services are configured per CRS: WGS84_Pseudo-Mercator tiles for geographic CRSs and EPSG:3857, ETRS-TM35FIN tiles (with the tile origin) for EPSG:3067, 3903 and 10774, see `docker/cfg/addresses.properties`. The NLS services require an API key. + ### GeoPackage The [GeoPackage (GPKG)](https://www.geopackage.org/) output format (the media type `application/geopackage+vnd.sqlite3`) is supported by the `hakunapi-gpgk` module. When needed it must be enabled using a configuration like `formats=geojson,gpgk`. The implementation supports outputting same feature, feature collection, property and geometry objects (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon and GeometryCollection) as GeoJSON writer too. diff --git a/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/backgroundMap.ftl b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/backgroundMap.ftl new file mode 100644 index 00000000..c6119e4b --- /dev/null +++ b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/backgroundMap.ftl @@ -0,0 +1,10 @@ +<#-- Background map decision shared by featureCollection.ftl and feature.ftl. + Geographic CRSs and EPSG:3857 are drawn by Leaflet itself and get the configured tile layer (OpenStreetMap by default). + Other projected CRSs get a tile layer only when one is configured for them (OpenStreetMap does not serve them). --> +<#assign bgWebMercator = (srid == 3857)> +<#assign bgLeafletCrs = (sridCode?? && sridCode.degrees) || bgWebMercator> +<#assign bgProj4 = ""> +<#if !bgLeafletCrs && sridCode?? && sridCode.proj4??><#assign bgProj4 = sridCode.proj4> +<#assign bgProjected = bgProj4?has_content || bgWebMercator> +<#assign bgTileUrl = ""> +<#if settings.tileUrl?? && (bgLeafletCrs || settings.tileUrl != "https://tile.openstreetmap.org/{z}/{x}/{y}.png")><#assign bgTileUrl = settings.tileUrl> diff --git a/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/feature.ftl b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/feature.ftl index fb174424..812c1a55 100644 --- a/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/feature.ftl +++ b/src/hakunapi-html/src/main/resources/fi/nls/hakunapi/html/feature.ftl @@ -1,3 +1,4 @@ +<#include "backgroundMap.ftl"> @@ -9,7 +10,7 @@ - <#if sridCode?? && sridCode.proj4??> + <#if bgProj4?has_content> @@ -18,6 +19,7 @@ +<#assign crsUri = (srid == 84)?then("http://www.opengis.net/def/crs/OGC/1.3/CRS84", "http://www.opengis.net/def/crs/EPSG/0/" + srid?c)>