Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for OGC API - Styles #1809

Open
doublebyte1 opened this issue Sep 12, 2024 · 7 comments
Open

Add Support for OGC API - Styles #1809

doublebyte1 opened this issue Sep 12, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request OGC API - Styles OGC API - Styles
Milestone

Comments

@doublebyte1
Copy link
Contributor

The OGC API - Styles Draft Standard enables map servers, clients as well as visual style editors, to manage and fetch styles. The styles consist of symbolizing instructions that can be applied by a rendering engine on features and/or coverages. The API implements the conceptual model for style encodings and style metadata.

@doublebyte1 doublebyte1 added the enhancement New feature or request label Sep 12, 2024
@tomkralidis tomkralidis added the OGC API - Styles OGC API - Styles label Sep 12, 2024
@tomkralidis
Copy link
Member

As discussed, an initial iteration could be listing/access of styles via /styles. Future iterations would include association of a style to a resource and transaction interfaces.

@tomkralidis tomkralidis added this to the 0.19.0 milestone Sep 12, 2024
@Youssef-Harby
Copy link

I have a question regarding how styles should be configured in the pygeoapi configuration YAML file. Specifically, how should styles be associated with a collection?

For example, should the style be configured under the providers section of a collection, and how would this work for both Mapbox and SLD 1.1 styles? Could you provide a sample configuration for both vector tiles (Mapbox style) and GeoJSON (SLD 1.1)?

Here are two example configurations I'm trying to achieve:

resources:
    bathingwater-estonia:
        type: collection
        title: Bathing water sources
        description: Data of bathing water sources used by water supply systems under the supervision of the Health Board from the Water Health Information System.
        keywords:
            - Water
            - Water bodies
            - Drilled wells
            - Surface water
            - Groundwater
            - Environmental health
            - Health
            - Bathing water
        links:
            - type: text/html
              rel: canonical
              title: information
              href: https://avaandmed.eesti.ee/api/datasets/slug/supluskohad
              hreflang: en-US
        extents:
            spatial:
                bbox:
                    [
                        22.2290936066586440,
                        57.6912449743385451,
                        28.2024877654160555,
                        59.6097269178904412,
                    ]
                crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
            temporal:
                begin: null
                end: null # or empty
        providers:
            - type: feature
              name: GeoJSON
              data: tests/data/tartu/bathingwater-estonia.geojson
              id_field: id
              styles:
                  - name: water-bodies
                    title: Water Bodies SLD Style
                    style:
                        type: sld
                        version: 1.1
                        data: tests/styles/bathing_water_sources.sld
            - type: tile
              name: MVT-tippecanoe
              data: tests/data/tiles_es/ # local directory tree
              options:
                  zoom:
                      min: 0
                      max: 16
              format:
                  name: pbf
                  mimetype: application/vnd.mapbox-vector-tile
              styles:
                  - name: mapbox style test
                    title: style title
                    style:
                        type: mapbox
                        data: tests/styles/bathing_water_sources.json

Could you confirm if this is the right way to configure the styles, and if there's anything else that should be included for proper style support?

Additionally, I'm curious about the compatibility of certain style types with specific providers (assuming that it will be under providers). From what I understand, it's possible to define a GeoJSON source (either inline or as a remote URL) within a Mapbox style JSON, but it's not possible to define an SLD style for a vector tiles (PBF) provider. Could you clarify if this assumption is correct?

If there are limitations on which style types (e.g., Mapbox vs. SLD) can be applied to specific providers (e.g., GeoJSON vs. PBF), it would be helpful to understand how pygeoapi handles this, and whether these limitations are enforced in the configuration.

@Youssef-Harby
Copy link

Youssef-Harby commented Sep 18, 2024

Should we add XML support in https://github.com/geopython/pygeoapi/blob/master/pygeoapi/api/__init__.py#L81-L101 for SLD ?
Or it will be a different query parameter like ?f=mbsor ?f=sld for example ?

@doublebyte1
Copy link
Contributor Author

I have a question regarding how styles should be configured in the pygeoapi configuration YAML file. Specifically, how should styles be associated with a collection?

For example, should the style be configured under the providers section of a collection, and how would this work for both Mapbox and SLD 1.1 styles? Could you provide a sample configuration for both vector tiles (Mapbox style) and GeoJSON (SLD 1.1)?

Here are two example configurations I'm trying to achieve:

resources:
    bathingwater-estonia:
        type: collection
        title: Bathing water sources
        description: Data of bathing water sources used by water supply systems under the supervision of the Health Board from the Water Health Information System.
        keywords:
            - Water
            - Water bodies
            - Drilled wells
            - Surface water
            - Groundwater
            - Environmental health
            - Health
            - Bathing water
        links:
            - type: text/html
              rel: canonical
              title: information
              href: https://avaandmed.eesti.ee/api/datasets/slug/supluskohad
              hreflang: en-US
        extents:
            spatial:
                bbox:
                    [
                        22.2290936066586440,
                        57.6912449743385451,
                        28.2024877654160555,
                        59.6097269178904412,
                    ]
                crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
            temporal:
                begin: null
                end: null # or empty
        providers:
            - type: feature
              name: GeoJSON
              data: tests/data/tartu/bathingwater-estonia.geojson
              id_field: id
              styles:
                  - name: water-bodies
                    title: Water Bodies SLD Style
                    style:
                        type: sld
                        version: 1.1
                        data: tests/styles/bathing_water_sources.sld
            - type: tile
              name: MVT-tippecanoe
              data: tests/data/tiles_es/ # local directory tree
              options:
                  zoom:
                      min: 0
                      max: 16
              format:
                  name: pbf
                  mimetype: application/vnd.mapbox-vector-tile
              styles:
                  - name: mapbox style test
                    title: style title
                    style:
                        type: mapbox
                        data: tests/styles/bathing_water_sources.json

