@lbdudc/gp-gis-dsl 0.2.6 → 0.3.0

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/src/spl/Map.js CHANGED
@@ -1,53 +1,55 @@
1
- import TileLayer from "./TileLayer.js";
2
- import WMSLayer from "./WMSLayer.js";
3
- import WMSStyle from "./WMSStyle.js";
4
- import GeoJSONLayer from "./GeoJSONLayer.js";
5
- import GeoJSONLayerStyle from "./GeoJSONLayerStyle.js";
6
- import WMSStyleCustom from "./WMSStyleCustom.js";
7
-
8
- class Map {
9
- constructor(id, label, sortable = false) {
10
- this.name = id;
11
- this.label = label;
12
- this.sortable = sortable;
13
- this.layers = [];
14
- }
15
-
16
- getId() {
17
- return this.name;
18
- }
19
-
20
- addLayer(layer, isBaseLayer = false, hidden = false) {
21
- this.layers.push({
22
- name: layer,
23
- baseLayer: isBaseLayer,
24
- selected: !hidden,
25
- });
26
- }
27
-
28
- toString() {
29
- return (
30
- `\n${this.sortable ? "Sortable" : ""}Map(${this.name} as ${
31
- this.label
32
- }) - ${this.layers.length} layers:\n\t` +
33
- `${this.layers
34
- .map(
35
- (l) =>
36
- (l.isBaseLayer ? "BL-" : "") +
37
- (l.hidden ? "H-" : "") +
38
- l.layer.toString(),
39
- )
40
- .join("\n\t")}`
41
- );
42
- }
43
- }
44
-
45
- export {
46
- GeoJSONLayer,
47
- TileLayer,
48
- WMSStyle,
49
- WMSStyleCustom,
50
- WMSLayer,
51
- Map,
52
- GeoJSONLayerStyle,
53
- };
1
+ import TileLayer from "./TileLayer.js";
2
+ import WMSLayer from "./WMSLayer.js";
3
+ import WMSStyle from "./WMSStyle.js";
4
+ import GeoJSONLayer from "./GeoJSONLayer.js";
5
+ import GeoJSONLayerStyle from "./GeoJSONLayerStyle.js";
6
+ import WMSStyleCustom from "./WMSStyleCustom.js";
7
+ import WMSServiceLayer from "./WMSServiceLayer.js";
8
+
9
+ class Map {
10
+ constructor(id, label, sortable = false) {
11
+ this.name = id;
12
+ this.label = label;
13
+ this.sortable = sortable;
14
+ this.layers = [];
15
+ }
16
+
17
+ getId() {
18
+ return this.name;
19
+ }
20
+
21
+ addLayer(layer, isBaseLayer = false, hidden = false) {
22
+ this.layers.push({
23
+ name: layer,
24
+ baseLayer: isBaseLayer,
25
+ selected: !hidden,
26
+ });
27
+ }
28
+
29
+ toString() {
30
+ return (
31
+ `\n${this.sortable ? "Sortable" : ""}Map(${this.name} as ${
32
+ this.label
33
+ }) - ${this.layers.length} layers:\n\t` +
34
+ `${this.layers
35
+ .map(
36
+ (l) =>
37
+ (l.isBaseLayer ? "BL-" : "") +
38
+ (l.hidden ? "H-" : "") +
39
+ l.layer.toString(),
40
+ )
41
+ .join("\n\t")}`
42
+ );
43
+ }
44
+ }
45
+
46
+ export {
47
+ GeoJSONLayer,
48
+ TileLayer,
49
+ WMSStyle,
50
+ WMSStyleCustom,
51
+ WMSLayer,
52
+ Map,
53
+ GeoJSONLayerStyle,
54
+ WMSServiceLayer,
55
+ };
@@ -1,16 +1,16 @@
1
- export default class TileLayer {
2
- constructor(id, label, url) {
3
- this.name = id;
4
- this.type = "tilelayer";
5
- this.label = label;
6
- this.url = url;
7
- }
8
-
9
- getId() {
10
- return this.name;
11
- }
12
-
13
- toString() {
14
- return `TileLayer(${this.name} as ${this.label}) with url ${this.url}`;
15
- }
16
- }
1
+ export default class TileLayer {
2
+ constructor(id, label, url) {
3
+ this.name = id;
4
+ this.type = "tilelayer";
5
+ this.label = label;
6
+ this.url = url;
7
+ }
8
+
9
+ getId() {
10
+ return this.name;
11
+ }
12
+
13
+ toString() {
14
+ return `TileLayer(${this.name} as ${this.label}) with url ${this.url}`;
15
+ }
16
+ }
@@ -1,30 +1,30 @@
1
- export default class WMSLayer {
2
- constructor(id, label) {
3
- this.name = id;
4
- this.type = "wms";
5
- this.label = label;
6
- this.list = null;
7
- this.layers = [];
8
- this.availableStyles = [];
9
- this.defaultStyles = [];
10
- }
11
-
12
- getId() {
13
- return this.name;
14
- }
15
-
16
- addSubLayer(entityId, style) {
17
- this.list = entityId;
18
- this.layers.push(entityId);
19
- if (style) this.availableStyles.push(style);
20
- this.defaultStyles = style;
21
- }
22
-
23
- toString() {
24
- return `WMSLayer(${this.name} as ${this.label}) - ${
25
- this.layers.length
26
- } sublayers for entities ${this.layers
27
- .map((sl) => sl.entityId)
28
- .join(", ")}`;
29
- }
30
- }
1
+ export default class WMSLayer {
2
+ constructor(id, label) {
3
+ this.name = id;
4
+ this.type = "wms";
5
+ this.label = label;
6
+ this.list = null;
7
+ this.layers = [];
8
+ this.availableStyles = [];
9
+ this.defaultStyles = [];
10
+ }
11
+
12
+ getId() {
13
+ return this.name;
14
+ }
15
+
16
+ addSubLayer(entityId, style) {
17
+ this.list = entityId;
18
+ this.layers.push(entityId);
19
+ if (style) this.availableStyles.push(style);
20
+ this.defaultStyles = style;
21
+ }
22
+
23
+ toString() {
24
+ return `WMSLayer(${this.name} as ${this.label}) - ${
25
+ this.layers.length
26
+ } sublayers for entities ${this.layers
27
+ .map((sl) => sl.entityId)
28
+ .join(", ")}`;
29
+ }
30
+ }
@@ -0,0 +1,40 @@
1
+ import WMSLayer from "./WMSLayer.js";
2
+
3
+ export default class WMSServiceLayer extends WMSLayer {
4
+ constructor({
5
+ id,
6
+ label,
7
+ url,
8
+ layerName,
9
+ format,
10
+ crs,
11
+ bbox,
12
+ styles = [],
13
+ queryable = false,
14
+ attribution = null,
15
+ version,
16
+ }) {
17
+ super(id, label);
18
+
19
+ this.type = "wms";
20
+ this.external = true;
21
+
22
+ this.url = url;
23
+ this.layerName = layerName;
24
+ this.format = format;
25
+ this.crs = crs;
26
+ this.bbox = bbox;
27
+ this.version = version;
28
+
29
+ this.styles = styles;
30
+ this.defaultStyles = styles?.[0] || null;
31
+ this.queryable = queryable;
32
+ this.attribution = attribution;
33
+
34
+ this.visible = true;
35
+ this.opacity = 1.0;
36
+
37
+ this.layers = [layerName];
38
+ this.availableStyles = styles;
39
+ }
40
+ }
@@ -1,13 +1,13 @@
1
- export default class WMSStyle {
2
- constructor(id, sldPath) {
3
- this.name = id;
4
- this.type = "WMSLayerSLDStyle";
5
- this.cached = true;
6
- this.sldPath = sldPath;
7
- this.sld = `@include:${sldPath}`;
8
- }
9
-
10
- getId() {
11
- return this.name;
12
- }
13
- }
1
+ export default class WMSStyle {
2
+ constructor(id, sldPath) {
3
+ this.name = id;
4
+ this.type = "WMSLayerSLDStyle";
5
+ this.cached = true;
6
+ this.sldPath = sldPath;
7
+ this.sld = `@include:${sldPath}`;
8
+ }
9
+
10
+ getId() {
11
+ return this.name;
12
+ }
13
+ }
@@ -1,22 +1,22 @@
1
- export default class WMSStyleCustom {
2
- constructor(
3
- id,
4
- geometryType,
5
- fillColor,
6
- strokeColor,
7
- fillOpacity,
8
- strokeOpacity,
9
- ) {
10
- this.name = id;
11
- this.type = "WMSLayerStyle";
12
- this.geometryType = geometryType;
13
- this.fillColor = fillColor;
14
- this.strokeColor = strokeColor;
15
- this.fillOpacity = fillOpacity;
16
- this.strokeOpacity = strokeOpacity;
17
- }
18
-
19
- getId() {
20
- return this.name;
21
- }
22
- }
1
+ export default class WMSStyleCustom {
2
+ constructor(
3
+ id,
4
+ geometryType,
5
+ fillColor,
6
+ strokeColor,
7
+ fillOpacity,
8
+ strokeOpacity,
9
+ ) {
10
+ this.name = id;
11
+ this.type = "WMSLayerStyle";
12
+ this.geometryType = geometryType;
13
+ this.fillColor = fillColor;
14
+ this.strokeColor = strokeColor;
15
+ this.fillOpacity = fillOpacity;
16
+ this.strokeOpacity = strokeOpacity;
17
+ }
18
+
19
+ getId() {
20
+ return this.name;
21
+ }
22
+ }
package/src/store.js CHANGED
@@ -1,74 +1,74 @@
1
- const store = {
2
- products: [],
3
- currentProduct: null,
4
- currentEntity: null,
5
- lastGeneratedProduct: null,
6
- };
7
-
8
- function getProducts() {
9
- return store.products;
10
- }
11
-
12
- function getCurrentProduct() {
13
- return store.currentProduct;
14
- }
15
-
16
- function setCurrentProduct(productName) {
17
- if (!productName) {
18
- store.currentProduct = null;
19
- } else {
20
- store.currentProduct = getProduct(productName);
21
- if (!store.currentProduct) {
22
- throw `GIS ${productName} does not exist!!!`;
23
- }
24
- }
25
- }
26
-
27
- function getCurrentEntity() {
28
- return store.currentEntity;
29
- }
30
-
31
- function setCurrentEntity(entityName) {
32
- if (!entityName) {
33
- store.currentEntity = null;
34
- } else {
35
- store.currentEntity = getCurrentProduct().getEntity(entityName);
36
- if (!store.currentEntity) {
37
- throw `Entity ${entityName} does not exist in current product!!!`;
38
- }
39
- }
40
- }
41
-
42
- function getProduct(name) {
43
- return store.products.find((e) => e.name == name);
44
- }
45
-
46
- function addProduct(id, product) {
47
- store.products.push(product);
48
- }
49
-
50
- function getLastGeneratedProduct() {
51
- return store.lastGeneratedProduct;
52
- }
53
-
54
- function setLastGeneratedProduct(generatedProduct) {
55
- store.lastGeneratedProduct = generatedProduct;
56
- }
57
-
58
- function reset() {
59
- store.products.splice(0, store.products.length);
60
- store.lastGeneratedProduct = null;
61
- }
62
-
63
- export default {
64
- getCurrentProduct,
65
- setCurrentProduct,
66
- getCurrentEntity,
67
- setCurrentEntity,
68
- getProducts,
69
- getProduct,
70
- addProduct,
71
- getLastGeneratedProduct,
72
- setLastGeneratedProduct,
73
- reset,
74
- };
1
+ const store = {
2
+ products: [],
3
+ currentProduct: null,
4
+ currentEntity: null,
5
+ lastGeneratedProduct: null,
6
+ };
7
+
8
+ function getProducts() {
9
+ return store.products;
10
+ }
11
+
12
+ function getCurrentProduct() {
13
+ return store.currentProduct;
14
+ }
15
+
16
+ function setCurrentProduct(productName) {
17
+ if (!productName) {
18
+ store.currentProduct = null;
19
+ } else {
20
+ store.currentProduct = getProduct(productName);
21
+ if (!store.currentProduct) {
22
+ throw `GIS ${productName} does not exist!!!`;
23
+ }
24
+ }
25
+ }
26
+
27
+ function getCurrentEntity() {
28
+ return store.currentEntity;
29
+ }
30
+
31
+ function setCurrentEntity(entityName) {
32
+ if (!entityName) {
33
+ store.currentEntity = null;
34
+ } else {
35
+ store.currentEntity = getCurrentProduct().getEntity(entityName);
36
+ if (!store.currentEntity) {
37
+ throw `Entity ${entityName} does not exist in current product!!!`;
38
+ }
39
+ }
40
+ }
41
+
42
+ function getProduct(name) {
43
+ return store.products.find((e) => e.name == name);
44
+ }
45
+
46
+ function addProduct(id, product) {
47
+ store.products.push(product);
48
+ }
49
+
50
+ function getLastGeneratedProduct() {
51
+ return store.lastGeneratedProduct;
52
+ }
53
+
54
+ function setLastGeneratedProduct(generatedProduct) {
55
+ store.lastGeneratedProduct = generatedProduct;
56
+ }
57
+
58
+ function reset() {
59
+ store.products.splice(0, store.products.length);
60
+ store.lastGeneratedProduct = null;
61
+ }
62
+
63
+ export default {
64
+ getCurrentProduct,
65
+ setCurrentProduct,
66
+ getCurrentEntity,
67
+ setCurrentEntity,
68
+ getProducts,
69
+ getProduct,
70
+ addProduct,
71
+ getLastGeneratedProduct,
72
+ setLastGeneratedProduct,
73
+ reset,
74
+ };