Giter VIP home page Giter VIP logo

geostyler-qgis-parser's Introduction

GeoStyler Logo

Test, Coverage & Docs (main) Create & publish versioned documentation Coverage Status License

Code: github Package: npm

Documentation: main / latest / 14.1.4

Examples: Demo application

Developer Guide: Developer Guide

Discord Banner 2

🚀 GeoStyler Code Sprint 2024

We are happy to announce the third GeoStyler Code Sprint from 17.-21.06.2024 in Paris. Be part of it! More infos on https://geostyler.org/.

📆 Monthly meetings

On the first tuesday of every month, there is a video meeting on the GeoStyler Discord at 2pm CET. The meeting is for all contributors, users or other people interested in GeoStyler.

What is this all about?

The GeoStyler is a generic styler for geodata*.

GeoStyler provides a set of UI Components for map styling. Just like a modular building block system all components can be stacked together to create a nice UI for your web applications. To simplify the setup, we also provide some high-level components (based on our building blocks) that already do the work for you. These include among many others Symbolizer Editors, RuleTables and a fully-fledged StyleEditor including filters and scaleDenominators.

Furthermore, GeoStyler allows for the translation between multiple styling formats, i.e. SLD, OpenLayers, QGIS, Mapbox. Since we are following the concept of micro packages, these translators (we call them parsers) can be used as standalone libraries, without the need to include the UI components as a dependency. Just take a look at StyleParser Implementations.

* geodata as a single dataset (layer) not a complete map appearance.

If you are missing any UI components, formats or even have a custom style format, feel free to open a PR. We are happy for any kind of contributions.

To see the GeoStyler in action have a look at the demo application. It demonstrates the GeoStyler UI components as a standalone application.

Every parser works as a standalone library, too. So you can easily translate between style formats.

For example a small SLD to OpenLayers-Style parser (untested code 😄):

import SLDParser from "geostyler-sld-parser";
import OpenLayersParser from "geostyle-openlayers-parser";
const sldParser = new SLDParser();
const olParser = new OpenLayersParser();

const sldToOL = async (sld) => {
  const { output: geostylerStyle } = await sldParser.readStyle(someSld);
  const { output: olStyle } = await olParser.writeStyle(geostylerStyle);
  return olStyle;
};

export default sldToOl;

Installation

Run

npm i geostyler

from within your project directory to add GeoStyler as a dependency. Please be aware of the peerDependencies that come along with GeoStyler.

Components can be used as follows:

import {wanted-geostyler-compoment} from 'geostyler';

//... your component code
render() {
  return (
    <wanted-geostyler-component
      foo=""
      bar={}
    />
  );
}

GeoStyler - Behind the Scenes

Internally we are using our own style definition called GeoStyler Style (see TypeScript Declaration Files), which takes the best from SLD and Mapbox. We are not trying to establish just another standard, but we need an exchange format that is flexible and highly compatible with current styling standards. Understanding GeoStyler Style is only necessary for developers of the project, not for users! Our style parsers all read and write from and to GeoStyler Style to keep the complexity low. As a positive side effect this lets you translate from any supported style to any other supported style.

Imagine your previous project was based on QGIS and now you want to setup your own web application. With GeoStyler you can still use your QGIS styles and either save all future formats in qml as well, or you simply translate all your old styles to another format e.g. OpenLayers styles or SLD. It's simple as that!

To populate the UI with information from imported data we provide a set of data parsers (defined in GeoStyler Data). Currently, we support GeoJSON, Shapefile and WFS.

With these two formats there come two interfaces. You can implement these interfaces to create a parser. Compare the list of existing parsers below.

Architecture

Related projects

TypeScript Declaration Files

DataParser Implementations

StyleParser Implementations

More

Developer Guide

For our guidelines for contributions, please take a look at CONTRIBUTING.md. Head there if you need general advice for first contributing steps (code or documentation).

More detailed information to ensure a great development experience when working on geostyler is summarized in DEVELOPING.md. You'll find hints with regard to developing UI components or guidance when you want to enhance (or create) parsers for style formats or data formats there.

Additionally, please read through our code of conduct.

We look forward to seeing you contribute soon!

License

GeoStyler is released under the BSD 2-Clause license. Please see the file LICENSE in the root of this repository.

Thanks to all contributors ❤

Avatars of contributors of GeoStyler

Funding & financial sponsorship

Maintenance and further development of this code can be funded through the GeoStyler Open Collective. All contributions and expenses can transparently be reviewed by anyone; you see what we use the donated money for. Thank you for any financial support you give the GeoStyler project 💞

geostyler-qgis-parser's People

Contributors

