UNPKG

@ngageoint/mage.arcgis.service

Version:

A mage service plugin that synchronizes mage observations to a configured ArcGIS feature layer.

51 lines 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GeometryChangedHandler = void 0; /** * Class that handles geometry changes of an observation. */ class GeometryChangedHandler { /** * Constructor. * @param {ObservationsTransformer} transformer Used to create any delete observations to remove the old geometry observation. */ constructor(transformer) { this._transformer = transformer; this._previousGeoms = new Map(); } /** * Checks for any geometry changes within an observation, if there is a change create a delete object to delete it * from its previous geometry layers. * @param {ObservationAttrs[]} observations The observations to check for geometry changes. * @param {ArcObjects} arcObjects The collection to add any previous geometry deletions. * @param {FeatureLayerProcessor[]} layerProcessors All the layer processors. * @param {boolean} firstRun True if this is our first run and we need to make sure any changed geometries that occurred right before shutting down, are removed from their previous geometry layer. */ checkForGeometryChange(observations, arcObjects, layerProcessors, firstRun) { for (const observation of observations) { if (observation.states.length <= 0 || !observation.states[0].name.startsWith('archive')) { if (this._previousGeoms.has(observation.id)) { const previousGeomType = this._previousGeoms.get(observation.id); if (previousGeomType !== undefined && previousGeomType !== observation.geometry.type) { const arcObservation = this._transformer.createObservation(observation); arcObservation.esriGeometryType = this._transformer.mageTypeToEsriType(previousGeomType); arcObjects.deletions.push(arcObservation); } } if (firstRun) { const observationGeomType = this._transformer.mageTypeToEsriType(observation.geometry.type); for (const layerProcessor of layerProcessors) { if (layerProcessor.layerInfo.geometryType !== observationGeomType) { const arcObservation = this._transformer.createObservation(observation); arcObservation.esriGeometryType = layerProcessor.layerInfo.geometryType; arcObjects.deletions.push(arcObservation); } } } this._previousGeoms.set(observation.id, observation.geometry.type); } } } } exports.GeometryChangedHandler = GeometryChangedHandler; //# sourceMappingURL=GeometryChangedHandler.js.map