geostyler / geostyler-mapbox-parser

GeoStyler-Style-Parser implementation for Mapbox
BSD 2-Clause "Simplified" License
13 stars 9 forks source link

mapbox integration level #127

Open fxi opened 2 years ago

fxi commented 2 years ago

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 ```json { "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": "iceland_test_numeric", "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 ```json { "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 iceland numeric test iceland numeric test iceland numeric test MX-3Q41Y-AH46I-1QGD9@8TqF9 circle #023858 30 MX-3Q41Y-AH46I-1QGD9@W82FL circle #f60675 30 MX-3Q41Y-AH46I-1QGD9@rRHVt circle #fff7fb 30 ```

Thanks :)

marcjansen commented 2 years ago

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 commented 2 years ago

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

jansule commented 2 years ago

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 commented 2 years ago

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