geostyler
    TypeScript icon, indicating that this package has built-in type declarations

    7.2.1 • Public • Published

    GeoStyler Logo

    Build Status Coverage Status License

    Code: github Package: npm

    Documentation: master / latest / 4.3.0

    Examples: Demo application

    Developer Guide: Developer Guide

    Roadmap: Roadmap 2021

    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 geostylerStyle = await sldParser.readStyle(someSld);
      const 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

    Developing GeoStyler UI Components

    The easiest way to develop UI components is to npm link your local repository to the GeoStyler Demo. If you include your component into one of our high-level components, you will be able to directly see the new components in your browser. To do so, follow these steps:

    git clone https://github.com/geostyler/geostyler.git
    cd geostyler
    npm i
    npm link
    npm run build
    
    cd ..
    git clone https://github.com/geostyler/geostyler-demo.git
    cd geostyler-demo
    npm i
    npm link geostyler
    npm run start

    The GeoStyler Demo will then be served on localhost:3000. When doing changes to GeoStyler you have to rebuild the project via one of the following commands:

    npm run build
    npm run build:dist

    Changes will automatically be updated in the browser. Please also provide tests and a minimal code example as <ComponentName>.example.md, if you add a new component, so the api documentation will always be up to date and other users can benefit from your work.

    Troubleshooting

    Invalid hook call error: If the demo does not start but shows the above error it means that geostyler-demo and geostyler are using different react sources. To fixes this issue you need to add react to resolve.alias the webpack.config.js of create-react-app: In the project geostyler-demo in the file node_modules/react-scripts/config/webpack.config.js (~ line 320):

    [...]
        resolve: {
        [...]
          alias: {
            // Support React Native Web
            // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
            'react-native': 'react-native-web',
            // Fixes npm link
            'react': path.join(__dirname, '../../', 'react'),
            // Allows for better profiling with ReactDevTools
            ...(isEnvProductionProfile && {
              'react-dom$': 'react-dom/profiling',
              'scheduler/tracing': 'scheduler/tracing-profiling',
            }),
            ...(modules.webpackAliases || {}),
          },
        [...]
        },
    [...]
    

    Developing GeoStyler Style Parsers

    If you want to write your own style parser please take a look at the existing parsers for a consistent project setup. Developing them is a straighforward task, but don't forget: style parsers have to implement the GeoStyler Style interface.

    If you want to work on an existing parser, do following steps to setup the project:

    git clone <wanted-parser-repo>
    cd <wanted-parser>
    npm i

    Parsers can be directly tested within their repositories, respectively. The best way to integrate your local changes into the UI/Demo is using npm link. Run

    npm link

    from within your style parser repo and

    npm link <wanted-parser>

    from within the GeoStyler Demo.

    Developing GeoStyler Data Parsers

    Developing GeoStyler data parsers follows the same pattern as described in Developing GeoStyler Style Parser, but keep in mind that data parsers have to implement the GeoStyler Data interface.

    License

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

    Install

    npm i geostyler

    DownloadsWeekly Downloads

    462

    Version

    7.2.1

    License

    BSD-2-Clause

    Unpacked Size

    5.39 MB

    Total Files

    358

    Last publish

    Collaborators

    • jansule
    • annarieger
    • terrestris-info
    • marcjansen
    • kaivolland
    • dnlkoch
    • ahennr
    • buehner
    • hwbllmnn
    • lukaslohoff
    • mholthausen
    • sgoetsch
    • jorzekowsky
    • simonseyock
    • hblitza
    • jweskamm
    • unraveler
    • chrismayer