openlayers-style-editor 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,147 +1,151 @@
1
- <p align="center"><img src="https://land-it.github.io/openlayers-style-editor/favicons/android-chrome-192x192.png"></p>
2
- <h1 align="center">Welcome to <code>openlayers-style-editor</code></h1>
3
- <p>
4
- <a href="https://www.npmjs.com/package/openlayers-style-editor" target="_blank">
5
- <img alt="Version" src="https://img.shields.io/npm/v/openlayers-style-editor.svg">
6
- </a>
7
- <a href="https://www.npmjs.com/package/openlayers-style-editor" target="_blank">
8
- <img alt="Downloads" src="https://img.shields.io/npm/dw/openlayers-style-editor">
9
- </a>
10
- <a href="https://openlayers-style-editor.rajinwonderland.vercel.app" target="_blank">
11
- <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
12
- </a>
13
-
14
- [//]: # ( <a href="#" target="_blank">)
15
-
16
- [//]: # ( <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />)
17
-
18
- [//]: # ( </a>)
19
- </p>
20
-
21
-
22
- ### ✨ [Demo](https://land-it.github.io/openlayers-style-editor/#/demo)
23
-
24
- ## Contents
25
-
26
- - [Background](#background)
27
- - [Presentation](#presentation)
28
- - [Installation](#installation)
29
- - [Usage](#usage)
30
- - [Props Details](#props-details)
31
- - [TODOs](#todos)
32
- - [Show your support](#show-your-support)
33
- - [Author & Maintainer](#author--maintainer)
34
-
35
- ## Background
36
-
37
- This package was created in the context of the [LAND IT](https://land-it.github.io/) project,
38
- a decision support system to help stakeholders planning a new
39
- landscape for the most affected areas by wildfires in Portugal.
40
- LAND IT uses OpenLayers as its main GIS dependency,
41
- and throughout the project the need to edit layers styles increased.
42
-
43
- ## Presentation
44
-
45
- This Style Editor for OpenLayers allows the user to change the style of layers. This editor was inspired in both QGIS and ArcMap editors.
46
-
47
- **There are three edition modes:**
48
-
49
- - **Unique Symbol:** Allows the user to change the layer's color, opacity, and stroke.
50
- - **Categorized:** Allows the user to change the layer's color, opacity, and stroke based on the values of an attribute.
51
- - **Graduated:** Allows the user to change the layer's color, opacity, and stroke based on a numeric attribute and the
52
- mode used to group its values. This package has six modes implemented, some of them are implemented using the
53
- [GeoBuckets](https://www.npmjs.com/package/geobuckets) package. The implemented modes are:
54
- - Manual
55
- - Equal Intervals
56
- - Defined Intervals
57
- - Quantile
58
- - Natural Breaks (Jenks)
59
- - Standard Deviation
60
-
61
- A detailed explanation of each mode can be found [here](https://resources.arcgis.com/en/help/main/10.2/index.html#//00s50000001r000000).
62
-
63
- ## Installation
64
-
65
- Depending on the installed package provider, this package can be installed with one of the following commands.
66
-
67
- ```
68
- npm install openlayers-style-editor
69
- ```
70
-
71
- ```
72
- yarn add openlayers-style-editor
73
- ```
74
-
75
- ## Usage
76
-
77
- It is possible to enjoy this package by adding the following code snippets to your code.
78
-
79
- ```tsx
80
- import { Render, RenderType, StyleEditor } from "openlayers-style-editor";
81
- ```
82
-
83
-
84
- ```tsx
85
- const [visible, setVisible] = useState<boolean>(false);
86
-
87
- const defaultRender: Render = {
88
- type: RenderType.Unique,
89
- rendererOL: {
90
- 'fill-color': [255, 255, 50, 1],
91
- 'stroke-color': [0, 0, 0, 1],
92
- 'stroke-width': 1,
93
- }
94
- }
95
-
96
- const [renderer, setRenderer] = useState<Render>(defaultRender);
97
- ```
98
-
99
- ```tsx
100
- <StyleEditor visible={visible}
101
- setVisible={setVisible}
102
- layerDefaultRenderer={defaultRender}
103
- layerCurrentRenderer={renderer}
104
- applyRenderer={(renderer) => setRenderer(renderer)}
105
- features={features}
106
- primeReactTheme={"bootstrap4-light-blue"}
107
- showPreDefinedRamps={true} />
108
- ```
109
-
110
- ***To see a full example click [here](https://github.com/LAND-IT/openlayers-style-editor/blob/master/page/src/examples/Test.tsx).***
111
-
112
- ## Props Details
113
-
114
- | Name | Type | Requirement | Description | Example |
115
- |-------------------------|------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
116
- | `visible` | `boolean` | **mandatory** | Defines if the component<br/> is visible or not | true |
117
- | `setVisible` | `function` | **mandatory** | Function to set the <br/>visibility of the component | () => setVisible(!visible) |
118
- | `layerDefaultRenderer` | `Render` | **mandatory** | Default renderer of <br/>the layer to be edited | {<br/>&emsp;type: RenderType.Unique, <br/>&emsp;rendererOL: { <br/>&emsp;&emsp;'fill-color': [255, 255, 50, 1], <br/>&emsp;&emsp;'stroke-color': [0, 0, 0, 1], <br/>&emsp;&emsp;'stroke-width': 1<br/>&emsp;}<br/>} |
119
- | `layerCurrentRenderer ` | `Render` | **mandatory** | Current renderer of the layer | {<br/>&emsp;type: RenderType.Unique, <br/>&emsp;rendererOL: { <br/>&emsp;&emsp;'fill-color': [255, 255, 50, 1], <br/>&emsp;&emsp;'stroke-color': [0, 0, 0, 1], <br/>&emsp;&emsp;'stroke-width': 1<br/>&emsp;}<br/>} |
120
- | `applyRenderer` | `function` | **mandatory** | Function to apply the renderer to the layer, it has as parameter the renderer to be applied | (renderer: Render) => setRenderer(renderer) |
121
- | `features` | `Feature[]` | **mandatory** | Features to be rendered on the map | |
122
- | `showPreDefinedRamps` | `boolean` | **mandatory** | Show the predefined ramps of the package | true |
123
- | `moreRamps` | `ColorRamp[]` | optional | An array of color ramps that can be added to the package | [{<br/>&emsp;id: 28, //id needs to be >=28 <br/>&emsp;name: "GnBu", <br/>&emsp;palette: <br/>&emsp;&emsp;[{<br/>&emsp;&emsp;&emsp;offset: 0.25, <br/>&emsp;&emsp;&emsp;color: fromString("rgb(186,228,188)")<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;offset: 0.5,<br/>&emsp;&emsp;&emsp;color: fromString("rgb(123,204,196)")<br/>&emsp;&emsp;}, <br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;offset: 0.75, <br/>&emsp;&emsp;&emsp;color: fromString("rgb(67,162,202)")<br/>&emsp;&emsp;}]<br/>}] |
124
- | `predefinedStyles` | `PredefinedRenderer[]` | optional | Predefined styles to be used on the categorized style type | [{<br/>&emsp;name: "Dangerousness",<br/>&emsp;renderer: <br/>&emsp;&emsp;[{<br/>&emsp;&emsp;&emsp;value: "Very High", <br/>&emsp;&emsp;&emsp;color: [255, 0, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "High", <br/>&emsp;&emsp;&emsp;color: [255, 128, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Medium", <br/>&emsp;&emsp;&emsp;color: [255, 255, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Low", <br/>&emsp;&emsp;&emsp;color: [139, 209, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Very Low", <br/>&emsp;&emsp;&emsp;color: [56, 168, 0]<br/>&emsp;&emsp;}]<br/>}] |
125
- | `addingToHeader` | `string` | optional | Text to be added to the header | - Dangerousness Layer |
126
- | `primeReactTheme` | `string` | optional | PrimeReact theme to be used, all option can be found [here](https://primereact.org/theming/#themes) | bootstrap4-light-blue |
127
- | `numbersLocale` | `string` | optional | Locale to be used on numbers, represented using BCP 47 language tag. Default is 'en-US' | en-US |
128
- | `textLocale` | `string` | optional | Locale to be used for text. This package has two options available: 'en' and 'pt'. Default is 'en'. To add a custom locale, use the customLocale prop and in the textLocale prop use 'custom'. | pt |
129
- | `customLocale` | `Record<string, any>` | optional | Custom locale to be used in case the textLocale is set to 'custom'. This prop must have the same structure as the default locale, that can be found [here](https://github.com/LAND-IT/openlayers-style-editor/blob/master/openlayers-style-editor/src/locales/en/translation.json) | {"common": {<br/>&emsp;"style_editor": "Editor de Estilos",<br/>&emsp;"reset_style": "Repor Estilo",<br/>&emsp;...<br/>}} |
130
-
131
- ## TODOs
132
-
133
- - [ ] Add the condition style type
134
- - [ ] Add a license
135
-
136
- ## Show your support
137
-
138
- Give a ⭐️ if this project helped you!
139
-
140
- ## Author & Maintainer
141
-
142
- <img src="https://avatars.githubusercontent.com/u/45342267?v=4" height="80px" style="border-radius:50px" />
143
-
144
- Márcia Matias
145
-
146
- - Github: [@MarciaBM](https://github.com/MarciaBM)
147
- - Personal Page: [marciamatias.github.io](https://marciamatias.github.io/)
1
+ <p align="center"><img src="https://land-it.github.io/openlayers-style-editor/favicons/android-chrome-192x192.png"></p>
2
+ <h1 align="center">Welcome to <code>openlayers-style-editor</code></h1>
3
+
4
+ ![](https://img.shields.io/npm/v/openlayers-style-editor.svg)
5
+ ![](https://img.shields.io/npm/dw/openlayers-style-editor)
6
+ ![](https://img.shields.io/npm/dt/openlayers-style-editor)
7
+ ![](https://img.shields.io/github/stars/land-it/openlayers-style-editor)
8
+ ![](https://img.shields.io/github/commit-activity/m/land-it/openlayers-style-editor)
9
+ ![](https://img.shields.io/github/v/release/land-it/openlayers-style-editor)
10
+
11
+ ![](https://img.shields.io/badge/documentation-yes-brightgreen.svg)
12
+ ![](https://img.shields.io/github/issues/land-it/openlayers-style-editor)
13
+ ![](https://img.shields.io/github/issues-closed/land-it/openlayers-style-editor)
14
+ ![](https://img.shields.io/github/contributors/land-it/openlayers-style-editor)
15
+
16
+
17
+ ### ✨ [Demo](https://land-it.github.io/openlayers-style-editor/#/demo)
18
+
19
+ > [!NOTE]
20
+ > This package is compatible with SSR.
21
+
22
+ ## Contents
23
+
24
+ - [Background](#background)
25
+ - [Presentation](#presentation)
26
+ - [Installation](#installation)
27
+ - [Usage](#usage)
28
+ - [Props Details](#props-details)
29
+ - [TODOs](#todos)
30
+ - [Show your support](#show-your-support)
31
+ - [Author & Maintainer](#author--maintainer)
32
+
33
+ ## Background
34
+
35
+ This package was created in the context of the [LAND IT](https://land-it.github.io/) project,
36
+ a decision support system to help stakeholders planning a new
37
+ landscape for the most affected areas by wildfires in Portugal.
38
+ LAND IT uses OpenLayers as its main GIS dependency,
39
+ and throughout the project the need to edit layers styles increased.
40
+
41
+ ## Presentation
42
+
43
+ This Style Editor for OpenLayers allows the user to change the style of layers. This editor was inspired in both QGIS and ArcMap editors.
44
+
45
+ **There are three edition modes:**
46
+
47
+ - **Unique Symbol:** Allows the user to change the layer's color, opacity, and stroke.
48
+ - **Categorized:** Allows the user to change the layer's color, opacity, and stroke based on the values of an attribute.
49
+ - **Graduated:** Allows the user to change the layer's color, opacity, and stroke based on a numeric attribute and the
50
+ mode used to group its values. This package has six modes implemented, some of them are implemented using the
51
+ [GeoBuckets](https://www.npmjs.com/package/geobuckets) package. The implemented modes are:
52
+ - Manual
53
+ - Equal Intervals
54
+ - Defined Intervals
55
+ - Quantile
56
+ - Natural Breaks (Jenks)
57
+ - Standard Deviation
58
+
59
+ A detailed explanation of each mode can be found [here](https://resources.arcgis.com/en/help/main/10.2/index.html#//00s50000001r000000).
60
+
61
+ ## Installation
62
+
63
+ Depending on the installed package provider, this package can be installed with one of the following commands.
64
+
65
+ ```
66
+ npm install openlayers-style-editor
67
+ ```
68
+
69
+ ```
70
+ yarn add openlayers-style-editor
71
+ ```
72
+
73
+ ## Usage
74
+
75
+ Firstly it is necessary to import the styles of the package. This can be done by adding the following code snippet to your index/main file.
76
+
77
+ ```tsx
78
+ import 'openlayers-style-editor/dist/openlayers-style-editor.css';
79
+ ```
80
+
81
+ It is possible to enjoy this package by adding the following code snippets to your code.
82
+
83
+ ```tsx
84
+ import { Render, RenderType, StyleEditor } from "openlayers-style-editor";
85
+ ```
86
+
87
+
88
+ ```tsx
89
+ const [visible, setVisible] = useState<boolean>(false);
90
+
91
+ const defaultRender: Render = {
92
+ type: RenderType.Unique,
93
+ rendererOL: {
94
+ 'fill-color': [255, 255, 50, 1],
95
+ 'stroke-color': [0, 0, 0, 1],
96
+ 'stroke-width': 1,
97
+ }
98
+ }
99
+
100
+ const [renderer, setRenderer] = useState<Render>(defaultRender);
101
+ ```
102
+
103
+ ```tsx
104
+ <StyleEditor visible={visible}
105
+ setVisible={setVisible}
106
+ layerDefaultRenderer={defaultRender}
107
+ layerCurrentRenderer={renderer}
108
+ applyRenderer={(renderer) => setRenderer(renderer)}
109
+ features={features}
110
+ primeReactTheme={"bootstrap4-light-blue"}
111
+ showPreDefinedRamps={true} />
112
+ ```
113
+
114
+ ***To see a full example click [here](https://github.com/LAND-IT/openlayers-style-editor/blob/master/page/src/examples/Test.tsx).***
115
+
116
+ ## Props Details
117
+
118
+ | Name | Type | Requirement | Description | Example |
119
+ |-------------------------|------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
120
+ | `visible` | `boolean` | **mandatory** | Defines if the component<br/> is visible or not | true |
121
+ | `setVisible` | `function` | **mandatory** | Function to set the <br/>visibility of the component | () => setVisible(!visible) |
122
+ | `layerDefaultRenderer` | `Render` | **mandatory** | Default renderer of <br/>the layer to be edited | {<br/>&emsp;type: RenderType.Unique, <br/>&emsp;rendererOL: { <br/>&emsp;&emsp;'fill-color': [255, 255, 50, 1], <br/>&emsp;&emsp;'stroke-color': [0, 0, 0, 1], <br/>&emsp;&emsp;'stroke-width': 1<br/>&emsp;}<br/>} |
123
+ | `layerCurrentRenderer ` | `Render` | **mandatory** | Current renderer of the layer | {<br/>&emsp;type: RenderType.Unique, <br/>&emsp;rendererOL: { <br/>&emsp;&emsp;'fill-color': [255, 255, 50, 1], <br/>&emsp;&emsp;'stroke-color': [0, 0, 0, 1], <br/>&emsp;&emsp;'stroke-width': 1<br/>&emsp;}<br/>} |
124
+ | `applyRenderer` | `function` | **mandatory** | Function to apply the renderer to the layer, it has as parameter the renderer to be applied | (renderer: Render) => setRenderer(renderer) |
125
+ | `features` | `Feature[]` | **mandatory** | Features to be rendered on the map | |
126
+ | `showPreDefinedRamps` | `boolean` | **mandatory** | Show the predefined ramps of the package | true |
127
+ | `moreRamps` | `ColorRamp[]` | optional | An array of color ramps that can be added to the package | [{<br/>&emsp;id: 28, //id needs to be >=28 <br/>&emsp;name: "GnBu", <br/>&emsp;palette: <br/>&emsp;&emsp;[{<br/>&emsp;&emsp;&emsp;offset: 0.25, <br/>&emsp;&emsp;&emsp;color: fromString("rgb(186,228,188)")<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;offset: 0.5,<br/>&emsp;&emsp;&emsp;color: fromString("rgb(123,204,196)")<br/>&emsp;&emsp;}, <br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;offset: 0.75, <br/>&emsp;&emsp;&emsp;color: fromString("rgb(67,162,202)")<br/>&emsp;&emsp;}]<br/>}] |
128
+ | `predefinedStyles` | `PredefinedRenderer[]` | optional | Predefined styles to be used on the categorized style type | [{<br/>&emsp;name: "Dangerousness",<br/>&emsp;renderer: <br/>&emsp;&emsp;[{<br/>&emsp;&emsp;&emsp;value: "Very High", <br/>&emsp;&emsp;&emsp;color: [255, 0, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "High", <br/>&emsp;&emsp;&emsp;color: [255, 128, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Medium", <br/>&emsp;&emsp;&emsp;color: [255, 255, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Low", <br/>&emsp;&emsp;&emsp;color: [139, 209, 0]<br/>&emsp;&emsp;},<br/>&emsp;&emsp;{<br/>&emsp;&emsp;&emsp;value: "Very Low", <br/>&emsp;&emsp;&emsp;color: [56, 168, 0]<br/>&emsp;&emsp;}]<br/>}] |
129
+ | `addingToHeader` | `string` | optional | Text to be added to the header | - Dangerousness Layer |
130
+ | `primeReactTheme` | `string` | optional | PrimeReact theme to be used, all option can be found [here](https://primereact.org/theming/#themes) | bootstrap4-light-blue |
131
+ | `numbersLocale` | `string` | optional | Locale to be used on numbers, represented using BCP 47 language tag. Default is 'en-US' | en-US |
132
+ | `textLocale` | `string` | optional | Locale to be used for text. This package has two options available: 'en' and 'pt'. Default is 'en'. To add a custom locale, use the customLocale prop and in the textLocale prop use 'custom'. | pt |
133
+ | `customLocale` | `Record<string, any>` | optional | Custom locale to be used in case the textLocale is set to 'custom'. This prop must have the same structure as the default locale, that can be found [here](https://github.com/LAND-IT/openlayers-style-editor/blob/master/openlayers-style-editor/src/locales/en/translation.json) | {"common": {<br/>&emsp;"style_editor": "Editor de Estilos",<br/>&emsp;"reset_style": "Repor Estilo",<br/>&emsp;...<br/>}} |
134
+
135
+ ## TODOs
136
+
137
+ - [ ] Add the condition style type
138
+ - [ ] Add a license
139
+
140
+ ## Show your support
141
+
142
+ Give a ⭐️ if this project helped you!
143
+
144
+ ## Author & Maintainer
145
+
146
+ <img src="https://avatars.githubusercontent.com/u/45342267?v=4" height="80px" style="border-radius:50px" />
147
+
148
+ Márcia Matias
149
+
150
+ - Github: [@MarciaBM](https://github.com/MarciaBM)
151
+ - Personal Page: [marciabm.github.io](https://marciabm.github.io/)
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { ColorRamp } from './rampColors';
3
- import { PredefinedRenderer, Render, SEAttribute } from '../RendererObjects.ts';
3
+ import { PredefinedRenderer, Render, SEAttribute } from '../rendererUtils';
4
4
  interface Props {
5
5
  attr: SEAttribute[];
6
6
  layerDefaultRenderer: Render;
@@ -1,5 +1,5 @@
1
1
  import { default as React, Dispatch, SetStateAction } from 'react';
2
- import { SEAttribute, PredefinedRenderer, Render } from '../RendererObjects.ts';
2
+ import { SEAttribute, PredefinedRenderer, Render } from '../rendererUtils';
3
3
  import { ColorRamp } from './rampColors.ts';
4
4
  interface Props {
5
5
  attributes: SEAttribute[];
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { SEAttribute, Render } from '../RendererObjects.ts';
2
+ import { SEAttribute, Render } from '../rendererUtils';
3
3
  import { ColorRamp } from './rampColors.ts';
4
4
  interface GraduatedProps {
5
5
  attr: SEAttribute[];
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { PredefinedRenderer, Render } from './RendererObjects.ts';
2
+ import { PredefinedRenderer, Render } from '../../rendererUtils.ts';
3
3
  import { Feature } from 'ol';
4
- import { ColorRamp } from './components/rampColors.ts';
4
+ import { ColorRamp } from '../rampColors.ts';
5
5
  interface Props {
6
6
  visible: boolean;
7
7
  setVisible: Dispatch<SetStateAction<boolean>>;
@@ -1,6 +1,6 @@
1
1
  import { default as React, Dispatch, SetStateAction } from 'react';
2
- import { PredefinedRenderer, Render } from './RendererObjects.ts';
3
- import { ColorRamp } from './components/rampColors.ts';
2
+ import { PredefinedRenderer, Render } from '../../rendererUtils.ts';
3
+ import { ColorRamp } from '../rampColors.ts';
4
4
  import { Feature } from 'ol';
5
5
  interface Props {
6
6
  visible: boolean;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Render } from '../RendererObjects.ts';
2
+ import { Render } from '../rendererUtils';
3
3
  interface UniqueSymbolProps {
4
4
  layerDefaultRenderer: Render;
5
5
  layerCurrentRenderer: Render;
@@ -1,3 +1,3 @@
1
1
  import { Feature } from 'ol';
2
- import { SEAttribute } from '../RendererObjects.ts';
2
+ import { SEAttribute } from '../rendererUtils';
3
3
  export declare function mapFeaturesToSEAttributes(features: Feature[]): SEAttribute[];
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { default as i18n } from 'i18next';
2
+ export default i18n;