ahennr avatar dependabot[bot] avatar dnlkoch avatar greenkeeper[bot] avatar hwbllmnn avatar jansule avatar jmacura avatar juburr avatar kaivolland avatar marcjansen avatar mholthausen avatar pprev94 avatar renovate[bot] avatar slafayign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geostyler-qgis-parser's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency terser-webpack-plugin to v5.3.10
  • chore(deps): update dependency eslint to v8.57.0
  • chore(deps): update dependency webpack to v5.91.0
  • fix(deps): update dependency @types/lodash to v4.17.4
  • chore(deps): update actions/cache action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency @terrestris/eslint-config-typescript to v5
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency np to v10
  • fix(deps): update dependency geostyler-style to v8
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/on-pull-request.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
.github/workflows/on-push-master.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
npm
package.json
  • @types/lodash ^4.14.190
  • @types/xml2js ^0.4.11
  • @xmldom/xmldom ^0.8.6
  • buffer ^6.0.3
  • color ^4.2.3
  • core-js ^3.26.1
  • geostyler-cql-parser ^3.0.1
  • geostyler-style ^7.2.0
  • lodash ^4.17.21
  • stream ^0.0.2
  • string_decoder ^1.3.0
  • timers ^0.1.1
  • xml2js ^0.6.0
  • @babel/core ^7.20.5
  • @babel/plugin-proposal-class-properties ^7.18.6
  • @babel/plugin-proposal-object-rest-spread ^7.20.2
  • @babel/polyfill ^7.12.1
  • @babel/preset-env ^7.20.2
  • @babel/preset-typescript ^7.18.6
  • @terrestris/eslint-config-typescript ^3.1.0
  • @types/color ^3.0.3
  • @types/jest ^29.2.3
  • @types/node ^20.1.3
  • @typescript-eslint/eslint-plugin ^5.44.0
  • @typescript-eslint/parser ^5.44.0
  • babel-jest ^29.3.1
  • babel-loader ^9.1.0
  • coveralls ^3.1.1
  • eslint ^8.28.0
  • jest ^29.3.1
  • np ^8.0.0
  • terser-webpack-plugin ^5.3.6
  • typescript ^4.9.3
  • webpack ^5.75.0
  • webpack-cli ^5.0.0
travis
.travis.yml
  • node 10
  • node 12

  • Check this box to trigger a request for Renovate to run again on this repository

QML style from QGIS 3.28 cannot be parsed

Question

Hello, I am failing to parse any QML file created in QGIS 3.28. Looking in the code, there seem to be a significantly different inner structure of the <symbol> element. I am attaching a short example below. It should be a rough equivalent to https://github.com/geostyler/geostyler-qgis-parser/blob/master/data/qmls/polygon_simple.qml – a fill symbol with color, outline color and outline width.

super-ugly-zones_only-symbology.zip

<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.28.3-Firenze" styleCategories="Symbology">
  <renderer-v2 type="singleSymbol" referencescale="-1" enableorderby="0" forceraster="0" symbollevels="0">
    <symbols>
      <symbol type="fill" frame_rate="10" alpha="1" force_rhr="0" name="0" clip_to_extent="1" is_animated="0">
        <data_defined_properties>
          <Option type="Map">
            <Option type="QString" value="" name="name"/>
            <Option name="properties"/>
            <Option type="QString" value="collection" name="type"/>
          </Option>
        </data_defined_properties>
        <layer pass="0" locked="0" enabled="1" class="SimpleFill">
          <Option type="Map">
            <Option type="QString" value="3x:0,0,0,0,0,0" name="border_width_map_unit_scale"/>
            <Option type="QString" value="1,225,255,255" name="color"/>
            <Option type="QString" value="bevel" name="joinstyle"/>
            <Option type="QString" value="0,0" name="offset"/>
            <Option type="QString" value="3x:0,0,0,0,0,0" name="offset_map_unit_scale"/>
            <Option type="QString" value="MM" name="offset_unit"/>
            <Option type="QString" value="36,164,0,255" name="outline_color"/>
            <Option type="QString" value="solid" name="outline_style"/>
            <Option type="QString" value="1.06" name="outline_width"/>
            <Option type="QString" value="MM" name="outline_width_unit"/>
            <Option type="QString" value="solid" name="style"/>
          </Option>
          <data_defined_properties>
            <Option type="Map">
              <Option type="QString" value="" name="name"/>
              <Option name="properties"/>
              <Option type="QString" value="collection" name="type"/>
            </Option>
          </data_defined_properties>
        </layer>
      </symbol>
    </symbols>
    <rotation/>
    <sizescale/>
  </renderer-v2>
  <blendMode>0</blendMode>
  <featureBlendMode>0</featureBlendMode>
  <layerGeometryType>2</layerGeometryType>
</qgis>

Parsing this QML with geostyler-qgis-parser leaves me with a following error (trimmed):
image

Related issue in hslayers: hslayers/hslayers-ng#3513

Could you please confirm that the issue is relevant? Is there a change in the way QGIS is exporting QML files which is not yet reflected in geostyler? I went through the QGIS visual changelogs but I have found no mention about any change in this regard (until version 3.30 which is not yet relevant as I am using 3.28)... Thanks!

grid style in classes not supported?

Feature Request

Is your feature request related to a problem? Please describe.

When I run npx geostyler-cli grid.qml on a single-band grid with pixel-classes, i get a almost empty geostyler object. My impression is that this styling case is not supported by this parser, the qml is attached to the feature request (qgis 3.30)

Describe the solution you'd like

support for pixel classes in grids

