@open-pioneer/editing 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @open-pioneer/editing
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 434fd3e: Implemented update feature workflow in EditingService
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [520a97b]
12
+ - @open-pioneer/map@0.5.0
13
+
3
14
  ## 0.1.0
4
15
 
5
16
  ### Minor Changes
@@ -1,44 +1,37 @@
1
1
  import { EventEmitter } from "@open-pioneer/core";
2
- import { MapModel } from "@open-pioneer/map";
3
2
  import { Draw } from "ol/interaction";
4
- import { HttpService } from "@open-pioneer/http";
5
- import { PackageIntl } from "@open-pioneer/runtime";
6
- import { FlatStyleLike } from "ol/style/flat";
7
- import { EditingWorkflowEvents, EditingWorkflowState, EditingWorkflow } from "./api";
8
- interface EditingWorkflowProps {
9
- map: MapModel;
10
- ogcApiFeatureLayerUrl: URL;
11
- polygonDrawStyle: FlatStyleLike;
12
- httpService: HttpService;
13
- intl: PackageIntl;
14
- }
15
- export declare class EditingWorkflowImpl extends EventEmitter<EditingWorkflowEvents> implements EditingWorkflow {
3
+ import { EditingWorkflowEvents, EditingWorkflowState, EditingWorkflow, EditingWorkflowProps } from "./api";
4
+ export declare class EditingCreateWorkflowImpl extends EventEmitter<EditingWorkflowEvents> implements EditingWorkflow {
16
5
  #private;
17
6
  private _httpService;
18
7
  private _intl;
19
8
  private _map;
20
- private _polygonDrawStyle;
9
+ private _polygonStyle;
10
+ private _vertexStyle;
21
11
  private _state;
22
12
  private _editLayerURL;
23
- private _drawSource;
24
- private _drawLayer;
13
+ private _featureId;
14
+ private _editingSource;
15
+ private _editingLayer;
25
16
  private _drawInteraction;
26
17
  private _olMap;
27
18
  private _mapContainer;
28
19
  private _tooltip;
29
20
  private _enterHandler;
30
21
  private _escapeHandler;
22
+ private _error;
31
23
  private _interactionListener;
32
24
  private _mapListener;
33
25
  constructor(options: EditingWorkflowProps);
34
26
  getDrawInteraction(): Draw;
35
27
  getState(): EditingWorkflowState;
36
28
  private _setState;
29
+ private _save;
37
30
  private _start;
38
31
  reset(): void;
39
32
  stop(): void;
40
33
  private _destroy;
41
- whenComplete(): Promise<string | undefined>;
34
+ triggerSave(): void;
35
+ whenComplete(): Promise<Record<string, string> | undefined>;
42
36
  private _createTooltip;
43
37
  }
44
- export {};
@@ -1,4 +1,4 @@
1
- import { EventEmitter, createManualPromise } from '@open-pioneer/core';
1
+ import { createLogger, EventEmitter, createManualPromise } from '@open-pioneer/core';
2
2
  import { TOPMOST_LAYER_Z } from '@open-pioneer/map';
3
3
  import { Draw } from 'ol/interaction';
4
4
  import VectorLayer from 'ol/layer/Vector';
@@ -7,53 +7,62 @@ import GeoJSON from 'ol/format/GeoJSON';
7
7
  import { saveCreatedFeature } from './SaveFeaturesHandler.js';
8
8
  import Overlay from 'ol/Overlay';
9
9
  import { unByKey } from 'ol/Observable';
10
+ import { createStyles } from './style-utils.js';
10
11
 
11
- class EditingWorkflowImpl extends EventEmitter {
12
+ const LOG = createLogger("editing:EditingCreateWorkflowImpl");
13
+ class EditingCreateWorkflowImpl extends EventEmitter {
12
14
  #waiter;
13
15
  _httpService;
14
16
  _intl;
15
17
  _map;
16
- _polygonDrawStyle;
18
+ _polygonStyle;
19
+ _vertexStyle;
17
20
  _state;
18
21
  _editLayerURL;
19
- _drawSource;
20
- _drawLayer;
22
+ _featureId;
23
+ _editingSource;
24
+ _editingLayer;
21
25
  _drawInteraction;
22
26
  _olMap;
23
27
  _mapContainer;
24
28
  _tooltip;
25
29
  _enterHandler;
26
30
  _escapeHandler;
31
+ _error;
27
32
  _interactionListener;
28
33
  _mapListener;
29
34
  constructor(options) {
30
35
  super();
31
36
  this._httpService = options.httpService;
32
37
  this._intl = options.intl;
33
- this._polygonDrawStyle = options.polygonDrawStyle;
38
+ this._polygonStyle = options.polygonStyle;
39
+ this._vertexStyle = options.vertexStyle;
34
40
  this._map = options.map;
35
41
  this._olMap = options.map.olMap;
36
42
  this._state = "active:initialized";
37
43
  this._editLayerURL = options.ogcApiFeatureLayerUrl;
38
- this._drawSource = new VectorSource();
39
- this._drawLayer = new VectorLayer({
40
- source: this._drawSource,
44
+ this._editingSource = new VectorSource();
45
+ this._editingLayer = new VectorLayer({
46
+ source: this._editingSource,
41
47
  zIndex: TOPMOST_LAYER_Z,
42
48
  properties: {
43
49
  name: "editing-layer"
44
50
  }
45
51
  });
46
52
  this._drawInteraction = new Draw({
47
- source: this._drawSource,
53
+ source: this._editingSource,
48
54
  type: "Polygon",
49
- style: this._polygonDrawStyle
55
+ style: createStyles({
56
+ polygon: this._polygonStyle,
57
+ vertex: this._vertexStyle
58
+ })
50
59
  });
51
60
  this._tooltip = this._createTooltip(this._olMap);
52
61
  this._enterHandler = (e) => {
53
- if (e.code === "Enter" && e.target === this._olMap.getTargetElement()) {
62
+ if ((e.code === "Enter" || e.code === "NumpadEnter") && e.target === this._olMap.getTargetElement()) {
54
63
  const features = this._drawInteraction.getOverlay().getSource().getFeatures();
55
64
  if (features[0] && features[0].getGeometry().getCoordinates()[0].length > 4) {
56
- this._drawInteraction.finishDrawing();
65
+ this.triggerSave();
57
66
  }
58
67
  }
59
68
  };
@@ -76,8 +85,37 @@ class EditingWorkflowImpl extends EventEmitter {
76
85
  this._state = state;
77
86
  this.emit(state);
78
87
  }
88
+ _save(feature) {
89
+ this._setState("active:saving");
90
+ const layerUrl = this._editLayerURL;
91
+ const geometry = feature.getGeometry();
92
+ if (!geometry) {
93
+ this._destroy();
94
+ this._error = new Error("no geometry available");
95
+ this.#waiter?.reject(this._error);
96
+ return;
97
+ }
98
+ const projection = this._olMap.getView().getProjection();
99
+ const geoJson = new GeoJSON({
100
+ dataProjection: projection
101
+ });
102
+ const geoJSONGeometry = geoJson.writeGeometryObject(geometry, {
103
+ rightHanded: true,
104
+ decimals: 10
105
+ });
106
+ saveCreatedFeature(this._httpService, layerUrl, geoJSONGeometry, projection).then((featureId) => {
107
+ this._featureId = featureId;
108
+ this._destroy();
109
+ this.#waiter?.resolve({ featureId: this._featureId });
110
+ }).catch((err) => {
111
+ LOG.error(err);
112
+ this._destroy();
113
+ this._error = new Error("Failed to save feature", { cause: err });
114
+ this.#waiter?.reject(this._error);
115
+ });
116
+ }
79
117
  _start() {
80
- this._olMap.addLayer(this._drawLayer);
118
+ this._olMap.addLayer(this._editingLayer);
81
119
  this._olMap.addInteraction(this._drawInteraction);
82
120
  this._mapContainer = this._olMap.getTargetElement() ?? void 0;
83
121
  if (this._mapContainer) {
@@ -88,34 +126,18 @@ class EditingWorkflowImpl extends EventEmitter {
88
126
  const drawStart = this._drawInteraction.on("drawstart", () => {
89
127
  this._setState("active:drawing");
90
128
  this._tooltip.element.textContent = this._intl.formatMessage({
91
- id: "tooltip.continue"
129
+ id: "create.tooltip.continue"
92
130
  });
93
131
  });
94
132
  const drawEnd = this._drawInteraction.on("drawend", (e) => {
95
- this._setState("active:saving");
96
- const layerUrl = this._editLayerURL;
97
- const geometry = e.feature.getGeometry();
98
- if (!geometry) {
133
+ const feature = e.feature;
134
+ if (!feature) {
99
135
  this._destroy();
100
- this.#waiter?.reject(new Error("no geometry available"));
136
+ this._error = new Error("no feature available");
137
+ this.#waiter?.reject(this._error);
101
138
  return;
102
139
  }
103
- const projection = this._olMap.getView().getProjection();
104
- const geoJson = new GeoJSON({
105
- dataProjection: projection
106
- });
107
- const geoJSONGeometry = geoJson.writeGeometryObject(geometry, {
108
- rightHanded: true,
109
- decimals: 10
110
- });
111
- saveCreatedFeature(this._httpService, layerUrl, geoJSONGeometry, projection).then((featureId) => {
112
- this._destroy();
113
- this.#waiter?.resolve(featureId);
114
- }).catch((err) => {
115
- console.log(err);
116
- this._destroy();
117
- this.#waiter?.reject(err);
118
- });
140
+ this._save(feature);
119
141
  });
120
142
  const changedContainer = this._map.on("changed:container", () => {
121
143
  this._mapContainer?.removeEventListener("keydown", this._enterHandler);
@@ -131,7 +153,9 @@ class EditingWorkflowImpl extends EventEmitter {
131
153
  }
132
154
  reset() {
133
155
  this._drawInteraction.abortDrawing();
134
- this._tooltip.element.textContent = this._intl.formatMessage({ id: "tooltip.begin" });
156
+ this._tooltip.element.textContent = this._intl.formatMessage({
157
+ id: "create.tooltip.begin"
158
+ });
135
159
  this._setState("active:initialized");
136
160
  }
137
161
  stop() {
@@ -139,7 +163,7 @@ class EditingWorkflowImpl extends EventEmitter {
139
163
  this.#waiter?.resolve(void 0);
140
164
  }
141
165
  _destroy() {
142
- this._olMap.removeLayer(this._drawLayer);
166
+ this._olMap.removeLayer(this._editingLayer);
143
167
  this._olMap.removeInteraction(this._drawInteraction);
144
168
  this._tooltip.destroy();
145
169
  this._interactionListener.map((listener) => {
@@ -150,16 +174,30 @@ class EditingWorkflowImpl extends EventEmitter {
150
174
  });
151
175
  this._mapContainer?.removeEventListener("keydown", this._enterHandler);
152
176
  this._mapContainer?.removeEventListener("keydown", this._escapeHandler);
153
- this._state = "inactive";
177
+ this._setState("destroyed");
178
+ }
179
+ triggerSave() {
180
+ this._drawInteraction.finishDrawing();
154
181
  }
155
182
  whenComplete() {
183
+ if (this._state === "destroyed") {
184
+ if (this._error) {
185
+ return Promise.reject(this._error);
186
+ } else {
187
+ if (this._featureId) {
188
+ return Promise.resolve({ featureId: this._featureId });
189
+ } else {
190
+ return Promise.resolve(void 0);
191
+ }
192
+ }
193
+ }
156
194
  const manualPromise = this.#waiter ??= createManualPromise();
157
195
  return manualPromise.promise;
158
196
  }
159
197
  _createTooltip(olMap) {
160
198
  const element = document.createElement("div");
161
199
  element.className = "editing-tooltip editing-tooltip-hidden";
162
- element.textContent = this._intl.formatMessage({ id: "tooltip.begin" });
200
+ element.textContent = this._intl.formatMessage({ id: "create.tooltip.begin" });
163
201
  const overlay = new Overlay({
164
202
  element,
165
203
  offset: [15, 0],
@@ -183,5 +221,5 @@ class EditingWorkflowImpl extends EventEmitter {
183
221
  }
184
222
  }
185
223
 
186
- export { EditingWorkflowImpl };
187
- //# sourceMappingURL=EditingWorkflowImpl.js.map
224
+ export { EditingCreateWorkflowImpl };
225
+ //# sourceMappingURL=EditingCreateWorkflowImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditingCreateWorkflowImpl.js","sources":["EditingCreateWorkflowImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, ManualPromise, createLogger, createManualPromise } from \"@open-pioneer/core\";\nimport { MapModel, TOPMOST_LAYER_Z } from \"@open-pioneer/map\";\nimport { Draw } from \"ol/interaction\";\nimport VectorLayer from \"ol/layer/Vector\";\nimport VectorSource from \"ol/source/Vector\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { FlatStyle } from \"ol/style/flat\";\nimport GeoJSON from \"ol/format/GeoJSON\";\nimport GeoJSONGeometry from \"ol/format/GeoJSON\";\nimport GeoJSONGeometryCollection from \"ol/format/GeoJSON\";\nimport { saveCreatedFeature } from \"./SaveFeaturesHandler\";\nimport OlMap from \"ol/Map\";\nimport Overlay from \"ol/Overlay\";\nimport { Resource } from \"@open-pioneer/core\";\nimport { unByKey } from \"ol/Observable\";\nimport { EventsKey } from \"ol/events\";\nimport {\n EditingWorkflowEvents,\n EditingWorkflowState,\n EditingWorkflow,\n EditingWorkflowProps\n} from \"./api\";\nimport Feature from \"ol/Feature\";\nimport { createStyles } from \"./style-utils\";\n\nconst LOG = createLogger(\"editing:EditingCreateWorkflowImpl\");\n\n// Represents a tooltip rendered on the OpenLayers map\ninterface Tooltip extends Resource {\n overlay: Overlay;\n element: HTMLDivElement;\n}\n\nexport class EditingCreateWorkflowImpl\n extends EventEmitter<EditingWorkflowEvents>\n implements EditingWorkflow\n{\n #waiter: ManualPromise<Record<string, string> | undefined> | undefined;\n\n private _httpService: HttpService;\n private _intl: PackageIntl;\n\n private _map: MapModel;\n private _polygonStyle: FlatStyle;\n private _vertexStyle: FlatStyle;\n private _state: EditingWorkflowState;\n private _editLayerURL: URL;\n private _featureId: string | undefined;\n\n private _editingSource: VectorSource;\n private _editingLayer: VectorLayer<VectorSource>;\n private _drawInteraction: Draw;\n private _olMap: OlMap;\n private _mapContainer: HTMLElement | undefined;\n private _tooltip: Tooltip;\n private _enterHandler: (e: KeyboardEvent) => void;\n private _escapeHandler: (e: KeyboardEvent) => void;\n\n private _error: Error | undefined;\n\n private _interactionListener: Array<EventsKey>;\n private _mapListener: Array<Resource>;\n\n constructor(options: EditingWorkflowProps) {\n super();\n this._httpService = options.httpService;\n this._intl = options.intl;\n\n this._polygonStyle = options.polygonStyle;\n this._vertexStyle = options.vertexStyle;\n\n this._map = options.map;\n this._olMap = options.map.olMap;\n this._state = \"active:initialized\";\n this._editLayerURL = options.ogcApiFeatureLayerUrl;\n\n this._editingSource = new VectorSource();\n this._editingLayer = new VectorLayer({\n source: this._editingSource,\n zIndex: TOPMOST_LAYER_Z,\n properties: {\n name: \"editing-layer\"\n }\n });\n\n this._drawInteraction = new Draw({\n source: this._editingSource,\n type: \"Polygon\",\n style: createStyles({\n polygon: this._polygonStyle,\n vertex: this._vertexStyle\n })\n });\n\n this._tooltip = this._createTooltip(this._olMap);\n\n this._enterHandler = (e: KeyboardEvent) => {\n if (\n (e.code === \"Enter\" || e.code === \"NumpadEnter\") &&\n e.target === this._olMap.getTargetElement()\n ) {\n const features = this._drawInteraction.getOverlay().getSource().getFeatures();\n\n /**\n * Get the first linear ring of the polygon\n * Coordinates include closing vertex, so a triangle has 4, while drawing the\n * actual mouse position is an extra vertex, therefor we have to check\n * \"length > 4\" instead of \"length >= 4\"\n */\n if (features[0] && features[0].getGeometry().getCoordinates()[0].length > 4) {\n this.triggerSave();\n }\n }\n };\n\n this._escapeHandler = (e: KeyboardEvent) => {\n if (e.code === \"Escape\" && e.target === this._olMap.getTargetElement()) {\n this.reset();\n }\n };\n\n this._interactionListener = [];\n this._mapListener = [];\n\n this._start();\n }\n\n getDrawInteraction() {\n return this._drawInteraction;\n }\n\n getState() {\n return this._state;\n }\n\n private _setState(state: EditingWorkflowState) {\n this._state = state;\n this.emit(state);\n }\n\n private _save(feature: Feature) {\n this._setState(\"active:saving\");\n\n const layerUrl = this._editLayerURL;\n\n const geometry = feature.getGeometry();\n if (!geometry) {\n this._destroy();\n this._error = new Error(\"no geometry available\");\n this.#waiter?.reject(this._error);\n return;\n }\n const projection = this._olMap.getView().getProjection();\n const geoJson = new GeoJSON({\n dataProjection: projection\n });\n const geoJSONGeometry: GeoJSONGeometry | GeoJSONGeometryCollection =\n geoJson.writeGeometryObject(geometry, {\n rightHanded: true,\n decimals: 10\n });\n\n saveCreatedFeature(this._httpService, layerUrl, geoJSONGeometry, projection)\n .then((featureId) => {\n this._featureId = featureId;\n this._destroy();\n this.#waiter?.resolve({ featureId: this._featureId });\n })\n .catch((err: Error) => {\n LOG.error(err);\n this._destroy();\n this._error = new Error(\"Failed to save feature\", { cause: err });\n this.#waiter?.reject(this._error);\n });\n }\n\n private _start() {\n this._olMap.addLayer(this._editingLayer);\n this._olMap.addInteraction(this._drawInteraction);\n\n // Add EventListener on focused map to abort actual interaction via `Escape`\n this._mapContainer = this._olMap.getTargetElement() ?? undefined;\n if (this._mapContainer) {\n this._mapContainer.addEventListener(\"keydown\", this._enterHandler, false);\n this._mapContainer.addEventListener(\"keydown\", this._escapeHandler, false);\n }\n\n this._tooltip.element.classList.remove(\"editing-tooltip-hidden\");\n\n const drawStart = this._drawInteraction.on(\"drawstart\", () => {\n this._setState(\"active:drawing\");\n this._tooltip.element.textContent = this._intl.formatMessage({\n id: \"create.tooltip.continue\"\n });\n });\n\n const drawEnd = this._drawInteraction.on(\"drawend\", (e) => {\n const feature = e.feature;\n if (!feature) {\n this._destroy();\n this._error = new Error(\"no feature available\");\n this.#waiter?.reject(this._error);\n return;\n }\n this._save(feature);\n });\n\n // update event handler when container changes\n const changedContainer = this._map.on(\"changed:container\", () => {\n this._mapContainer?.removeEventListener(\"keydown\", this._enterHandler);\n this._mapContainer?.removeEventListener(\"keydown\", this._escapeHandler);\n\n this._mapContainer = this._olMap.getTargetElement() ?? undefined;\n if (this._mapContainer) {\n this._mapContainer.addEventListener(\"keydown\", this._enterHandler, false);\n this._mapContainer.addEventListener(\"keydown\", this._escapeHandler, false);\n }\n });\n\n this._interactionListener.push(drawStart, drawEnd);\n this._mapListener.push(changedContainer);\n }\n\n reset() {\n this._drawInteraction.abortDrawing();\n this._tooltip.element.textContent = this._intl.formatMessage({\n id: \"create.tooltip.begin\"\n });\n this._setState(\"active:initialized\");\n }\n\n stop() {\n this._destroy();\n this.#waiter?.resolve(undefined);\n }\n\n private _destroy() {\n this._olMap.removeLayer(this._editingLayer);\n this._olMap.removeInteraction(this._drawInteraction);\n this._tooltip.destroy();\n\n // Remove event listener on interaction and on map\n this._interactionListener.map((listener) => {\n unByKey(listener);\n });\n this._mapListener.map((listener) => {\n listener.destroy();\n });\n\n // Remove event escape listener\n this._mapContainer?.removeEventListener(\"keydown\", this._enterHandler);\n this._mapContainer?.removeEventListener(\"keydown\", this._escapeHandler);\n\n this._setState(\"destroyed\");\n }\n\n triggerSave() {\n // Stop drawing - the `drawend` event is dispatched before inserting the feature.\n this._drawInteraction.finishDrawing();\n }\n\n whenComplete(): Promise<Record<string, string> | undefined> {\n if (this._state === \"destroyed\") {\n if (this._error) {\n return Promise.reject(this._error);\n } else {\n if (this._featureId) {\n return Promise.resolve({ featureId: this._featureId });\n } else {\n return Promise.resolve(undefined);\n }\n }\n }\n\n const manualPromise = (this.#waiter ??= createManualPromise());\n return manualPromise.promise;\n }\n\n private _createTooltip(olMap: OlMap): Tooltip {\n const element = document.createElement(\"div\");\n element.className = \"editing-tooltip editing-tooltip-hidden\";\n element.textContent = this._intl.formatMessage({ id: \"create.tooltip.begin\" });\n\n const overlay = new Overlay({\n element: element,\n offset: [15, 0],\n positioning: \"center-left\"\n });\n\n const pointerMove = olMap.on(\"pointermove\", (evt) => {\n if (evt.dragging) {\n return;\n }\n\n overlay.setPosition(evt.coordinate);\n });\n\n olMap.addOverlay(overlay);\n\n return {\n overlay,\n element,\n destroy() {\n unByKey(pointerMove);\n olMap.removeOverlay(overlay);\n }\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA4BA,MAAM,GAAA,GAAM,aAAa,mCAAmC,CAAA,CAAA;AAQrD,MAAM,kCACD,YAEZ,CAAA;AAAA,EACI,OAAA,CAAA;AAAA,EAEQ,YAAA,CAAA;AAAA,EACA,KAAA,CAAA;AAAA,EAEA,IAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,YAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EAEA,cAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,gBAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EACA,cAAA,CAAA;AAAA,EAEA,MAAA,CAAA;AAAA,EAEA,oBAAA,CAAA;AAAA,EACA,YAAA,CAAA;AAAA,EAER,YAAY,OAA+B,EAAA;AACvC,IAAM,KAAA,EAAA,CAAA;AACN,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,WAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,IAAA,CAAA;AAErB,IAAA,IAAA,CAAK,gBAAgB,OAAQ,CAAA,YAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,WAAA,CAAA;AAE5B,IAAA,IAAA,CAAK,OAAO,OAAQ,CAAA,GAAA,CAAA;AACpB,IAAK,IAAA,CAAA,MAAA,GAAS,QAAQ,GAAI,CAAA,KAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,MAAS,GAAA,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,EAEQ,eAAe,KAAuB,EAAA;AAC1C,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAC5C,IAAA,OAAA,CAAQ,SAAY,GAAA,wCAAA,CAAA;AACpB,IAAA,OAAA,CAAQ,cAAc,IAAK,CAAA,KAAA,CAAM,cAAc,EAAE,EAAA,EAAI,wBAAwB,CAAA,CAAA;AAE7E,IAAM,MAAA,OAAA,GAAU,IAAI,OAAQ,CAAA;AAAA,MACxB,OAAA;AAAA,MACA,MAAA,EAAQ,CAAC,EAAA,EAAI,CAAC,CAAA;AAAA,MACd,WAAa,EAAA,aAAA;AAAA,KAChB,CAAA,CAAA;AAED,IAAA,MAAM,WAAc,GAAA,KAAA,CAAM,EAAG,CAAA,aAAA,EAAe,CAAC,GAAQ,KAAA;AACjD,MAAA,IAAI,IAAI,QAAU,EAAA;AACd,QAAA,OAAA;AAAA,OACJ;AAEA,MAAQ,OAAA,CAAA,WAAA,CAAY,IAAI,UAAU,CAAA,CAAA;AAAA,KACrC,CAAA,CAAA;AAED,IAAA,KAAA,CAAM,WAAW,OAAO,CAAA,CAAA;AAExB,IAAO,OAAA;AAAA,MACH,OAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAU,GAAA;AACN,QAAA,OAAA,CAAQ,WAAW,CAAA,CAAA;AACnB,QAAA,KAAA,CAAM,cAAc,OAAO,CAAA,CAAA;AAAA,OAC/B;AAAA,KACJ,CAAA;AAAA,GACJ;AACJ;;;;"}
@@ -1,8 +1,10 @@
1
1
  import { MapModel, MapRegistry } from "@open-pioneer/map";
2
2
  import { EditingService } from "./api";
3
- import { EditingWorkflowImpl } from "./EditingWorkflowImpl";
3
+ import { EditingCreateWorkflowImpl } from "./EditingCreateWorkflowImpl";
4
+ import { EditingUpdateWorkflowImpl } from "./EditingUpdateWorkflowImpl";
4
5
  import { ServiceOptions } from "@open-pioneer/runtime";
5
6
  import { HttpService } from "@open-pioneer/http";
7
+ import { Feature } from "ol";
6
8
  export interface References {
7
9
  mapRegistry: MapRegistry;
8
10
  httpService: HttpService;
@@ -11,8 +13,9 @@ export declare class EditingServiceImpl implements EditingService {
11
13
  private _serviceOptions;
12
14
  private _workflows;
13
15
  constructor(serviceOptions: ServiceOptions<References>);
14
- start(map: MapModel, ogcApiFeatureLayerUrl: URL): EditingWorkflowImpl;
16
+ createFeature(map: MapModel, ogcApiFeatureLayerUrl: URL): EditingCreateWorkflowImpl;
17
+ updateFeature(map: MapModel, ogcApiFeatureLayerUrl: URL, feature: Feature): EditingUpdateWorkflowImpl;
15
18
  stop(mapId: string): Error | void;
16
19
  reset(mapId: string): Error | void;
17
- _connectToWorkflowComplete(workflow: EditingWorkflowImpl, mapId: string): void;
20
+ _connectToWorkflowDestroyEvent(workflow: EditingCreateWorkflowImpl | EditingUpdateWorkflowImpl, mapId: string): void;
18
21
  }
@@ -1,4 +1,5 @@
1
- import { EditingWorkflowImpl } from './EditingWorkflowImpl.js';
1
+ import { EditingCreateWorkflowImpl } from './EditingCreateWorkflowImpl.js';
2
+ import { EditingUpdateWorkflowImpl } from './EditingUpdateWorkflowImpl.js';
2
3
 
3
4
  class EditingServiceImpl {
4
5
  _serviceOptions;
@@ -7,7 +8,7 @@ class EditingServiceImpl {
7
8
  this._serviceOptions = serviceOptions;
8
9
  this._workflows = /* @__PURE__ */ new Map();
9
10
  }
10
- start(map, ogcApiFeatureLayerUrl) {
11
+ createFeature(map, ogcApiFeatureLayerUrl) {
11
12
  if (!ogcApiFeatureLayerUrl || !map || !map.id) {
12
13
  throw new Error("Map, mapId or url is undefined.");
13
14
  }
@@ -18,15 +19,40 @@ class EditingServiceImpl {
18
19
  "EditingWorkflow could not be started. EditingWorkflow already in progress for this map."
19
20
  );
20
21
  }
21
- workflow = new EditingWorkflowImpl({
22
+ workflow = new EditingCreateWorkflowImpl({
22
23
  map,
23
24
  ogcApiFeatureLayerUrl,
24
- polygonDrawStyle: this._serviceOptions.properties.polygonDrawStyle,
25
+ polygonStyle: this._serviceOptions.properties.polygonStyle,
26
+ vertexStyle: this._serviceOptions.properties.vertexStyle,
25
27
  httpService: this._serviceOptions.references.httpService,
26
28
  intl: this._serviceOptions.intl
27
29
  });
28
30
  this._workflows.set(mapId, workflow);
29
- this._connectToWorkflowComplete(workflow, mapId);
31
+ this._connectToWorkflowDestroyEvent(workflow, mapId);
32
+ return workflow;
33
+ }
34
+ updateFeature(map, ogcApiFeatureLayerUrl, feature) {
35
+ if (!ogcApiFeatureLayerUrl || !map || !map.id) {
36
+ throw new Error("Map, mapId or url is undefined.");
37
+ }
38
+ const mapId = map.id;
39
+ let workflow = this._workflows.get(mapId);
40
+ if (workflow) {
41
+ throw new Error(
42
+ "EditingWorkflow could not be started. EditingWorkflow already in progress for this map."
43
+ );
44
+ }
45
+ workflow = new EditingUpdateWorkflowImpl({
46
+ map,
47
+ ogcApiFeatureLayerUrl,
48
+ feature,
49
+ polygonStyle: this._serviceOptions.properties.polygonStyle,
50
+ vertexStyle: this._serviceOptions.properties.vertexStyle,
51
+ httpService: this._serviceOptions.references.httpService,
52
+ intl: this._serviceOptions.intl
53
+ });
54
+ this._workflows.set(mapId, workflow);
55
+ this._connectToWorkflowDestroyEvent(workflow, mapId);
30
56
  return workflow;
31
57
  }
32
58
  stop(mapId) {
@@ -45,8 +71,8 @@ class EditingServiceImpl {
45
71
  return new Error("No workflow found for mapId: " + mapId);
46
72
  }
47
73
  }
48
- _connectToWorkflowComplete(workflow, mapId) {
49
- workflow.whenComplete().finally(() => {
74
+ _connectToWorkflowDestroyEvent(workflow, mapId) {
75
+ workflow.on("destroyed", () => {
50
76
  this._workflows.delete(mapId);
51
77
  });
52
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditingServiceImpl.js","sources":["EditingServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { MapModel, MapRegistry } from \"@open-pioneer/map\";\nimport { EditingService } from \"./api\";\nimport { EditingWorkflowImpl } from \"./EditingWorkflowImpl\";\nimport { FlatStyleLike } from \"ol/style/flat\";\nimport { ServiceOptions } from \"@open-pioneer/runtime\";\nimport { HttpService } from \"@open-pioneer/http\";\n\nexport interface References {\n mapRegistry: MapRegistry;\n httpService: HttpService;\n}\n\nexport class EditingServiceImpl implements EditingService {\n private _serviceOptions: ServiceOptions<References>;\n private _workflows: Map<string, EditingWorkflowImpl>;\n\n constructor(serviceOptions: ServiceOptions<References>) {\n this._serviceOptions = serviceOptions;\n this._workflows = new Map();\n }\n\n start(map: MapModel, ogcApiFeatureLayerUrl: URL): EditingWorkflowImpl {\n if (!ogcApiFeatureLayerUrl || !map || !map.id) {\n throw new Error(\"Map, mapId or url is undefined.\");\n }\n\n const mapId = map.id;\n\n let workflow = this._workflows.get(mapId);\n if (workflow) {\n throw new Error(\n \"EditingWorkflow could not be started. EditingWorkflow already in progress for this map.\"\n );\n }\n\n workflow = new EditingWorkflowImpl({\n map,\n ogcApiFeatureLayerUrl,\n polygonDrawStyle: this._serviceOptions.properties.polygonDrawStyle as FlatStyleLike,\n httpService: this._serviceOptions.references.httpService,\n intl: this._serviceOptions.intl\n });\n this._workflows.set(mapId, workflow);\n this._connectToWorkflowComplete(workflow, mapId);\n\n return workflow;\n }\n\n stop(mapId: string): Error | void {\n const workflow = this._workflows.get(mapId);\n if (workflow) {\n workflow.stop();\n } else {\n return new Error(\"No workflow found for mapId: \" + mapId);\n }\n }\n\n reset(mapId: string): Error | void {\n const workflow = this._workflows.get(mapId);\n if (workflow) {\n workflow.reset();\n } else {\n return new Error(\"No workflow found for mapId: \" + mapId);\n }\n }\n\n _connectToWorkflowComplete(workflow: EditingWorkflowImpl, mapId: string) {\n workflow.whenComplete().finally(() => {\n this._workflows.delete(mapId);\n });\n }\n}\n"],"names":[],"mappings":";;AAcO,MAAM,kBAA6C,CAAA;AAAA,EAC9C,eAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EAER,YAAY,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A,KACX,MAAA;AACH,MAAO,OAAA,IAAI,KAAM,CAAA,+BAAA,GAAkC,KAAK,CAAA,CAAA;AAAA,KAC5D;AAAA,GACJ;AAAA,EAEA,MAAM,KAA6B,EAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,UAAW,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAC1C,IAAA,IAAI,QAAU,EAAA;AACV,MAAA,QAAA,CAAS,KAAM,EAAA,CAAA;AAAA,KACZ,MAAA;AACH,MAAO,OAAA,IAAI,KAAM,CAAA,+BAAA,GAAkC,KAAK,CAAA,CAAA;AAAA,KAC5D;AAAA,GACJ;AAAA,EAEA,0BAAA,CAA2B,UAA+B,KAAe,EAAA;AACrE,IAAS,QAAA,CAAA,YAAA,EAAe,CAAA,OAAA,CAAQ,MAAM;AAClC,MAAK,IAAA,CAAA,UAAA,CAAW,OAAO,KAAK,CAAA,CAAA;AAAA,KAC/B,CAAA,CAAA;AAAA,GACL;AACJ;;;;"}
1
+ {"version":3,"file":"EditingServiceImpl.js","sources":["EditingServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { MapModel, MapRegistry } from \"@open-pioneer/map\";\nimport { EditingService } from \"./api\";\nimport { EditingCreateWorkflowImpl } from \"./EditingCreateWorkflowImpl\";\nimport { EditingUpdateWorkflowImpl } from \"./EditingUpdateWorkflowImpl\";\nimport { FlatStyle } from \"ol/style/flat\";\nimport { ServiceOptions } from \"@open-pioneer/runtime\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { Feature } from \"ol\";\n\nexport interface References {\n mapRegistry: MapRegistry;\n httpService: HttpService;\n}\n\nexport class EditingServiceImpl implements EditingService {\n private _serviceOptions: ServiceOptions<References>;\n private _workflows: Map<string, EditingCreateWorkflowImpl | EditingUpdateWorkflowImpl>;\n\n constructor(serviceOptions: ServiceOptions<References>) {\n this._serviceOptions = serviceOptions;\n this._workflows = new Map();\n }\n\n createFeature(map: MapModel, ogcApiFeatureLayerUrl: URL): EditingCreateWorkflowImpl {\n if (!ogcApiFeatureLayerUrl || !map || !map.id) {\n throw new Error(\"Map, mapId or url is undefined.\");\n }\n\n const mapId = map.id;\n\n let workflow = this._workflows.get(mapId);\n if (workflow) {\n throw new Error(\n \"EditingWorkflow could not be started. EditingWorkflow already in progress for this map.\"\n );\n }\n\n workflow = new EditingCreateWorkflowImpl({\n map,\n ogcApiFeatureLayerUrl,\n polygonStyle: this._serviceOptions.properties.polygonStyle as FlatStyle,\n vertexStyle: this._serviceOptions.properties.vertexStyle as FlatStyle,\n httpService: this._serviceOptions.references.httpService,\n intl: this._serviceOptions.intl\n });\n this._workflows.set(mapId, workflow);\n this._connectToWorkflowDestroyEvent(workflow, mapId);\n\n return workflow;\n }\n\n updateFeature(\n map: MapModel,\n ogcApiFeatureLayerUrl: URL,\n feature: Feature\n ): EditingUpdateWorkflowImpl {\n if (!ogcApiFeatureLayerUrl || !map || !map.id) {\n throw new Error(\"Map, mapId or url is undefined.\");\n }\n\n const mapId = map.id;\n\n let workflow = this._workflows.get(mapId);\n if (workflow) {\n throw new Error(\n \"EditingWorkflow could not be started. EditingWorkflow already in progress for this map.\"\n );\n }\n\n workflow = new EditingUpdateWorkflowImpl({\n map,\n ogcApiFeatureLayerUrl,\n feature,\n polygonStyle: this._serviceOptions.properties.polygonStyle as FlatStyle,\n vertexStyle: this._serviceOptions.properties.vertexStyle as FlatStyle,\n httpService: this._serviceOptions.references.httpService,\n intl: this._serviceOptions.intl\n });\n this._workflows.set(mapId, workflow);\n this._connectToWorkflowDestroyEvent(workflow, mapId);\n\n return workflow;\n }\n\n stop(mapId: string): Error | void {\n const workflow = this._workflows.get(mapId);\n if (workflow) {\n workflow.stop();\n } else {\n return new Error(\"No workflow found for mapId: \" + mapId);\n }\n }\n\n reset(mapId: string): Error | void {\n const workflow = this._workflows.get(mapId);\n if (workflow) {\n workflow.reset();\n } else {\n return new Error(\"No workflow found for mapId: \" + mapId);\n }\n }\n\n _connectToWorkflowDestroyEvent(\n workflow: EditingCreateWorkflowImpl | EditingUpdateWorkflowImpl,\n mapId: string\n ) {\n workflow.on(\"destroyed\", () => {\n this._workflows.delete(mapId);\n });\n }\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,kBAA6C,CAAA;AAAA,EAC9C,eAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EAER,YAAY,cAA4C,EAAA;AACpD,IAAA,IAAA,CAAK,eAAkB,GAAA,cAAA,CAAA;AACvB,IAAK,IAAA,CAAA,UAAA,uBAAiB,GAAI,EAAA,CAAA;AAAA,GAC9B;AAAA,EAEA,aAAA,CAAc,KAAe,qBAAuD,EAAA;AAChF,IAAA,IAAI,CAAC,qBAAyB,IAAA,CAAC,GAAO,IAAA,CAAC,IAAI,EAAI,EAAA;AAC3C,MAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA,CAAA;AAAA,KACrD;AAEA,IAAA,MAAM,QAAQ,GAAI,CAAA,EAAA,CAAA;AAElB,IAAA,IAAI,QAAW,GAAA,IAAA,CAAK,UAAW,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AACxC,IAAA,IAAI,QAAU,EAAA;AACV,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,yFAAA;AAAA,OACJ,CAAA;AAAA,KACJ;AAEA,IAAA,QAAA,GAAW,IAAI,yBAA0B,CAAA;AAAA,MACrC,GAAA;AAAA,MACA,qBAAA;AAAA,MACA,YAAA,EAAc,IAAK,CAAA,eAAA,CAAgB,UAAW,CAAA,YAAA;AAAA,MAC9C,WAAA,EAAa,IAAK,CAAA,eAAA,CAAgB,UAAW,CAAA,WAAA;AAAA,MAC7C,WAAA,EAAa,IAAK,CAAA,eAAA,CAAgB,UAAW,CAAA,WAAA;AAAA,MAC7C,IAAA,EAAM,KAAK,eAAgB,CAAA,IAAA;AAAA,KAC9B,CAAA,CAAA;AACD,IAAK,IAAA,CAA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,CAAK,UAAW,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAC1C,IAAA,IAAI,QAAU,EAAA;AACV,MAAA,QAAA,CAAS,IAAK,EAAA,CAAA;AAAA,KACX,MAAA;AACH,MAAO,OAAA,IAAI,KAAM,CAAA,+BAAA,GAAkC,KAAK,CAAA,CAAA;AAAA,KAC5D;AAAA,GACJ;AAAA,EAEA,MAAM,KAA6B,EAAA;AAC/B,IAAA,MAAM,QAAW,GAAA,IAAA,CAAK,UAAW,CAAA,GAAA,CAAI,KAAK,CAAA,CAAA;AAC1C,IAAA,IAAI,QAAU,EAAA;AACV,MAAA,QAAA,CAAS,KAAM,EAAA,CAAA;AAAA,KACZ,MAAA;AACH,MAAO,OAAA,IAAI,KAAM,CAAA,+BAAA,GAAkC,KAAK,CAAA,CAAA;AAAA,KAC5D;AAAA,GACJ;AAAA,EAEA,8BAAA,CACI,UACA,KACF,EAAA;AACE,IAAS,QAAA,CAAA,EAAA,CAAG,aAAa,MAAM;AAC3B,MAAK,IAAA,CAAA,UAAA,CAAW,OAAO,KAAK,CAAA,CAAA;AAAA,KAC/B,CAAA,CAAA;AAAA,GACL;AACJ;;;;"}
@@ -0,0 +1,42 @@
1
+ import { EventEmitter } from "@open-pioneer/core";
2
+ import { Modify } from "ol/interaction";
3
+ import Feature from "ol/Feature";
4
+ import { EditingWorkflowEvents, EditingWorkflowState, EditingWorkflow, EditingWorkflowProps } from "./api";
5
+ export declare class EditingUpdateWorkflowImpl extends EventEmitter<EditingWorkflowEvents> implements EditingWorkflow {
6
+ #private;
7
+ private _httpService;
8
+ private _intl;
9
+ private _map;
10
+ private _polygonStyle;
11
+ private _vertexStyle;
12
+ private _state;
13
+ private _editLayerURL;
14
+ private _featureId;
15
+ private _initialFeature;
16
+ private _editFeature;
17
+ private _editingSource;
18
+ private _editingLayer;
19
+ private _modifyInteraction;
20
+ private _olMap;
21
+ private _mapContainer;
22
+ private _tooltip;
23
+ private _enterHandler;
24
+ private _escapeHandler;
25
+ private _error;
26
+ private _interactionListener;
27
+ private _mapListener;
28
+ constructor(options: {
29
+ feature: Feature;
30
+ } & EditingWorkflowProps);
31
+ getModifyInteraction(): Modify;
32
+ getState(): EditingWorkflowState;
33
+ private _setState;
34
+ private _save;
35
+ private _start;
36
+ reset(): void;
37
+ stop(): void;
38
+ private _destroy;
39
+ triggerSave(): void;
40
+ whenComplete(): Promise<Record<string, string> | undefined>;
41
+ private _createTooltip;
42
+ }