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

mapbox integration level #127

Open
fxi opened this issue Apr 29, 2022 · 4 comments
Open

mapbox integration level #127

fxi opened this issue Apr 29, 2022 · 4 comments
Labels
question Further information is requested

Comments

@fxi
Copy link

fxi commented Apr 29, 2022

Question

I'm not sure to understand the level of completion of this package. Is there a roadmap I've missed ?

I have – a lot – of mapbox styles that need to be converted to SLD. My idea was to parse and convert them using this package, but the expressions not handled seems to be passed to geostyler "as is" : not processed at all in the resulting SLD.

Example :

mapbox
{
  "version": 8,
  "name": "iceland numeric test",
  "sprite": "",
  "glyphs": "",
  "sources": {
    "MX-3Q41Y-AH46I-1QGD9-SRC": {
      "type": "vector",
      "layerInfo": {
        "name": "mx_vector_2r63w_aailg_s7xbb_mfprt"
      },
      "attribution": "<a>iceland_test_numeric</a>",
      "tiles": []
      "promoteId": "gid"
    }
  },
  "layers": [
    {
      "id": "MX-3Q41Y-AH46I-1QGD9@8TqF9",
      "source": "MX-3Q41Y-AH46I-1QGD9-SRC",
      "filter": [
        "all",
        ["==", ["typeof", ["get", "amount"]], "number"],
        [">", ["get", "amount"], 0],
        ["<=", ["get", "amount"], 10.12]
      ],
      "source-layer": "MX-3Q41Y-AH46I-1QGD9",
      "metadata": {
        "type": "number",
        "position": 1,
        "priority": 1
      },
      "type": "circle",
      "paint": {
        "circle-color": "#023858",
        "circle-radius": 15
      }
    },
    {
      "id": "MX-3Q41Y-AH46I-1QGD9@W82FL",
      "source": "MX-3Q41Y-AH46I-1QGD9-SRC",
      "filter": ["all", ["!=", ["typeof", ["get", "amount"]], "number"]],
      "source-layer": "MX-3Q41Y-AH46I-1QGD9",
      "metadata": {
        "type": "number",
        "position": 0,
        "priority": 1
      },
      "type": "circle",
      "paint": {
        "circle-color": "#f60675",
        "circle-radius": 15
      }
    },
    {
      "id": "MX-3Q41Y-AH46I-1QGD9@rRHVt",
      "source": "MX-3Q41Y-AH46I-1QGD9-SRC",
      "filter": [
        "all",
        ["==", ["typeof", ["get", "amount"]], "number"],
        ["==", ["get", "amount"], 0]
      ],
      "source-layer": "MX-3Q41Y-AH46I-1QGD9",
      "metadata": {
        "type": "number",
        "position": 0,
        "priority": 1
      },
      "type": "circle",
      "paint": {
        "circle-color": "#fff7fb",
        "circle-radius": 15
      }
    }
  ]
}
gstyle
{
  "output": {
    "name": "iceland numeric test",
    "rules": [
      {
        "name": "MX-3Q41Y-AH46I-1QGD9@8TqF9",
        "filter": [
          "&&",
          ["==", ["typeof", ["get", "amount"]], "number"],
          [">", ["get", "amount"], 0],
          ["<=", ["get", "amount"], 10.12]
        ],
        "symbolizers": [
          {
            "kind": "Mark",
            "color": "#023858",
            "radius": 15,
            "wellKnownName": "circle"
          }
        ]
      },
      {
        "name": "MX-3Q41Y-AH46I-1QGD9@W82FL",
        "filter": ["&&", ["!=", ["typeof", ["get", "amount"]], "number"]],
        "symbolizers": [
          {
            "kind": "Mark",
            "color": "#f60675",
            "radius": 15,
            "wellKnownName": "circle"
          }
        ]
      },
      {
        "name": "MX-3Q41Y-AH46I-1QGD9@rRHVt",
        "filter": [
          "&&",
          ["==", ["typeof", ["get", "amount"]], "number"],
          ["==", ["get", "amount"], 0]
        ],
        "symbolizers": [
          {
            "kind": "Mark",
            "color": "#fff7fb",
            "radius": 15,
            "wellKnownName": "circle"
          }
        ]
      }
    ]
  }
}

