@lbdudc/gp-gis-dsl 0.2.1 → 0.2.3
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/grammar/GISGrammar.g4 +11 -1
- package/package.json +1 -1
- package/src/GISVisitor.js +54 -4
- package/src/GISVisitorHelper.js +93 -162
- package/src/cli.js +34 -34
- package/src/error/ErrorListener.js +26 -26
- package/src/features.js +53 -0
- package/src/index.js +26 -26
- package/src/lib/GISGrammar.interp +5 -1
- package/src/lib/GISGrammar.tokens +45 -44
- package/src/lib/GISGrammarLexer.interp +4 -1
- package/src/lib/GISGrammarLexer.js +287 -279
- package/src/lib/GISGrammarLexer.tokens +45 -44
- package/src/lib/GISGrammarListener.js +19 -1
- package/src/lib/GISGrammarParser.js +724 -365
- package/src/lib/GISGrammarVisitor.js +13 -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/Map.js +10 -1
- 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 -0
- package/src/store.js +74 -74
package/grammar/GISGrammar.g4
CHANGED
|
@@ -43,8 +43,15 @@ createGeoJSONLayer: GEOJSON_SYMBOL LAYER_SYMBOL identifier (AS_SYMBOL text)? OPA
|
|
|
43
43
|
STROKE_OPACITY_SYMBOL floatNumber
|
|
44
44
|
CPAR_SYMBOL SCOL_SYMBOL;
|
|
45
45
|
|
|
46
|
+
sldCustomBody: GEOMETRY_TYPE_SYMBOL TYPE COMMA_SYMBOL
|
|
47
|
+
FILL_COLOR_SYMBOL? hexColor? COMMA_SYMBOL?
|
|
48
|
+
STROKE_COLOR_SYMBOL? hexColor? COMMA_SYMBOL?
|
|
49
|
+
FILL_OPACITY_SYMBOL? (floatNumber | intNumber)? COMMA_SYMBOL?
|
|
50
|
+
STROKE_OPACITY_SYMBOL? (floatNumber | intNumber)?;
|
|
51
|
+
|
|
46
52
|
createWmsStyle: WMS_SYMBOL STYLE_SYMBOL identifier OPAR_SYMBOL
|
|
47
|
-
SLD_SYMBOL text
|
|
53
|
+
(SLD_SYMBOL text)? COMMA_SYMBOL?
|
|
54
|
+
sldCustomBody?
|
|
48
55
|
CPAR_SYMBOL SCOL_SYMBOL;
|
|
49
56
|
|
|
50
57
|
createWmsLayer: WMS_SYMBOL LAYER_SYMBOL identifier (AS_SYMBOL text)? OPAR_SYMBOL
|
|
@@ -106,6 +113,7 @@ text: QUOTED_TEXT;
|
|
|
106
113
|
|
|
107
114
|
hexColor: HEX_COLOR;
|
|
108
115
|
floatNumber: FLOAT_NUMBER;
|
|
116
|
+
intNumber: INT_NUMBER;
|
|
109
117
|
|
|
110
118
|
|
|
111
119
|
//-----------------------------------------------------------------------
|
|
@@ -168,6 +176,7 @@ MAPPEDBY_SYMBOL: M A P P E D UNDERLINE_SYMBOL B Y;
|
|
|
168
176
|
LAYER_SYMBOL: L A Y E R;
|
|
169
177
|
TILE_SYMBOL: T I L E;
|
|
170
178
|
GEOJSON_SYMBOL: G E O J S O N;
|
|
179
|
+
GEOMETRY_TYPE_SYMBOL: G E O M E T R Y T Y P E;
|
|
171
180
|
AS_SYMBOL: A S;
|
|
172
181
|
URL_SYMBOL: U R L;
|
|
173
182
|
SLD_SYMBOL: S T Y L E L A Y E R D E S C R I P T O R;
|
|
@@ -198,6 +207,7 @@ TYPE
|
|
|
198
207
|
| L O C A L D A T E
|
|
199
208
|
| S T R I N G
|
|
200
209
|
| L I N E S T R I N G
|
|
210
|
+
| L I N E
|
|
201
211
|
| M U L T I L I N E S T R I N G
|
|
202
212
|
| P O L Y G O N
|
|
203
213
|
| M U L T I P O L Y G O N
|
package/package.json
CHANGED
package/src/GISVisitor.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
WMSLayer,
|
|
8
8
|
Map,
|
|
9
9
|
GeoJSONLayerStyle,
|
|
10
|
+
WMSStyleCustom,
|
|
10
11
|
} from "./spl/Map.js";
|
|
11
12
|
import { transformation, getPropertyParams } from "./GISVisitorHelper.js";
|
|
12
13
|
// import { generateProduct } from "./project-generator.js";
|
|
@@ -198,10 +199,59 @@ class Visitor extends GISGrammarVisitor {
|
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
visitCreateWmsStyle(ctx) {
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
const descriptor = ctx
|
|
203
|
+
.getChild(4)
|
|
204
|
+
.getText()
|
|
205
|
+
.startsWith("styleLayerDescriptor");
|
|
206
|
+
if (descriptor) {
|
|
207
|
+
const id = ctx.getChild(2).getText();
|
|
208
|
+
const sld = ctx.getChild(5).getText().slice(1, -1);
|
|
209
|
+
this.log(`visitCreateWmsStyle ${id} with ${sld}`);
|
|
210
|
+
this.store.getCurrentProduct().addStyle(new WMSStyle(id, sld));
|
|
211
|
+
} else {
|
|
212
|
+
let style = {
|
|
213
|
+
geometryType: null,
|
|
214
|
+
fillColor: null,
|
|
215
|
+
strokeColor: null,
|
|
216
|
+
fillOpacity: null,
|
|
217
|
+
strokeOpacity: null,
|
|
218
|
+
};
|
|
219
|
+
const id = ctx.getChild(2).getText();
|
|
220
|
+
const props = ctx.getChild(4).getText();
|
|
221
|
+
|
|
222
|
+
props.split(",").forEach((field) => {
|
|
223
|
+
if (field.startsWith("geometryType")) {
|
|
224
|
+
style.geometryType = field.split("geometryType")[1];
|
|
225
|
+
} else if (field.startsWith("fillColor")) {
|
|
226
|
+
if (field.split("fillColor")[1] == "null") style.fillColor = null;
|
|
227
|
+
else style.fillColor = field.split("fillColor")[1]; // Remove the '#' symbol
|
|
228
|
+
} else if (field.startsWith("strokeColor")) {
|
|
229
|
+
if (field.split("strokeColor")[1] == "null") style.strokeColor = null;
|
|
230
|
+
else style.strokeColor = field.split("strokeColor")[1]; // Remove the '#' symbol
|
|
231
|
+
} else if (field.startsWith("fillOpacity")) {
|
|
232
|
+
style.fillOpacity = parseFloat(field.split("fillOpacity")[1]);
|
|
233
|
+
} else if (field.startsWith("strokeOpacity")) {
|
|
234
|
+
style.strokeOpacity = parseFloat(field.split("strokeOpacity")[1]);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
this.log(
|
|
239
|
+
`visitCreateWmsStyle ${id} - ${style.geometryType}, ${style.fillColor}, ${style.strokeColor}, ${style.fillOpacity}, ${style.strokeOpacity}`,
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
this.store
|
|
243
|
+
.getCurrentProduct()
|
|
244
|
+
.addStyle(
|
|
245
|
+
new WMSStyleCustom(
|
|
246
|
+
id,
|
|
247
|
+
style.geometryType,
|
|
248
|
+
style.fillColor,
|
|
249
|
+
style.strokeColor,
|
|
250
|
+
style.fillOpacity,
|
|
251
|
+
style.strokeOpacity,
|
|
252
|
+
),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
205
255
|
}
|
|
206
256
|
|
|
207
257
|
visitCreateWmsLayer(ctx) {
|
package/src/GISVisitorHelper.js
CHANGED
|
@@ -1,162 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return newSpec;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function _relationships(spec) {
|
|
100
|
-
let source, target;
|
|
101
|
-
|
|
102
|
-
spec.relationships.forEach((r) => {
|
|
103
|
-
source = spec.getEntity(r.source);
|
|
104
|
-
target = spec.getEntity(r.target);
|
|
105
|
-
let sourceOwner = false;
|
|
106
|
-
let targetOwner = false;
|
|
107
|
-
let sourceMultiple = _multiple(r.sourceOpts.multiplicity);
|
|
108
|
-
let targetMultiple = _multiple(r.targetOpts.multiplicity);
|
|
109
|
-
if (sourceMultiple && !targetMultiple) {
|
|
110
|
-
targetOwner = true;
|
|
111
|
-
} else {
|
|
112
|
-
sourceOwner = true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
source.properties.push({
|
|
116
|
-
name: r.sourceOpts.label,
|
|
117
|
-
class: target.name,
|
|
118
|
-
owner: sourceOwner,
|
|
119
|
-
bidirectional: r.targetOpts.label,
|
|
120
|
-
multiple: sourceMultiple,
|
|
121
|
-
required: _required(r.sourceOpts.multiplicity),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
target.properties.push({
|
|
125
|
-
name: r.targetOpts.label,
|
|
126
|
-
class: source.name,
|
|
127
|
-
owner: targetOwner,
|
|
128
|
-
bidirectional: r.sourceOpts.label,
|
|
129
|
-
multiple: targetMultiple,
|
|
130
|
-
required: _required(r.targetOpts.multiplicity),
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function _multiple(multiplicity) {
|
|
136
|
-
return ["1..1", "0..1"].find((a) => a == multiplicity) == null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function _required(multiplicity) {
|
|
140
|
-
return ["1..1", "1..*"].find((a) => a == multiplicity) != null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function getPropertyParams(symbols) {
|
|
144
|
-
if (!symbols.length) return null;
|
|
145
|
-
|
|
146
|
-
const ret = {};
|
|
147
|
-
if (symbols.includes("identifier")) {
|
|
148
|
-
ret.pk = true;
|
|
149
|
-
}
|
|
150
|
-
if (symbols.includes("required")) {
|
|
151
|
-
ret.required = true;
|
|
152
|
-
}
|
|
153
|
-
if (symbols.includes("unique")) {
|
|
154
|
-
ret.unique = true;
|
|
155
|
-
}
|
|
156
|
-
if (symbols.includes("display_string")) {
|
|
157
|
-
ret.displayString = true;
|
|
158
|
-
}
|
|
159
|
-
return ret;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
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;
|
package/src/features.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
"MapViewer",
|
|
3
|
+
"Tools",
|
|
4
|
+
"DM_SpatialDatabase",
|
|
5
|
+
"DM_GenerationType",
|
|
6
|
+
"DM_DataServer",
|
|
7
|
+
"MV_MapServer",
|
|
8
|
+
"MV_Tools",
|
|
9
|
+
"MV_MapManagement",
|
|
10
|
+
"DM_SD_PostGIS",
|
|
11
|
+
"DM_GT_Sequence",
|
|
12
|
+
"MV_MM_MultipleMapViewer",
|
|
13
|
+
"MV_MM_MMV_MapSelectorInMapViewer",
|
|
14
|
+
"MV_MM_MMV_MapSelectorInMenuElement",
|
|
15
|
+
"MV_MS_GeoServer",
|
|
16
|
+
"GUI_Lists",
|
|
17
|
+
"GUI_L_FormLink",
|
|
18
|
+
"GUI_L_F_BasicSearch",
|
|
19
|
+
"GUI_L_Filterable",
|
|
20
|
+
"GUI_L_Sortable",
|
|
21
|
+
"GUI_L_LocateInMap",
|
|
22
|
+
"GUI_L_ViewListAsMap",
|
|
23
|
+
"MV_ContextInformation",
|
|
24
|
+
"MV_CI_Scale",
|
|
25
|
+
"MV_CI_Map",
|
|
26
|
+
"MV_CI_CenterCoordinates",
|
|
27
|
+
"MV_CI_Dimensions",
|
|
28
|
+
"MV_DetailOnClick",
|
|
29
|
+
"MV_LayerManagement",
|
|
30
|
+
"MV_LM_CenterViewOnLayer",
|
|
31
|
+
"MV_LM_Order",
|
|
32
|
+
"MV_LM_Opacity",
|
|
33
|
+
"MV_LM_HideLayer",
|
|
34
|
+
"MV_LM_Style",
|
|
35
|
+
"MV_LM_ExternalLayer",
|
|
36
|
+
"MV_LM_StylePreview",
|
|
37
|
+
"MV_T_E_Type",
|
|
38
|
+
"MV_T_E_F_URL",
|
|
39
|
+
"MV_T_E_F_PDF",
|
|
40
|
+
"MV_T_E_SetScale",
|
|
41
|
+
"MV_T_E_ShowLegend",
|
|
42
|
+
"MV_T_InformationMode",
|
|
43
|
+
"MV_T_MeasureControl",
|
|
44
|
+
"MV_T_ZoomWindow",
|
|
45
|
+
"DM_DataInput",
|
|
46
|
+
"DM_DI_DataFeeding",
|
|
47
|
+
"DM_DI_DF_Shapefile",
|
|
48
|
+
"T_GIS",
|
|
49
|
+
"T_EntitiesInformation",
|
|
50
|
+
"D_C_Postgres",
|
|
51
|
+
"D_C_Geoserver",
|
|
52
|
+
"D_C_Nginx",
|
|
53
|
+
];
|
package/src/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import antlr4 from "antlr4";
|
|
2
|
-
import GISGrammarLexer from "./lib/GISGrammarLexer.js";
|
|
3
|
-
import GISGrammarParser from "./lib/GISGrammarParser.js";
|
|
4
|
-
import ErrorListener from "./error/ErrorListener.js";
|
|
5
|
-
import GISVisitor from "./GISVisitor.js";
|
|
6
|
-
import store from "./store.js";
|
|
7
|
-
|
|
8
|
-
export default function parse(inputStr, debug = false) {
|
|
9
|
-
const chars = new antlr4.InputStream(inputStr);
|
|
10
|
-
const lexer = new GISGrammarLexer(chars);
|
|
11
|
-
lexer.strictMode = false; // do not use js strictMode
|
|
12
|
-
|
|
13
|
-
const tokens = new antlr4.CommonTokenStream(lexer);
|
|
14
|
-
const parser = new GISGrammarParser(tokens);
|
|
15
|
-
|
|
16
|
-
const errorListener = new ErrorListener();
|
|
17
|
-
// Do this after creating the parser and before running it
|
|
18
|
-
parser.removeErrorListeners(); // Remove default ConsoleErrorListener
|
|
19
|
-
parser.addErrorListener(errorListener); // Add custom error listener
|
|
20
|
-
|
|
21
|
-
const visitor = new GISVisitor(store, debug);
|
|
22
|
-
const tree = parser.parse();
|
|
23
|
-
visitor.start(tree);
|
|
24
|
-
|
|
25
|
-
return store.getLastGeneratedProduct();
|
|
26
|
-
}
|
|
1
|
+
import antlr4 from "antlr4";
|
|
2
|
+
import GISGrammarLexer from "./lib/GISGrammarLexer.js";
|
|
3
|
+
import GISGrammarParser from "./lib/GISGrammarParser.js";
|
|
4
|
+
import ErrorListener from "./error/ErrorListener.js";
|
|
5
|
+
import GISVisitor from "./GISVisitor.js";
|
|
6
|
+
import store from "./store.js";
|
|
7
|
+
|
|
8
|
+
export default function parse(inputStr, debug = false) {
|
|
9
|
+
const chars = new antlr4.InputStream(inputStr);
|
|
10
|
+
const lexer = new GISGrammarLexer(chars);
|
|
11
|
+
lexer.strictMode = false; // do not use js strictMode
|
|
12
|
+
|
|
13
|
+
const tokens = new antlr4.CommonTokenStream(lexer);
|
|
14
|
+
const parser = new GISGrammarParser(tokens);
|
|
15
|
+
|
|
16
|
+
const errorListener = new ErrorListener();
|
|
17
|
+
// Do this after creating the parser and before running it
|
|
18
|
+
parser.removeErrorListeners(); // Remove default ConsoleErrorListener
|
|
19
|
+
parser.addErrorListener(errorListener); // Add custom error listener
|
|
20
|
+
|
|
21
|
+
const visitor = new GISVisitor(store, debug);
|
|
22
|
+
const tree = parser.parse();
|
|
23
|
+
visitor.start(tree);
|
|
24
|
+
|
|
25
|
+
return store.getLastGeneratedProduct();
|
|
26
|
+
}
|