@lbdudc/gp-gis-dsl 0.3.1 → 0.3.2
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/package.json +2 -2
- package/src/GISVisitorHelper.js +93 -93
- package/src/cli.js +34 -34
- package/src/error/ErrorListener.js +26 -26
- package/src/error/SyntaxGenericError.js +18 -18
- package/src/index.js +4 -1
- package/src/spl/GIS.js +234 -234
- package/src/spl/GeoJSONLayer.js +21 -21
- package/src/spl/GeoJSONLayerStyle.js +14 -14
- package/src/spl/TileLayer.js +16 -16
- package/src/spl/WMSLayer.js +30 -30
- package/src/spl/WMSStyle.js +13 -13
- package/src/spl/WMSStyleCustom.js +22 -22
- package/src/store.js +74 -74
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lbdudc/gp-gis-dsl",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"homepage": "https://github.com/lbdudc/gis-dsl#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"prepare": "husky install",
|
|
52
52
|
"test": "mocha --ui qunit"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
package/src/GISVisitorHelper.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import features from "./features.js";
|
|
2
|
-
|
|
3
|
-
function transformation(spec) {
|
|
4
|
-
_relationships(spec);
|
|
5
|
-
const newSpec = {
|
|
6
|
-
features: features,
|
|
7
|
-
basicData: {
|
|
8
|
-
name: spec.name,
|
|
9
|
-
},
|
|
10
|
-
data: {
|
|
11
|
-
dataModel: {
|
|
12
|
-
entities: spec.entities,
|
|
13
|
-
enums: [],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
mapViewer: {
|
|
17
|
-
maps: spec.maps,
|
|
18
|
-
layers: spec.layers,
|
|
19
|
-
styles: spec.styles,
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
if (spec.extra) {
|
|
24
|
-
newSpec.basicData.extra = spec.extra;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return newSpec;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _relationships(spec) {
|
|
31
|
-
let source, target;
|
|
32
|
-
|
|
33
|
-
spec.relationships.forEach((r) => {
|
|
34
|
-
source = spec.getEntity(r.source);
|
|
35
|
-
target = spec.getEntity(r.target);
|
|
36
|
-
let sourceOwner = false;
|
|
37
|
-
let targetOwner = false;
|
|
38
|
-
let sourceMultiple = _multiple(r.sourceOpts.multiplicity);
|
|
39
|
-
let targetMultiple = _multiple(r.targetOpts.multiplicity);
|
|
40
|
-
if (sourceMultiple && !targetMultiple) {
|
|
41
|
-
targetOwner = true;
|
|
42
|
-
} else {
|
|
43
|
-
sourceOwner = true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
source.properties.push({
|
|
47
|
-
name: r.sourceOpts.label,
|
|
48
|
-
class: target.name,
|
|
49
|
-
owner: sourceOwner,
|
|
50
|
-
bidirectional: r.targetOpts.label,
|
|
51
|
-
multiple: sourceMultiple,
|
|
52
|
-
required: _required(r.sourceOpts.multiplicity),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
target.properties.push({
|
|
56
|
-
name: r.targetOpts.label,
|
|
57
|
-
class: source.name,
|
|
58
|
-
owner: targetOwner,
|
|
59
|
-
bidirectional: r.sourceOpts.label,
|
|
60
|
-
multiple: targetMultiple,
|
|
61
|
-
required: _required(r.targetOpts.multiplicity),
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _multiple(multiplicity) {
|
|
67
|
-
return ["1..1", "0..1"].find((a) => a == multiplicity) == null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _required(multiplicity) {
|
|
71
|
-
return ["1..1", "1..*"].find((a) => a == multiplicity) != null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getPropertyParams(symbols) {
|
|
75
|
-
if (!symbols.length) return null;
|
|
76
|
-
|
|
77
|
-
const ret = {};
|
|
78
|
-
if (symbols.includes("identifier")) {
|
|
79
|
-
ret.pk = true;
|
|
80
|
-
}
|
|
81
|
-
if (symbols.includes("required")) {
|
|
82
|
-
ret.required = true;
|
|
83
|
-
}
|
|
84
|
-
if (symbols.includes("unique")) {
|
|
85
|
-
ret.unique = true;
|
|
86
|
-
}
|
|
87
|
-
if (symbols.includes("display_string")) {
|
|
88
|
-
ret.displayString = true;
|
|
89
|
-
}
|
|
90
|
-
return ret;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { transformation, getPropertyParams };
|
|
1
|
+
import features from "./features.js";
|
|
2
|
+
|
|
3
|
+
function transformation(spec) {
|
|
4
|
+
_relationships(spec);
|
|
5
|
+
const newSpec = {
|
|
6
|
+
features: features,
|
|
7
|
+
basicData: {
|
|
8
|
+
name: spec.name,
|
|
9
|
+
},
|
|
10
|
+
data: {
|
|
11
|
+
dataModel: {
|
|
12
|
+
entities: spec.entities,
|
|
13
|
+
enums: [],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
mapViewer: {
|
|
17
|
+
maps: spec.maps,
|
|
18
|
+
layers: spec.layers,
|
|
19
|
+
styles: spec.styles,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
if (spec.extra) {
|
|
24
|
+
newSpec.basicData.extra = spec.extra;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return newSpec;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _relationships(spec) {
|
|
31
|
+
let source, target;
|
|
32
|
+
|
|
33
|
+
spec.relationships.forEach((r) => {
|
|
34
|
+
source = spec.getEntity(r.source);
|
|
35
|
+
target = spec.getEntity(r.target);
|
|
36
|
+
let sourceOwner = false;
|
|
37
|
+
let targetOwner = false;
|
|
38
|
+
let sourceMultiple = _multiple(r.sourceOpts.multiplicity);
|
|
39
|
+
let targetMultiple = _multiple(r.targetOpts.multiplicity);
|
|
40
|
+
if (sourceMultiple && !targetMultiple) {
|
|
41
|
+
targetOwner = true;
|
|
42
|
+
} else {
|
|
43
|
+
sourceOwner = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
source.properties.push({
|
|
47
|
+
name: r.sourceOpts.label,
|
|
48
|
+
class: target.name,
|
|
49
|
+
owner: sourceOwner,
|
|
50
|
+
bidirectional: r.targetOpts.label,
|
|
51
|
+
multiple: sourceMultiple,
|
|
52
|
+
required: _required(r.sourceOpts.multiplicity),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
target.properties.push({
|
|
56
|
+
name: r.targetOpts.label,
|
|
57
|
+
class: source.name,
|
|
58
|
+
owner: targetOwner,
|
|
59
|
+
bidirectional: r.sourceOpts.label,
|
|
60
|
+
multiple: targetMultiple,
|
|
61
|
+
required: _required(r.targetOpts.multiplicity),
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _multiple(multiplicity) {
|
|
67
|
+
return ["1..1", "0..1"].find((a) => a == multiplicity) == null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _required(multiplicity) {
|
|
71
|
+
return ["1..1", "1..*"].find((a) => a == multiplicity) != null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getPropertyParams(symbols) {
|
|
75
|
+
if (!symbols.length) return null;
|
|
76
|
+
|
|
77
|
+
const ret = {};
|
|
78
|
+
if (symbols.includes("identifier")) {
|
|
79
|
+
ret.pk = true;
|
|
80
|
+
}
|
|
81
|
+
if (symbols.includes("required")) {
|
|
82
|
+
ret.required = true;
|
|
83
|
+
}
|
|
84
|
+
if (symbols.includes("unique")) {
|
|
85
|
+
ret.unique = true;
|
|
86
|
+
}
|
|
87
|
+
if (symbols.includes("display_string")) {
|
|
88
|
+
ret.displayString = true;
|
|
89
|
+
}
|
|
90
|
+
return ret;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { transformation, getPropertyParams };
|
package/src/cli.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import meow from "meow";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import gisdslParser from "./index.js";
|
|
6
|
-
import path from "path";
|
|
7
|
-
|
|
8
|
-
const usage = "Usage: gisdsl input output";
|
|
9
|
-
|
|
10
|
-
const cli = meow(usage, {
|
|
11
|
-
importMeta: import.meta,
|
|
12
|
-
flags: {
|
|
13
|
-
debug: {
|
|
14
|
-
type: "boolean",
|
|
15
|
-
default: false,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
if (cli.input.length < 2) {
|
|
21
|
-
cli.showHelp();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const inputPath = path.resolve(process.cwd(), cli.input.at(0));
|
|
25
|
-
const input = fs.readFileSync(inputPath, {
|
|
26
|
-
encoding: "utf-8",
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const spec = gisdslParser(input, cli.flags.debug);
|
|
30
|
-
|
|
31
|
-
const outputPath = path.resolve(process.cwd(), cli.input.at(1));
|
|
32
|
-
fs.writeFileSync(outputPath, JSON.stringify(spec, null, 2), "utf8");
|
|
33
|
-
|
|
34
|
-
console.log(`File ${cli.input.at(1)} generated`);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import meow from "meow";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import gisdslParser from "./index.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
|
|
8
|
+
const usage = "Usage: gisdsl input output";
|
|
9
|
+
|
|
10
|
+
const cli = meow(usage, {
|
|
11
|
+
importMeta: import.meta,
|
|
12
|
+
flags: {
|
|
13
|
+
debug: {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (cli.input.length < 2) {
|
|
21
|
+
cli.showHelp();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const inputPath = path.resolve(process.cwd(), cli.input.at(0));
|
|
25
|
+
const input = fs.readFileSync(inputPath, {
|
|
26
|
+
encoding: "utf-8",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const spec = gisdslParser(input, cli.flags.debug);
|
|
30
|
+
|
|
31
|
+
const outputPath = path.resolve(process.cwd(), cli.input.at(1));
|
|
32
|
+
fs.writeFileSync(outputPath, JSON.stringify(spec, null, 2), "utf8");
|
|
33
|
+
|
|
34
|
+
console.log(`File ${cli.input.at(1)} generated`);
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import antlr4 from "antlr4";
|
|
2
|
-
|
|
3
|
-
import SyntaxGenericError from "./SyntaxGenericError.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Custom Error Listener
|
|
7
|
-
*
|
|
8
|
-
* @returns {object}
|
|
9
|
-
*/
|
|
10
|
-
class ErrorListener extends antlr4.error.ErrorListener {
|
|
11
|
-
/**
|
|
12
|
-
* Checks syntax error
|
|
13
|
-
*
|
|
14
|
-
* @param {object} recognizer The parsing support code essentially. Most of it is error recovery stuff
|
|
15
|
-
* @param {object} symbol Offending symbol
|
|
16
|
-
* @param {int} line Line of offending symbol
|
|
17
|
-
* @param {int} column Position in line of offending symbol
|
|
18
|
-
* @param {string} message Error message
|
|
19
|
-
* @param {string} payload Stack trace
|
|
20
|
-
*/
|
|
21
|
-
syntaxError(recognizer, symbol, line, column, message) {
|
|
22
|
-
throw new SyntaxGenericError({ line, column, message });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default ErrorListener;
|
|
1
|
+
import antlr4 from "antlr4";
|
|
2
|
+
|
|
3
|
+
import SyntaxGenericError from "./SyntaxGenericError.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Custom Error Listener
|
|
7
|
+
*
|
|
8
|
+
* @returns {object}
|
|
9
|
+
*/
|
|
10
|
+
class ErrorListener extends antlr4.error.ErrorListener {
|
|
11
|
+
/**
|
|
12
|
+
* Checks syntax error
|
|
13
|
+
*
|
|
14
|
+
* @param {object} recognizer The parsing support code essentially. Most of it is error recovery stuff
|
|
15
|
+
* @param {object} symbol Offending symbol
|
|
16
|
+
* @param {int} line Line of offending symbol
|
|
17
|
+
* @param {int} column Position in line of offending symbol
|
|
18
|
+
* @param {string} message Error message
|
|
19
|
+
* @param {string} payload Stack trace
|
|
20
|
+
*/
|
|
21
|
+
syntaxError(recognizer, symbol, line, column, message) {
|
|
22
|
+
throw new SyntaxGenericError({ line, column, message });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ErrorListener;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export default class SyntaxGenericError extends Error {
|
|
2
|
-
constructor(payload) {
|
|
3
|
-
super(payload);
|
|
4
|
-
|
|
5
|
-
this.code = "E_SYNTAX_GENERIC";
|
|
6
|
-
this.message = "Something went wrong";
|
|
7
|
-
|
|
8
|
-
if (typeof payload !== "undefined") {
|
|
9
|
-
this.message = payload.message || this.message;
|
|
10
|
-
this.payload = payload;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
console.error(
|
|
14
|
-
`line ${this.payload.line}, col ${this.payload.column}: ${this.payload.message}`,
|
|
15
|
-
);
|
|
16
|
-
Error.captureStackTrace(this, SyntaxGenericError);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
export default class SyntaxGenericError extends Error {
|
|
2
|
+
constructor(payload) {
|
|
3
|
+
super(payload);
|
|
4
|
+
|
|
5
|
+
this.code = "E_SYNTAX_GENERIC";
|
|
6
|
+
this.message = "Something went wrong";
|
|
7
|
+
|
|
8
|
+
if (typeof payload !== "undefined") {
|
|
9
|
+
this.message = payload.message || this.message;
|
|
10
|
+
this.payload = payload;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
console.error(
|
|
14
|
+
`line ${this.payload.line}, col ${this.payload.column}: ${this.payload.message}`,
|
|
15
|
+
);
|
|
16
|
+
Error.captureStackTrace(this, SyntaxGenericError);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.js
CHANGED
package/src/spl/GIS.js
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
class GIS {
|
|
2
|
-
constructor(name, srid) {
|
|
3
|
-
this.name = name;
|
|
4
|
-
this.srid = parseInt(srid);
|
|
5
|
-
if (srid != 4326) {
|
|
6
|
-
console.warn("Only SRID 4326 supported!");
|
|
7
|
-
}
|
|
8
|
-
this.entities = [];
|
|
9
|
-
this.relationships = [];
|
|
10
|
-
this.enums = [];
|
|
11
|
-
this.layers = [];
|
|
12
|
-
this.styles = [];
|
|
13
|
-
this.maps = [];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
addEntity(name) {
|
|
17
|
-
if (this.getEntity(name)) {
|
|
18
|
-
throw `Entity ${name} already exists!!!`;
|
|
19
|
-
}
|
|
20
|
-
this.entities.push(new Entity(name));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getEntity(name) {
|
|
24
|
-
return this.entities.find((e) => e.name == name);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
addRelationship(source, target, sourceOpts, targetOpts) {
|
|
28
|
-
const existingRelationship = this.getRelationship(
|
|
29
|
-
source,
|
|
30
|
-
target,
|
|
31
|
-
sourceOpts.label,
|
|
32
|
-
);
|
|
33
|
-
if (existingRelationship) {
|
|
34
|
-
existingRelationship.update(sourceOpts, targetOpts);
|
|
35
|
-
} else {
|
|
36
|
-
this.relationships.push(
|
|
37
|
-
new Relationship(source, target, sourceOpts, targetOpts),
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getRelationship(source, target, sourceLabel) {
|
|
43
|
-
return this.relationships.find(
|
|
44
|
-
(e) =>
|
|
45
|
-
e.source == source &&
|
|
46
|
-
e.target == target &&
|
|
47
|
-
e.sourceOpts.label == sourceLabel,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_entityExists(name) {
|
|
52
|
-
return this.getEntity(name) != null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Only for things that cannot be validated earlier
|
|
57
|
-
*/
|
|
58
|
-
validate() {
|
|
59
|
-
this.relationships.forEach((r) => {
|
|
60
|
-
if (!this._entityExists(r.source)) {
|
|
61
|
-
throw `ERROR: entity ${r.source} required by relationship does not exists!!`;
|
|
62
|
-
}
|
|
63
|
-
if (!this._entityExists(r.target)) {
|
|
64
|
-
throw `ERROR: entity ${r.target} required by relationship does not exists!!`;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
this.layers.forEach((layer) => {
|
|
69
|
-
if (layer.type == "GeoJSONLayer") {
|
|
70
|
-
if (!this._entityExists(layer.entityId)) {
|
|
71
|
-
throw `ERROR: entity ${layer.entityId} required by layer ${layer.id} does not exists!!`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getMaps() {
|
|
78
|
-
return this.maps;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
getLayer(id) {
|
|
82
|
-
return this.layers.find((l) => l.getId() == id);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
addLayer(layer) {
|
|
86
|
-
this.layers.push(layer);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getStyle(id) {
|
|
90
|
-
return this.styles.find((s) => s.getId() == id);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
addStyle(style) {
|
|
94
|
-
this.styles.push(style);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getMap(id) {
|
|
98
|
-
return this.maps.find((m) => m.id == id);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
addMap(id, map) {
|
|
102
|
-
this.maps.push(map);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
addDeploymentProperty(key, value) {
|
|
106
|
-
if (!this.extra) {
|
|
107
|
-
this.extra = {};
|
|
108
|
-
}
|
|
109
|
-
this.extra[key] = value;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
toString() {
|
|
113
|
-
return (
|
|
114
|
-
`\nGIS(${this.name} in ${this.srid}) - ${this.entities.length} entities, ${this.relationships.length} relationships:\n\t` +
|
|
115
|
-
`${this.entities.map((e) => e.toString()).join("\n\t")}\n\n\t` +
|
|
116
|
-
`${this.relationships.map((r) => r.toString()).join("\n\t")}` +
|
|
117
|
-
`${this.getMaps()
|
|
118
|
-
.map((m) => m.toString())
|
|
119
|
-
.join("\n\t")}`
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
class Entity {
|
|
125
|
-
constructor(name) {
|
|
126
|
-
this.name = name;
|
|
127
|
-
this.properties = [];
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
addProperty(name, type, params) {
|
|
131
|
-
if (this.getProperty(name)) {
|
|
132
|
-
throw `Property ${name} already exists in entity ${this.name}!!!`;
|
|
133
|
-
}
|
|
134
|
-
this.properties.push(new Property(name, type, params));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
getProperty(name) {
|
|
138
|
-
return this.properties.find((p) => p.name == name);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
validate() {
|
|
142
|
-
let pk = false;
|
|
143
|
-
let displayString = false;
|
|
144
|
-
this.properties.forEach((prop) => {
|
|
145
|
-
if (prop.pk) {
|
|
146
|
-
if (pk) throw "ERROR: already has a primary key";
|
|
147
|
-
pk = true;
|
|
148
|
-
}
|
|
149
|
-
if (prop.displayString) {
|
|
150
|
-
if (displayString) throw "ERROR: already has a displayString";
|
|
151
|
-
this.displayString = "$" + prop.name;
|
|
152
|
-
delete prop.displayString;
|
|
153
|
-
displayString = true;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
toString() {
|
|
159
|
-
return `Entity ${this.name}: ${this.properties
|
|
160
|
-
.map((e) => e.toString())
|
|
161
|
-
.join(", ")}`;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
class Property {
|
|
166
|
-
constructor(name, type, params) {
|
|
167
|
-
this.name = name;
|
|
168
|
-
this.class = type;
|
|
169
|
-
if (params) {
|
|
170
|
-
if (params.pk) {
|
|
171
|
-
this.pk = true;
|
|
172
|
-
this.required = true;
|
|
173
|
-
this.unique = true;
|
|
174
|
-
if (this.class == "Long") {
|
|
175
|
-
this.class = "Long (autoinc)";
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (params.required) {
|
|
179
|
-
this.required = true;
|
|
180
|
-
}
|
|
181
|
-
if (params.unique) {
|
|
182
|
-
this.unique = true;
|
|
183
|
-
}
|
|
184
|
-
if (params.displayString) {
|
|
185
|
-
this.displayString = true;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
toString() {
|
|
191
|
-
return (
|
|
192
|
-
this.name +
|
|
193
|
-
":" +
|
|
194
|
-
this.class +
|
|
195
|
-
(this.params ? "(" + Object.keys(this.params).join(", ") + ")" : "")
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
class Relationship {
|
|
201
|
-
constructor(source, target, sourceOpts, targetOpts) {
|
|
202
|
-
this.source = source;
|
|
203
|
-
this.target = target;
|
|
204
|
-
this.sourceOpts = sourceOpts;
|
|
205
|
-
this.targetOpts = targetOpts;
|
|
206
|
-
if (!this.targetOpts.label) {
|
|
207
|
-
this.targetOpts.label = this.source.toLowerCase();
|
|
208
|
-
if (this.targetOpts.multiplicity.indexOf("*") != -1) {
|
|
209
|
-
this.targetOpts.label += "s";
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
update(sourceOpts, targetOpts) {
|
|
215
|
-
if (targetOpts.label) {
|
|
216
|
-
this.targetOpts.label = targetOpts.label;
|
|
217
|
-
}
|
|
218
|
-
if (targetOpts.multiplicity) {
|
|
219
|
-
this.targetOpts.multiplicity = targetOpts.multiplicity;
|
|
220
|
-
}
|
|
221
|
-
if (sourceOpts.multiplicity) {
|
|
222
|
-
this.sourceOpts.multiplicity = sourceOpts.multiplicity;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
toString() {
|
|
227
|
-
return (
|
|
228
|
-
`${this.source}.${this.sourceOpts.label}(${this.sourceOpts.multiplicity})` +
|
|
229
|
-
` -> ${this.target}.${this.targetOpts.label}(${this.targetOpts.multiplicity})`
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export default GIS;
|
|
1
|
+
class GIS {
|
|
2
|
+
constructor(name, srid) {
|
|
3
|
+
this.name = name;
|
|
4
|
+
this.srid = parseInt(srid);
|
|
5
|
+
if (srid != 4326) {
|
|
6
|
+
console.warn("Only SRID 4326 supported!");
|
|
7
|
+
}
|
|
8
|
+
this.entities = [];
|
|
9
|
+
this.relationships = [];
|
|
10
|
+
this.enums = [];
|
|
11
|
+
this.layers = [];
|
|
12
|
+
this.styles = [];
|
|
13
|
+
this.maps = [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
addEntity(name) {
|
|
17
|
+
if (this.getEntity(name)) {
|
|
18
|
+
throw `Entity ${name} already exists!!!`;
|
|
19
|
+
}
|
|
20
|
+
this.entities.push(new Entity(name));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getEntity(name) {
|
|
24
|
+
return this.entities.find((e) => e.name == name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
addRelationship(source, target, sourceOpts, targetOpts) {
|
|
28
|
+
const existingRelationship = this.getRelationship(
|
|
29
|
+
source,
|
|
30
|
+
target,
|
|
31
|
+
sourceOpts.label,
|
|
32
|
+
);
|
|
33
|
+
if (existingRelationship) {
|
|
34
|
+
existingRelationship.update(sourceOpts, targetOpts);
|
|
35
|
+
} else {
|
|
36
|
+
this.relationships.push(
|
|
37
|
+
new Relationship(source, target, sourceOpts, targetOpts),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getRelationship(source, target, sourceLabel) {
|
|
43
|
+
return this.relationships.find(
|
|
44
|
+
(e) =>
|
|
45
|
+
e.source == source &&
|
|
46
|
+
e.target == target &&
|
|
47
|
+
e.sourceOpts.label == sourceLabel,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_entityExists(name) {
|
|
52
|
+
return this.getEntity(name) != null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Only for things that cannot be validated earlier
|
|
57
|
+
*/
|
|
58
|
+
validate() {
|
|
59
|
+
this.relationships.forEach((r) => {
|
|
60
|
+
if (!this._entityExists(r.source)) {
|
|
61
|
+
throw `ERROR: entity ${r.source} required by relationship does not exists!!`;
|
|
62
|
+
}
|
|
63
|
+
if (!this._entityExists(r.target)) {
|
|
64
|
+
throw `ERROR: entity ${r.target} required by relationship does not exists!!`;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.layers.forEach((layer) => {
|
|
69
|
+
if (layer.type == "GeoJSONLayer") {
|
|
70
|
+
if (!this._entityExists(layer.entityId)) {
|
|
71
|
+
throw `ERROR: entity ${layer.entityId} required by layer ${layer.id} does not exists!!`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getMaps() {
|
|
78
|
+
return this.maps;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getLayer(id) {
|
|
82
|
+
return this.layers.find((l) => l.getId() == id);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
addLayer(layer) {
|
|
86
|
+
this.layers.push(layer);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getStyle(id) {
|
|
90
|
+
return this.styles.find((s) => s.getId() == id);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
addStyle(style) {
|
|
94
|
+
this.styles.push(style);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getMap(id) {
|
|
98
|
+
return this.maps.find((m) => m.id == id);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
addMap(id, map) {
|
|
102
|
+
this.maps.push(map);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
addDeploymentProperty(key, value) {
|
|
106
|
+
if (!this.extra) {
|
|
107
|
+
this.extra = {};
|
|
108
|
+
}
|
|
109
|
+
this.extra[key] = value;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
toString() {
|
|
113
|
+
return (
|
|
114
|
+
`\nGIS(${this.name} in ${this.srid}) - ${this.entities.length} entities, ${this.relationships.length} relationships:\n\t` +
|
|
115
|
+
`${this.entities.map((e) => e.toString()).join("\n\t")}\n\n\t` +
|
|
116
|
+
`${this.relationships.map((r) => r.toString()).join("\n\t")}` +
|
|
117
|
+
`${this.getMaps()
|
|
118
|
+
.map((m) => m.toString())
|
|
119
|
+
.join("\n\t")}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
class Entity {
|
|
125
|
+
constructor(name) {
|
|
126
|
+
this.name = name;
|
|
127
|
+
this.properties = [];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
addProperty(name, type, params) {
|
|
131
|
+
if (this.getProperty(name)) {
|
|
132
|
+
throw `Property ${name} already exists in entity ${this.name}!!!`;
|
|
133
|
+
}
|
|
134
|
+
this.properties.push(new Property(name, type, params));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
getProperty(name) {
|
|
138
|
+
return this.properties.find((p) => p.name == name);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
validate() {
|
|
142
|
+
let pk = false;
|
|
143
|
+
let displayString = false;
|
|
144
|
+
this.properties.forEach((prop) => {
|
|
145
|
+
if (prop.pk) {
|
|
146
|
+
if (pk) throw "ERROR: already has a primary key";
|
|
147
|
+
pk = true;
|
|
148
|
+
}
|
|
149
|
+
if (prop.displayString) {
|
|
150
|
+
if (displayString) throw "ERROR: already has a displayString";
|
|
151
|
+
this.displayString = "$" + prop.name;
|
|
152
|
+
delete prop.displayString;
|
|
153
|
+
displayString = true;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
toString() {
|
|
159
|
+
return `Entity ${this.name}: ${this.properties
|
|
160
|
+
.map((e) => e.toString())
|
|
161
|
+
.join(", ")}`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
class Property {
|
|
166
|
+
constructor(name, type, params) {
|
|
167
|
+
this.name = name;
|
|
168
|
+
this.class = type;
|
|
169
|
+
if (params) {
|
|
170
|
+
if (params.pk) {
|
|
171
|
+
this.pk = true;
|
|
172
|
+
this.required = true;
|
|
173
|
+
this.unique = true;
|
|
174
|
+
if (this.class == "Long") {
|
|
175
|
+
this.class = "Long (autoinc)";
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (params.required) {
|
|
179
|
+
this.required = true;
|
|
180
|
+
}
|
|
181
|
+
if (params.unique) {
|
|
182
|
+
this.unique = true;
|
|
183
|
+
}
|
|
184
|
+
if (params.displayString) {
|
|
185
|
+
this.displayString = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
toString() {
|
|
191
|
+
return (
|
|
192
|
+
this.name +
|
|
193
|
+
":" +
|
|
194
|
+
this.class +
|
|
195
|
+
(this.params ? "(" + Object.keys(this.params).join(", ") + ")" : "")
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
class Relationship {
|
|
201
|
+
constructor(source, target, sourceOpts, targetOpts) {
|
|
202
|
+
this.source = source;
|
|
203
|
+
this.target = target;
|
|
204
|
+
this.sourceOpts = sourceOpts;
|
|
205
|
+
this.targetOpts = targetOpts;
|
|
206
|
+
if (!this.targetOpts.label) {
|
|
207
|
+
this.targetOpts.label = this.source.toLowerCase();
|
|
208
|
+
if (this.targetOpts.multiplicity.indexOf("*") != -1) {
|
|
209
|
+
this.targetOpts.label += "s";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
update(sourceOpts, targetOpts) {
|
|
215
|
+
if (targetOpts.label) {
|
|
216
|
+
this.targetOpts.label = targetOpts.label;
|
|
217
|
+
}
|
|
218
|
+
if (targetOpts.multiplicity) {
|
|
219
|
+
this.targetOpts.multiplicity = targetOpts.multiplicity;
|
|
220
|
+
}
|
|
221
|
+
if (sourceOpts.multiplicity) {
|
|
222
|
+
this.sourceOpts.multiplicity = sourceOpts.multiplicity;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
toString() {
|
|
227
|
+
return (
|
|
228
|
+
`${this.source}.${this.sourceOpts.label}(${this.sourceOpts.multiplicity})` +
|
|
229
|
+
` -> ${this.target}.${this.targetOpts.label}(${this.targetOpts.multiplicity})`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export default GIS;
|
package/src/spl/GeoJSONLayer.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export default class GeoJSONLayer {
|
|
2
|
-
constructor(id, label, entityId, editable, style) {
|
|
3
|
-
this.name = id;
|
|
4
|
-
this.type = "geojson";
|
|
5
|
-
this.label = label;
|
|
6
|
-
this.entityName = entityId;
|
|
7
|
-
this.editable = editable;
|
|
8
|
-
this.defaultStyle = style;
|
|
9
|
-
this.availableStyles = [style];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getId() {
|
|
13
|
-
return this.name;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
toString() {
|
|
17
|
-
return `GeoJSONLayer(${this.name} as ${this.label}) for entity ${
|
|
18
|
-
this.entityName
|
|
19
|
-
} ${this.editable ? "(editable)" : ""}`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
export default class GeoJSONLayer {
|
|
2
|
+
constructor(id, label, entityId, editable, style) {
|
|
3
|
+
this.name = id;
|
|
4
|
+
this.type = "geojson";
|
|
5
|
+
this.label = label;
|
|
6
|
+
this.entityName = entityId;
|
|
7
|
+
this.editable = editable;
|
|
8
|
+
this.defaultStyle = style;
|
|
9
|
+
this.availableStyles = [style];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getId() {
|
|
13
|
+
return this.name;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toString() {
|
|
17
|
+
return `GeoJSONLayer(${this.name} as ${this.label}) for entity ${
|
|
18
|
+
this.entityName
|
|
19
|
+
} ${this.editable ? "(editable)" : ""}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export default class GeoJSONLayerStyle {
|
|
2
|
-
constructor(id, fillColor, strokeColor, fillOpacity, strokeOpacity) {
|
|
3
|
-
this.name = id;
|
|
4
|
-
this.type = "GeoJSONLayerStyle";
|
|
5
|
-
this.fillColor = fillColor;
|
|
6
|
-
this.strokeColor = strokeColor;
|
|
7
|
-
this.fillOpacity = fillOpacity;
|
|
8
|
-
this.strokeOpacity = strokeOpacity;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getId() {
|
|
12
|
-
return this.name;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
export default class GeoJSONLayerStyle {
|
|
2
|
+
constructor(id, fillColor, strokeColor, fillOpacity, strokeOpacity) {
|
|
3
|
+
this.name = id;
|
|
4
|
+
this.type = "GeoJSONLayerStyle";
|
|
5
|
+
this.fillColor = fillColor;
|
|
6
|
+
this.strokeColor = strokeColor;
|
|
7
|
+
this.fillOpacity = fillOpacity;
|
|
8
|
+
this.strokeOpacity = strokeOpacity;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getId() {
|
|
12
|
+
return this.name;
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/spl/TileLayer.js
CHANGED
|
@@ -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
|
+
}
|
package/src/spl/WMSLayer.js
CHANGED
|
@@ -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
|
+
}
|
package/src/spl/WMSStyle.js
CHANGED
|
@@ -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
|
+
};
|