Giter VIP home page Giter VIP logo

geostyler-cli'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-cli's People

Contributors

dependabot[bot] avatar geographika avatar ger-benjamin avatar giohappy avatar jansule avatar kaivolland avatar marcjansen avatar semantic-release-bot avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

geostyler-cli's Issues

Subdirectories will lead to an error

When converting styles by specifing a folder the CLI crashes when this folder contains subfolders.
We should make this more failsafe and maybe even support nested folders etc.

Is there a way to convert a QML raster style to an OpenLayer Style via cli?

Hi,
I need to create, starting from a qml, something like this in the OL schema:

      style: {
        color: [
          "case",
          ["==", ["band", 2], 0],
          [0, 0, 0, 0],
          ["==", ["band", 1], 0],
          ["color", 31, 119, 180, 1],
          ["==", ["band", 1], 1],
          ["color", 255, 127, 14, 1],
          ["==", ["band", 1], 2],
          ["color", 44, 160, 44, 1],
          ["==", ["band", 1], 3],
          ["color", 214, 39, 40, 1],
          ["==", ["band", 1], 4],
          ["color", 255, 0, 12, 1],
          ["color", 1, 1, 1, 255]
        ]
      }

Is there a way to do it?

Thank you

Handle Windows Paths

The following command, using Windows style paths:

npm start -- -s sld -t geostyler -o C:\Temp C:\Temp\itasca.sld

Currently returns:

ร— Error during translation of file "C:\\Temp\\itasca.sld": Error: ENOENT: no such file or directory, open 'C:\Temp\Temp\itasca.geostyler'

Fix on way that will convert Windows paths to Linux paths to avoid this error.

Conversion to an output file writes to a directory instead of a file

This issue is linked to changes in #335
The code below checks if the output parameter exists and if it is a file, however when writing an output this file won't exist, and targetIsFile is always false.

  // Try to define type of target (file or dir).
  let targetIsFile = false;
  const outputExists = existsSync(outputPath);
  if (outputExists) {
    targetIsFile = lstatSync(outputPath).isFile();
  }

This leads to the output being written to subdirectories based on the input e.g.

npm start -- -s qgis -t qgis -o output.sld testdata/point_simple.qml creates output.qml/point_simplepoint.qml

The workflow in #343 highlights this issue.
See for example the output at https://github.com/geographika/geostyler-cli/actions/runs/4925040568/jobs/8798798475#step:8:13

I'm unsure of the best approach to fix this. Would simply checking for an extension of the output parameter to set targetIsFile be enough?

SyntaxError: Unexpected token export

I run geostyler command on your testdata with the command geostyler-cli -s sld -t qgis -o output.qml point_simplepoint.sld and get the following error:

export * from './style';
^^^^^^

SyntaxError: Unexpected token export

I installed geostyler with npm 7.16.0 using sudo npm install -g geostyler-cli and no error shows up, but some warnings:

npm WARN deprecated @types/[email protected]: This is a stub types definition. loglevel provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: now available as @ungap/url-search-params
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

Any hint?

SLD to QML : no display using HEX colors (?)

Hello,

I used the CLI to translate an SLD file to QML.
Everything worked well ๐Ÿ‘

But, no symbol displays in QGIS (3.16)

The SLD legend is a categorized polygon, fill color HEX format (#bb000), no outline

The result in the QML file is

<prop k="color" v="0,0,0,0"/>

Expected :

<prop k="color" v="51,18,58,255"/>

Is there missing support for HEX colors?
I'm gonna try with RGBA format to see if it works better, will tell you (EDIT: no more sucess with RGB / RGBA)

Create tests for CLI

Currently there are no tests for the functionality of the geostyler-cli.

It would be nice if we can find a way to test:

  • all the option parameters
  • expected structure of nested files and folders
  • behaviour of mixed files in a folder (e.g. folder includes *.txt. *.jpg files)

IMHO the content of the created files should not be tested as this is in the responsibility of the parsers themselves.

Maybe @marcjansen has an idea of how we could test this as this is outside of the JS scope and I have not much experience on testing things on the filesystem base.

Support OpenLayers parser

I see that some code is commented, is there any reason why this doesn't support OpenLayers parsers?

Error when running geostyler-cli for raw output

To recreate:

npm install
npm build
npm start -- -s sld -t geostyler -o C:/Temp C:/Temp/itasca.sld

Returns the following error, as there is only a folder name for the output rather than a file with an extension:

- Starting Geostyler CLIC:\GitHub\geostyler-cli\dist\src\index.js:58
    switch (fileEnding.toLowerCase()) {
                       ^

TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at getParserFromFilename (C:\GitHub\geostyler-cli\dist\src\index.js:58:24)
    at C:\GitHub\geostyler-cli\dist\src\index.js:199:67
    at Generator.next (<anonymous>)
    at C:\GitHub\geostyler-cli\dist\src\index.js:9:71
    at new Promise (<anonymous>)
    at __awaiter (C:\GitHub\geostyler-cli\dist\src\index.js:5:12)
    at main (C:\GitHub\geostyler-cli\dist\src\index.js:156:12)
    at Object.<anonymous> (C:\GitHub\geostyler-cli\dist\src\index.js:220:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

Specify Version of SLD

Currently, the geostyler-cli does not allow to specify the SLD version for the geostyler-sld-parser. We might want to add a flag here.

Based on the info from #186

Create executables of geostyler-cli

It would be nice to create executables of geostyler-cli that can run without having node installed. Such an executable could be used e.g. in order to create a QGIS plugin that allows the conversion from/to other formats from within QGIS. With the current setup users would have to have nodejs installed on their systems, which is probably not the case for non-developers.

Maybe it might be worth to check out https://github.com/nexe/nexe for creating such executables.

Add option to set default used encoding

Currently, we read and write file using utf-8.
It would be nice to have an option to use another encoding .

Question:
Should we have only one option to set the encoding used to read AND write ?
Or two ? : One to set the used encoding to read, and one to set the used encoding to write ?
Or three options ? With one more to set both at once ?

GeoStyler CLI on OSGeoLive

Currently the OSGeoLive hosts a (now probably quite outdated version of the) GeoStyler beginner tutorial, which shows users how to include GeoStyler in webapplications. With the existence of the GeoStyler CLI, we should think about if we want to replace the tutorial and instead add the CLI to OSGeoLive (after properly testing it ๐Ÿ˜ ). Thereby we would add something that users of OSGeoLive can actually use...

@KaiVolland @marcjansen @dnlkoch @geographika What do you think?

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.