sld
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>iceland numeric test</Name>
    <UserStyle>
      <Name>iceland numeric test</Name>
      <Title>iceland numeric test</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>MX-3Q41Y-AH46I-1QGD9@8TqF9</Name>
          <Filter xmlns="http://www.opengis.net/ogc"/>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#023858</CssParameter>
                </Fill>
              </Mark>
              <Size>30</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <Name>MX-3Q41Y-AH46I-1QGD9@W82FL</Name>
          <Filter xmlns="http://www.opengis.net/ogc"/>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#f60675</CssParameter>
                </Fill>
              </Mark>
              <Size>30</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
        <Rule>
          <Name>MX-3Q41Y-AH46I-1QGD9@rRHVt</Name>
          <Filter xmlns="http://www.opengis.net/ogc"/>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <WellKnownName>circle</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#fff7fb</CssParameter>
                </Fill>
              </Mark>
              <Size>30</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Thanks :)

@fxi fxi added the question Further information is requested label Apr 29, 2022
@marcjansen
Copy link
Contributor

Nice timing, we are planning a codesprint right now, and you are invited of course :-) https://geostyler.org should have all needed infos.

We'll surely then find time to work in a roadmap, and maybe even find time to support more Mapbox syntax.

I hope others might weigh in with more details to your actual questions.

@fxi
Copy link
Author

fxi commented Apr 29, 2022

Great ! Nice project. I will discuss with my team. We are quite on a tight schedule on this, but we will discuss. Thanks :)

@jansule
Copy link
Contributor

jansule commented May 3, 2022

We currently only provide a small subset of mapbox expressions, since it is a lot of work to implement these for the other parsers.

Currently supported expressions for the mapbox parser can be found here: https://github.com/geostyler/geostyler-mapbox-parser/blob/master/src/MapboxStyleParser.ts#L372.

Currently supported filters/expressions in geostyler-style can be found here: https://github.com/geostyler/geostyler-style/blob/master/style.ts#L103

Please notice that not all parsers support all filters/expressions specified in geostyler-style.

We are also thinking about more verbose ways for listing supported/unsupported features of the different parsers, which we might be able to work on in the upcoming code sprint.

@fxi
Copy link
Author

fxi commented May 3, 2022

Thanks :)

In the meantime, I looked at the code source to check where I would be able to improve stuff. Then I looked at the source code of mapbox/maplibre-gl to see how they parse their own filters. Then I went outside for a bike ride :/

I spotted two fundamental issues :

  1. No support for testing nulls. GeoStyler has it, SLD has it, Postgres has it, not mapbox. It's not even part of the vector tiles specs : everything used downstream should adapt to incomplete specs. In mapbox style, null === "". For numbers, it's even worse, style for nulls have to specify ["==","attribute",""] which translate in SLD to testing for an empty string which is a type error in Postgres. This is not usable as is. Workaround: coercion to boolean to_boolean => issue with value 0. Testing ["!",["has","attribute"]] for the absence of a feature value, but null is a value. In SLD, that specific case should create <propertyIsNull>. So the mapbox parser should probably have an option to specify the variable data type and value used to express nulls and perhaps a very opinionated view of what's possible or not. I'm no expert, though.

  2. Mapbox still maintain two methods for filtering stuff : deprecated filters and newer expressions. Geostyler should probably focus on the newer expression and ditch support for the deprecated filters' system: both overlaps quite a lot.

For now, my strategy is to simplify a lot all our styles to get something basic, easy to parse and convert, while making sure it will not bring errors later in the process.

We will keep in touch for the next steps

@fxi fxi changed the title mpabox integration level mapbox integration level Jun 26, 2022
@KaiVolland KaiVolland moved this to Todo in CodeSprint 2024 May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
No open projects
Status: Todo
Development

No branches or pull requests

4 participants