Could you confirm if this is the right way to configure the styles, and if there's anything else that should be included for proper style support?

Additionally, I'm curious about the compatibility of certain style types with specific providers (assuming that it will be under providers). From what I understand, it's possible to define a GeoJSON source (either inline or as a remote URL) within a Mapbox style JSON, but it's not possible to define an SLD style for a vector tiles (PBF) provider. Could you clarify if this assumption is correct?

If there are limitations on which style types (e.g., Mapbox vs. SLD) can be applied to specific providers (e.g., GeoJSON vs. PBF), it would be helpful to understand how pygeoapi handles this, and whether these limitations are enforced in the configuration.

Hi @Youssef-Harby these are all valid questions, but they regard the application of styles in other Standards (e.g: tiles) and we may be stepping ourselves ahead a bit, as we do not have any support for serving the actual style, yet (:

The PR I am working on aims for support for publishing styles, starting from a very simple case (e.g.: SLDs on a folder). Once we are able to provide a list of styles and styles metadata, we can start thinking about calling these styles from other APIs (:

If you have some sample style files that you can provide, as examples, I would be very grateful! ☺️

@Youssef-Harby
Copy link

Thanks, @doublebyte1 . I am using the exercise data from https://dive.pygeoapi.io/setup/ (bathingwater-estonia) to generate a very simple style using QGIS for SLD 1.1 and Maputnik for Mapbox GL style.

tests/styles/bathing_water_sources.json:

{
  "version": 8,
  "name": "Empty Style",
  "metadata": {"maputnik:renderer": "mlgljs"},
  "sources": {
    "earth": {
      "type": "raster",
      "tiles": ["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],
      "minzoom": 0,
      "maxzoom": 16
    },
    "pygeoapi": {
      "type": "vector",
      "tiles": [
        "https://localhost/collections/bathingwater-estonia/tiles/WebMercatorQuad/{z}/{x}/{y}?f=pbf"
      ],
      "minzoom": 0,
      "maxzoom": 16
    }
  },
  "sprite": "",
  "glyphs": "https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf",
  "layers": [
    {"id": "earth", "type": "raster", "source": "earth"},
    {
      "id": "bathingwaterestonia",
      "type": "circle",
      "source": "pygeoapi",
      "source-layer": "bathingwaterestonia",
      "paint": {"circle-color": "rgba(255, 0, 0, 1)", "circle-radius": 10}
    }
  ],
  "id": "oi0gcaa"
}

tests/styles/bathing_water_sources.sld:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd">
  <NamedLayer>
    <se:Name>bathingwater-estonia</se:Name>
    <UserStyle>
      <se:Name>bathingwater-estonia</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>star</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#b80808</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#b80808</se:SvgParameter>
                  <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>24</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
          <se:PointSymbolizer>
            <se:Graphic>
              <se:Mark>
                <se:WellKnownName>star</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#ff0000</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#ff0000</se:SvgParameter>
                  <se:SvgParameter name="stroke-width">1</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>26</se:Size>
              <se:Rotation>
                <ogc:Literal>34</ogc:Literal>
              </se:Rotation>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Also, I have started working on https://github.com/Youssef-Harby/pygeoapi/tree/styles , incorporating your changes/boilerplate, and began drafting from that point. However, since your plan involves serving only simple SLDs from a directory, I would like to ask if you could provide an example configuration YAML showing how you would prefer the SLD to be defined, so we're aligned on the same page.

@doublebyte1
Copy link
Contributor Author

doublebyte1 commented Oct 15, 2024

@Youssef-Harby: sure, based on your example, I was thinking of something like this (but open to feedback!): 😁

          bathingwater-estonia:
              type: collection
              title: Bathing water sources
              description: Data of bathing water sources used by water supply systems under the supervision of the Health Board from the Water Health Information System.
              keywords:
                  - Water
                  - Water bodies
                  - Drilled wells
                  - Surface water
                  - Groundwater
                  - Environmental health
                  - Health
                  - Bathing water
              links:
                  - type: text/html
                    rel: canonical
                    title: information
                    href: https://avaandmed.eesti.ee/api/datasets/slug/supluskohad
                    hreflang: en-US
              extents:
                  spatial:
                      bbox:
                          [
                              22.2290936066586440,
                              57.6912449743385451,
                              28.2024877654160555,
                              59.6097269178904412,
                          ]
                      crs: http://www.opengis.net/def/crs/OGC/1.3/CRS84
                  temporal:
                      begin: null
                      end: null # or empty
              providers:
                  - type: feature
                    name: GeoJSON
                    data: tests/data/tartu/bathingwater-estonia.geojson
                    id_field: id
                  - type: tile
                    name: MVT-tippecanoe
                    data: tests/data/tiles_es/ # local directory tree
                    options:
                        zoom:
                            min: 0
                            max: 16
                    format:
                        name: pbf
                        mimetype: application/vnd.mapbox-vector-tile
                  - type: style
                    name: style-file
                    options:
                        format: mbs
                    data: tests/styles/bathing_water_sources.json # local directory tree

In summary, the type would be the new type, style and we would have to implement one provider to load the style from a file on disk. Ultimately, this plugin should have as option the style format, but for now, we could even remove the options and just assume a default format (e.g.: mapbox or sld).

@doublebyte1
Copy link
Contributor Author

@tomkralidis what do you think? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OGC API - Styles OGC API - Styles
Projects
None yet
Development

No branches or pull requests

3 participants