grid-5class.zip

An in-range update of babel7 is breaking the build 🚨

There have been updates to the babel7 monorepo:

    • The dependency @babel/core was updated from 7.7.7 to 7.8.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • Travis CI - Branch: The build errored.

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet.
We recommend using:

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Support QML expressions

Feature Request

We have a web based map viewer based on Openlayers for QGIS projects and generally use WFS together with SLDReader to apply styles to vector layers.

QGIS has the ability to export symbology to SLD, but ignores expressions. See this QGIS issue for more info about this limitation.

But it includes expressions when exporting symbology to QML. That's why I was thinking of using Geostyler to overcome this limitation of QGIS, as I already use it successfully to convert QML to Mapbox styles.

Any plans to accept expressions for QML parser?

Use `style` property in qml file to guess if fill color should be used or ignored

QML format has a style property that describes how a SimpleFill should be filled.

For instance :

<prop k="style" v="no"/>

means there is no fill, even if it is used next to a color property.
The fill color should be applied only if style prop is solid.


Here is a full example of a SimpleFill that describes a red outline with no fill :

<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.16.14-Hannover" styleCategories="Symbology">
  <renderer-v2 symbollevels="0" enableorderby="0" forceraster="0" type="RuleRenderer">
    <rules key="{840c37c9-8be8-4f42-8efe-5c501026cc1b}">
      <rule key="{aaa898c5-263a-4f2d-b3e9-775c7d753e4a}" symbol="0" filter="typepsc = 30" label="Majoration des volumes constructibles"/>
    </rules>
    <symbols>
      <symbol force_rhr="0" alpha="1" type="fill" clip_to_extent="1" name="0">
        <layer enabled="1" pass="0" class="SimpleFill" locked="0">
          <prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
          <prop k="color" v="128,128,128,255"/>
          <prop k="joinstyle" v="round"/>
          <prop k="offset" v="0,0"/>
          <prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
          <prop k="offset_unit" v="Pixel"/>
          <prop k="outline_color" v="230,0,0,255"/>
          <prop k="outline_style" v="solid"/>
          <prop k="outline_width" v="4"/>
          <prop k="outline_width_unit" v="Pixel"/>
          <prop k="style" v="no"/>
          <data_defined_properties>
            <Option type="Map">
              <Option value="" type="QString" name="name"/>
              <Option name="properties"/>
              <Option value="collection" type="QString" name="type"/>
            </Option>
          </data_defined_properties>
        </layer>
      </symbol>
    </symbols>
  </renderer-v2>
  <blendMode>0</blendMode>
  <featureBlendMode>6</featureBlendMode>
  <layerGeometryType>2</layerGeometryType>
</qgis>

This style property can have other values that will probably be difficult to support but I think dealing with solid and no would be a nice start.

image

Capitalized invalid WellKnownName value for mark symbolizer

Bug

Describe the bug
Well known name of circle gets capitalized unnecessarily resulting in invalid WellKnownName in geostyler style object - "Circle" insted of "circle", which makes OlStyleParser fail in turn.

To Reproduce
Steps to reproduce the behavior:

  1. Parse qml http://hub4everybody.lesprojekt.cz/rest/workspaces/franta/layers/bioregions_pilots/style (it has correct value "circle")
  2. Observe resulting style object:
    image with value "Circle"
  3. Since OlStyleParser is case sensitive to WellKnowName values, it would fail with:
    image

Expected behavior
WellKnownName property should be lowercased. Probably in https://github.com/geostyler/geostyler-qgis-parser/blob/master/src/QGISStyleParser.ts#L493

Screenshots
image

Desktop (please complete the following information):

  • OS: arch
  • Browser chrome

Additional context

[email protected]

Related bug in hslayers hslayers/hslayers-ng#3431

Error importing qml of vector layer with classes (qgis 3.30)

Bug

Describe the bug

when i run:
npx geostyler-cli vector-classes.qml

I get this error:

Error during translation of file "vector-classes.qml": TypeError: Cannot read property 'forEach' of undefined

Style file exported with qgis 3.30 (attached)

image

Desktop (please complete the following information):

  • OS: Windows, command line

vector-classes.zip

build failed (on windows)

Bug

npm run build fails on windows (not sure if it's related to os)

Error message is
`
ERROR in ./src/QGISStyleParser.ts 30:5
Module parse failed: Unexpected token (30:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import _get from 'lodash/get';
|

type SymbolizerMap = {
| [key: string]: Symbolizer[]
| };
@ multi ./src/QGISStyleParser.ts main[0]
`

On Windows, "#writeStyle" tests fail

On Windows :

  • When reading QML file, linebreaks are \r\n
  • When writing style, linebreaks are \n only

To fix it, I suggest in function writeStyle of QGISStyleParser class

let renderOpts = { pretty: true, indent: '  ', newline: '\n' };
if ('win32' === process.platform) {
  renderOpts.newline = '\r\n'; 
}

return new Promise<WriteStyleResult<string>>(resolve => {
  try {
	const builder = new Builder({ renderOpts: renderOpts });
...

Is there a better way to do it ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.