@lbdudc/gp-gis-dsl 0.2.2 → 0.2.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/grammar/GISGrammar.g4 +240 -240
- package/package.json +54 -54
- package/src/GISVisitor.js +368 -368
- package/src/GISVisitorHelper.js +93 -93
- package/src/cli.js +34 -34
- package/src/error/ErrorListener.js +26 -26
- package/src/features.js +0 -20
- package/src/index.js +26 -26
- package/src/lib/GISGrammar.interp +143 -143
- package/src/lib/GISGrammarLexer.interp +203 -203
- 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 +53 -53
- 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/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/Map.js
CHANGED
|
@@ -1,53 +1,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
|
-
|
|
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
|
+
|
|
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
|
+
};
|
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
|
+
}
|