diff --git a/dev-docs/RFCs/v1.0/react-map-gl-draw.md b/dev-docs/RFCs/v1.0/react-map-gl-draw.md index 6df4036cb..462bd21c0 100644 --- a/dev-docs/RFCs/v1.0/react-map-gl-draw.md +++ b/dev-docs/RFCs/v1.0/react-map-gl-draw.md @@ -86,7 +86,7 @@ As shown in the above image, for the feature currently being edited, ## Code Example ```js -import React, { Component } from 'react'; +import * as React from 'react'; import MapGL, {_MapContext as MapContext} from 'react-map-gl'; import MapGLDraw, { EditorModes } from 'react-map-gl-draw'; @@ -98,7 +98,7 @@ const MODES = [ { id: EditorModes.DRAW_RECTANGLE, text: 'Draw Rectangle'} ]; -class App extends Component { +class App extends React.Component { constructor(props) { super(props); this.state = { diff --git a/docs/api-reference/react-map-gl-draw/react-map-gl-draw.md b/docs/api-reference/react-map-gl-draw/react-map-gl-draw.md index 0c195f899..c98a69e50 100644 --- a/docs/api-reference/react-map-gl-draw/react-map-gl-draw.md +++ b/docs/api-reference/react-map-gl-draw/react-map-gl-draw.md @@ -113,7 +113,7 @@ As shown in the above image, for the feature currently being edited, **Simple example: Draw polygon** ```js -import React, { Component } from 'react'; +import * as React from 'react'; import MapGL from 'react-map-gl'; import { Editor, diff --git a/docs/get-started/basic-usage.md b/docs/get-started/basic-usage.md index 2cf8bfca4..570384e84 100644 --- a/docs/get-started/basic-usage.md +++ b/docs/get-started/basic-usage.md @@ -2,7 +2,7 @@ ## Imports ```jsx -import React from 'react'; +import * as React from 'react'; import DeckGL from '@deck.gl/react'; import { EditableGeoJsonLayer } from '@nebula.gl/layers'; import { StaticMap } from 'react-map-gl'; diff --git a/examples/advanced/src/app.tsx b/examples/advanced/src/app.tsx index 5121d915c..6230dc70c 100644 --- a/examples/advanced/src/app.tsx +++ b/examples/advanced/src/app.tsx @@ -1,6 +1,6 @@ import document from 'global/document'; import * as React from 'react'; -import ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import Example from './example'; diff --git a/examples/advanced/src/example.tsx b/examples/advanced/src/example.tsx index 2f41f2bb3..66ac71278 100644 --- a/examples/advanced/src/example.tsx +++ b/examples/advanced/src/example.tsx @@ -1,7 +1,7 @@ /* eslint-env browser */ import window from 'global/window'; -import React, { Component } from 'react'; +import * as React from 'react'; import DeckGL from '@deck.gl/react'; import { MapView, MapController } from '@deck.gl/core'; import { StaticMap } from 'react-map-gl'; @@ -197,7 +197,7 @@ function getEditHandleColor(handle: {}) { } } -export default class Example extends Component< +export default class Example extends React.Component< {}, { viewport: Record; diff --git a/examples/advanced/src/toolbox.tsx b/examples/advanced/src/toolbox.tsx index ba8c6162b..340cb7b4e 100644 --- a/examples/advanced/src/toolbox.tsx +++ b/examples/advanced/src/toolbox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import styled from 'styled-components'; const styles = { diff --git a/examples/codesandbox/examples.old.txt b/examples/codesandbox/examples.old.txt index 11ca70f7b..e3557cb87 100644 --- a/examples/codesandbox/examples.old.txt +++ b/examples/codesandbox/examples.old.txt @@ -1,5 +1,5 @@ import window from 'global/window'; -import React, { Component } from 'react'; +import * as React from 'react'; import MapGL from 'react-map-gl'; import DeckGL from 'deck.gl'; import { featureCollection, point } from '@turf/helpers'; @@ -7,7 +7,7 @@ import { featureCollection, point } from '@turf/helpers'; import { EditableGeoJsonLayer } from 'nebula.gl'; import { Nebula, HtmlOverlay, HtmlOverlayItem, HtmlClusterOverlay } from 'nebula.gl-react'; -class Example extends Component { +class Example extends React.Component { constructor() { super(); this.state = { diff --git a/examples/editor/app.js b/examples/editor/app.js index a21a02869..fb27e50e4 100644 --- a/examples/editor/app.js +++ b/examples/editor/app.js @@ -1,6 +1,6 @@ import document from 'global/document'; import * as React from 'react'; -import ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import { Example } from './example'; diff --git a/examples/editor/example.js b/examples/editor/example.js index 90fa3ee15..599089737 100644 --- a/examples/editor/example.js +++ b/examples/editor/example.js @@ -1,6 +1,6 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import DeckGL from '@deck.gl/react'; import { EditableGeoJsonLayer } from '@nebula.gl/layers'; import { Toolbox } from '@nebula.gl/editor'; diff --git a/examples/no-map/app.js b/examples/no-map/app.js index d8e776c2b..8de7a9049 100644 --- a/examples/no-map/app.js +++ b/examples/no-map/app.js @@ -1,6 +1,6 @@ import document from 'global/document'; import * as React from 'react'; -import ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import ExampleNoMap from './example-no-map'; diff --git a/examples/overlays/app.js b/examples/overlays/app.js index 5121d915c..6230dc70c 100644 --- a/examples/overlays/app.js +++ b/examples/overlays/app.js @@ -1,6 +1,6 @@ import document from 'global/document'; import * as React from 'react'; -import ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import Example from './example'; diff --git a/examples/overlays/example.js b/examples/overlays/example.js index b059b02b9..cd993bb70 100644 --- a/examples/overlays/example.js +++ b/examples/overlays/example.js @@ -1,5 +1,5 @@ import window from 'global/window'; -import React, { Component } from 'react'; +import * as React from 'react'; import DeckGL from '@deck.gl/react'; import { StaticMap } from 'react-map-gl'; @@ -109,7 +109,7 @@ class WorldHeritage extends HtmlClusterOverlay { } } -export default class Example extends Component { +export default class Example extends React.Component { constructor(props) { super(props); diff --git a/examples/react-map-gl-draw/app.js b/examples/react-map-gl-draw/app.js index 26ba76d9a..0a2ccbc9d 100644 --- a/examples/react-map-gl-draw/app.js +++ b/examples/react-map-gl-draw/app.js @@ -1,5 +1,5 @@ -import React, { Component } from 'react'; -import { render } from 'react-dom'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import MapGL from 'react-map-gl'; import { Editor, EditingMode } from 'react-map-gl-draw'; @@ -33,7 +33,7 @@ const DEFAULT_VIEWPORT = { zoom: 14, }; -export default class App extends Component { +export default class App extends React.Component { constructor(props) { super(props); this.state = { @@ -106,5 +106,5 @@ export default class App extends Component { } export function renderToDom(container) { - render(, container); + ReactDOM.render(, container); } diff --git a/examples/sf/app.js b/examples/sf/app.js index 5121d915c..6230dc70c 100644 --- a/examples/sf/app.js +++ b/examples/sf/app.js @@ -1,6 +1,6 @@ import document from 'global/document'; import * as React from 'react'; -import ReactDOM from 'react-dom'; +import * as ReactDOM from 'react-dom'; import Example from './example'; diff --git a/examples/sf/example.js b/examples/sf/example.js index 3ce24a863..59e8bf9b3 100644 --- a/examples/sf/example.js +++ b/examples/sf/example.js @@ -1,5 +1,5 @@ import window from 'global/window'; -import React, { Component } from 'react'; +import * as React from 'react'; import DeckGL, { TextLayer } from 'deck.gl'; import MapGL from 'react-map-gl'; @@ -35,7 +35,7 @@ const styles = { }, }; -export default class Example extends Component< +export default class Example extends React.Component< {}, { viewport: Object, diff --git a/lib/examples/advanced/src/app.d.ts b/lib/examples/advanced/src/app.d.ts new file mode 100644 index 000000000..0b123fde5 --- /dev/null +++ b/lib/examples/advanced/src/app.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=app.d.ts.map \ No newline at end of file diff --git a/lib/examples/advanced/src/app.d.ts.map b/lib/examples/advanced/src/app.d.ts.map new file mode 100644 index 000000000..57f6a1a1d --- /dev/null +++ b/lib/examples/advanced/src/app.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../examples/advanced/src/app.tsx"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/examples/advanced/src/app.js b/lib/examples/advanced/src/app.js new file mode 100644 index 000000000..6e5ef21a1 --- /dev/null +++ b/lib/examples/advanced/src/app.js @@ -0,0 +1,11 @@ +import document from 'global/document'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import Example from './example'; +var root = document.createElement('div'); +if (document.body) { + document.body.style.margin = '0'; + document.body.appendChild(root); + ReactDOM.render(React.createElement(Example, null), root); +} +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/lib/examples/advanced/src/app.js.map b/lib/examples/advanced/src/app.js.map new file mode 100644 index 000000000..8c13a5c24 --- /dev/null +++ b/lib/examples/advanced/src/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../../examples/advanced/src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAE3C,IAAI,QAAQ,CAAC,IAAI,EAAE;IACjB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;IAEjC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,oBAAC,OAAO,OAAG,EAAE,IAAI,CAAC,CAAC;CACpC"} \ No newline at end of file diff --git a/lib/examples/advanced/src/example.d.ts b/lib/examples/advanced/src/example.d.ts new file mode 100644 index 000000000..e9f6973a2 --- /dev/null +++ b/lib/examples/advanced/src/example.d.ts @@ -0,0 +1,60 @@ +import * as React from 'react'; +import { GeoJsonEditMode } from 'nebula.gl'; +export default class Example extends React.Component<{}, { + viewport: Record; + testFeatures: any; + mode: typeof GeoJsonEditMode; + modeConfig: any; + pointsRemovable: boolean; + selectedFeatureIndexes: number[]; + editHandleType: string; + selectionTool?: string; + showGeoJson: boolean; + pathMarkerLayer: boolean; + featureMenu?: { + index: number; + x: number; + y: number; + }; +}> { + constructor(props: {}); + componentDidMount(): void; + componentWillUnmount(): void; + _onChangeViewport: (viewport: Record) => void; + _onLayerClick: (info: any) => void; + _resize: () => void; + _loadSample: (type: string) => void; + _copy: () => void; + _paste: () => void; + _download: () => void; + _parseStringJson: (json: string) => void; + _error: (err: any) => void; + _getHtmlColorForFeature(index: number, selected: boolean): string; + _getDeckColorForFeature(index: number, bright: number, alpha: number): number[]; + _renderSelectFeatureCheckbox(index: number, featureType: string): JSX.Element; + _renderSelectFeatureCheckboxes(): any[]; + _renderBooleanOperationControls(): JSX.Element; + _renderTwoClickPolygonControls(): JSX.Element; + _renderModifyModeControls(): JSX.Element; + _renderSplitModeControls(): JSX.Element; + _renderSnappingControls(): JSX.Element; + _renderMeasureDistanceControls(): JSX.Element; + _renderModeConfigControls(): any[]; + _renderToolBox(): JSX.Element; + renderStaticMap(viewport: Record): JSX.Element; + _featureMenuClick(action: string): void; + _renderFeatureMenu({ x, y }: { + x: number; + y: number; + }): JSX.Element; + customizeLayers(layers: Record[]): void; + onEdit: ({ updatedData, editType, editContext }: { + updatedData: any; + editType: any; + editContext: any; + }) => void; + getFillColor: (feature: any, isSelected: any) => number[]; + getLineColor: (feature: any, isSelected: any) => number[]; + render(): JSX.Element; +} +//# sourceMappingURL=example.d.ts.map \ No newline at end of file diff --git a/lib/examples/advanced/src/example.d.ts.map b/lib/examples/advanced/src/example.d.ts.map new file mode 100644 index 000000000..a38d0b1ad --- /dev/null +++ b/lib/examples/advanced/src/example.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../examples/advanced/src/example.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAiCL,eAAe,EAChB,MAAM,WAAW,CAAC;AA2JnB,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,KAAK,CAAC,SAAS,CAClD,EAAE,EACF;IACE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,YAAY,EAAE,GAAG,CAAC;IAClB,IAAI,EAAE,OAAO,eAAe,CAAC;IAC7B,UAAU,EAAE,GAAG,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IACzB,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OA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000..ab08ff723 --- /dev/null +++ b/lib/examples/advanced/src/example.js @@ -0,0 +1,769 @@ +/* eslint-env browser */ +import { __assign, __extends, __read, __spread } from "tslib"; +import window from 'global/window'; +import * as React from 'react'; +import DeckGL from '@deck.gl/react'; +import { MapView, MapController } from '@deck.gl/core'; +import { StaticMap } from 'react-map-gl'; +import GL from '@luma.gl/constants'; +import circle from '@turf/circle'; +import { EditableGeoJsonLayer, SelectionLayer, ModifyMode, TranslateMode, TransformMode, ScaleMode, RotateMode, DuplicateMode, ExtendLineStringMode, SplitPolygonMode, ExtrudeMode, ElevationMode, DrawPointMode, DrawLineStringMode, DrawPolygonMode, DrawRectangleMode, DrawCircleByDiameterMode, DrawCircleFromCenterMode, DrawEllipseByBoundingBoxMode, DrawEllipseUsingThreePointsMode, DrawRectangleUsingThreePointsMode, Draw90DegreePolygonMode, DrawPolygonByDraggingMode, MeasureDistanceMode, MeasureAreaMode, MeasureAngleMode, ViewMode, CompositeMode, SnappableMode, ElevatedEditHandleLayer, PathMarkerLayer, SELECTION_TYPE, } from 'nebula.gl'; +import sampleGeoJson from '../../data/sample-geojson.json'; +import iconSheet from '../../data/edit-handles.png'; +import { Toolbox, ToolboxControl, ToolboxTitle, ToolboxRow, ToolboxButton, ToolboxCheckbox, } from './toolbox'; +var COMPOSITE_MODE = new CompositeMode([new DrawLineStringMode(), new ModifyMode()]); +var styles = { + mapContainer: { + alignItems: 'stretch', + display: 'flex', + height: '100vh', + }, + checkbox: { + margin: 10, + }, +}; +var initialViewport = { + bearing: 0, + height: 0, + latitude: 37.76, + longitude: -122.44, + pitch: 0, + width: 0, + zoom: 11, +}; +var ALL_MODES = [ + { + category: 'View', + modes: [ + { label: 'View', mode: ViewMode }, + { label: 'Measure Distance', mode: MeasureDistanceMode }, + { label: 'Measure Area', mode: MeasureAreaMode }, + { label: 'Measure Angle', mode: MeasureAngleMode }, + ], + }, + { + category: 'Draw', + modes: [ + { label: 'Draw Point', mode: DrawPointMode }, + { label: 'Draw LineString', mode: DrawLineStringMode }, + { label: 'Draw Polygon', mode: DrawPolygonMode }, + { label: 'Draw 90° Polygon', mode: Draw90DegreePolygonMode }, + { label: 'Draw Polygon By Dragging', mode: DrawPolygonByDraggingMode }, + { label: 'Draw Rectangle', mode: DrawRectangleMode }, + { label: 'Draw Rectangle Using 3 Points', mode: DrawRectangleUsingThreePointsMode }, + { label: 'Draw Circle From Center', mode: DrawCircleFromCenterMode }, + { label: 'Draw Circle By Diameter', mode: DrawCircleByDiameterMode }, + { label: 'Draw Ellipse By Bounding Box', mode: DrawEllipseByBoundingBoxMode }, + { label: 'Draw Ellipse Using 3 Points', mode: DrawEllipseUsingThreePointsMode }, + ], + }, + { + category: 'Alter', + modes: [ + { label: 'Modify', mode: ModifyMode }, + { label: 'Elevation', mode: ElevationMode }, + { label: 'Translate', mode: new SnappableMode(new TranslateMode()) }, + { label: 'Rotate', mode: RotateMode }, + { label: 'Scale', mode: ScaleMode }, + { label: 'Duplicate', mode: DuplicateMode }, + { label: 'Extend LineString', mode: ExtendLineStringMode }, + { label: 'Extrude', mode: ExtrudeMode }, + { label: 'Split', mode: SplitPolygonMode }, + { label: 'Transform', mode: new SnappableMode(new TransformMode()) }, + ], + }, + { + category: 'Composite', + modes: [{ label: 'Draw LineString + Modify', mode: COMPOSITE_MODE }], + }, +]; +var POLYGON_DRAWING_MODES = [ + DrawPolygonMode, + Draw90DegreePolygonMode, + DrawPolygonByDraggingMode, + DrawRectangleMode, + DrawRectangleUsingThreePointsMode, + DrawCircleFromCenterMode, + DrawCircleByDiameterMode, + DrawEllipseByBoundingBoxMode, + DrawEllipseUsingThreePointsMode, +]; +var TWO_CLICK_POLYGON_MODES = [ + DrawRectangleMode, + DrawCircleFromCenterMode, + DrawCircleByDiameterMode, + DrawEllipseByBoundingBoxMode, +]; +var EMPTY_FEATURE_COLLECTION = { + type: 'FeatureCollection', + features: [], +}; +function hex2rgb(hex) { + var value = parseInt(hex, 16); + return [16, 8, 0].map(function (shift) { return ((value >> shift) & 0xff) / 255; }); +} +var FEATURE_COLORS = [ + '00AEE4', + 'DAF0E3', + '9BCC32', + '07A35A', + 'F7DF90', + 'EA376C', + '6A126A', + 'FCB09B', + 'B0592D', + 'C1B5E3', + '9C805B', + 'CCDFE5', +].map(hex2rgb); +// TODO edit-modes: delete once fully on EditMode implementation and just use handle.properties.editHandleType... +// Unwrap the edit handle object from either layer implementation +function getEditHandleTypeFromEitherLayer(handleOrFeature) { + if (handleOrFeature.__source) { + return handleOrFeature.__source.object.properties.editHandleType; + } + else if (handleOrFeature.sourceFeature) { + return handleOrFeature.sourceFeature.feature.properties.editHandleType; + } + else if (handleOrFeature.properties) { + return handleOrFeature.properties.editHandleType; + } + return handleOrFeature.type; +} +function getEditHandleColor(handle) { + switch (getEditHandleTypeFromEitherLayer(handle)) { + case 'existing': + return [0xff, 0x80, 0x00, 0xff]; + case 'snap-source': + return [0xc0, 0x80, 0xf0, 0xff]; + case 'intermediate': + default: + return [0xff, 0xc0, 0x80, 0xff]; + } +} +var Example = /** @class */ (function (_super) { + __extends(Example, _super); + function Example(props) { + var _this = _super.call(this, props) || this; + _this._onChangeViewport = function (viewport) { + _this.setState({ + viewport: __assign(__assign({}, _this.state.viewport), viewport), + }); + }; + _this._onLayerClick = function (info) { + console.log('onLayerClick', info); // eslint-disable-line + if (_this.state.mode !== ViewMode || _this.state.selectionTool) { + // don't change selection while editing + return; + } + if (info) { + console.log("select editing feature " + info.index); // eslint-disable-line + // a feature was clicked + _this.setState({ selectedFeatureIndexes: [info.index] }); + } + else { + console.log('deselect editing feature'); // eslint-disable-line + // open space was clicked, so stop editing + _this.setState({ selectedFeatureIndexes: [] }); + } + }; + _this._resize = function () { + _this.forceUpdate(); + }; + _this._loadSample = function (type) { + if (type === 'mixed') { + _this.setState({ + testFeatures: sampleGeoJson, + selectedFeatureIndexes: [], + }); + } + else if (type === 'complex') { + _this.setState({ + testFeatures: { + type: 'FeatureCollection', + features: [ + circle([-122.45, 37.81], 4, { steps: 5000 }), + circle([-122.33, 37.81], 4, { steps: 5000 }), + circle([-122.45, 37.73], 4, { steps: 5000 }), + circle([-122.33, 37.73], 4, { steps: 5000 }), + ], + }, + selectedFeatureIndexes: [], + }); + } + else if (type === 'blank') { + _this.setState({ + testFeatures: EMPTY_FEATURE_COLLECTION, + selectedFeatureIndexes: [], + }); + } + else if (type === 'file') { + var el = document.createElement('input'); + el.type = 'file'; + el.onchange = function (e) { + var eventTarget = e.target; + if (eventTarget.files && eventTarget.files[0]) { + var reader = new FileReader(); + reader.onload = function (_a) { + var target = _a.target; + _this._parseStringJson(target.result); + }; + reader.readAsText(eventTarget.files[0]); + } + }; + el.click(); + } + }; + _this._copy = function () { + if (navigator && navigator.clipboard) { + navigator.clipboard.writeText(JSON.stringify(_this.state.testFeatures)); + } + else { + _this._error('No navigator.clipboard'); + } + }; + _this._paste = function () { + if (navigator && navigator.clipboard) { + navigator.clipboard.readText().then(function (value) { + _this._parseStringJson(value); + }, function (reason) { + _this._error(reason); + }); + } + else { + _this._error('No navigator.clipboard'); + } + }; + _this._download = function () { + var blob = new Blob([JSON.stringify(_this.state.testFeatures)], { type: 'octet/stream' }); + var a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = 'nebula.geojson'; + a.click(); + }; + _this._parseStringJson = function (json) { + var testFeatures = null; + try { + testFeatures = JSON.parse(json); + if (Array.isArray(testFeatures)) { + testFeatures = { + type: 'FeatureCollection', + features: testFeatures, + }; + } + // eslint-disable-next-line + console.log('Loaded JSON:', testFeatures); + _this.setState({ testFeatures: testFeatures }); + } + catch (err) { + _this._error(err); + } + }; + _this._error = function (err) { + // eslint-disable-next-line + alert(err); + }; + _this.onEdit = function (_a) { + var updatedData = _a.updatedData, editType = _a.editType, editContext = _a.editContext; + var updatedSelectedFeatureIndexes = _this.state.selectedFeatureIndexes; + if (!['movePosition', 'extruding', 'rotating', 'translating', 'scaling'].includes(editType)) { + // Don't log edits that happen as the pointer moves since they're really chatty + var updatedDataInfo = featuresToInfoString(updatedData); + // eslint-disable-next-line + console.log('onEdit', editType, editContext, updatedDataInfo); + } + if (editType === 'removePosition' && !_this.state.pointsRemovable) { + // This is a simple example of custom handling of edits + // reject the edit + return; + } + if (editType === 'addFeature' && _this.state.mode !== DuplicateMode) { + var featureIndexes = editContext.featureIndexes; + // Add the new feature to the selection + updatedSelectedFeatureIndexes = __spread(_this.state.selectedFeatureIndexes, featureIndexes); + } + _this.setState({ + testFeatures: updatedData, + selectedFeatureIndexes: updatedSelectedFeatureIndexes, + }); + }; + _this.getFillColor = function (feature, isSelected) { + var index = _this.state.testFeatures.features.indexOf(feature); + return isSelected + ? _this._getDeckColorForFeature(index, 1.0, 0.5) + : _this._getDeckColorForFeature(index, 0.5, 0.5); + }; + _this.getLineColor = function (feature, isSelected) { + var index = _this.state.testFeatures.features.indexOf(feature); + return isSelected + ? _this._getDeckColorForFeature(index, 1.0, 1.0) + : _this._getDeckColorForFeature(index, 0.5, 1.0); + }; + _this.state = { + viewport: initialViewport, + testFeatures: sampleGeoJson, + mode: DrawPolygonMode, + modeConfig: null, + pointsRemovable: true, + selectedFeatureIndexes: [], + editHandleType: 'point', + selectionTool: null, + showGeoJson: false, + pathMarkerLayer: false, + featureMenu: null, + }; + return _this; + } + Example.prototype.componentDidMount = function () { + window.addEventListener('resize', this._resize); + }; + Example.prototype.componentWillUnmount = function () { + window.removeEventListener('resize', this._resize); + }; + Example.prototype._getHtmlColorForFeature = function (index, selected) { + var length = FEATURE_COLORS.length; + var color = FEATURE_COLORS[index % length].map(function (c) { return c * 255; }).join(','); + var alpha = selected ? 1.0 : 0.7; + return "rgba(" + color + ", " + alpha + ")"; + }; + Example.prototype._getDeckColorForFeature = function (index, bright, alpha) { + var length = FEATURE_COLORS.length; + var color = FEATURE_COLORS[index % length].map(function (c) { return c * bright * 255; }); + return __spread(color, [alpha * 255]); + }; + Example.prototype._renderSelectFeatureCheckbox = function (index, featureType) { + var _this = this; + var selectedFeatureIndexes = this.state.selectedFeatureIndexes; + return (React.createElement("div", { key: index }, + React.createElement(ToolboxCheckbox, { style: styles.checkbox, type: "checkbox", checked: selectedFeatureIndexes.includes(index), onChange: function () { + if (selectedFeatureIndexes.includes(index)) { + _this.setState({ + selectedFeatureIndexes: selectedFeatureIndexes.filter(function (e) { return e !== index; }), + }); + } + else { + _this.setState({ + selectedFeatureIndexes: __spread(selectedFeatureIndexes, [index]), + }); + } + } }, + React.createElement("span", { style: { + color: this._getHtmlColorForFeature(index, selectedFeatureIndexes.includes(index)), + } }, + index, + ': ', + featureType), + React.createElement("a", { style: { position: 'absolute', right: 12 }, onClick: function (e) { + e.preventDefault(); + e.stopPropagation(); + _this.setState({ + selectedFeatureIndexes: [index], + featureMenu: { index: index, x: e.clientX, y: e.clientY }, + }); + } }, ">>")))); + }; + Example.prototype._renderSelectFeatureCheckboxes = function () { + var features = this.state.testFeatures.features; + var checkboxes = []; + for (var i = 0; i < features.length; ++i) { + checkboxes.push(this._renderSelectFeatureCheckbox(i, features[i].geometry.type)); + } + return checkboxes; + }; + Example.prototype._renderBooleanOperationControls = function () { + var _this = this; + var operations = ['union', 'difference', 'intersection']; + return (React.createElement(ToolboxRow, { key: "booleanOperations" }, + React.createElement(ToolboxTitle, null, + "Boolean operation", + React.createElement("br", null), + "(requires single selection)"), + React.createElement(ToolboxControl, null, operations.map(function (operation) { return (React.createElement(ToolboxButton, { key: operation, selected: _this.state.modeConfig && _this.state.modeConfig.booleanOperation === operation, onClick: function () { + if (_this.state.modeConfig && _this.state.modeConfig.booleanOperation === operation) { + _this.setState({ + modeConfig: __assign(__assign({}, (_this.state.modeConfig || {})), { booleanOperation: null }), + }); + } + else { + _this.setState({ + modeConfig: __assign(__assign({}, (_this.state.modeConfig || {})), { booleanOperation: operation }), + }); + } + } }, operation)); })))); + }; + Example.prototype._renderTwoClickPolygonControls = function () { + var _this = this; + return (React.createElement(ToolboxRow, { key: "twoClick" }, + React.createElement(ToolboxTitle, null, "Drag to draw"), + React.createElement(ToolboxControl, null, + React.createElement("input", { type: "checkbox", checked: Boolean(this.state.modeConfig && this.state.modeConfig.dragToDraw), onChange: function (event) { + return _this.setState({ + modeConfig: __assign(__assign({}, (_this.state.modeConfig || {})), { dragToDraw: Boolean(event.target.checked) }), + }); + } })))); + }; + Example.prototype._renderModifyModeControls = function () { + var _this = this; + return (React.createElement(ToolboxRow, { key: "modify" }, + React.createElement(ToolboxTitle, null, "Allow removing points"), + React.createElement(ToolboxControl, null, + React.createElement("input", { type: "checkbox", checked: this.state.pointsRemovable, onChange: function () { return _this.setState({ pointsRemovable: !_this.state.pointsRemovable }); } })))); + }; + Example.prototype._renderSplitModeControls = function () { + var _this = this; + return (React.createElement(ToolboxRow, { key: "split" }, + React.createElement(ToolboxTitle, null, "Constrain to 90\u00B0"), + React.createElement(ToolboxControl, null, + React.createElement("input", { type: "checkbox", checked: Boolean(this.state.modeConfig && this.state.modeConfig.lock90Degree), onChange: function (event) { + return _this.setState({ modeConfig: { lock90Degree: Boolean(event.target.checked) } }); + } })))); + }; + Example.prototype._renderSnappingControls = function () { + var _this = this; + return (React.createElement("div", { key: "snap" }, + React.createElement(ToolboxRow, null, + React.createElement(ToolboxTitle, null, "Enable snapping"), + React.createElement(ToolboxControl, null, + React.createElement("input", { type: "checkbox", checked: Boolean(this.state.modeConfig && this.state.modeConfig.enableSnapping), onChange: function (event) { + var modeConfig = __assign(__assign({}, _this.state.modeConfig), { enableSnapping: Boolean(event.target.checked) }); + _this.setState({ modeConfig: modeConfig }); + } }))))); + }; + Example.prototype._renderMeasureDistanceControls = function () { + var _this = this; + return (React.createElement(ToolboxRow, { key: "measure-distance" }, + React.createElement(ToolboxTitle, null, "Units"), + React.createElement(ToolboxControl, null, + React.createElement("select", { value: (this.state.modeConfig && + this.state.modeConfig.turfOptions && + this.state.modeConfig.turfOptions.units) || + 'kilometers', onChange: function (event) { + return _this.setState({ modeConfig: { turfOptions: { units: event.target.value } } }); + } }, + React.createElement("option", { value: "kilometers" }, "kilometers"), + React.createElement("option", { value: "miles" }, "miles"), + React.createElement("option", { value: "degrees" }, "degrees"), + React.createElement("option", { value: "radians" }, "radians"))))); + }; + Example.prototype._renderModeConfigControls = function () { + var controls = []; + if (POLYGON_DRAWING_MODES.indexOf(this.state.mode) > -1) { + controls.push(this._renderBooleanOperationControls()); + } + // @ts-ignore + if (TWO_CLICK_POLYGON_MODES.indexOf(this.state.mode) > -1) { + controls.push(this._renderTwoClickPolygonControls()); + } + if (this.state.mode === ModifyMode) { + controls.push(this._renderModifyModeControls()); + } + if (this.state.mode === SplitPolygonMode) { + controls.push(this._renderSplitModeControls()); + } + if (this.state.mode instanceof SnappableMode) { + controls.push(this._renderSnappingControls()); + } + if (this.state.mode === MeasureDistanceMode) { + controls.push(this._renderMeasureDistanceControls()); + } + return controls; + }; + Example.prototype._renderToolBox = function () { + var _this = this; + return (React.createElement(Toolbox, null, + ALL_MODES.map(function (category) { return (React.createElement(ToolboxRow, { key: category.category }, + React.createElement(ToolboxTitle, null, + category.category, + " Modes"), + category.modes.map(function (_a) { + var mode = _a.mode, label = _a.label; + return (React.createElement(ToolboxButton, { key: label, selected: _this.state.mode === mode, onClick: function () { + _this.setState({ mode: mode, modeConfig: {}, selectionTool: null }); + } }, label)); + }))); }), + this._renderModeConfigControls(), + this.state.showGeoJson && (React.createElement(React.Fragment, null, + React.createElement(ToolboxTitle, null, "GeoJSON"), + React.createElement(ToolboxButton, { onClick: function () { return _this.setState({ showGeoJson: !_this.state.showGeoJson }); } }, "hide \u25B2"), + React.createElement(ToolboxControl, null, + React.createElement("textarea", { id: "geo-json-text", rows: 5, style: { width: '100%' }, value: JSON.stringify(this.state.testFeatures), onChange: function (event) { + return _this.setState({ testFeatures: JSON.parse(event.target.value) }); + } })))), + !this.state.showGeoJson && (React.createElement(React.Fragment, null, + React.createElement(ToolboxTitle, null, "GeoJSON"), + React.createElement(ToolboxButton, { onClick: function () { return _this.setState({ showGeoJson: !_this.state.showGeoJson }); } }, "show \u25BC"))), + React.createElement(ToolboxButton, { onClick: function () { return _this._copy(); } }, "Copy"), + React.createElement(ToolboxButton, { onClick: function () { return _this._paste(); } }, "Paste"), + React.createElement(ToolboxButton, { onClick: function () { return _this._download(); } }, "Download"), + React.createElement(ToolboxRow, null, + React.createElement(ToolboxTitle, null, "Load data"), + React.createElement(ToolboxControl, null, + React.createElement(ToolboxButton, { onClick: function () { return _this._loadSample('mixed'); } }, "Mixed Sample"), + React.createElement(ToolboxButton, { onClick: function () { return _this._loadSample('complex'); } }, "Complex Sample"), + React.createElement(ToolboxButton, { onClick: function () { return _this._loadSample('blank'); } }, "Blank"), + React.createElement(ToolboxButton, { onClick: function () { return _this._loadSample('file'); } }, "Open file..."))), + React.createElement(ToolboxRow, null, + React.createElement(ToolboxTitle, null, "Options"), + React.createElement(ToolboxControl, null, + React.createElement(ToolboxCheckbox, { type: "checkbox", checked: this.state.editHandleType === 'icon', onChange: function () { + return _this.setState({ + editHandleType: _this.state.editHandleType === 'icon' ? 'point' : 'icon', + }); + } }, "Use Icons")), + React.createElement(ToolboxControl, null, + React.createElement(ToolboxCheckbox, { type: "checkbox", checked: this.state.editHandleType === 'elevated', onChange: function () { + return _this.setState({ + editHandleType: _this.state.editHandleType === 'elevated' ? 'point' : 'elevated', + }); + } }, "Use ElevatedEditHandleLayer")), + React.createElement(ToolboxControl, null, + React.createElement(ToolboxCheckbox, { type: "checkbox", checked: this.state.pathMarkerLayer, onChange: function () { + return _this.setState({ + pathMarkerLayer: !_this.state.pathMarkerLayer, + }); + } }, "Use PathMarkerLayer"))), + React.createElement(ToolboxRow, null, + React.createElement(ToolboxTitle, null, "Select Features"), + React.createElement(ToolboxControl, null, + React.createElement(ToolboxButton, { onClick: function () { + return _this.setState({ selectedFeatureIndexes: [], selectionTool: SELECTION_TYPE.NONE }); + } }, "Clear Selection"), + React.createElement(ToolboxButton, { onClick: function () { + return _this.setState({ mode: ViewMode, selectionTool: SELECTION_TYPE.RECTANGLE }); + } }, "Rect Select"), + React.createElement(ToolboxButton, { onClick: function () { + return _this.setState({ mode: ViewMode, selectionTool: SELECTION_TYPE.POLYGON }); + } }, "Lasso Select"))), + React.createElement(ToolboxTitle, null, "Features"), + React.createElement(ToolboxRow, null, this._renderSelectFeatureCheckboxes()))); + }; + Example.prototype.renderStaticMap = function (viewport) { + // @ts-ignore + return React.createElement(StaticMap, __assign({}, viewport, { mapStyle: 'mapbox://styles/mapbox/dark-v10' })); + }; + Example.prototype._featureMenuClick = function (action) { + var index = (this.state.featureMenu || {}).index; + var testFeatures = this.state.testFeatures; + if (action === 'delete') { + var features = __spread(testFeatures.features); + features.splice(index, 1); + testFeatures = Object.assign({}, testFeatures, { + features: features, + }); + } + else if (action === 'split') { + // TODO + } + else if (action === 'info') { + // eslint-disable-next-line + console.log(testFeatures.features[index]); + } + this.setState({ featureMenu: null, testFeatures: testFeatures }); + }; + Example.prototype._renderFeatureMenu = function (_a) { + var _this = this; + var x = _a.x, y = _a.y; + return (React.createElement("div", { style: { position: 'fixed', top: y - 40, left: x + 20 } }, + React.createElement(ToolboxButton, { onClick: function () { return _this._featureMenuClick('delete'); } }, "Delete"), + React.createElement(ToolboxButton, { onClick: function () { return _this._featureMenuClick('split'); } }, "Split"), + React.createElement(ToolboxButton, { onClick: function () { return _this._featureMenuClick('info'); } }, "Info"), + React.createElement(ToolboxButton, { onClick: function () { return _this._featureMenuClick(''); } }, "Close"))); + }; + Example.prototype.customizeLayers = function (layers) { }; + Example.prototype.render = function () { + var _this = this; + var _a = this.state, testFeatures = _a.testFeatures, selectedFeatureIndexes = _a.selectedFeatureIndexes, mode = _a.mode; + var modeConfig = this.state.modeConfig; + var viewport = __assign(__assign({}, this.state.viewport), { height: window.innerHeight, width: window.innerWidth }); + if (mode === ElevationMode) { + modeConfig = __assign(__assign({}, modeConfig), { viewport: viewport, calculateElevationChange: function (opts) { + return ElevationMode.calculateElevationChangeWithViewport(viewport, opts); + } }); + } + else if (mode === ModifyMode) { + modeConfig = __assign(__assign({}, modeConfig), { viewport: viewport }); + } + else if (mode instanceof SnappableMode && modeConfig && modeConfig.enableSnapping) { + // Snapping can be accomplished to features that aren't rendered in the same layer + modeConfig = __assign(__assign({}, modeConfig), { additionalSnapTargets: [ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.52235, 37.734008], + [-122.52217, 37.712706], + [-122.49436, 37.711979], + [-122.49725, 37.734306], + [-122.52235, 37.734008], + ], + ], + }, + }, + ] }); + } + else if (mode === DrawPolygonByDraggingMode) { + modeConfig = __assign(__assign({}, modeConfig), { throttleMs: 100 }); + } + // Demonstrate how to override sub layer properties + var _subLayerProps = { + tooltips: { + getColor: [255, 255, 255, 255], + }, + }; + if (this.state.editHandleType === 'elevated') { + _subLayerProps = Object.assign(_subLayerProps, { + guides: { + _subLayerProps: { + points: { + type: ElevatedEditHandleLayer, + getFillColor: [0, 255, 0], + }, + }, + }, + }); + } + if (this.state.pathMarkerLayer) { + _subLayerProps = Object.assign(_subLayerProps, { + geojson: { + _subLayerProps: { + 'line-strings': { + type: PathMarkerLayer, + getMarkerColor: function (x) { return [255, 255, 255, 255]; }, + sizeScale: 1500, + }, + }, + }, + }); + } + var editableGeoJsonLayer = new EditableGeoJsonLayer({ + id: 'geojson', + data: testFeatures, + // @ts-ignore + selectedFeatureIndexes: selectedFeatureIndexes, + mode: mode, + modeConfig: modeConfig, + autoHighlight: false, + // Editing callbacks + onEdit: this.onEdit, + editHandleType: this.state.editHandleType, + // test using icons for edit handles + editHandleIconAtlas: iconSheet, + editHandleIconMapping: { + intermediate: { + x: 0, + y: 0, + width: 58, + height: 58, + mask: false, + }, + existing: { + x: 58, + y: 0, + width: 58, + height: 58, + mask: false, + }, + 'snap-source': { + x: 58, + y: 0, + width: 58, + height: 58, + mask: false, + }, + 'snap-target': { + x: 0, + y: 0, + width: 58, + height: 58, + mask: false, + }, + }, + getEditHandleIcon: function (d) { return getEditHandleTypeFromEitherLayer(d); }, + getEditHandleIconSize: 40, + getEditHandleIconColor: getEditHandleColor, + // Specify the same GeoJsonLayer props + // lineWidthMinPixels: 2, + pointRadiusMinPixels: 5, + // getLineDashArray: () => [0, 0], + // Accessors receive an isSelected argument + getFillColor: this.getFillColor, + getLineColor: this.getLineColor, + // Can customize editing points props + getEditHandlePointColor: getEditHandleColor, + editHandlePointRadiusScale: 2, + // customize tentative feature style + // getTentativeLineDashArray: () => [7, 4], + // getTentativeLineColor: () => [0x8f, 0x8f, 0x8f, 0xff], + _subLayerProps: _subLayerProps, + parameters: { + depthTest: true, + depthMask: false, + blend: true, + blendEquation: GL.FUNC_ADD, + blendFunc: [GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA], + }, + }); + var layers = [editableGeoJsonLayer]; + if (this.state.selectionTool) { + layers.push(new SelectionLayer({ + id: 'selection', + // @ts-ignore + selectionType: this.state.selectionTool, + onSelect: function (_a) { + var pickingInfos = _a.pickingInfos; + _this.setState({ selectedFeatureIndexes: pickingInfos.map(function (pi) { return pi.index; }) }); + }, + layerIds: ['geojson'], + getTentativeFillColor: function () { return [255, 0, 255, 100]; }, + getTentativeLineColor: function () { return [0, 0, 255, 255]; }, + lineWidthMinPixels: 3, + })); + } + this.customizeLayers(layers); + return (React.createElement("div", { style: styles.mapContainer }, + React.createElement("link", { href: "https://api.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.css", rel: "stylesheet" }), + React.createElement(DeckGL, { viewState: viewport, getCursor: editableGeoJsonLayer.getCursor.bind(editableGeoJsonLayer), layers: layers, height: "100%", width: "100%", views: [ + new MapView({ + id: 'basemap', + controller: { + type: MapController, + // @ts-ignore + doubleClickZoom: this.state.mode === 'view' && !this.state.selectionTool, + }, + }), + ], onClick: this._onLayerClick, onViewStateChange: function (_a) { + var viewState = _a.viewState; + return _this.setState({ viewport: viewState }); + } }, this.renderStaticMap(viewport)), + this._renderToolBox(), + this.state.featureMenu && this._renderFeatureMenu(this.state.featureMenu))); + }; + return Example; +}(React.Component)); +export default Example; +function featuresToInfoString(featureCollection) { + var info = featureCollection.features.map(function (feature) { return feature.geometry.type + "(" + getPositionCount(feature.geometry) + ")"; }); + return JSON.stringify(info); +} +function getPositionCount(geometry) { + var flatMap = function (f, arr) { return arr.reduce(function (x, y) { return __spread(x, f(y)); }, []); }; + var type = geometry.type, coordinates = geometry.coordinates; + switch (type) { + case 'Point': + return 1; + case 'LineString': + case 'MultiPoint': + return coordinates.length; + case 'Polygon': + case 'MultiLineString': + return flatMap(function (x) { return x; }, coordinates).length; + case 'MultiPolygon': + return flatMap(function (x) { return flatMap(function (y) { return y; }, x); }, coordinates).length; + default: + throw Error("Unknown geometry type: " + type); + } +} +//# sourceMappingURL=example.js.map \ No newline at end of file diff --git a/lib/examples/advanced/src/example.js.map b/lib/examples/advanced/src/example.js.map new file mode 100644 index 000000000..a66c3b41a --- /dev/null +++ b/lib/examples/advanced/src/example.js.map @@ -0,0 +1 @@ +{"version":3,"file":"example.js","sourceRoot":"","sources":["../../../../examples/advanced/src/example.tsx"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpC,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,+BAA+B,EAC/B,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EAC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AG,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,gBAAI,CAAC,EAAK,CAAC,CAAC,CAAC,CAAC,GAAd,CAAe,EAAE,EAAE,CAAC,EAAzC,CAAyC,CAAC;IAE9D,IAAA,oBAAI,EAAE,kCAAW,CAAc;IACvC,QAAQ,IAAI,EAAE;QACZ,KAAK,OAAO;YACV,OAAO,CAAC,CAAC;QACX,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,WAAW,CAAC,MAAM,CAAC;QAC5B,KAAK,SAAS,CAAC;QACf,KAAK,iBAAiB;YACpB,OAAO,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC;QAC/C,KAAK,cAAc;YACjB,OAAO,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,EAAE,CAAC,CAAC,EAApB,CAAoB,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC;QAClE;YACE,MAAM,KAAK,CAAC,4BAA0B,IAAM,CAAC,CAAC;KACjD;AACH,CAAC"} \ No newline at end of file diff --git a/lib/examples/advanced/src/toolbox.d.ts b/lib/examples/advanced/src/toolbox.d.ts new file mode 100644 index 000000000..4a54d1450 --- /dev/null +++ b/lib/examples/advanced/src/toolbox.d.ts @@ -0,0 +1,9 @@ +export declare const Toolbox: import("styled-components").StyledComponent<"div", any, {}, never>; +export declare const ToolboxRow: (props: any) => JSX.Element; +export declare const ToolboxControl: (props: any) => JSX.Element; +export declare const ToolboxTitle: import("styled-components").StyledComponent<"div", any, {}, never>; +export declare const ToolboxButton: import("styled-components").StyledComponent<"button", any, { + selected?: boolean; +}, never>; +export declare const ToolboxCheckbox: (props: any) => JSX.Element; +//# sourceMappingURL=toolbox.d.ts.map \ No newline at end of file diff --git a/lib/examples/advanced/src/toolbox.d.ts.map b/lib/examples/advanced/src/toolbox.d.ts.map new file mode 100644 index 000000000..1a1d5f88b --- /dev/null +++ b/lib/examples/advanced/src/toolbox.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"toolbox.d.ts","sourceRoot":"","sources":["../../../../examples/advanced/src/toolbox.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO,oEAYnB,CAAC;AAEF,eAAO,MAAM,UAAU,6BAAyC,CAAC;AACjE,eAAO,MAAM,cAAc,6BAAoE,CAAC;AAEhG,eAAO,MAAM,YAAY,oEAOxB,CAAC;AAKF,eAAO,MAAM,aAAa;;SAezB,CAAC;AAqBF,eAAO,MAAM,eAAe,6BAO3B,CAAC"} \ No newline at end of file diff --git a/lib/examples/advanced/src/toolbox.js b/lib/examples/advanced/src/toolbox.js new file mode 100644 index 000000000..2fe083d1d --- /dev/null +++ b/lib/examples/advanced/src/toolbox.js @@ -0,0 +1,23 @@ +import { __assign, __makeTemplateObject } from "tslib"; +import * as React from 'react'; +import styled from 'styled-components'; +var styles = { + toolboxItem: { + flexBasis: '50%', + }, +}; +export var Toolbox = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0px;\n left: 0px;\n color: #f0f0f0;\n padding: 0;\n width: 230px;\n height: 100%;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n overflow: scroll;\n z-index: 999;\n"], ["\n position: absolute;\n top: 0px;\n left: 0px;\n color: #f0f0f0;\n padding: 0;\n width: 230px;\n height: 100%;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 16px;\n overflow: scroll;\n z-index: 999;\n"]))); +export var ToolboxRow = function (props) { return React.createElement("div", null, props.children); }; +export var ToolboxControl = function (props) { return React.createElement("div", { style: styles.toolboxItem }, props.children); }; +export var ToolboxTitle = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: rgba(39, 45, 59, 0.8);\n font-size: 16px;\n height: 44px;\n display: flex;\n align-items: center;\n padding: 0px 8px;\n"], ["\n background: rgba(39, 45, 59, 0.8);\n font-size: 16px;\n height: 44px;\n display: flex;\n align-items: center;\n padding: 0px 8px;\n"]))); +var buttonBackground = function (props) { + return props.selected ? 'rgba(30, 84, 183, 0.8)' : 'rgba(23, 28, 41, 0.8)'; +}; +export var ToolboxButton = styled.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: block;\n width: 100%;\n border: none;\n color: #f0f0f0;\n background: ", ";\n text-align: left;\n font-size: 16px;\n outline: none;\n height: 44px;\n cursor: pointer;\n\n &:hover {\n background: #276ef1;\n }\n"], ["\n display: block;\n width: 100%;\n border: none;\n color: #f0f0f0;\n background: ", ";\n text-align: left;\n font-size: 16px;\n outline: none;\n height: 44px;\n cursor: pointer;\n\n &:hover {\n background: #276ef1;\n }\n"])), buttonBackground); +var ToolboxCheckboxContainer = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n width: 100%;\n border: none;\n color: #f0f0f0;\n background: ", ";\n text-align: left;\n text-transform: capitalize;\n font-size: 16px;\n outline: none;\n height: 44px;\n cursor: pointer;\n\n &:hover {\n background: #276ef1;\n }\n"], ["\n display: flex;\n align-items: center;\n width: 100%;\n border: none;\n color: #f0f0f0;\n background: ", ";\n text-align: left;\n text-transform: capitalize;\n font-size: 16px;\n outline: none;\n height: 44px;\n cursor: pointer;\n\n &:hover {\n background: #276ef1;\n }\n"])), buttonBackground); +export var ToolboxCheckbox = function (props) { return (React.createElement("label", null, + React.createElement(ToolboxCheckboxContainer, null, + React.createElement("input", __assign({}, __assign(__assign({}, props), { children: null }))), + props.children))); }; +var templateObject_1, templateObject_2, templateObject_3, templateObject_4; +//# sourceMappingURL=toolbox.js.map \ No newline at end of file diff --git a/lib/examples/advanced/src/toolbox.js.map b/lib/examples/advanced/src/toolbox.js.map new file mode 100644 index 000000000..4baa37363 --- /dev/null +++ b/lib/examples/advanced/src/toolbox.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toolbox.js","sourceRoot":"","sources":["../../../../examples/adv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/data/sample-geojson.json new file mode 100644 index 000000000..8f6900134 --- /dev/null +++ b/lib/examples/data/sample-geojson.json @@ -0,0 +1,177 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "marker-color": "#ff0000", + "marker-size": "medium", + "marker-symbol": "" + }, + "geometry": { + "type": "Point", + "coordinates": [-122.44477272033691, 37.79906910652822] + } + }, + { + "type": "Feature", + "properties": { + "marker-color": "#0000ff", + "marker-size": "large", + "marker-symbol": "" + }, + "geometry": { + "type": "Point", + "coordinates": [-122.42451667785645, 37.8019175085504] + } + }, + { + "type": "Feature", + "properties": { + "marker-size": "small" + }, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [-122.46923446655273, 37.803273851858656], + [-122.46957778930665, 37.79934038764369], + [-122.46434211730958, 37.80313821864869], + [-122.46451377868652, 37.8001542250124] + ] + } + }, + { + "type": "Feature", + "properties": { + "stroke": "#ff0000", + "stroke-width": 10, + "stroke-opacity": 1 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [-122.40880966186523, 37.783536601521924], + [-122.43893623352051, 37.779669924659004], + [-122.43515968322752, 37.7624370109886], + [-122.42348670959471, 37.77180027337861], + [-122.4250316619873, 37.778584505321376], + [-122.42314338684082, 37.778652344496926], + [-122.42357254028322, 37.77987343901049], + [-122.41198539733887, 37.78109451335266] + ] + } + }, + { + "type": "Feature", + "properties": { + "stroke": "#408000", + "stroke-width": 2, + "stroke-opacity": 1 + }, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [[-122.39670753479004, 37.7947284731866], [-122.44726181030273, 37.788352705583755]], + [[-122.44709014892577, 37.78733524495977], [-122.39670753479004, 37.79371110035437]] + ] + } + }, + { + "type": "Feature", + "properties": { + "stroke": "#800000", + "stroke-width": 3, + "stroke-opacity": 0.5, + "fill": "#ffff66", + "fill-opacity": 1 + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-122.51129150390625, 37.771461045439764], + [-122.46588706970215, 37.77342854582093], + [-122.45464324951172, 37.77471756940714], + [-122.45284080505371, 37.76644028998291], + [-122.45747566223145, 37.765761783370465], + [-122.45902061462401, 37.76644028998291], + [-122.5100040435791, 37.763997637045456], + [-122.51026153564452, 37.767254489700846], + [-122.51129150390625, 37.771461045439764] + ], + [ + [-122.50802993774414, 37.770239811973674], + [-122.45644569396974, 37.77302148107203], + [-122.45515823364258, 37.76759373693769], + [-122.45884895324706, 37.76847577247014], + [-122.50811576843262, 37.765693932366865], + [-122.50802993774414, 37.770239811973674] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "stroke": "#004080", + "stroke-width": 2, + "stroke-opacity": 1, + "fill": "#66ff66", + "fill-opacity": 0.5 + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [-122.4717664718628, 37.73094604426975], + [-122.47253894805908, 37.71706268973759], + [-122.47116565704346, 37.71275119199666], + [-122.47017860412596, 37.71275119199666], + [-122.46803283691405, 37.712411693330296], + [-122.46524333953857, 37.712445643266925], + [-122.46339797973633, 37.71146108878938], + [-122.46026515960692, 37.71037466866717], + [-122.45494365692137, 37.7111215842122], + [-122.44975090026854, 37.71533133102705], + [-122.4481201171875, 37.72123815310796], + [-122.45236873626708, 37.723037263958275], + [-122.4605655670166, 37.72480238685191], + [-122.46584415435791, 37.72670324138648], + [-122.46803283691405, 37.72863798965106], + [-122.468204498291, 37.72938472107615], + [-122.4717664718628, 37.73094604426975] + ] + ], + [ + [ + [-122.435245513916, 37.73155698786267], + [-122.42983818054199, 37.73237157147889], + [-122.42563247680664, 37.73155698786267], + [-122.42048263549805, 37.73182851673044], + [-122.41559028625487, 37.732100044602525], + [-122.40846633911133, 37.73488314788311], + [-122.40752220153807, 37.73732676207096], + [-122.40769386291502, 37.74173863896063], + [-122.4052906036377, 37.74920429313147], + [-122.4085521697998, 37.748322027789115], + [-122.42511749267578, 37.74777909004261], + [-122.42374420166016, 37.73977029560411], + [-122.42683410644533, 37.73603708685575], + [-122.435245513916, 37.73155698786267] + ] + ], + [ + [ + [-122.49532699584961, 37.75347973770911], + [-122.493953704834, 37.73379707124429], + [-122.4752426147461, 37.73488314788311], + [-122.47644424438477, 37.75429408009598], + [-122.49532699584961, 37.75347973770911] + ] + ] + ] + } + } + ] +} diff --git a/lib/modules/edit-modes/src/geojson-types.d.ts b/lib/modules/edit-modes/src/geojson-types.d.ts new file mode 100644 index 000000000..ff4f3a6e2 --- /dev/null +++ b/lib/modules/edit-modes/src/geojson-types.d.ts @@ -0,0 +1,59 @@ +export declare type Position = [number, number] | [number, number, number]; +export declare type PointCoordinates = Position; +export declare type LineStringCoordinates = Position[]; +export declare type PolygonCoordinates = Position[][]; +export declare type MultiPointCoordinates = Position[]; +export declare type MultiLineStringCoordinates = Position[][]; +export declare type MultiPolygonCoordinates = Position[][][]; +export declare type AnyCoordinates = PointCoordinates | LineStringCoordinates | PolygonCoordinates | MultiPointCoordinates | MultiLineStringCoordinates | MultiPolygonCoordinates; +export declare type Point = { + type: 'Point'; + coordinates: PointCoordinates; +}; +export declare type LineString = { + type: 'LineString'; + coordinates: LineStringCoordinates; +}; +export declare type Polygon = { + type: 'Polygon'; + coordinates: PolygonCoordinates; +}; +export declare type MultiPoint = { + type: 'MultiPoint'; + coordinates: MultiPointCoordinates; +}; +export declare type MultiLineString = { + type: 'MultiLineString'; + coordinates: MultiLineStringCoordinates; +}; +export declare type MultiPolygon = { + type: 'MultiPolygon'; + coordinates: MultiPolygonCoordinates; +}; +export declare type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon; +export declare type Polygonal = Polygon | MultiPolygon; +export declare type BoundingBoxArray = [number, number, number, number]; +export declare type FeatureOf = { + type: 'Feature'; + geometry: T; + properties?: { + [key: string]: any; + }; + id?: string | number; + bbox?: BoundingBoxArray; +}; +export declare type FeatureWithProps = { + type: 'Feature'; + geometry: T; + properties: P; +}; +export declare type Feature = FeatureOf | FeatureOf | FeatureOf | FeatureOf | FeatureOf | FeatureOf; +export declare type FeatureCollection = { + type: 'FeatureCollection'; + features: Feature[]; + properties?: {}; + id?: string | number; + bbox?: BoundingBoxArray; +}; +export declare type AnyGeoJson = Feature | FeatureCollection; +//# sourceMappingURL=geojson-types.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/geojson-types.d.ts.map b/lib/modules/edit-modes/src/geojson-types.d.ts.map new file mode 100644 index 000000000..8c2920631 --- /dev/null +++ b/lib/modules/edit-modes/src/geojson-types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-types.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/src/geojson-types.ts"],"names":[],"mappings":"AAEA,oBAAY,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACnE,oBAAY,gBAAgB,GAAG,QAAQ,CAAC;AACxC,oBAAY,qBAAqB,GAAG,QAAQ,EAAE,CAAC;AAC/C,oBAAY,kBAAkB,GAAG,QAAQ,EAAE,EAAE,CAAC;AAC9C,oBAAY,qBAAqB,GAAG,QAAQ,EAAE,CAAC;AAC/C,oBAAY,0BAA0B,GAAG,QAAQ,EAAE,EAAE,CAAC;AACtD,oBAAY,uBAAuB,GAAG,QAAQ,EAAE,EAAE,EAAE,CAAC;AAErD,oBAAY,cAAc,GACtB,gBAAgB,GAChB,qBAAqB,GACrB,kBAAkB,GAClB,qBAAqB,GACrB,0BAA0B,GAC1B,uBAAuB,CAAC;AAE5B,oBAAY,KAAK,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB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B,CAAC;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,oBAAY,UAAU,GAAG,OAAO,GAAG,iBAAiB,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/geojson-types.js b/lib/modules/edit-modes/src/geojson-types.js new file mode 100644 index 000000000..72c5d830d --- /dev/null +++ b/lib/modules/edit-modes/src/geojson-types.js @@ -0,0 +1,2 @@ +// Geometry types +//# sourceMappingURL=geojson-types.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/geojson-types.js.map b/lib/modules/edit-modes/src/geojson-types.js.map new file mode 100644 index 000000000..3a9326c54 --- /dev/null +++ b/lib/modules/edit-modes/src/geojson-types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-types.js","sourceRoot":"","sources":["../../../../modules/edit-modes/src/geojson-types.ts"],"names":[],"mappings":"AAAA,iBAAiB"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/index.d.ts b/lib/modules/edit-modes/src/index.d.ts new file mode 100644 index 000000000..0e854988e --- /dev/null +++ b/lib/modules/edit-modes/src/index.d.ts @@ -0,0 +1,35 @@ +export type { EditMode } from './lib/edit-mode'; +export type { GeoJsonEditModeType } from './lib/geojson-edit-mode'; +export { GeoJsonEditMode } from './lib/geojson-edit-mode'; +export { ModifyMode } from './lib/modify-mode'; +export { TranslateMode } from './lib/translate-mode'; +export { ScaleMode } from './lib/scale-mode'; +export { RotateMode } from './lib/rotate-mode'; +export { DuplicateMode } from './lib/duplicate-mode'; +export { ExtendLineStringMode } from './lib/extend-line-string-mode'; +export { SplitPolygonMode } from './lib/split-polygon-mode'; +export { ExtrudeMode } from './lib/extrude-mode'; +export { ElevationMode } from './lib/elevation-mode'; +export { TransformMode } from './lib/transform-mode'; +export { DrawPointMode } from './lib/draw-point-mode'; +export { DrawLineStringMode } from './lib/draw-line-string-mode'; +export { DrawPolygonMode } from './lib/draw-polygon-mode'; +export { DrawRectangleMode } from './lib/draw-rectangle-mode'; +export { DrawCircleByDiameterMode } from './lib/draw-circle-by-diameter-mode'; +export { DrawCircleFromCenterMode } from './lib/draw-circle-from-center-mode'; +export { DrawEllipseByBoundingBoxMode } from './lib/draw-ellipse-by-bounding-box-mode'; +export { DrawEllipseUsingThreePointsMode } from './lib/draw-ellipse-using-three-points-mode'; +export { DrawRectangleUsingThreePointsMode } from './lib/draw-rectangle-using-three-points-mode'; +export { Draw90DegreePolygonMode } from './lib/draw-90degree-polygon-mode'; +export { DrawPolygonByDraggingMode } from './lib/draw-polygon-by-dragging-mode'; +export { ImmutableFeatureCollection } from './lib/immutable-feature-collection'; +export { ViewMode } from './lib/view-mode'; +export { MeasureDistanceMode } from './lib/measure-distance-mode'; +export { MeasureAreaMode } from './lib/measure-area-mode'; +export { MeasureAngleMode } from './lib/measure-angle-mode'; +export { CompositeMode } from './lib/composite-mode'; +export { SnappableMode } from './lib/snappable-mode'; +export { default as _memoize } from './memoize'; +export type { ScreenCoordinates, EditAction, Pick, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, DoubleClickEvent, ModeProps, GuideFeatureCollection, Viewport, Tooltip, } from './types'; +export type { Position, PointCoordinates, LineStringCoordinates, PolygonCoordinates, MultiPointCoordinates, MultiLineStringCoordinates, MultiPolygonCoordinates, AnyCoordinates, Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Geometry, Polygonal, BoundingBoxArray, FeatureOf, FeatureWithProps, Feature, FeatureCollection, AnyGeoJson, } from './geojson-types'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/index.d.ts.map b/lib/modules/edit-modes/src/index.d.ts.map new file mode 100644 index 000000000..461e2639e --- /dev/null +++ b/lib/modules/edit-modes/src/index.d.ts.map @@ -0,0 +1 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ACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAGhF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEhD,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,sBAAsB,EACtB,QAAQ,EACR,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,cAAc,EACd,KAAK,EACL,UAAU,EACV,OAAO,EACP,UAAU,EACV,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,UAAU,GACX,MAAM,iBAAiB,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/index.js b/lib/modules/edit-modes/src/index.js new file mode 100644 index 000000000..2068a36aa --- /dev/null +++ b/lib/modules/edit-modes/src/index.js @@ -0,0 +1,35 @@ +export { GeoJsonEditMode } from './lib/geojson-edit-mode'; +// Alter modes +export { ModifyMode } from './lib/modify-mode'; +export { TranslateMode } from './lib/translate-mode'; +export { ScaleMode } from './lib/scale-mode'; +export { RotateMode } from './lib/rotate-mode'; +export { DuplicateMode } from './lib/duplicate-mode'; +export { ExtendLineStringMode } from './lib/extend-line-string-mode'; +export { SplitPolygonMode } from './lib/split-polygon-mode'; +export { ExtrudeMode } from './lib/extrude-mode'; +export { ElevationMode } from './lib/elevation-mode'; +export { TransformMode } from './lib/transform-mode'; +// Draw modes +export { DrawPointMode } from './lib/draw-point-mode'; +export { DrawLineStringMode } from './lib/draw-line-string-mode'; +export { DrawPolygonMode } from './lib/draw-polygon-mode'; +export { DrawRectangleMode } from './lib/draw-rectangle-mode'; +export { DrawCircleByDiameterMode } from './lib/draw-circle-by-diameter-mode'; +export { DrawCircleFromCenterMode } from './lib/draw-circle-from-center-mode'; +export { DrawEllipseByBoundingBoxMode } from './lib/draw-ellipse-by-bounding-box-mode'; +export { DrawEllipseUsingThreePointsMode } from './lib/draw-ellipse-using-three-points-mode'; +export { DrawRectangleUsingThreePointsMode } from './lib/draw-rectangle-using-three-points-mode'; +export { Draw90DegreePolygonMode } from './lib/draw-90degree-polygon-mode'; +export { DrawPolygonByDraggingMode } from './lib/draw-polygon-by-dragging-mode'; +export { ImmutableFeatureCollection } from './lib/immutable-feature-collection'; +// Other modes +export { ViewMode } from './lib/view-mode'; +export { MeasureDistanceMode } from './lib/measure-distance-mode'; +export { MeasureAreaMode } from './lib/measure-area-mode'; +export { MeasureAngleMode } from './lib/measure-angle-mode'; +export { CompositeMode } from './lib/composite-mode'; +export { SnappableMode } from './lib/snappable-mode'; +// Experimental +export { default as _memoize } from './memoize'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/index.js.map b/lib/modules/edit-modes/src/index.js.map new file mode 100644 index 000000000..032957463 --- /dev/null +++ b/lib/modules/edit-modes/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../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B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,cAAc;AACd,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAe;AACf,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/composite-mode.d.ts b/lib/modules/edit-modes/src/lib/composite-mode.d.ts new file mode 100644 index 000000000..61877a55d --- /dev/null +++ b/lib/modules/edit-modes/src/lib/composite-mode.d.ts @@ -0,0 +1,15 @@ +import { FeatureCollection } from '../geojson-types'; +import { ModeProps, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, GuideFeatureCollection } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class CompositeMode extends GeoJsonEditMode { + _modes: Array; + constructor(modes: Array); + _coalesce(callback: (arg0: GeoJsonEditMode) => T, resultEval?: (arg0: T) => boolean | null | undefined): T; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; +} +//# sourceMappingURL=composite-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/composite-mode.d.ts.map b/lib/modules/edit-modes/src/lib/composite-mode.d.ts.map new file mode 100644 index 000000000..74f65fbba --- /dev/null +++ b/lib/modules/edit-modes/src/lib/composite-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"composite-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/composite-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,aAAc,SAAQ,eAAe;IAChD,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;gBAEnB,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC;IAKzC,SAAS,CAAC,CAAC,EACT,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,EACtC,UAAU,GAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,GAAG,SAAgB,GACzD,CAAC;IAaJ,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAIzE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAIrF,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAIzF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAIvF,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAI/E,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;CAevE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/composite-mode.js b/lib/modules/edit-modes/src/lib/composite-mode.js new file mode 100644 index 000000000..a08fae2dc --- /dev/null +++ b/lib/modules/edit-modes/src/lib/composite-mode.js @@ -0,0 +1,63 @@ +import { __extends, __read, __spread, __values } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var CompositeMode = /** @class */ (function (_super) { + __extends(CompositeMode, _super); + function CompositeMode(modes) { + var _this = _super.call(this) || this; + _this._modes = modes; + return _this; + } + CompositeMode.prototype._coalesce = function (callback, resultEval) { + if (resultEval === void 0) { resultEval = null; } + var result; + for (var i = 0; i < this._modes.length; i++) { + result = callback(this._modes[i]); + if (resultEval ? resultEval(result) : result) { + break; + } + } + return result; + }; + CompositeMode.prototype.handleClick = function (event, props) { + this._coalesce(function (handler) { return handler.handleClick(event, props); }); + }; + CompositeMode.prototype.handlePointerMove = function (event, props) { + return this._coalesce(function (handler) { return handler.handlePointerMove(event, props); }); + }; + CompositeMode.prototype.handleStartDragging = function (event, props) { + return this._coalesce(function (handler) { return handler.handleStartDragging(event, props); }); + }; + CompositeMode.prototype.handleStopDragging = function (event, props) { + return this._coalesce(function (handler) { return handler.handleStopDragging(event, props); }); + }; + CompositeMode.prototype.handleDragging = function (event, props) { + return this._coalesce(function (handler) { return handler.handleDragging(event, props); }); + }; + CompositeMode.prototype.getGuides = function (props) { + // TODO: Combine the guides *BUT* make sure if none of the results have + // changed to return the same object so that "guides !== this.state.guides" + // in editable-geojson-layer works. + var e_1, _a; + var allGuides = []; + try { + for (var _b = __values(this._modes), _c = _b.next(); !_c.done; _c = _b.next()) { + var mode = _c.value; + allGuides.push.apply(allGuides, __spread(mode.getGuides(props).features)); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + return { + type: 'FeatureCollection', + features: allGuides, + }; + }; + return CompositeMode; +}(GeoJsonEditMode)); +export { CompositeMode }; +//# sourceMappingURL=composite-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/composite-mode.js.map b/lib/modules/edit-modes/src/lib/composite-mode.js.map new file mode 100644 index 000000000..c55e80521 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/composite-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"composite-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/composite-mode.ts"],"names":[],"mappings":";AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAAmC,iCAAe;IAGhD,uBAAY,KAA6B;QAAzC,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,KAAK,CAAC;;IACtB,CAAC;IAED,iCAAS,GAAT,UACE,QAAsC,EACtC,UAA0D;QAA1D,2BAAA,EAAA,iBAA0D;QAE1D,IAAI,MAAS,CAAC;QAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;gBAC5C,MAAM;aACP;SACF;QAED,OAAO,MAAa,CAAC;IACvB,CAAC;IAED,mCAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QAChE,IAAI,CAAC,SAAS,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,EAAjC,CAAiC,CAAC,CAAC;IACjE,CAAC;IAED,yCAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,OAAO,IAAI,CAAC,SAAS,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAvC,CAAuC,CAAC,CAAC;IAC9E,CAAC;IAED,2CAAmB,GAAnB,UAAoB,KAAyB,EAAE,KAAmC;QAChF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAzC,CAAyC,CAAC,CAAC;IAChF,CAAC;IAED,0CAAkB,GAAlB,UAAmB,KAAwB,EAAE,KAAmC;QAC9E,OAAO,IAAI,CAAC,SAAS,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAxC,CAAwC,CAAC,CAAC;IAC/E,CAAC;IAED,sCAAc,GAAd,UAAe,KAAoB,EAAE,KAAmC;QACtE,OAAO,IAAI,CAAC,SAAS,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,EAApC,CAAoC,CAAC,CAAC;IAC3E,CAAC;IAED,iCAAS,GAAT,UAAU,KAAmC;QAC3C,uEAAuE;QACvE,2EAA2E;QAC3E,mCAAmC;;QAEnC,IAAM,SAAS,GAAG,EAAE,CAAC;;YACrB,KAAmB,IAAA,KAAA,SAAA,IAAI,CAAC,MAAM,CAAA,gBAAA,4BAAE;gBAA3B,IAAM,IAAI,WAAA;gBACb,SAAS,CAAC,IAAI,OAAd,SAAS,WAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAE;aACnD;;;;;;;;;QAED,OAAO;YACL,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,SAAS;SACpB,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AA3DD,CAAmC,eAAe,GA2DjD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts new file mode 100644 index 000000000..e0b9f0124 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts @@ -0,0 +1,11 @@ +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { Position, FeatureCollection } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class Draw90DegreePolygonMode extends GeoJsonEditMode { + getGuides(props: ModeProps): GuideFeatureCollection; + handlePointerMove({ mapCoords }: PointerMoveEvent, props: ModeProps): void; + handleClick(event: ClickEvent, props: ModeProps): void; + finalizedCoordinates(coords: Position[]): Position[][]; + getIntermediatePoint(coordinates: Position[]): any; +} +//# sourceMappingURL=draw-90degree-polygon-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts.map new file mode 100644 index 000000000..52d28f2e0 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-90degree-polygon-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-90degree-polygon-mode.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAuB,QAAQ,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IA8DtE,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAItF,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA8DlE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE;IAmBvC,oBAAoB,CAAC,WAAW,EAAE,QAAQ,EAAE;CA0C7C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js new file mode 100644 index 000000000..b6a91f1c5 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js @@ -0,0 +1,183 @@ +import { __extends, __read, __spread } from "tslib"; +import destination from '@turf/destination'; +import bearing from '@turf/bearing'; +import lineIntersect from '@turf/line-intersect'; +import turfDistance from '@turf/distance'; +import { point, lineString as turfLineString } from '@turf/helpers'; +import { generatePointsParallelToLinePoints, getPickedEditHandle, getEditHandlesForGeometry, } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var Draw90DegreePolygonMode = /** @class */ (function (_super) { + __extends(Draw90DegreePolygonMode, _super); + function Draw90DegreePolygonMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + Draw90DegreePolygonMode.prototype.getGuides = function (props) { + var _a; + var guides = { + type: 'FeatureCollection', + features: [], + }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0 || !props.lastPointerMoveEvent) { + return guides; + } + var mapCoords = props.lastPointerMoveEvent.mapCoords; + var p3; + if (clickSequence.length === 1) { + p3 = mapCoords; + } + else { + var p1 = clickSequence[clickSequence.length - 2]; + var p2 = clickSequence[clickSequence.length - 1]; + _a = __read(generatePointsParallelToLinePoints(p1, p2, mapCoords), 1), p3 = _a[0]; + } + var tentativeFeature; + if (clickSequence.length < 3) { + // Draw a LineString connecting all the clicked points with the hovered point + tentativeFeature = { + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, [p3]), + }, + }; + } + else { + // Draw a Polygon connecting all the clicked points with the hovered point + tentativeFeature = { + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'Polygon', + coordinates: [__spread(clickSequence, [p3, clickSequence[0]])], + }, + }; + } + guides.features.push(tentativeFeature); + guides.features = guides.features.concat(getEditHandlesForGeometry(tentativeFeature.geometry, -1)); + // Slice off the handles that are are next to the pointer + guides.features = guides.features.slice(0, -1); + return guides; + }; + Draw90DegreePolygonMode.prototype.handlePointerMove = function (_a, props) { + var mapCoords = _a.mapCoords; + props.onUpdateCursor('cell'); + }; + Draw90DegreePolygonMode.prototype.handleClick = function (event, props) { + var picks = event.picks; + var tentativeFeature = this.getTentativeGuide(props); + this.addClickSequence(event); + var clickSequence = this.getClickSequence(); + if (!tentativeFeature) { + // nothing else to do + return; + } + if (clickSequence.length === 3 && tentativeFeature.geometry.type === 'LineString') { + var lineString = tentativeFeature.geometry; + // Tweak the clicked position to be the snapped 90 degree point along the polygon + clickSequence[clickSequence.length - 1] = + lineString.coordinates[lineString.coordinates.length - 1]; + } + else if (clickSequence.length > 3 && tentativeFeature.geometry.type === 'Polygon') { + var polygon = tentativeFeature.geometry; + // Tweak the clicked position to be the snapped 90 degree point along the polygon + clickSequence[clickSequence.length - 1] = + polygon.coordinates[0][polygon.coordinates[0].length - 2]; + var clickedEditHandle = getPickedEditHandle(picks); + if (clickedEditHandle && + Array.isArray(clickedEditHandle.properties.positionIndexes) && + (clickedEditHandle.properties.positionIndexes[1] === 0 || + clickedEditHandle.properties.positionIndexes[1] === polygon.coordinates[0].length - 3)) { + // They clicked the first or last point (or double-clicked), so complete the polygon + var polygonToAdd = { + type: 'Polygon', + coordinates: this.finalizedCoordinates(__spread(polygon.coordinates[0])), + }; + this.resetClickSequence(); + var editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props); + if (editAction) { + props.onEdit(editAction); + } + } + } + // Trigger pointer move right away in order for it to update edit handles (to support double-click) + var fakePointerMoveEvent = { + screenCoords: [-1, -1], + mapCoords: event.mapCoords, + picks: [], + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownMapCoords: null, + cancelPan: function () { }, + sourceEvent: null, + }; + this.handlePointerMove(fakePointerMoveEvent, props); + }; + Draw90DegreePolygonMode.prototype.finalizedCoordinates = function (coords) { + // Remove the hovered position + var coordinates = [__spread(coords.slice(0, -2), [coords[0]])]; + var pt = this.getIntermediatePoint(__spread(coords)); + if (!pt) { + // if intermediate point with 90 degree not available + // try remove the last clicked point and get the intermediate point. + var tc = __spread(coords); + tc.splice(-3, 1); + pt = this.getIntermediatePoint(__spread(tc)); + if (pt) { + coordinates = [__spread(coords.slice(0, -3), [pt, coords[0]])]; + } + } + else { + coordinates = [__spread(coords.slice(0, -2), [pt, coords[0]])]; + } + return coordinates; + }; + Draw90DegreePolygonMode.prototype.getIntermediatePoint = function (coordinates) { + var pt; + if (coordinates.length > 4) { + var _a = __read(__spread(coordinates), 2), p1_1 = _a[0], p2 = _a[1]; + var angle1_1 = bearing(p1_1, p2); + var p3_1 = coordinates[coordinates.length - 3]; + var p4 = coordinates[coordinates.length - 4]; + var angle2_1 = bearing(p3_1, p4); + var angles_1 = { first: [], second: [] }; + // calculate 3 right angle points for first and last points in lineString + [1, 2, 3].forEach(function (factor) { + var newAngle1 = angle1_1 + factor * 90; + // convert angles to 0 to -180 for anti-clock and 0 to 180 for clock wise + angles_1.first.push(newAngle1 > 180 ? newAngle1 - 360 : newAngle1); + var newAngle2 = angle2_1 + factor * 90; + angles_1.second.push(newAngle2 > 180 ? newAngle2 - 360 : newAngle2); + }); + var distance_1 = turfDistance(point(p1_1), point(p3_1)); + // Draw imaginary right angle lines for both first and last points in lineString + // If there is intersection point for any 2 lines, will be the 90 degree point. + [0, 1, 2].forEach(function (indexFirst) { + var line1 = turfLineString([ + p1_1, + destination(p1_1, distance_1, angles_1.first[indexFirst]).geometry.coordinates, + ]); + [0, 1, 2].forEach(function (indexSecond) { + var line2 = turfLineString([ + p3_1, + destination(p3_1, distance_1, angles_1.second[indexSecond]).geometry.coordinates, + ]); + var fc = lineIntersect(line1, line2); + if (fc && fc.features.length) { + // found the intersect point + pt = fc.features[0].geometry.coordinates; + } + }); + }); + } + return pt; + }; + return Draw90DegreePolygonMode; +}(GeoJsonEditMode)); +export { Draw90DegreePolygonMode }; +//# sourceMappingURL=draw-90degree-polygon-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js.map b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js.map new file mode 100644 index 000000000..a4bcbd564 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-90degree-polygon-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-90degree-polygon-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-90degree-polygon-mode.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,kCAAkC,EAClC,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAA6C,2CAAe;IAA5D;;IA8LA,CAAC;IA7LC,2CAAS,GAAT,UAAU,KAAmC;;QAC3C,IAAM,MAAM,GAA2B;YACrC,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC7D,OAAO,MAAM,CAAC;SACf;QACO,IAAA,gDAAS,CAAgC;QAEjD,IAAI,EAAE,CAAC;QACP,IAAI,aAAa,CAAC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C,WAAW,CAAC;qBAC1C;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,8BAAC;AAAD,CAAC,AA9LD,CAA6C,eAAe,GA8L3D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts new file mode 100644 index 000000000..f98e46465 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +export declare class DrawCircleByDiameterMode extends TwoClickPolygonMode { + getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf; +} +//# sourceMappingURL=draw-circle-by-diameter-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts.map new file mode 100644 index 000000000..f6efd75aa --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-diameter-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-circle-by-diameter-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,wBAAyB,SAAQ,mBAAmB;IAC/D,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;CAoB5F"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js new file mode 100644 index 000000000..42eeb1071 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js @@ -0,0 +1,29 @@ +import { __extends } from "tslib"; +import circle from '@turf/circle'; +import distance from '@turf/distance'; +import { getIntermediatePosition } from './geojson-edit-mode'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +var DrawCircleByDiameterMode = /** @class */ (function (_super) { + __extends(DrawCircleByDiameterMode, _super); + function DrawCircleByDiameterMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawCircleByDiameterMode.prototype.getTwoClickPolygon = function (coord1, coord2, modeConfig) { + // Default turf value for circle is 64 + var _a = (modeConfig || {}).steps, steps = _a === void 0 ? 64 : _a; + var options = { steps: steps }; + if (steps < 4) { + console.warn("Minimum steps to draw a circle is 4 "); // eslint-disable-line no-console,no-undef + options.steps = 4; + } + var centerCoordinates = getIntermediatePosition(coord1, coord2); + var radius = Math.max(distance(coord1, centerCoordinates), 0.001); + var geometry = circle(centerCoordinates, radius, options); + geometry.properties = geometry.properties || {}; + geometry.properties.shape = 'Circle'; + return geometry; + }; + return DrawCircleByDiameterMode; +}(TwoClickPolygonMode)); +export { DrawCircleByDiameterMode }; +//# sourceMappingURL=draw-circle-by-diameter-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js.map b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js.map new file mode 100644 index 000000000..575bdb7ec --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-by-diameter-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-diameter-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-circle-by-diameter-mode.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;IAA8C,4CAAmB;IAAjE;;IAqBA,CAAC;IApBC,qDAAkB,GAAlB,UAAmB,MAAgB,EAAE,MAAgB,EAAE,UAAe;QACpE,sCAAsC;QAC9B,IAAA,6BAAU,EAAV,+BAAU,CAAsB;QACxC,IAAM,OAAO,GAAG,EAAE,KAAK,OAAA,EAAE,CAAC;QAE1B,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC,0CAA0C;YAChG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;SACnB;QAED,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClE,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,KAAK,CAAC,CAAC;QAEpE,IAAM,QAAQ,GAAG,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE5D,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;QAChD,QAAQ,CAAC,UAAU,CAAC,KAAK,GAAG,QAAQ,CAAC;QAErC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACH,+BAAC;AAAD,CAAC,AArBD,CAA8C,mBAAmB,GAqBhE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts new file mode 100644 index 000000000..3b02a5873 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +export declare class DrawCircleFromCenterMode extends TwoClickPolygonMode { + getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf; +} +//# sourceMappingURL=draw-circle-from-center-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts.map new file mode 100644 index 000000000..6e324e2aa --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-from-center-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-circle-from-center-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,wBAAyB,SAAQ,mBAAmB;IAC/D,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;CAkB5F"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js new file mode 100644 index 000000000..8e3693524 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js @@ -0,0 +1,27 @@ +import { __extends } from "tslib"; +import circle from '@turf/circle'; +import distance from '@turf/distance'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +var DrawCircleFromCenterMode = /** @class */ (function (_super) { + __extends(DrawCircleFromCenterMode, _super); + function DrawCircleFromCenterMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawCircleFromCenterMode.prototype.getTwoClickPolygon = function (coord1, coord2, modeConfig) { + // Default turf value for circle is 64 + var _a = (modeConfig || {}).steps, steps = _a === void 0 ? 64 : _a; + var options = { steps: steps }; + if (steps < 4) { + console.warn("Minimum steps to draw a circle is 4 "); // eslint-disable-line no-console,no-undef + options.steps = 4; + } + var radius = Math.max(distance(coord1, coord2), 0.001); + var geometry = circle(coord1, radius, options); + geometry.properties = geometry.properties || {}; + geometry.properties.shape = 'Circle'; + return geometry; + }; + return DrawCircleFromCenterMode; +}(TwoClickPolygonMode)); +export { DrawCircleFromCenterMode }; +//# sourceMappingURL=draw-circle-from-center-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js.map b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js.map new file mode 100644 index 000000000..d9a0d87d4 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-circle-from-center-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-from-center-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-circle-from-center-mode.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;IAA8C,4CAAmB;IAAjE;;IAmBA,CAAC;IAlBC,qDAAkB,GAAlB,UAAmB,MAAgB,EAAE,MAAgB,EAAE,UAAe;QACpE,sCAAsC;QAC9B,IAAA,6BAAU,EAAV,+BAAU,CAAsB;QACxC,IAAM,OAAO,GAAG,EAAE,KAAK,OAAA,EAAE,CAAC;QAE1B,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC,0CAA0C;YAChG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;SACnB;QAED,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;QACzD,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEjD,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;QAChD,QAAQ,CAAC,UAAU,CAAC,KAAK,GAAG,QAAQ,CAAC;QAErC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACH,+BAAC;AAAD,CAAC,AAnBD,CAA8C,mBAAmB,GAmBhE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts new file mode 100644 index 000000000..e276c495a --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +export declare class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode { + getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf; +} +//# sourceMappingURL=draw-ellipse-by-bounding-box-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts.map new file mode 100644 index 000000000..61c2ce0b8 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-by-bounding-box-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,4BAA6B,SAAQ,mBAAmB;IACnE,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;CAc5F"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js new file mode 100644 index 000000000..ab8cc3996 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js @@ -0,0 +1,28 @@ +import { __extends } from "tslib"; +import bboxPolygon from '@turf/bbox-polygon'; +import distance from '@turf/distance'; +import ellipse from '@turf/ellipse'; +import { point } from '@turf/helpers'; +import { getIntermediatePosition } from './geojson-edit-mode'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +var DrawEllipseByBoundingBoxMode = /** @class */ (function (_super) { + __extends(DrawEllipseByBoundingBoxMode, _super); + function DrawEllipseByBoundingBoxMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawEllipseByBoundingBoxMode.prototype.getTwoClickPolygon = function (coord1, coord2, modeConfig) { + var minX = Math.min(coord1[0], coord2[0]); + var minY = Math.min(coord1[1], coord2[1]); + var maxX = Math.max(coord1[0], coord2[0]); + var maxY = Math.max(coord1[1], coord2[1]); + var polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0]; + var centerCoordinates = getIntermediatePosition(coord1, coord2); + var xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001); + var ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001); + // @ts-ignore + return ellipse(centerCoordinates, xSemiAxis, ySemiAxis); + }; + return DrawEllipseByBoundingBoxMode; +}(TwoClickPolygonMode)); +export { DrawEllipseByBoundingBoxMode }; +//# sourceMappingURL=draw-ellipse-by-bounding-box-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js.map b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js.map new file mode 100644 index 000000000..7c69b7413 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-by-bounding-box-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-ellipse-by-bounding-box-mode.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;IAAkD,gDAAmB;IAArE;;IAeA,CAAC;IAdC,yDAAkB,GAAlB,UAAmB,MAAgB,EAAE,MAAgB,EAAE,UAAe;QACpE,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5C,IAAM,aAAa,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACpF,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAElE,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC9F,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC9F,aAAa;QACb,OAAO,OAAO,CAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;IACH,mCAAC;AAAD,CAAC,AAfD,CAAkD,mBAAmB,GAepE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts new file mode 100644 index 000000000..0f5717579 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { ThreeClickPolygonMode } from './three-click-polygon-mode'; +export declare class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode { + getThreeClickPolygon(coord1: Position, coord2: Position, coord3: Position, modeConfig: any): FeatureOf | null | undefined; +} +//# sourceMappingURL=draw-ellipse-using-three-points-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts.map new file mode 100644 index 000000000..48fd54b8e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-using-three-points-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,qBAAa,+BAAgC,SAAQ,qBAAqB;IACxE,oBAAoB,CAClB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,GAAG,GACd,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS;CAQzC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js new file mode 100644 index 000000000..9e2a9df19 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js @@ -0,0 +1,24 @@ +import { __extends } from "tslib"; +import distance from '@turf/distance'; +import ellipse from '@turf/ellipse'; +import bearing from '@turf/bearing'; +import { point } from '@turf/helpers'; +import { getIntermediatePosition } from './geojson-edit-mode'; +import { ThreeClickPolygonMode } from './three-click-polygon-mode'; +var DrawEllipseUsingThreePointsMode = /** @class */ (function (_super) { + __extends(DrawEllipseUsingThreePointsMode, _super); + function DrawEllipseUsingThreePointsMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawEllipseUsingThreePointsMode.prototype.getThreeClickPolygon = function (coord1, coord2, coord3, modeConfig) { + var centerCoordinates = getIntermediatePosition(coord1, coord2); + var xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001); + var ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2; + var options = { angle: bearing(coord1, coord2) }; + // @ts-ignore + return ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options); + }; + return DrawEllipseUsingThreePointsMode; +}(ThreeClickPolygonMode)); +export { DrawEllipseUsingThreePointsMode }; +//# sourceMappingURL=draw-ellipse-using-three-points-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js.map b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js.map new file mode 100644 index 000000000..4e2f7961f --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-using-three-points-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-ellipse-using-three-points-mode.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;IAAqD,mDAAqB;IAA1E;;IAcA,CAAC;IAbC,8DAAoB,GAApB,UACE,MAAgB,EAChB,MAAgB,EAChB,MAAgB,EAChB,UAAe;QAEf,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClE,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAC9E,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAChE,IAAM,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QACnD,aAAa;QACb,OAAO,OAAO,CAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IACH,sCAAC;AAAD,CAAC,AAdD,CAAqD,qBAAqB,GAczE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts new file mode 100644 index 000000000..5ba72bf52 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts @@ -0,0 +1,9 @@ +import { FeatureCollection } from '../geojson-types'; +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class DrawLineStringMode extends GeoJsonEditMode { + handleClick(event: ClickEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=draw-line-string-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts.map new file mode 100644 index 000000000..1eac7c27b --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-line-string-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-line-string-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE3F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA4ClE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IAgDtE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-line-string-mode.js b/lib/modules/edit-modes/src/lib/draw-line-string-mode.js new file mode 100644 index 000000000..2c6f88753 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-line-string-mode.js @@ -0,0 +1,94 @@ +import { __extends, __read, __spread } from "tslib"; +import { getPickedEditHandle } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var DrawLineStringMode = /** @class */ (function (_super) { + __extends(DrawLineStringMode, _super); + function DrawLineStringMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawLineStringMode.prototype.handleClick = function (event, props) { + var picks = event.picks; + var clickedEditHandle = getPickedEditHandle(picks); + var positionAdded = false; + if (!clickedEditHandle) { + // Don't add another point right next to an existing one + this.addClickSequence(event); + positionAdded = true; + } + var clickSequence = this.getClickSequence(); + if (clickSequence.length > 1 && + clickedEditHandle && + Array.isArray(clickedEditHandle.properties.positionIndexes) && + clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1) { + // They clicked the last point (or double-clicked), so add the LineString + var lineStringToAdd = { + type: 'LineString', + coordinates: __spread(clickSequence), + }; + this.resetClickSequence(); + var editAction = this.getAddFeatureAction(lineStringToAdd, props.data); + if (editAction) { + props.onEdit(editAction); + } + } + else if (positionAdded) { + // new tentative point + props.onEdit({ + // data is the same + updatedData: props.data, + editType: 'addTentativePosition', + editContext: { + position: event.mapCoords, + }, + }); + } + }; + DrawLineStringMode.prototype.getGuides = function (props) { + var _a; + var lastPointerMoveEvent = props.lastPointerMoveEvent; + var clickSequence = this.getClickSequence(); + var lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : []; + var guides = { + type: 'FeatureCollection', + features: [], + }; + var tentativeFeature; + if (clickSequence.length > 0) { + tentativeFeature = { + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, lastCoords), + }, + }; + } + if (tentativeFeature) { + guides.features.push(tentativeFeature); + } + var editHandles = clickSequence.map(function (clickedCoord, index) { return ({ + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: 'existing', + featureIndex: -1, + positionIndexes: [index], + }, + geometry: { + type: 'Point', + coordinates: clickedCoord, + }, + }); }); + (_a = guides.features).push.apply(_a, __spread(editHandles)); + // @ts-ignore + return guides; + }; + DrawLineStringMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + return DrawLineStringMode; +}(GeoJsonEditMode)); +export { DrawLineStringMode }; +//# sourceMappingURL=draw-line-string-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-line-string-mode.js.map b/lib/modules/edit-modes/src/lib/draw-line-string-mode.js.map new file mode 100644 index 000000000..441252c45 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-line-string-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-line-string-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAAwC,sCAAe;IAAvD;;IAgGA,CAAC;IA/FC,wCAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QACxD,IAAA,mBAAK,CAAW;QACxB,IAAM,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAErD,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,iBAAiB,EAAE;YACtB,wDAAwD;YACxD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC7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B,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,gBAAgB,GAAG;gBACjB,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,SAAS,EAAE,WAAW;iBACvB;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY;oBAClB,WAAW,WAAM,aAAa,EAAK,UAAU,CAAC;iBAC/C;aACF,CAAC;SACH;QAED,IAAI,gBAAgB,EAAE;YACpB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;QAED,IAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,UAAC,YAAY,EAAE,KAAK,IAAK,OAAA,CAAC;YAC9D,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,SAAS,EAAE,YAAY;gBACvB,cAAc,EAAE,UAAU;gBAC1B,YAAY,EAAE,CAAC,CAAC;gBAChB,eAAe,EAAE,CAAC,KAAK,CAAC;aACzB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,YAAY;aAC1B;SACF,CAAC,EAZ6D,CAY7D,CAAC,CAAC;QAEJ,CAAA,KAAA,MAAM,CAAC,QAAQ,CAAA,CAAC,IAAI,oBAAI,WAAW,GAAE;QACrC,aAAa;QACb,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,8CAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACH,yBAAC;AAAD,CAAC,AAhGD,CAAwC,eAAe,GAgGtD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts new file mode 100644 index 000000000..9497afc14 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts @@ -0,0 +1,8 @@ +import { ClickEvent, PointerMoveEvent, ModeProps } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class DrawPointMode extends GeoJsonEditMode { + handleClick({ mapCoords }: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=draw-point-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts.map new file mode 100644 index 000000000..c21a2c5a6 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-point-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-point-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-point-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,aAAc,SAAQ,eAAe;IAChD,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IASjF,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-point-mode.js b/lib/modules/edit-modes/src/lib/draw-point-mode.js new file mode 100644 index 000000000..c98ac94c7 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-point-mode.js @@ -0,0 +1,23 @@ +import { __extends } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var DrawPointMode = /** @class */ (function (_super) { + __extends(DrawPointMode, _super); + function DrawPointMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawPointMode.prototype.handleClick = function (_a, props) { + var mapCoords = _a.mapCoords; + var geometry = { + type: 'Point', + coordinates: mapCoords, + }; + // @ts-ignore + props.onEdit(this.getAddFeatureAction(geometry, props.data)); + }; + DrawPointMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + return DrawPointMode; +}(GeoJsonEditMode)); +export { DrawPointMode }; +//# sourceMappingURL=draw-point-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-point-mode.js.map b/lib/modules/edit-modes/src/lib/draw-point-mode.js.map new file mode 100644 index 000000000..62c4f5874 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-point-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-point-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-point-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAAmC,iCAAe;IAAlD;;IAaA,CAAC;IAZC,mCAAW,GAAX,UAAY,EAAyB,EAAE,KAAmC;YAA5D,wBAAS;QACrB,IAAM,QAAQ,GAAG;YACf,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,SAAS;SACvB,CAAC;QACF,aAAa;QACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,yCAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACH,oBAAC;AAAD,CAAC,AAbD,CAAmC,eAAe,GAajD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts new file mode 100644 index 000000000..6082f313e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts @@ -0,0 +1,14 @@ +import { ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { DrawPolygonMode } from './draw-polygon-mode'; +declare type DraggingHandler = (event: DraggingEvent, props: ModeProps) => void; +export declare class DrawPolygonByDraggingMode extends DrawPolygonMode { + handleDraggingThrottled: DraggingHandler | null | undefined; + handleClick(event: ClickEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + handleDraggingAux(event: DraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; +} +export {}; +//# sourceMappingURL=draw-polygon-by-dragging-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts.map new file mode 100644 index 000000000..ae8e69950 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-by-dragging-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAW,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,aAAK,eAAe,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AAE3F,qBAAa,yBAA0B,SAAQ,eAAe;IAC5D,uBAAuB,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAQ;IAEnE,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAIlE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IASlF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAyBhF,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAU3E,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAKzE"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js new file mode 100644 index 000000000..16eb5e456 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js @@ -0,0 +1,61 @@ +import { __extends, __read, __spread } from "tslib"; +import throttle from 'lodash.throttle'; +import { getPickedEditHandle } from '../utils'; +import { DrawPolygonMode } from './draw-polygon-mode'; +var DrawPolygonByDraggingMode = /** @class */ (function (_super) { + __extends(DrawPolygonByDraggingMode, _super); + function DrawPolygonByDraggingMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.handleDraggingThrottled = null; + return _this; + } + DrawPolygonByDraggingMode.prototype.handleClick = function (event, props) { + // No-op + }; + DrawPolygonByDraggingMode.prototype.handleStartDragging = function (event, props) { + event.cancelPan(); + if (props.modeConfig && props.modeConfig.throttleMs) { + this.handleDraggingThrottled = throttle(this.handleDraggingAux, props.modeConfig.throttleMs); + } + else { + this.handleDraggingThrottled = this.handleDraggingAux; + } + }; + DrawPolygonByDraggingMode.prototype.handleStopDragging = function (event, props) { + this.addClickSequence(event); + var clickSequence = this.getClickSequence(); + // @ts-ignore + if (this.handleDraggingThrottled && this.handleDraggingThrottled.cancel) { + // @ts-ignore + this.handleDraggingThrottled.cancel(); + } + if (clickSequence.length > 2) { + // Complete the polygon. + var polygonToAdd = { + type: 'Polygon', + coordinates: [__spread(clickSequence, [clickSequence[0]])], + }; + this.resetClickSequence(); + var editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props); + if (editAction) { + props.onEdit(editAction); + } + } + }; + DrawPolygonByDraggingMode.prototype.handleDraggingAux = function (event, props) { + var picks = event.picks; + var clickedEditHandle = getPickedEditHandle(picks); + if (!clickedEditHandle) { + // Don't add another point right next to an existing one. + this.addClickSequence(event); + } + }; + DrawPolygonByDraggingMode.prototype.handleDragging = function (event, props) { + if (this.handleDraggingThrottled) { + this.handleDraggingThrottled(event, props); + } + }; + return DrawPolygonByDraggingMode; +}(DrawPolygonMode)); +export { DrawPolygonByDraggingMode }; +//# sourceMappingURL=draw-polygon-by-dragging-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js.map b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js.map new file mode 100644 index 000000000..89381239d --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-by-dragging-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-polygon-by-dragging-mode.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AASvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD;IAA+C,6CAAe;IAA9D;QAAA,qEAwDC;QAvDC,6BAAuB,GAAuC,IAAI,CAAC;;IAuDrE,CAAC;IArDC,+CAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QAChE,QAAQ;IACV,CAAC;IAED,uDAAmB,GAAnB,UAAoB,KAAyB,EAAE,KAAmC;QAChF,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,IAAI,KAAK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DAAc,GAAd,UAAe,KAAoB,EAAE,KAAmC;QACtE,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAChC,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SAC5C;IACH,CAAC;IACH,gCAAC;AAAD,CAAC,AAxDD,CAA+C,eAAe,GAwD7D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts new file mode 100644 index 000000000..671bcec3a --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts @@ -0,0 +1,9 @@ +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class DrawPolygonMode extends GeoJsonEditMode { + getGuides(props: ModeProps): GuideFeatureCollection; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove({ mapCoords }: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=draw-polygon-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts.map new file mode 100644 index 000000000..c211d2326 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-polygon-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAW,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,eAAgB,SAAQ,eAAe;IAClD,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IA2DtE,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA8ClE,iBAAiB,CAAC,EAAE,SAAS,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAGvF"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-mode.js b/lib/modules/edit-modes/src/lib/draw-polygon-mode.js new file mode 100644 index 000000000..0a8de8c0d --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-mode.js @@ -0,0 +1,109 @@ +import { __extends, __read, __spread } from "tslib"; +import { getPickedEditHandle } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var DrawPolygonMode = /** @class */ (function (_super) { + __extends(DrawPolygonMode, _super); + function DrawPolygonMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawPolygonMode.prototype.getGuides = function (props) { + var _a; + var lastPointerMoveEvent = props.lastPointerMoveEvent; + var clickSequence = this.getClickSequence(); + var lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : []; + var guides = { + type: 'FeatureCollection', + features: [], + }; + var tentativeFeature; + if (clickSequence.length === 1 || clickSequence.length === 2) { + tentativeFeature = { + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, lastCoords), + }, + }; + } + else if (clickSequence.length > 2) { + tentativeFeature = { + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'Polygon', + coordinates: [__spread(clickSequence, lastCoords, [clickSequence[0]])], + }, + }; + } + if (tentativeFeature) { + guides.features.push(tentativeFeature); + } + var editHandles = clickSequence.map(function (clickedCoord, index) { return ({ + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: 'existing', + featureIndex: -1, + positionIndexes: [index], + }, + geometry: { + type: 'Point', + coordinates: clickedCoord, + }, + }); }); + (_a = guides.features).push.apply(_a, __spread(editHandles)); + // @ts-ignore + return guides; + }; + DrawPolygonMode.prototype.handleClick = function (event, props) { + var picks = event.picks; + var clickedEditHandle = getPickedEditHandle(picks); + var positionAdded = false; + if (!clickedEditHandle) { + // Don't add another point right next to an existing one + this.addClickSequence(event); + positionAdded = true; + } + var clickSequence = this.getClickSequence(); + if (clickSequence.length > 2 && + clickedEditHandle && + Array.isArray(clickedEditHandle.properties.positionIndexes) && + (clickedEditHandle.properties.positionIndexes[0] === 0 || + clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1)) { + // They clicked the first or last point (or double-clicked), so complete the polygon + // Remove the hovered position + var polygonToAdd = { + type: 'Polygon', + coordinates: [__spread(clickSequence, [clickSequence[0]])], + }; + this.resetClickSequence(); + var editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props); + if (editAction) { + props.onEdit(editAction); + } + } + else if (positionAdded) { + // new tentative point + props.onEdit({ + // data is the same + updatedData: props.data, + editType: 'addTentativePosition', + editContext: { + position: event.mapCoords, + }, + }); + } + }; + DrawPolygonMode.prototype.handlePointerMove = function (_a, props) { + var mapCoords = _a.mapCoords; + props.onUpdateCursor('cell'); + }; + return DrawPolygonMode; +}(GeoJsonEditMode)); +export { DrawPolygonMode }; +//# sourceMappingURL=draw-polygon-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-polygon-mode.js.map b/lib/modules/edit-modes/src/lib/draw-polygon-mode.js.map new file mode 100644 index 000000000..7e6ac8ddd --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-polygon-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-polygon-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAA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E,KAAK,CAAC,CAAC;YACjF,IAAI,UAAU,EAAE;gBACd,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aAC1B;SACF;aAAM,IAAI,aAAa,EAAE;YACxB,sBAAsB;YACtB,KAAK,CAAC,MAAM,CAAC;gBACX,mBAAmB;gBACnB,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,QAAQ,EAAE,sBAAsB;gBAChC,WAAW,EAAE;oBACX,QAAQ,EAAE,KAAK,CAAC,SAAS;iBAC1B;aACF,CAAC,CAAC;SACJ;IACH,CAAC;IAED,2CAAiB,GAAjB,UAAkB,EAA+B,EAAE,KAAmC;YAAlE,wBAAS;QAC3B,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACH,sBAAC;AAAD,CAAC,AA7GD,CAAqC,eAAe,GA6GnD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts new file mode 100644 index 000000000..72eba6bd4 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +export declare class DrawRectangleMode extends TwoClickPolygonMode { + getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf; +} +//# sourceMappingURL=draw-rectangle-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts.map new file mode 100644 index 000000000..38ce072c3 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-rectangle-mode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,iBAAkB,SAAQ,mBAAmB;IACxD,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;CAQ5F"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js new file mode 100644 index 000000000..c21f2a8a0 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js @@ -0,0 +1,19 @@ +import { __extends } from "tslib"; +import bboxPolygon from '@turf/bbox-polygon'; +import { TwoClickPolygonMode } from './two-click-polygon-mode'; +var DrawRectangleMode = /** @class */ (function (_super) { + __extends(DrawRectangleMode, _super); + function DrawRectangleMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawRectangleMode.prototype.getTwoClickPolygon = function (coord1, coord2, modeConfig) { + var rectangle = bboxPolygon([coord1[0], coord1[1], coord2[0], coord2[1]]); + rectangle.properties = rectangle.properties || {}; + rectangle.properties.shape = 'Rectangle'; + // @ts-ignore + return rectangle; + }; + return DrawRectangleMode; +}(TwoClickPolygonMode)); +export { DrawRectangleMode }; +//# sourceMappingURL=draw-rectangle-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js.map b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js.map new file mode 100644 index 000000000..c609e3a84 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-rectangle-mode.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;IAAuC,qCAAmB;IAA1D;;IASA,CAAC;IARC,8CAAkB,GAAlB,UAAmB,MAAgB,EAAE,MAAgB,EAAE,UAAe;QACpE,IAAM,SAAS,GAAG,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC;QAClD,SAAS,CAAC,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC;QAEzC,aAAa;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IACH,wBAAC;AAAD,CAAC,AATD,CAAuC,mBAAmB,GASzD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts new file mode 100644 index 000000000..787fbf907 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts @@ -0,0 +1,6 @@ +import { Position, Polygon, FeatureOf } from '../geojson-types'; +import { ThreeClickPolygonMode } from './three-click-polygon-mode'; +export declare class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode { + getThreeClickPolygon(coord1: Position, coord2: Position, coord3: Position, modeConfig: any): FeatureOf | null | undefined; +} +//# sourceMappingURL=draw-rectangle-using-three-points-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts.map b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts.map new file mode 100644 index 000000000..9eff61ea0 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-using-three-points-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,qBAAa,iCAAkC,SAAQ,qBAAqB;IAC1E,oBAAoB,CAClB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,GAAG,GACd,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS;CAyBzC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js new file mode 100644 index 000000000..937a7ab56 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js @@ -0,0 +1,36 @@ +import { __extends, __read } from "tslib"; +import { generatePointsParallelToLinePoints } from '../utils'; +import { ThreeClickPolygonMode } from './three-click-polygon-mode'; +var DrawRectangleUsingThreePointsMode = /** @class */ (function (_super) { + __extends(DrawRectangleUsingThreePointsMode, _super); + function DrawRectangleUsingThreePointsMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawRectangleUsingThreePointsMode.prototype.getThreeClickPolygon = function (coord1, coord2, coord3, modeConfig) { + var _a = __read(generatePointsParallelToLinePoints(coord1, coord2, coord3), 2), p3 = _a[0], p4 = _a[1]; + return { + type: 'Feature', + properties: { + shape: 'Rectangle', + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + // Draw a polygon containing all the points of the LineString, + // then the points orthogonal to the lineString, + // then back to the starting position + coord1, + coord2, + p3, + p4, + coord1, + ], + ], + }, + }; + }; + return DrawRectangleUsingThreePointsMode; +}(ThreeClickPolygonMode)); +export { DrawRectangleUsingThreePointsMode }; +//# sourceMappingURL=draw-rectangle-using-three-points-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js.map b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js.map new file mode 100644 index 000000000..17c581ba5 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-using-three-points-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/draw-rectangle-using-three-points-mode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;IAAuD,qDAAqB;IAA5E;;IA+BA,CAAC;IA9BC,gEAAoB,GAApB,UACE,MAAgB,EAChB,MAAgB,EAChB,MAAgB,EAChB,UAAe;QAET,IAAA,0EAAqE,EAApE,UAAE,EAAE,UAAgE,CAAC;QAE5E,OAAO;YACL,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,KAAK,EAAE,WAAW;aACnB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE;oBACX;wBACE,8DAA8D;wBAC9D,gDAAgD;wBAChD,qCAAqC;wBACrC,MAAM;wBACN,MAAM;wBACN,EAAE;wBACF,EAAE;wBACF,MAAM;qBACP;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IACH,wCAAC;AAAD,CAAC,AA/BD,CAAuD,qBAAqB,GA+B3E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts b/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts new file mode 100644 index 000000000..1fb2e79a4 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts @@ -0,0 +1,8 @@ +import { StartDraggingEvent, ModeProps } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { TranslateMode } from './translate-mode'; +export declare class DuplicateMode extends TranslateMode { + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + updateCursor(props: ModeProps): void; +} +//# sourceMappingURL=duplicate-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts.map b/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts.map new file mode 100644 index 000000000..2d2d8e57a --- /dev/null +++ b/lib/modules/edit-modes/src/lib/duplicate-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"duplicate-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/duplicate-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,aAAc,SAAQ,aAAa;IAC9C,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAQlF,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAOjD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/duplicate-mode.js b/lib/modules/edit-modes/src/lib/duplicate-mode.js new file mode 100644 index 000000000..948496383 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/duplicate-mode.js @@ -0,0 +1,25 @@ +import { __extends } from "tslib"; +import { TranslateMode } from './translate-mode'; +var DuplicateMode = /** @class */ (function (_super) { + __extends(DuplicateMode, _super); + function DuplicateMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + DuplicateMode.prototype.handleStartDragging = function (event, props) { + _super.prototype.handleStartDragging.call(this, event, props); + if (this._geometryBeforeTranslate) { + props.onEdit(this.getAddManyFeaturesAction(this._geometryBeforeTranslate, props.data)); + } + }; + DuplicateMode.prototype.updateCursor = function (props) { + if (this._isTranslatable) { + props.onUpdateCursor('copy'); + } + else { + props.onUpdateCursor(null); + } + }; + return DuplicateMode; +}(TranslateMode)); +export { DuplicateMode }; +//# sourceMappingURL=duplicate-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/duplicate-mode.js.map b/lib/modules/edit-modes/src/lib/duplicate-mode.js.map new file mode 100644 index 000000000..f5e0db2c0 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/duplicate-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"duplicate-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/duplicate-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;IAAmC,iCAAa;IAAhD;;IAgBA,CAAC;IAfC,2CAAmB,GAAnB,UAAoB,KAAyB,EAAE,KAAmC;QAChF,iBAAM,mBAAmB,YAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAExC,IAAI,IAAI,CAAC,wBAAwB,EAAE;YACjC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;SACxF;IACH,CAAC;IAED,oCAAY,GAAZ,UAAa,KAAmC;QAC9C,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;SAC9B;aAAM;YACL,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SAC5B;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAhBD,CAAmC,aAAa,GAgB/C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/edit-mode.d.ts b/lib/modules/edit-modes/src/lib/edit-mode.d.ts new file mode 100644 index 000000000..3343f32c2 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/edit-mode.d.ts @@ -0,0 +1,11 @@ +import { ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, Tooltip, ModeProps } from '../types'; +export interface EditMode { + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; + getGuides(props: ModeProps): TGuides | undefined; + getTooltips(props: ModeProps): Tooltip[]; +} +//# sourceMappingURL=edit-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/edit-mode.d.ts.map b/lib/modules/edit-modes/src/lib/edit-mode.d.ts.map new file mode 100644 index 000000000..eb3b236a8 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/edit-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"edit-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/edit-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,SAAS,EACV,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,QAAQ,CAAC,KAAK,EAAE,OAAO;IAEtC,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAE9D,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAE1E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAE9E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAE5E,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAEpE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC;IAExD,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,EAAE,CAAC;CACjD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/edit-mode.js b/lib/modules/edit-modes/src/lib/edit-mode.js new file mode 100644 index 000000000..90fb3894a --- /dev/null +++ b/lib/modules/edit-modes/src/lib/edit-mode.js @@ -0,0 +1,2 @@ +/* istanbul ignore file */ +//# sourceMappingURL=edit-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/edit-mode.js.map b/lib/modules/edit-modes/src/lib/edit-mode.js.map new file mode 100644 index 000000000..85238b95f --- /dev/null +++ b/lib/modules/edit-modes/src/lib/edit-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"edit-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/edit-mode.ts"],"names":[],"mappings":"AAAA,0BAA0B"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/elevation-mode.d.ts b/lib/modules/edit-modes/src/lib/elevation-mode.d.ts new file mode 100644 index 000000000..72e7394d4 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/elevation-mode.d.ts @@ -0,0 +1,14 @@ +import { ModeProps, PointerMoveEvent, StopDraggingEvent } from '../types'; +import { Position, FeatureCollection } from '../geojson-types'; +import { ModifyMode } from './modify-mode'; +export declare class ElevationMode extends ModifyMode { + makeElevatedEvent(event: PointerMoveEvent | StopDraggingEvent, position: Position, props: ModeProps): Record; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + getCursor(event: PointerMoveEvent): string | null | undefined; + static calculateElevationChangeWithViewport(viewport: any, { pointerDownScreenCoords, screenCoords, }: { + pointerDownScreenCoords: Position; + screenCoords: Position; + }): number; +} +//# sourceMappingURL=elevation-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/elevation-mode.d.ts.map b/lib/modules/edit-modes/src/lib/elevation-mode.d.ts.map new file mode 100644 index 000000000..3b8713ec8 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/elevation-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"elevation-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/elevation-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAY3C,qBAAa,aAAc,SAAQ,UAAU;IAC3C,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,EAC3C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA2BtB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAO9E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAOhF,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IAQ7D,MAAM,CAAC,oCAAoC,CACzC,QAAQ,EAAE,GAAG,EACb,EACE,uBAAuB,EACvB,YAAY,GACb,EAAE;QACD,uBAAuB,EAAE,QAAQ,CAAC;QAClC,YAAY,EAAE,QAAQ,CAAC;KACxB,GACA,MAAM;CAOV"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/elevation-mode.js b/lib/modules/edit-modes/src/lib/elevation-mode.js new file mode 100644 index 000000000..4dd4e7dad --- /dev/null +++ b/lib/modules/edit-modes/src/lib/elevation-mode.js @@ -0,0 +1,59 @@ +import { __extends } from "tslib"; +import { getPickedEditHandle } from '../utils'; +import { ModifyMode } from './modify-mode'; +function defaultCalculateElevationChange(_a) { + var pointerDownScreenCoords = _a.pointerDownScreenCoords, screenCoords = _a.screenCoords; + return 10 * (pointerDownScreenCoords[1] - screenCoords[1]); +} +var ElevationMode = /** @class */ (function (_super) { + __extends(ElevationMode, _super); + function ElevationMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + ElevationMode.prototype.makeElevatedEvent = function (event, position, props) { + var _a = props.modeConfig || {}, _b = _a.minElevation, minElevation = _b === void 0 ? 0 : _b, _c = _a.maxElevation, maxElevation = _c === void 0 ? 20000 : _c, _d = _a.calculateElevationChange, calculateElevationChange = _d === void 0 ? defaultCalculateElevationChange : _d; + if (!event.pointerDownScreenCoords) { + return event; + } + // $FlowFixMe - really, I know it has something at index 2 + var elevation = position.length === 3 ? position[2] : 0; + // calculateElevationChange is configurable because (at this time) modes are not aware of the viewport + elevation += calculateElevationChange({ + pointerDownScreenCoords: event.pointerDownScreenCoords, + screenCoords: event.screenCoords, + }); + elevation = Math.min(elevation, maxElevation); + elevation = Math.max(elevation, minElevation); + return Object.assign({}, event, { + mapCoords: [position[0], position[1], elevation], + }); + }; + ElevationMode.prototype.handlePointerMove = function (event, props) { + var editHandle = getPickedEditHandle(event.pointerDownPicks); + var position = editHandle ? editHandle.geometry.coordinates : event.mapCoords; + // @ts-ignore + _super.prototype.handlePointerMove.call(this, this.makeElevatedEvent(event, position, props), props); + }; + ElevationMode.prototype.handleStopDragging = function (event, props) { + var editHandle = getPickedEditHandle(event.picks); + var position = editHandle ? editHandle.geometry.coordinates : event.mapCoords; + // @ts-ignore + _super.prototype.handleStopDragging.call(this, this.makeElevatedEvent(event, position, props), props); + }; + ElevationMode.prototype.getCursor = function (event) { + var cursor = _super.prototype.getCursor.call(this, event); + if (cursor === 'cell') { + cursor = 'ns-resize'; + } + return cursor; + }; + ElevationMode.calculateElevationChangeWithViewport = function (viewport, _a) { + var pointerDownScreenCoords = _a.pointerDownScreenCoords, screenCoords = _a.screenCoords; + // Source: https://gis.stackexchange.com/a/127949/111804 + var metersPerPixel = (156543.03392 * Math.cos((viewport.latitude * Math.PI) / 180)) / Math.pow(2, viewport.zoom); + return (metersPerPixel * (pointerDownScreenCoords[1] - screenCoords[1])) / 2; + }; + return ElevationMode; +}(ModifyMode)); +export { ElevationMode }; +//# sourceMappingURL=elevation-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/elevation-mode.js.map b/lib/modules/edit-modes/src/lib/elevation-mode.js.map new file mode 100644 index 000000000..c2c3cc80b --- /dev/null +++ b/lib/modules/edit-modes/src/lib/elevation-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"elevation-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/elevation-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,SAAS,+BAA+B,CAAC,EAMxC;QALC,oDAAuB,EACvB,8BAAY;IAKZ,OAAO,EAAE,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;IAAmC,iCAAU;IAA7C;;IAsEA,CAAC;IArEC,yCAAiB,GAAjB,UACE,KAA2C,EAC3C,QAAkB,EAClB,KAAmC;QAE7B,IAAA,2BAIoB,EAHxB,oBAAgB,EAAhB,qCAAgB,EAChB,oBAAoB,EAApB,yCAAoB,EACpB,gCAA0D,EAA1D,+EACwB,CAAC;QAE3B,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,0DAA0D;QAC1D,IAAI,SAAS,GAAG,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AkB,YAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IAED,iCAAS,GAAT,UAAU,KAAuB;QAC/B,IAAI,MAAM,GAAG,iBAAM,SAAS,YAAC,KAAK,CAAC,CAAC;QACpC,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,GAAG,WAAW,CAAC;SACtB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,kDAAoC,GAA3C,UACE,QAAa,EACb,EAMC;YALC,oDAAuB,EACvB,8BAAY;QAMd,wDAAwD;QACxD,IAAM,cAAc,GAClB,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE9F,OAAO,CAAC,cAAc,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/E,CAAC;IACH,oBAAC;AAAD,CAAC,AAtED,CAAmC,UAAU,GAsE5C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts b/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts new file mode 100644 index 000000000..ba7e4193e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts @@ -0,0 +1,10 @@ +import { LineString, FeatureCollection } from '../geojson-types'; +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class ExtendLineStringMode extends GeoJsonEditMode { + getSingleSelectedLineString(props: ModeProps): LineString | null | undefined; + handleClick(event: ClickEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=extend-line-string-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts.map b/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts.map new file mode 100644 index 000000000..39bccb93c --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extend-line-string-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"extend-line-string-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/extend-line-string-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,2BAA2B,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAS/F,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAgClE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IAsCtE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extend-line-string-mode.js b/lib/modules/edit-modes/src/lib/extend-line-string-mode.js new file mode 100644 index 000000000..7dc38d974 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extend-line-string-mode.js @@ -0,0 +1,83 @@ +import { __extends } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var ExtendLineStringMode = /** @class */ (function (_super) { + __extends(ExtendLineStringMode, _super); + function ExtendLineStringMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + ExtendLineStringMode.prototype.getSingleSelectedLineString = function (props) { + var selectedGeometry = this.getSelectedGeometry(props); + if (selectedGeometry && selectedGeometry.type === 'LineString') { + return selectedGeometry; + } + return null; + }; + ExtendLineStringMode.prototype.handleClick = function (event, props) { + var selectedIndexes = props.selectedIndexes; + var selectedLineString = this.getSingleSelectedLineString(props); + if (!selectedLineString) { + console.warn("ExtendLineStringMode only supported for single LineString selection"); // eslint-disable-line + return; + } + // Extend the LineString + var positionIndexes = [selectedLineString.coordinates.length]; + var modeConfig = props.modeConfig; + if (modeConfig && modeConfig.drawAtFront) { + positionIndexes = [0]; + } + var featureIndex = selectedIndexes[0]; + var updatedData = new ImmutableFeatureCollection(props.data) + .addPosition(featureIndex, positionIndexes, event.mapCoords) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'addPosition', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: positionIndexes, + position: event.mapCoords, + }, + }); + }; + ExtendLineStringMode.prototype.getGuides = function (props) { + var guides = { + type: 'FeatureCollection', + features: [], + }; + var selectedLineString = this.getSingleSelectedLineString(props); + if (!selectedLineString) { + // nothing to do + // @ts-ignore + return guides; + } + var mapCoords = props.lastPointerMoveEvent && props.lastPointerMoveEvent.mapCoords; + // Draw an extension line starting from one end of the selected LineString to the cursor + var startPosition = null; + var modeConfig = props.modeConfig; + if (modeConfig && modeConfig.drawAtFront) { + startPosition = selectedLineString.coordinates[0]; + } + else { + startPosition = selectedLineString.coordinates[selectedLineString.coordinates.length - 1]; + } + guides.features.push({ + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: [startPosition, mapCoords], + }, + }); + // @ts-ignore + return guides; + }; + ExtendLineStringMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + return ExtendLineStringMode; +}(GeoJsonEditMode)); +export { ExtendLineStringMode }; +//# sourceMappingURL=extend-line-string-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extend-line-string-mode.js.map b/lib/modules/edit-modes/src/lib/extend-line-string-mode.js.map new file mode 100644 index 000000000..1590f3f79 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extend-line-string-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extend-line-string-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/extend-line-string-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;IAA0C,wCAAe;IAAzD;;IAmFA,CAAC;IAlFC,0DAA2B,GAA3B,UAA4B,KAAmC;QAC7D,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAEzD,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,IAAI,KAAK,YAAY,EAAE;YAC9D,OAAO,gBAAgB,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0CAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QACxD,IAAA,uCAAe,CAAW;QAClC,IAAM,kBAAkB,GAAG,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAEnE,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC,CAAC,sBAAsB;YAC3G,OAAO;SACR;QAED,wBAAwB;QACxB,IAAI,eAAe,GAAG,CAAC,kBAAkB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE9D,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE;YACxC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC;SACvB;QACD,IAAM,Y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AAI,EAAE,YAAY;gBAClB,WAAW,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC;aACxC;SACF,CAAC,CAAC;QACH,aAAa;QACb,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gDAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACH,2BAAC;AAAD,CAAC,AAnFD,CAA0C,eAAe,GAmFxD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extrude-mode.d.ts b/lib/modules/edit-modes/src/lib/extrude-mode.d.ts new file mode 100644 index 000000000..bfbff0261 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extrude-mode.d.ts @@ -0,0 +1,16 @@ +import { FeatureCollection } from '../geojson-types'; +import { ModeProps, StartDraggingEvent, StopDraggingEvent, DraggingEvent } from '../types'; +import { ModifyMode } from './modify-mode'; +export declare class ExtrudeMode extends ModifyMode { + isPointAdded: boolean; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + coordinatesSize(positionIndexes: number[] | null | undefined, featureIndex: number, { features }: FeatureCollection): number; + getBearing(p1: any, p2: any): number; + isOrthogonal(positionIndexes: number[] | null | undefined, featureIndex: number, size: number, features: FeatureCollection): boolean; + nextPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[]; + prevPositionIndexes(positionIndexes: number[] | null | undefined, size: number): number[]; + getPointForPositionIndexes(positionIndexes: number[] | null | undefined, featureIndex: number, { features }: FeatureCollection): any; +} +//# sourceMappingURL=extrude-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extrude-mode.d.ts.map b/lib/modules/edit-modes/src/lib/extrude-mode.d.ts.map new file mode 100644 index 000000000..12e021880 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extrude-mode.d.ts.map @@ -0,0 +1 @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AG,SAAS,EAC5C,YAAY,EAAE,MAAM,EACpB,EAAE,QAAQ,EAAE,EAAE,iBAAiB;CAqBlC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extrude-mode.js b/lib/modules/edit-modes/src/lib/extrude-mode.js new file mode 100644 index 000000000..2ec6a8ae8 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extrude-mode.js @@ -0,0 +1,197 @@ +import { __extends, __read, __spread } from "tslib"; +import bearing from '@turf/bearing'; +import { generatePointsParallelToLinePoints, getPickedEditHandle, getPickedIntermediateEditHandle, } from '../utils'; +import { ModifyMode } from './modify-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var ExtrudeMode = /** @class */ (function (_super) { + __extends(ExtrudeMode, _super); + function ExtrudeMode() { + // this mode is busted =( + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.isPointAdded = false; + return _this; + } + ExtrudeMode.prototype.handleDragging = function (event, props) { + var editHandle = getPickedEditHandle(event.pointerDownPicks); + if (editHandle) { + var featureIndex = editHandle.properties.featureIndex; + var positionIndexes = editHandle.properties.positionIndexes; + var size = this.coordinatesSize(positionIndexes, featureIndex, props.data); + positionIndexes = this.isPointAdded + ? this.nextPositionIndexes(positionIndexes, size) + : positionIndexes; + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), featureIndex, props.data); + var p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data); + if (p1 && p2) { + // p3 and p4 are end points for moving (extruding) edge + var _a = __read(generatePointsParallelToLinePoints(p1, p2, event.mapCoords), 2), p3 = _a[0], p4 = _a[1]; + var updatedData = new ImmutableFeatureCollection(props.data) + .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4) + .replacePosition(featureIndex, positionIndexes, p3) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'extruding', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: this.nextPositionIndexes(positionIndexes, size), + position: p3, + }, + }); + event.cancelPan(); + } + } + }; + ExtrudeMode.prototype.handleStartDragging = function (event, props) { + var selectedFeatureIndexes = props.selectedIndexes; + var editHandle = getPickedIntermediateEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle) { + var _a = editHandle.properties, positionIndexes = _a.positionIndexes, featureIndex = _a.featureIndex; + var size = this.coordinatesSize(positionIndexes, featureIndex, props.data); + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), featureIndex, props.data); + var p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data); + if (p1 && p2) { + var updatedData = new ImmutableFeatureCollection(props.data); + if (!this.isOrthogonal(positionIndexes, featureIndex, size, props.data)) { + updatedData = updatedData.addPosition(featureIndex, positionIndexes, p2); + } + if (!this.isOrthogonal(this.prevPositionIndexes(positionIndexes, size), featureIndex, size, props.data)) { + updatedData = updatedData.addPosition(featureIndex, positionIndexes, p1); + this.isPointAdded = true; + } + props.onEdit({ + updatedData: updatedData.getObject(), + editType: 'startExtruding', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: positionIndexes, + position: p1, + }, + }); + } + } + }; + ExtrudeMode.prototype.handleStopDragging = function (event, props) { + var selectedFeatureIndexes = props.selectedIndexes; + var editHandle = getPickedEditHandle(event.pointerDownPicks); + if (selectedFeatureIndexes.length && editHandle) { + var featureIndex = editHandle.properties.featureIndex; + var positionIndexes = editHandle.properties.positionIndexes; + var size = this.coordinatesSize(positionIndexes, featureIndex, props.data); + positionIndexes = this.isPointAdded + ? this.nextPositionIndexes(positionIndexes, size) + : positionIndexes; + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), featureIndex, props.data); + var p2 = this.getPointForPositionIndexes(positionIndexes, featureIndex, props.data); + if (p1 && p2) { + // p3 and p4 are end points for new moved (extruded) edge + var _a = __read(generatePointsParallelToLinePoints(p1, p2, event.mapCoords), 2), p3 = _a[0], p4 = _a[1]; + var updatedData = new ImmutableFeatureCollection(props.data) + .replacePosition(featureIndex, this.prevPositionIndexes(positionIndexes, size), p4) + .replacePosition(featureIndex, positionIndexes, p3) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'extruded', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: positionIndexes, + position: p3, + }, + }); + } + } + this.isPointAdded = false; + }; + ExtrudeMode.prototype.coordinatesSize = function (positionIndexes, featureIndex, _a) { + var features = _a.features; + var size = 0; + if (Array.isArray(positionIndexes)) { + var feature = features[featureIndex]; + var coordinates = feature.geometry.coordinates; + // for Multi polygons, length will be 3 + if (positionIndexes.length === 3) { + var _b = __read(positionIndexes, 2), a = _b[0], b = _b[1]; + if (coordinates.length && coordinates[a].length) { + size = coordinates[a][b].length; + } + } + else { + var _c = __read(positionIndexes, 1), b = _c[0]; + if (coordinates.length && coordinates[b].length) { + size = coordinates[b].length; + } + } + } + return size; + }; + ExtrudeMode.prototype.getBearing = function (p1, p2) { + var angle = bearing(p1, p2); + if (angle < 0) { + return Math.floor(360 + angle); + } + return Math.floor(angle); + }; + ExtrudeMode.prototype.isOrthogonal = function (positionIndexes, featureIndex, size, features) { + if (!Array.isArray(positionIndexes)) { + return false; + } + if (positionIndexes[positionIndexes.length - 1] === size - 1) { + positionIndexes[positionIndexes.length - 1] = 0; + } + var prevPoint = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), featureIndex, features); + var nextPoint = this.getPointForPositionIndexes(this.nextPositionIndexes(positionIndexes, size), featureIndex, features); + var currentPoint = this.getPointForPositionIndexes(positionIndexes, featureIndex, features); + var prevAngle = this.getBearing(currentPoint, prevPoint); + var nextAngle = this.getBearing(currentPoint, nextPoint); + return [89, 90, 91, 269, 270, 271].includes(Math.abs(prevAngle - nextAngle)); + }; + ExtrudeMode.prototype.nextPositionIndexes = function (positionIndexes, size) { + if (!Array.isArray(positionIndexes)) { + return []; + } + var next = __spread(positionIndexes); + if (next.length) { + next[next.length - 1] = next[next.length - 1] === size - 1 ? 0 : next[next.length - 1] + 1; + } + return next; + }; + ExtrudeMode.prototype.prevPositionIndexes = function (positionIndexes, size) { + if (!Array.isArray(positionIndexes)) { + return []; + } + var prev = __spread(positionIndexes); + if (prev.length) { + prev[prev.length - 1] = prev[prev.length - 1] === 0 ? size - 2 : prev[prev.length - 1] - 1; + } + return prev; + }; + ExtrudeMode.prototype.getPointForPositionIndexes = function (positionIndexes, featureIndex, _a) { + var features = _a.features; + var p1; + if (Array.isArray(positionIndexes)) { + var feature = features[featureIndex]; + var coordinates = feature.geometry.coordinates; + // for Multi polygons, length will be 3 + if (positionIndexes.length === 3) { + var _b = __read(positionIndexes, 3), a = _b[0], b = _b[1], c = _b[2]; + if (coordinates.length && coordinates[a].length) { + p1 = coordinates[a][b][c]; + } + } + else { + var _c = __read(positionIndexes, 2), b = _c[0], c = _c[1]; + if (coordinates.length && coordinates[b].length) { + p1 = coordinates[b][c]; + } + } + } + return p1; + }; + return ExtrudeMode; +}(ModifyMode)); +export { ExtrudeMode }; +//# sourceMappingURL=extrude-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/extrude-mode.js.map b/lib/modules/edit-modes/src/lib/extrude-mode.js.map new file mode 100644 index 000000000..70f62cd91 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/extrude-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extrude-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/extrude-mode.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,kCAAkC,EAClC,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;IAAiC,+BAAU;IAA3C;QACE,yBAAyB;QAD3B,qEAkPC;QA/OC,kBAAY,GAAG,KAAK,CAAC;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,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gDAA0B,GAA1B,UACE,eAA4C,EAC5C,YAAoB,EACpB,EAA+B;YAA7B,sBAAQ;QAEV,IAAI,EAAE,CAAC;QACP,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;YAClC,IAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;YACvC,IAAM,WAAW,GAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YACtD,uCAAuC;YACvC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC1B,IAAA,+BAA2B,EAA1B,SAAC,EAAE,SAAC,EAAE,SAAoB,CAAC;gBAClC,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;oBAC/C,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC3B;aACF;iBAAM;gBACC,IAAA,+BAAwB,EAAvB,SAAC,EAAE,SAAoB,CAAC;gBAC/B,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;oBAC/C,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxB;aACF;SACF;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,kBAAC;AAAD,CAAC,AAlPD,CAAiC,UAAU,GAkP1C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts b/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts new file mode 100644 index 000000000..c16762429 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts @@ -0,0 +1,28 @@ +import { EditAction, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, Pick, Tooltip, ModeProps, GuideFeatureCollection, TentativeFeature } from '../types'; +import { FeatureCollection, Feature, Polygon, Geometry, Position } from '../geojson-types'; +import { EditMode } from './edit-mode'; +export declare type GeoJsonEditAction = EditAction; +export declare type GeoJsonEditModeType = EditMode; +export declare class GeoJsonEditMode implements EditMode { + _clickSequence: Position[]; + getGuides(props: ModeProps): GuideFeatureCollection; + getTooltips(props: ModeProps): Tooltip[]; + getSelectedFeature(props: ModeProps): Feature | null | undefined; + getSelectedGeometry(props: ModeProps): Geometry | null | undefined; + getSelectedFeaturesAsFeatureCollection(props: ModeProps): FeatureCollection; + getClickSequence(): Position[]; + addClickSequence({ mapCoords }: ClickEvent): void; + resetClickSequence(): void; + getTentativeGuide(props: ModeProps): TentativeFeature | null | undefined; + isSelectionPicked(picks: Pick[], props: ModeProps): boolean; + getAddFeatureAction(featureOrGeometry: Geometry | Feature, features: FeatureCollection): GeoJsonEditAction; + getAddManyFeaturesAction({ features: featuresToAdd }: FeatureCollection, features: FeatureCollection): GeoJsonEditAction; + getAddFeatureOrBooleanPolygonAction(featureOrGeometry: Polygon | Feature, props: ModeProps): GeoJsonEditAction | null | undefined; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; +} +export declare function getIntermediatePosition(position1: Position, position2: Position): Position; +//# sourceMappingURL=geojson-edit-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts.map b/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts.map new file mode 100644 index 000000000..f65bd23f7 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/geojson-edit-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-edit-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/geojson-edit-mode.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU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AAE,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO;IAU9E,mBAAmB,CACjB,iBAAiB,EAAE,QAAQ,GAAG,OAAO,EACrC,QAAQ,EAAE,iBAAiB,GAC1B,iBAAiB;IAwBpB,wBAAwB,CACtB,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,iBAAiB,EAC9C,QAAQ,EAAE,iBAAiB,GAC1B,iBAAiB;IAwBpB,mCAAmC,CACjC,iBAAiB,EAAE,OAAO,GAAG,OAAO,EACpC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAClC,iBAAiB,GAAG,IAAI,GAAG,SAAS;IAkEvC,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IACzE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IACrF,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IACzF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IACvF,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;CAChF;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAO1F"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/geojson-edit-mode.js b/lib/modules/edit-modes/src/lib/geojson-edit-mode.js new file mode 100644 index 000000000..b7dfbd0ca --- /dev/null +++ b/lib/modules/edit-modes/src/lib/geojson-edit-mode.js @@ -0,0 +1,196 @@ +import { __read, __spread, __values } from "tslib"; +import turfUnion from '@turf/union'; +import turfDifference from '@turf/difference'; +import turfIntersect from '@turf/intersect'; +import { getPickedEditHandles, getNonGuidePicks } from '../utils'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var DEFAULT_GUIDES = { + type: 'FeatureCollection', + features: [], +}; +var DEFAULT_TOOLTIPS = []; +var GeoJsonEditMode = /** @class */ (function () { + function GeoJsonEditMode() { + this._clickSequence = []; + } + GeoJsonEditMode.prototype.getGuides = function (props) { + return DEFAULT_GUIDES; + }; + GeoJsonEditMode.prototype.getTooltips = function (props) { + return DEFAULT_TOOLTIPS; + }; + GeoJsonEditMode.prototype.getSelectedFeature = function (props) { + if (props.selectedIndexes.length === 1) { + return props.data.features[props.selectedIndexes[0]]; + } + return null; + }; + GeoJsonEditMode.prototype.getSelectedGeometry = function (props) { + var feature = this.getSelectedFeature(props); + if (feature) { + return feature.geometry; + } + return null; + }; + GeoJsonEditMode.prototype.getSelectedFeaturesAsFeatureCollection = function (props) { + var features = props.data.features; + var selectedFeatures = props.selectedIndexes.map(function (selectedIndex) { return features[selectedIndex]; }); + return { + type: 'FeatureCollection', + features: selectedFeatures, + }; + }; + GeoJsonEditMode.prototype.getClickSequence = function () { + return this._clickSequence; + }; + GeoJsonEditMode.prototype.addClickSequence = function (_a) { + var mapCoords = _a.mapCoords; + this._clickSequence.push(mapCoords); + }; + GeoJsonEditMode.prototype.resetClickSequence = function () { + this._clickSequence = []; + }; + GeoJsonEditMode.prototype.getTentativeGuide = function (props) { + var guides = this.getGuides(props); + // @ts-ignore + return guides.features.find(function (f) { return f.properties && f.properties.guideType === 'tentative'; }); + }; + GeoJsonEditMode.prototype.isSelectionPicked = function (picks, props) { + if (!picks.length) + return false; + var pickedFeatures = getNonGuidePicks(picks).map(function (_a) { + var index = _a.index; + return index; + }); + var pickedHandles = getPickedEditHandles(picks).map(function (_a) { + var properties = _a.properties; + return properties.featureIndex; + }); + var pickedIndexes = new Set(__spread(pickedFeatures, pickedHandles)); + return props.selectedIndexes.some(function (index) { return pickedIndexes.has(index); }); + }; + GeoJsonEditMode.prototype.getAddFeatureAction = function (featureOrGeometry, features) { + // Unsure why flow can't deal with Geometry type, but there I fixed it + var featureOrGeometryAsAny = featureOrGeometry; + var feature = featureOrGeometryAsAny.type === 'Feature' + ? featureOrGeometryAsAny + : { + type: 'Feature', + properties: {}, + geometry: featureOrGeometryAsAny, + }; + var updatedData = new ImmutableFeatureCollection(features).addFeature(feature).getObject(); + return { + updatedData: updatedData, + editType: 'addFeature', + editContext: { + featureIndexes: [updatedData.features.length - 1], + }, + }; + }; + GeoJsonEditMode.prototype.getAddManyFeaturesAction = function (_a, features) { + var e_1, _b; + var featuresToAdd = _a.features; + var updatedData = new ImmutableFeatureCollection(features); + var initialIndex = updatedData.getObject().features.length; + var updatedIndexes = []; + try { + for (var featuresToAdd_1 = __values(featuresToAdd), featuresToAdd_1_1 = featuresToAdd_1.next(); !featuresToAdd_1_1.done; featuresToAdd_1_1 = featuresToAdd_1.next()) { + var feature = featuresToAdd_1_1.value; + var properties = feature.properties, geometry = feature.geometry; + var geometryAsAny = geometry; + updatedData = updatedData.addFeature({ + type: 'Feature', + properties: properties, + geometry: geometryAsAny, + }); + updatedIndexes.push(initialIndex + updatedIndexes.length); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (featuresToAdd_1_1 && !featuresToAdd_1_1.done && (_b = featuresToAdd_1.return)) _b.call(featuresToAdd_1); + } + finally { if (e_1) throw e_1.error; } + } + return { + updatedData: updatedData.getObject(), + editType: 'addFeature', + editContext: { + featureIndexes: updatedIndexes, + }, + }; + }; + GeoJsonEditMode.prototype.getAddFeatureOrBooleanPolygonAction = function (featureOrGeometry, props) { + var featureOrGeometryAsAny = featureOrGeometry; + var selectedFeature = this.getSelectedFeature(props); + var modeConfig = props.modeConfig; + if (modeConfig && modeConfig.booleanOperation) { + if (!selectedFeature || + (selectedFeature.geometry.type !== 'Polygon' && + selectedFeature.geometry.type !== 'MultiPolygon')) { + // eslint-disable-next-line no-console,no-undef + console.warn('booleanOperation only supported for single Polygon or MultiPolygon selection'); + return null; + } + var feature = featureOrGeometryAsAny.type === 'Feature' + ? featureOrGeometryAsAny + : { + type: 'Feature', + geometry: featureOrGeometryAsAny, + }; + var updatedGeometry = void 0; + if (modeConfig.booleanOperation === 'union') { + updatedGeometry = turfUnion(selectedFeature, feature); + } + else if (modeConfig.booleanOperation === 'difference') { + // @ts-ignore + updatedGeometry = turfDifference(selectedFeature, feature); + } + else if (modeConfig.booleanOperation === 'intersection') { + // @ts-ignore + updatedGeometry = turfIntersect(selectedFeature, feature); + } + else { + // eslint-disable-next-line no-console,no-undef + console.warn("Invalid booleanOperation " + modeConfig.booleanOperation); + return null; + } + if (!updatedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('Canceling edit. Boolean operation erased entire polygon.'); + return null; + } + var featureIndex = props.selectedIndexes[0]; + var updatedData = new ImmutableFeatureCollection(props.data) + .replaceGeometry(featureIndex, updatedGeometry.geometry) + .getObject(); + var editAction = { + updatedData: updatedData, + editType: 'unionGeometry', + editContext: { + featureIndexes: [featureIndex], + }, + }; + return editAction; + } + return this.getAddFeatureAction(featureOrGeometry, props.data); + }; + GeoJsonEditMode.prototype.handleClick = function (event, props) { }; + GeoJsonEditMode.prototype.handlePointerMove = function (event, props) { }; + GeoJsonEditMode.prototype.handleStartDragging = function (event, props) { }; + GeoJsonEditMode.prototype.handleStopDragging = function (event, props) { }; + GeoJsonEditMode.prototype.handleDragging = function (event, props) { }; + return GeoJsonEditMode; +}()); +export { GeoJsonEditMode }; +export function getIntermediatePosition(position1, position2) { + var intermediatePosition = [ + (position1[0] + position2[0]) / 2.0, + (position1[1] + position2[1]) / 2.0, + ]; + // @ts-ignore + return intermediatePosition; +} +//# sourceMappingURL=geojson-edit-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/geojson-edit-mode.js.map b/lib/modules/edit-modes/src/lib/geojson-edit-mode.js.map new file mode 100644 index 000000000..cbaa5c024 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/geojson-edit-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-edit-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/geojson-edit-mode.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAgB5C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAElE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAI5E,IAAM,cAAc,GAA2B;IAC7C,IAAI,EAAE,mBAAmB;IACzB,QAAQ,EAAE,EAAE;CACb,CAAC;AACF,IAAM,gBAAgB,GAAc,EAAE,CAAC;AAKvC;IAAA;QACE,mBAAc,GAAe,EAAE,CAAC;IA+LlC,CAAC;IA7LC,mCAAS,GAAT,UAAU,KAAmC;QAC3C,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,qCAAW,GAAX,UAAY,KAAmC;QAC7C,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,4CAAkB,GAAlB,UAAmB,KAAmC;QACpD,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YACtC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAAmB,GAAnB,UAAoB,KAAmC;QACrD,IAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,QAAQ,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gEAAsC,GAAtC,UAAuC,KAAmC;QAChE,IAAA,8BAAQ,CAAgB;QAChC,IAAM,gBAAgB,GAAG,K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IAC9E,IAAM,oBAAoB,GAAG;QAC3B,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;QACnC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;KACpC,CAAC;IACF,aAAa;IACb,OAAO,oBAAoB,CAAC;AAC9B,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts b/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts new file mode 100644 index 000000000..e1c80fdff --- /dev/null +++ b/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts @@ -0,0 +1,44 @@ +import { Feature, FeatureCollection, Geometry, Position } from '../geojson-types'; +export declare class ImmutableFeatureCollection { + featureCollection: FeatureCollection; + constructor(featureCollection: FeatureCollection); + getObject(): FeatureCollection; + /** + * Replaces the position deeply nested withing the given feature's geometry. + * Works with Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the position to replace + * @param updatedPosition The updated position to place in the result (i.e. [lng, lat]) + * + * @returns A new `ImmutableFeatureCollection` with the given position replaced. Does not modify this `ImmutableFeatureCollection`. + */ + replacePosition(featureIndex: number, positionIndexes: number[] | null | undefined, updatedPosition: Position): ImmutableFeatureCollection; + /** + * Removes a position deeply nested in a GeoJSON geometry coordinates array. + * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the postion to remove + * + * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`. + */ + removePosition(featureIndex: number, positionIndexes: number[] | null | undefined): ImmutableFeatureCollection; + /** + * Adds a position deeply nested in a GeoJSON geometry coordinates array. + * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the position that will proceed the new position + * @param positionToAdd The new position to place in the result (i.e. [lng, lat]) + * + * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`. + */ + addPosition(featureIndex: number, positionIndexes: number[] | null | undefined, positionToAdd: Position): ImmutableFeatureCollection; + replaceGeometry(featureIndex: number, geometry: Geometry): ImmutableFeatureCollection; + addFeature(feature: Feature): ImmutableFeatureCollection; + addFeatures(features: Feature[]): ImmutableFeatureCollection; + deleteFeature(featureIndex: number): ImmutableFeatureCollection; + deleteFeatures(featureIndexes: number[]): ImmutableFeatureCollection; +} +//# sourceMappingURL=immutable-feature-collection.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts.map b/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts.map new file mode 100644 index 000000000..f7690ff62 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/immutable-feature-collection.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"immutable-feature-collection.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/immutable-feature-collection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,QAAQ,EAIR,QAAQ,EAET,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,0BAA0B;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;gBAEzB,iBAAiB,EAAE,iBAAiB;IAIhD,SAAS;IAIT;;;;;;;;;OASG;IACH,eAAe,CACb,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EAC5C,eAAe,EAAE,QAAQ,GACxB,0BAA0B;IAiB7B;;;;;;;;OAQG;IACH,cAAc,CACZ,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,GAC3C,0BAA0B;IA0D7B;;;;;;;;;OASG;IACH,WAAW,CACT,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,EAC5C,aAAa,EAAE,QAAQ,GACtB,0BAA0B;IAqB7B,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,0BAA0B;IAkBrF,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,0BAA0B;IAIxD,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,0BAA0B;IAS5D,aAAa,CAAC,YAAY,EAAE,MAAM;IAIlC,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE;CAiBxC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/immutable-feature-collection.js b/lib/modules/edit-modes/src/lib/immutable-feature-collection.js new file mode 100644 index 000000000..91c9a161b --- /dev/null +++ b/lib/modules/edit-modes/src/lib/immutable-feature-collection.js @@ -0,0 +1,267 @@ +import { __assign, __read, __spread } from "tslib"; +var ImmutableFeatureCollection = /** @class */ (function () { + function ImmutableFeatureCollection(featureCollection) { + this.featureCollection = featureCollection; + } + ImmutableFeatureCollection.prototype.getObject = function () { + return this.featureCollection; + }; + /** + * Replaces the position deeply nested withing the given feature's geometry. + * Works with Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the position to replace + * @param updatedPosition The updated position to place in the result (i.e. [lng, lat]) + * + * @returns A new `ImmutableFeatureCollection` with the given position replaced. Does not modify this `ImmutableFeatureCollection`. + */ + ImmutableFeatureCollection.prototype.replacePosition = function (featureIndex, positionIndexes, updatedPosition) { + var geometry = this.featureCollection.features[featureIndex].geometry; + var isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon'; + var updatedGeometry = __assign(__assign({}, geometry), { coordinates: immutablyReplacePosition(geometry.coordinates, positionIndexes, updatedPosition, isPolygonal) }); + return this.replaceGeometry(featureIndex, updatedGeometry); + }; + /** + * Removes a position deeply nested in a GeoJSON geometry coordinates array. + * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the postion to remove + * + * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`. + */ + ImmutableFeatureCollection.prototype.removePosition = function (featureIndex, positionIndexes) { + var geometry = this.featureCollection.features[featureIndex].geometry; + if (geometry.type === 'Point') { + throw Error("Can't remove a position from a Point or there'd be nothing left"); + } + if (geometry.type === 'MultiPoint' && // only 1 point left + geometry.coordinates.length < 2) { + throw Error("Can't remove the last point of a MultiPoint or there'd be nothing left"); + } + if (geometry.type === 'LineString' && // only 2 positions + geometry.coordinates.length < 3) { + throw Error("Can't remove position. LineString must have at least two positions"); + } + if (geometry.type === 'Polygon' && // outer ring is a triangle + geometry.coordinates[0].length < 5 && + Array.isArray(positionIndexes) && // trying to remove from outer ring + positionIndexes[0] === 0) { + throw Error("Can't remove position. Polygon's outer ring must have at least four positions"); + } + if (geometry.type === 'MultiLineString' && // only 1 LineString left + geometry.coordinates.length === 1 && // only 2 positions + geometry.coordinates[0].length < 3) { + throw Error("Can't remove position. MultiLineString must have at least two positions"); + } + if (geometry.type === 'MultiPolygon' && // only 1 polygon left + geometry.coordinates.length === 1 && // outer ring is a triangle + geometry.coordinates[0][0].length < 5 && + Array.isArray(positionIndexes) && // trying to remove from first polygon + positionIndexes[0] === 0 && // trying to remove from outer ring + positionIndexes[1] === 0) { + throw Error("Can't remove position. MultiPolygon's outer ring must have at least four positions"); + } + var isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon'; + var updatedGeometry = __assign(__assign({}, geometry), { coordinates: immutablyRemovePosition(geometry.coordinates, positionIndexes, isPolygonal) }); + // Handle cases where incomplete geometries need pruned (e.g. holes that were triangles) + pruneGeometryIfNecessary(updatedGeometry); + return this.replaceGeometry(featureIndex, updatedGeometry); + }; + /** + * Adds a position deeply nested in a GeoJSON geometry coordinates array. + * Works with MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon. + * + * @param featureIndex The index of the feature to update + * @param positionIndexes An array containing the indexes of the position that will proceed the new position + * @param positionToAdd The new position to place in the result (i.e. [lng, lat]) + * + * @returns A new `ImmutableFeatureCollection` with the given coordinate removed. Does not modify this `ImmutableFeatureCollection`. + */ + ImmutableFeatureCollection.prototype.addPosition = function (featureIndex, positionIndexes, positionToAdd) { + var geometry = this.featureCollection.features[featureIndex].geometry; + if (geometry.type === 'Point') { + throw new Error('Unable to add a position to a Point feature'); + } + var isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon'; + var updatedGeometry = __assign(__assign({}, geometry), { coordinates: immutablyAddPosition(geometry.coordinates, positionIndexes, positionToAdd, isPolygonal) }); + return this.replaceGeometry(featureIndex, updatedGeometry); + }; + ImmutableFeatureCollection.prototype.replaceGeometry = function (featureIndex, geometry) { + var updatedFeature = __assign(__assign({}, this.featureCollection.features[featureIndex]), { geometry: geometry }); + var updatedFeatureCollection = __assign(__assign({}, this.featureCollection), { features: __spread(this.featureCollection.features.slice(0, featureIndex), [ + updatedFeature + ], this.featureCollection.features.slice(featureIndex + 1)) }); + return new ImmutableFeatureCollection(updatedFeatureCollection); + }; + ImmutableFeatureCollection.prototype.addFeature = function (feature) { + return this.addFeatures([feature]); + }; + ImmutableFeatureCollection.prototype.addFeatures = function (features) { + var updatedFeatureCollection = __assign(__assign({}, this.featureCollection), { features: __spread(this.featureCollection.features, features) }); + return new ImmutableFeatureCollection(updatedFeatureCollection); + }; + ImmutableFeatureCollection.prototype.deleteFeature = function (featureIndex) { + return this.deleteFeatures([featureIndex]); + }; + ImmutableFeatureCollection.prototype.deleteFeatures = function (featureIndexes) { + var features = __spread(this.featureCollection.features); + featureIndexes.sort(); + for (var i = featureIndexes.length - 1; i >= 0; i--) { + var featureIndex = featureIndexes[i]; + if (featureIndex >= 0 && featureIndex < features.length) { + features.splice(featureIndex, 1); + } + } + var updatedFeatureCollection = __assign(__assign({}, this.featureCollection), { features: features }); + return new ImmutableFeatureCollection(updatedFeatureCollection); + }; + return ImmutableFeatureCollection; +}()); +export { ImmutableFeatureCollection }; +function getUpdatedPosition(updatedPosition, previousPosition) { + // This function checks if the updatedPosition is missing elevation + // and copies it from previousPosition + if (updatedPosition.length === 2 && previousPosition.length === 3) { + var elevation = previousPosition[2]; + return [updatedPosition[0], updatedPosition[1], elevation]; + } + return updatedPosition; +} +function immutablyReplacePosition(coordinates, positionIndexes, updatedPosition, isPolygonal) { + if (!positionIndexes) { + return coordinates; + } + if (positionIndexes.length === 0) { + return getUpdatedPosition(updatedPosition, coordinates); + } + if (positionIndexes.length === 1) { + var updated = __spread(coordinates.slice(0, positionIndexes[0]), [ + getUpdatedPosition(updatedPosition, coordinates[positionIndexes[0]]) + ], coordinates.slice(positionIndexes[0] + 1)); + if (isPolygonal && + (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)) { + // for polygons, the first point is repeated at the end of the array + // so, update it on both ends of the array + updated[0] = getUpdatedPosition(updatedPosition, coordinates[0]); + updated[coordinates.length - 1] = getUpdatedPosition(updatedPosition, coordinates[0]); + } + return updated; + } + // recursively update inner array + return __spread(coordinates.slice(0, positionIndexes[0]), [ + immutablyReplacePosition(coordinates[positionIndexes[0]], positionIndexes.slice(1, positionIndexes.length), updatedPosition, isPolygonal) + ], coordinates.slice(positionIndexes[0] + 1)); +} +function immutablyRemovePosition(coordinates, positionIndexes, isPolygonal) { + if (!positionIndexes) { + return coordinates; + } + if (positionIndexes.length === 0) { + throw Error('Must specify the index of the position to remove'); + } + if (positionIndexes.length === 1) { + var updated = __spread(coordinates.slice(0, positionIndexes[0]), coordinates.slice(positionIndexes[0] + 1)); + if (isPolygonal && + (positionIndexes[0] === 0 || positionIndexes[0] === coordinates.length - 1)) { + // for polygons, the first point is repeated at the end of the array + // so, if the first/last coordinate is to be removed, coordinates[1] will be the new first/last coordinate + if (positionIndexes[0] === 0) { + // change the last to be the same as the first + updated[updated.length - 1] = updated[0]; + } + else if (positionIndexes[0] === coordinates.length - 1) { + // change the first to be the same as the last + updated[0] = updated[updated.length - 1]; + } + } + return updated; + } + // recursively update inner array + return __spread(coordinates.slice(0, positionIndexes[0]), [ + immutablyRemovePosition(coordinates[positionIndexes[0]], positionIndexes.slice(1, positionIndexes.length), isPolygonal) + ], coordinates.slice(positionIndexes[0] + 1)); +} +function immutablyAddPosition(coordinates, positionIndexes, positionToAdd, isPolygonal) { + if (!positionIndexes) { + return coordinates; + } + if (positionIndexes.length === 0) { + throw Error('Must specify the index of the position to remove'); + } + if (positionIndexes.length === 1) { + var updated = __spread(coordinates.slice(0, positionIndexes[0]), [ + positionToAdd + ], coordinates.slice(positionIndexes[0])); + return updated; + } + // recursively update inner array + return __spread(coordinates.slice(0, positionIndexes[0]), [ + immutablyAddPosition(coordinates[positionIndexes[0]], positionIndexes.slice(1, positionIndexes.length), positionToAdd, isPolygonal) + ], coordinates.slice(positionIndexes[0] + 1)); +} +function pruneGeometryIfNecessary(geometry) { + switch (geometry.type) { + case 'Polygon': + prunePolygonIfNecessary(geometry); + break; + case 'MultiLineString': + pruneMultiLineStringIfNecessary(geometry); + break; + case 'MultiPolygon': + pruneMultiPolygonIfNecessary(geometry); + break; + default: + // Not downgradable + break; + } +} +function prunePolygonIfNecessary(geometry) { + var polygon = geometry.coordinates; + // If any hole is no longer a polygon, remove the hole entirely + for (var holeIndex = 1; holeIndex < polygon.length; holeIndex++) { + if (removeHoleIfNecessary(polygon, holeIndex)) { + // It was removed, so keep the index the same + holeIndex--; + } + } +} +function pruneMultiLineStringIfNecessary(geometry) { + for (var lineStringIndex = 0; lineStringIndex < geometry.coordinates.length; lineStringIndex++) { + var lineString = geometry.coordinates[lineStringIndex]; + if (lineString.length === 1) { + // Only a single position left on this LineString, so remove it (can't have Point in MultiLineString) + geometry.coordinates.splice(lineStringIndex, 1); + // Keep the index the same + lineStringIndex--; + } + } +} +function pruneMultiPolygonIfNecessary(geometry) { + for (var polygonIndex = 0; polygonIndex < geometry.coordinates.length; polygonIndex++) { + var polygon = geometry.coordinates[polygonIndex]; + var outerRing = polygon[0]; + // If the outer ring is no longer a polygon, remove the whole polygon + if (outerRing.length <= 3) { + geometry.coordinates.splice(polygonIndex, 1); + // It was removed, so keep the index the same + polygonIndex--; + } + for (var holeIndex = 1; holeIndex < polygon.length; holeIndex++) { + if (removeHoleIfNecessary(polygon, holeIndex)) { + // It was removed, so keep the index the same + holeIndex--; + } + } + } +} +function removeHoleIfNecessary(polygon, holeIndex) { + var hole = polygon[holeIndex]; + if (hole.length <= 3) { + polygon.splice(holeIndex, 1); + return true; + } + return false; +} +//# sourceMappingURL=immutable-feature-collection.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/immutable-feature-collection.js.map b/lib/modules/edit-modes/src/lib/immutable-feature-collection.js.map new file mode 100644 index 000000000..fe894fe14 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/immutable-feature-collection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"immutable-feature-collection.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/immutable-feature-collection.ts"],"names":[],"mappings":";AAWA;IAGE,oCAAY,iBAAoC;QAC9C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,8CAAS,GAAT;QACE,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED;;;;;;;;;OASG;IACH,oDAAe,GAAf,UACE,YAAoB,EACpB,eAA4C,EAC5C,eAAyB;QAEzB,IAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC;QAExE,IAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC;QACpF,IAAM,eAAe,yBAChB,QAAQ,KACX,WAAW,EAAE,wBAAwB,CACnC,QAAQ,CAAC,WAAW,EACpB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,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts b/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts new file mode 100644 index 000000000..64e3be3d5 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts @@ -0,0 +1,12 @@ +import { ClickEvent, PointerMoveEvent, Tooltip, ModeProps, GuideFeatureCollection } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class MeasureAngleMode extends GeoJsonEditMode { + _getTooltips: (args: any) => any; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + getPoints(props: ModeProps): import("../geojson-types").Position[]; + getGuides(props: ModeProps): GuideFeatureCollection; + getTooltips(props: ModeProps): Tooltip[]; +} +//# sourceMappingURL=measure-angle-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts.map b/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts.map new file mode 100644 index 000000000..23e644845 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-angle-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-angle-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-angle-mode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,YAAY,qBA+CT;IAEH,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IASzE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAIrF,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAa7C,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IA6BtE,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO,EAAE;CAU5D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-angle-mode.js b/lib/modules/edit-modes/src/lib/measure-angle-mode.js new file mode 100644 index 000000000..0a98dad94 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-angle-mode.js @@ -0,0 +1,115 @@ +import { __extends, __read, __spread } from "tslib"; +import turfBearing from '@turf/bearing'; +// @ts-ignore +import turfCenter from '@turf/center'; +// @ts-ignore +import memoize from '../memoize'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var DEFAULT_TOOLTIPS = []; +var MeasureAngleMode = /** @class */ (function (_super) { + __extends(MeasureAngleMode, _super); + function MeasureAngleMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._getTooltips = memoize(function (_a) { + var modeConfig = _a.modeConfig, vertex = _a.vertex, point1 = _a.point1, point2 = _a.point2; + var tooltips = DEFAULT_TOOLTIPS; + if (vertex && point1 && point2) { + var _b = modeConfig || {}, formatTooltip = _b.formatTooltip, measurementCallback = _b.measurementCallback; + var units = 'deg'; + var angle1 = turfBearing(vertex, point1); + var angle2 = turfBearing(vertex, point2); + var angle = Math.abs(angle1 - angle2); + if (angle > 180) { + angle = 360 - angle; + } + var text = void 0; + if (formatTooltip) { + text = formatTooltip(angle); + } + else { + // By default, round to 2 decimal places and append units + // @ts-ignore + text = parseFloat(angle).toFixed(2) + " " + units; + } + if (measurementCallback) { + measurementCallback(angle); + } + var position = turfCenter({ + type: 'FeatureCollection', + features: [point1, point2].map(function (p) { return ({ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: p, + }, + }); }), + }).geometry.coordinates; + tooltips = [ + { + position: position, + text: text, + }, + ]; + } + return tooltips; + }); + return _this; + } + MeasureAngleMode.prototype.handleClick = function (event, props) { + if (this.getClickSequence().length >= 3) { + this.resetClickSequence(); + } + this.addClickSequence(event); + }; + // Called when the pointer moved, regardless of whether the pointer is down, up, and whether something was picked + MeasureAngleMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + MeasureAngleMode.prototype.getPoints = function (props) { + var clickSequence = this.getClickSequence(); + var points = __spread(clickSequence); + if (clickSequence.length < 3 && props.lastPointerMoveEvent) { + points.push(props.lastPointerMoveEvent.mapCoords); + } + return points; + }; + // Return features that can be used as a guide for editing the data + MeasureAngleMode.prototype.getGuides = function (props) { + var guides = { type: 'FeatureCollection', features: [] }; + var features = guides.features; + var points = this.getPoints(props); + if (points.length > 2) { + features.push({ + type: 'Feature', + properties: { guideType: 'tentative' }, + geometry: { + type: 'LineString', + coordinates: [points[1], points[0], points[2]], + }, + }); + } + else if (points.length > 1) { + features.push({ + type: 'Feature', + properties: { guideType: 'tentative' }, + geometry: { + type: 'LineString', + coordinates: [points[1], points[0]], + }, + }); + } + return guides; + }; + MeasureAngleMode.prototype.getTooltips = function (props) { + var points = this.getPoints(props); + return this._getTooltips({ + modeConfig: props.modeConfig, + vertex: points[0], + point1: points[1], + point2: points[2], + }); + }; + return MeasureAngleMode; +}(GeoJsonEditMode)); +export { MeasureAngleMode }; +//# sourceMappingURL=measure-angle-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-angle-mode.js.map b/lib/modules/edit-modes/src/lib/measure-angle-mode.js.map new file mode 100644 index 000000000..2af40bb37 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-angle-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-angle-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-angle-mode.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,aAAa;AACb,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,aAAa;AACb,OAAO,OAAO,MAAM,YAAY,CAAC;AAIjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,IAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;IAAsC,oCAAe;IAArD;QAAA,qEAmHC;QAlHC,kBAAY,GAAG,OAAO,CAAC,UAAC,EAAsC;gBAApC,0BAAU,EAAE,kBAAM,EAAE,kBAAM,EAAE,kBAAM;YAC1D,IAAI,QAAQ,GAAG,gBAAgB,CAAC;YAEhC,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE;gBACxB,IAAA,qBAAyD,EAAvD,gCAAa,EAAE,4CAAwC,CAAC;gBAChE,IAAM,KAAK,GAAG,KAAK,CAAC;gBAEpB,IAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC3C,IAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;gBACtC,IAAI,KAAK,GAAG,GAAG,EAAE;oBACf,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;iBACrB;gBAED,IAAI,IAAI,SAAA,CAAC;gBACT,IAAI,aAAa,EAAE;oBACjB,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;iBAC7B;qBAAM;oBACL,yDAAyD;oBACzD,aAAa;oBACb,IAAI,GAAM,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAI,KAAO,CAAC;iBACnD;gBAED,IAAI,mBAAmB,EAAE;oBACvB,mBAAmB,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AAC,AAnHD,CAAsC,eAAe,GAmHpD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts b/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts new file mode 100644 index 000000000..319949bc7 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts @@ -0,0 +1,8 @@ +import { ClickEvent, Tooltip, ModeProps } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { DrawPolygonMode } from './draw-polygon-mode'; +export declare class MeasureAreaMode extends DrawPolygonMode { + handleClick(event: ClickEvent, props: ModeProps): void; + getTooltips(props: ModeProps): Tooltip[]; +} +//# sourceMappingURL=measure-area-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts.map b/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts.map new file mode 100644 index 000000000..f6372ba16 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-area-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-area-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-area-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,qBAAa,eAAgB,SAAQ,eAAe;IAClD,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAUlE,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO,EAAE;CAiC5D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-area-mode.js b/lib/modules/edit-modes/src/lib/measure-area-mode.js new file mode 100644 index 000000000..627927f96 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-area-mode.js @@ -0,0 +1,49 @@ +import { __assign, __extends } from "tslib"; +import turfArea from '@turf/area'; +import turfCentroid from '@turf/centroid'; +import { DrawPolygonMode } from './draw-polygon-mode'; +var DEFAULT_TOOLTIPS = []; +var MeasureAreaMode = /** @class */ (function (_super) { + __extends(MeasureAreaMode, _super); + function MeasureAreaMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + MeasureAreaMode.prototype.handleClick = function (event, props) { + var propsWithoutEdit = __assign(__assign({}, props), { + // @ts-ignore + onEdit: function () { } }); + _super.prototype.handleClick.call(this, event, propsWithoutEdit); + }; + MeasureAreaMode.prototype.getTooltips = function (props) { + var tentativeGuide = this.getTentativeGuide(props); + if (tentativeGuide && tentativeGuide.geometry.type === 'Polygon') { + var modeConfig = props.modeConfig; + var _a = modeConfig || {}, formatTooltip = _a.formatTooltip, measurementCallback = _a.measurementCallback; + var units = 'sq. m'; + var centroid = turfCentroid(tentativeGuide); + var area = turfArea(tentativeGuide); + var text = void 0; + if (formatTooltip) { + text = formatTooltip(area); + } + else { + // By default, round to 2 decimal places and append units + // @ts-ignore + text = parseFloat(area).toFixed(2) + " " + units; + } + if (measurementCallback) { + measurementCallback(area); + } + return [ + { + position: centroid.geometry.coordinates, + text: text, + }, + ]; + } + return DEFAULT_TOOLTIPS; + }; + return MeasureAreaMode; +}(DrawPolygonMode)); +export { MeasureAreaMode }; +//# sourceMappingURL=measure-area-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-area-mode.js.map b/lib/modules/edit-modes/src/lib/measure-area-mode.js.map new file mode 100644 index 000000000..15e3140e2 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-area-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-area-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-area-mode.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;A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,CAAqC,eAAe,GA4CnD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts b/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts new file mode 100644 index 000000000..e1fa722ae --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts @@ -0,0 +1,15 @@ +import { ClickEvent, PointerMoveEvent, Tooltip, ModeProps, GuideFeatureCollection, EditHandleFeature } from '../types'; +import { FeatureCollection, Position } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class MeasureDistanceMode extends GeoJsonEditMode { + startingPoint: Readonly | null | undefined; + endingPoint: Readonly | null | undefined; + endingPointLocked: boolean; + _setEndingPoint(mapCoords: Position): void; + _getTooltips: (args: any) => any; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; + getTooltips(props: ModeProps): Tooltip[]; +} +//# sourceMappingURL=measure-distance-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts.map b/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts.map new file mode 100644 index 000000000..dc40a303e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-distance-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-distance-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-distance-mode.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,aAAa,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAQ;IACrE,WAAW,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAQ;IACnE,iBAAiB,UAAS;IAE1B,eAAe,CAAC,SAAS,EAAE,QAAQ;IAgBnC,YAAY,qBA8BT;IAEH,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAwBzE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IASrF,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IA0BtE,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO,EAAE;CAO5D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-distance-mode.js b/lib/modules/edit-modes/src/lib/measure-distance-mode.js new file mode 100644 index 000000000..d76005fd0 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-distance-mode.js @@ -0,0 +1,124 @@ +import { __extends } from "tslib"; +// @ts-ignore +import turfDistance from '@turf/distance'; +// @ts-ignore +import memoize from '../memoize'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var DEFAULT_TOOLTIPS = []; +var MeasureDistanceMode = /** @class */ (function (_super) { + __extends(MeasureDistanceMode, _super); + function MeasureDistanceMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.startingPoint = null; + _this.endingPoint = null; + _this.endingPointLocked = false; + _this._getTooltips = memoize(function (_a) { + var modeConfig = _a.modeConfig, startingPoint = _a.startingPoint, endingPoint = _a.endingPoint; + var tooltips = DEFAULT_TOOLTIPS; + if (startingPoint && endingPoint) { + var _b = modeConfig || {}, formatTooltip = _b.formatTooltip, turfOptions = _b.turfOptions, measurementCallback = _b.measurementCallback; + var units = (turfOptions && turfOptions.units) || 'kilometers'; + var distance = turfDistance(startingPoint, endingPoint, turfOptions); + var text = void 0; + if (formatTooltip) { + text = formatTooltip(distance); + } + else { + // By default, round to 2 decimal places and append units + text = parseFloat(distance).toFixed(2) + " " + units; + } + if (measurementCallback) { + measurementCallback(distance); + } + tooltips = [ + { + position: endingPoint.geometry.coordinates, + text: text, + }, + ]; + } + return tooltips; + }); + return _this; + } + MeasureDistanceMode.prototype._setEndingPoint = function (mapCoords) { + this.endingPoint = { + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: 'existing', + featureIndex: -1, + positionIndexes: [], + }, + geometry: { + type: 'Point', + coordinates: mapCoords, + }, + }; + }; + MeasureDistanceMode.prototype.handleClick = function (event, props) { + if (!this.startingPoint || this.endingPointLocked) { + this.startingPoint = { + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: 'existing', + featureIndex: -1, + positionIndexes: [], + }, + geometry: { + type: 'Point', + coordinates: event.mapCoords, + }, + }; + this.endingPoint = null; + this.endingPointLocked = false; + } + else if (this.startingPoint) { + this._setEndingPoint(event.mapCoords); + this.endingPointLocked = true; + } + }; + // Called when the pointer moved, regardless of whether the pointer is down, up, and whether something was picked + MeasureDistanceMode.prototype.handlePointerMove = function (event, props) { + if (this.startingPoint && !this.endingPointLocked) { + this._setEndingPoint(event.mapCoords); + } + props.onUpdateCursor('cell'); + }; + // Return features that can be used as a guide for editing the data + MeasureDistanceMode.prototype.getGuides = function (props) { + var guides = { type: 'FeatureCollection', features: [] }; + var features = guides.features; + if (this.startingPoint) { + features.push(this.startingPoint); + } + if (this.endingPoint) { + features.push(this.endingPoint); + } + if (this.startingPoint && this.endingPoint) { + features.push({ + type: 'Feature', + properties: { guideType: 'tentative' }, + geometry: { + type: 'LineString', + coordinates: [ + this.startingPoint.geometry.coordinates, + this.endingPoint.geometry.coordinates, + ], + }, + }); + } + return guides; + }; + MeasureDistanceMode.prototype.getTooltips = function (props) { + return this._getTooltips({ + modeConfig: props.modeConfig, + startingPoint: this.startingPoint, + endingPoint: this.endingPoint, + }); + }; + return MeasureDistanceMode; +}(GeoJsonEditMode)); +export { MeasureDistanceMode }; +//# sourceMappingURL=measure-distance-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/measure-distance-mode.js.map b/lib/modules/edit-modes/src/lib/measure-distance-mode.js.map new file mode 100644 index 000000000..ff6bbde55 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/measure-distance-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-distance-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/measure-distance-mode.ts"],"names":[],"mappings":";AAAA,aAAa;AACb,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,aAAa;AACb,OAAO,OAAO,MAAM,YAAY,CAAC;AAUjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,IAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;IAAyC,uCAAe;IAAxD;QAAA,qEAuHC;QAtHC,mBAAa,GAAmD,IAAI,CAAC;QACrE,iBAAW,GAAmD,IAAI,CAAC;QACnE,uBAAiB,GAAG,KAAK,CAAC;QAkB1B,kBAAY,GAAG,OAAO,CAAC,UAAC,EAA0C;gBAAxC,0BAAU,EAAE,gCAAa,EAAE,4BAAW;YAC9D,IAAI,QAAQ,GAAG,gBAAgB,CAAC;YAEhC,IAAI,aAAa,IAAI,WAAW,EAAE;gBAC1B,IAAA,qBAAsE,EAApE,gCAAa,EAAE,4BAAW,EAAE,4CAAwC,CAAC;gBAC7E,IAAM,KAAK,GAAG,CAAC,WAAW,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC;gBAEjE,IAAM,QAAQ,GAAG,YAAY,CAAC,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;gBAEvE,IAAI,IAAI,SAAA,CAAC;gBACT,IAAI,aAAa,EAAE;oBACjB,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;iBA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,KAAK,CAAC,UAAU;YAC5B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;IACH,0BAAC;AAAD,CAAC,AAvHD,CAAyC,eAAe,GAuHvD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/modify-mode.d.ts b/lib/modules/edit-modes/src/lib/modify-mode.d.ts new file mode 100644 index 000000000..767eb1885 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/modify-mode.d.ts @@ -0,0 +1,15 @@ +import { NearestPointType } from '../utils'; +import { LineString, Point, FeatureCollection, FeatureOf } from '../geojson-types'; +import { ModeProps, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, Viewport, GuideFeatureCollection } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class ModifyMode extends GeoJsonEditMode { + getGuides(props: ModeProps): GuideFeatureCollection; + nearestPointOnLine(line: FeatureOf, inPoint: FeatureOf, viewport: Viewport | null | undefined): NearestPointType; + handleClick(event: ClickEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + getCursor(event: PointerMoveEvent): string | null | undefined; +} +//# sourceMappingURL=modify-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/modify-mode.d.ts.map b/lib/modules/edit-modes/src/lib/modify-mode.d.ts.map new file mode 100644 index 000000000..09f7da759 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/modify-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/modify-mode.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,UAAW,SAAQ,eAAe;IAC7C,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IAmFtE,kBAAkB,CAChB,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,EAC3B,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GACpC,gBAAgB;IAgBnB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAgDlE,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IA6B/E,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAKrF,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA2BlF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA0BhF,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;CAS9D"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/modify-mode.js b/lib/modules/edit-modes/src/lib/modify-mode.js new file mode 100644 index 000000000..e49f421b6 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/modify-mode.js @@ -0,0 +1,217 @@ +import { __extends, __read, __spread, __values } from "tslib"; +import nearestPointOnLine from '@turf/nearest-point-on-line'; +import { point, lineString as toLineString } from '@turf/helpers'; +import { recursivelyTraverseNestedArrays, nearestPointOnProjectedLine, getEditHandlesForGeometry, getPickedEditHandles, getPickedEditHandle, getPickedExistingEditHandle, getPickedIntermediateEditHandle, } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var ModifyMode = /** @class */ (function (_super) { + __extends(ModifyMode, _super); + function ModifyMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + ModifyMode.prototype.getGuides = function (props) { + var e_1, _a; + var _this = this; + var handles = []; + var data = props.data, lastPointerMoveEvent = props.lastPointerMoveEvent; + var features = data.features; + var picks = lastPointerMoveEvent && lastPointerMoveEvent.picks; + var mapCoords = lastPointerMoveEvent && lastPointerMoveEvent.mapCoords; + try { + for (var _b = __values(props.selectedIndexes), _c = _b.next(); !_c.done; _c = _b.next()) { + var index = _c.value; + if (index < features.length) { + var geometry = features[index].geometry; + handles.push.apply(handles, __spread(getEditHandlesForGeometry(geometry, index))); + } + else { + console.warn("selectedFeatureIndexes out of range " + index); // eslint-disable-line no-console,no-undef + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + // intermediate edit handle + if (picks && picks.length && mapCoords) { + var existingEditHandle = getPickedExistingEditHandle(picks); + // don't show intermediate point when too close to an existing edit handle + var featureAsPick = !existingEditHandle && picks.find(function (pick) { return !pick.isGuide; }); + // is the feature in the pick selected + if (featureAsPick && + !featureAsPick.object.geometry.type.includes('Point') && + props.selectedIndexes.includes(featureAsPick.index)) { + var intermediatePoint_1 = null; + var positionIndexPrefix_1 = []; + var referencePoint_1 = point(mapCoords); + // process all lines of the (single) feature + recursivelyTraverseNestedArrays(featureAsPick.object.geometry.coordinates, [], function (lineString, prefix) { + var lineStringFeature = toLineString(lineString); + var candidateIntermediatePoint = _this.nearestPointOnLine( + // @ts-ignore + lineStringFeature, referencePoint_1, props.modeConfig && props.modeConfig.viewport); + if (!intermediatePoint_1 || + candidateIntermediatePoint.properties.dist < intermediatePoint_1.properties.dist) { + intermediatePoint_1 = candidateIntermediatePoint; + positionIndexPrefix_1 = prefix; + } + }); + // tack on the lone intermediate point to the set of handles + if (intermediatePoint_1) { + var position = intermediatePoint_1.geometry.coordinates, index = intermediatePoint_1.properties.index; + handles.push({ + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: 'intermediate', + featureIndex: featureAsPick.index, + positionIndexes: __spread(positionIndexPrefix_1, [index + 1]), + }, + geometry: { + type: 'Point', + coordinates: position, + }, + }); + } + } + } + return { + type: 'FeatureCollection', + features: handles, + }; + }; + // turf.js does not support elevation for nearestPointOnLine + ModifyMode.prototype.nearestPointOnLine = function (line, inPoint, viewport) { + var coordinates = line.geometry.coordinates; + if (coordinates.some(function (coord) { return coord.length > 2; })) { + if (viewport) { + // This line has elevation, we need to use alternative algorithm + return nearestPointOnProjectedLine(line, inPoint, viewport); + } + // eslint-disable-next-line no-console,no-undef + console.log('Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'); + } + return nearestPointOnLine(line, inPoint); + }; + ModifyMode.prototype.handleClick = function (event, props) { + var pickedExistingHandle = getPickedExistingEditHandle(event.picks); + var pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks); + if (pickedExistingHandle) { + var _a = pickedExistingHandle.properties, featureIndex = _a.featureIndex, positionIndexes = _a.positionIndexes; + var updatedData = void 0; + try { + updatedData = new ImmutableFeatureCollection(props.data) + .removePosition(featureIndex, positionIndexes) + .getObject(); + } + catch (ignored) { + // This happens if user attempts to remove the last point + } + if (updatedData) { + props.onEdit({ + updatedData: updatedData, + editType: 'removePosition', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: positionIndexes, + position: pickedExistingHandle.geometry.coordinates, + }, + }); + } + } + else if (pickedIntermediateHandle) { + var _b = pickedIntermediateHandle.properties, featureIndex = _b.featureIndex, positionIndexes = _b.positionIndexes; + var updatedData = new ImmutableFeatureCollection(props.data) + .addPosition(featureIndex, positionIndexes, pickedIntermediateHandle.geometry.coordinates) + .getObject(); + if (updatedData) { + props.onEdit({ + updatedData: updatedData, + editType: 'addPosition', + editContext: { + featureIndexes: [featureIndex], + positionIndexes: positionIndexes, + position: pickedIntermediateHandle.geometry.coordinates, + }, + }); + } + } + }; + ModifyMode.prototype.handleDragging = function (event, props) { + var editHandle = getPickedEditHandle(event.pointerDownPicks); + if (editHandle) { + // Cancel map panning if pointer went down on an edit handle + event.cancelPan(); + var editHandleProperties = editHandle.properties; + var updatedData = new ImmutableFeatureCollection(props.data) + .replacePosition(editHandleProperties.featureIndex, editHandleProperties.positionIndexes, event.mapCoords) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'movePosition', + editContext: { + featureIndexes: [editHandleProperties.featureIndex], + positionIndexes: editHandleProperties.positionIndexes, + position: event.mapCoords, + }, + }); + } + }; + ModifyMode.prototype.handlePointerMove = function (event, props) { + var cursor = this.getCursor(event); + props.onUpdateCursor(cursor); + }; + ModifyMode.prototype.handleStartDragging = function (event, props) { + var selectedFeatureIndexes = props.selectedIndexes; + var editHandle = getPickedIntermediateEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle) { + var editHandleProperties = editHandle.properties; + var updatedData = new ImmutableFeatureCollection(props.data) + .addPosition(editHandleProperties.featureIndex, editHandleProperties.positionIndexes, event.mapCoords) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'addPosition', + editContext: { + featureIndexes: [editHandleProperties.featureIndex], + positionIndexes: editHandleProperties.positionIndexes, + position: event.mapCoords, + }, + }); + } + }; + ModifyMode.prototype.handleStopDragging = function (event, props) { + var selectedFeatureIndexes = props.selectedIndexes; + var editHandle = getPickedEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle) { + var editHandleProperties = editHandle.properties; + var updatedData = new ImmutableFeatureCollection(props.data) + .replacePosition(editHandleProperties.featureIndex, editHandleProperties.positionIndexes, event.mapCoords) + .getObject(); + props.onEdit({ + updatedData: updatedData, + editType: 'finishMovePosition', + editContext: { + featureIndexes: [editHandleProperties.featureIndex], + positionIndexes: editHandleProperties.positionIndexes, + position: event.mapCoords, + }, + }); + } + }; + ModifyMode.prototype.getCursor = function (event) { + var picks = (event && event.picks) || []; + var handlesPicked = getPickedEditHandles(picks); + if (handlesPicked.length) { + return 'cell'; + } + return null; + }; + return ModifyMode; +}(GeoJsonEditMode)); +export { ModifyMode }; +//# sourceMappingURL=modify-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/modify-mode.js.map b/lib/modules/edit-modes/src/lib/modify-mode.js.map new file mode 100644 index 000000000..551d52423 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/modify-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/modify-mode.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,+BAA+B,GAEhC,MAAM,UAAU,CAAC;AAYlB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;IAAgC,8BAAe;IAA/C;;IAwPA,CAAC;IAvPC,8BAAS,GAAT,UAAU,KAAmC;;QAA7C,iBAgFC;QA/EC,IAAM,OAAO,GAAG,EAAE,CAAC;QAEX,IAAA,iBAAI,EAAE,iDAAoB,CAAW;QACrC,IAAA,wBAAQ,CAAU;QAC1B,IAAM,KAAK,GA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EAAE,oBAAoB,CAAC,eAAe;oBACrD,QAAQ,EAAE,KAAK,CAAC,SAAS;iBAC1B;aACF,CAAC,CAAC;SACJ;IACH,CAAC;IAED,8BAAS,GAAT,UAAU,KAAuB;QAC/B,IAAM,KAAK,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAE3C,IAAM,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,aAAa,CAAC,MAAM,EAAE;YACxB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACH,iBAAC;AAAD,CAAC,AAxPD,CAAgC,eAAe,GAwP9C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/rotate-mode.d.ts b/lib/modules/edit-modes/src/lib/rotate-mode.d.ts new file mode 100644 index 000000000..c13033132 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/rotate-mode.d.ts @@ -0,0 +1,18 @@ +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps, EditHandleFeature } from '../types'; +import { FeatureCollection, Position } from '../geojson-types'; +import { GeoJsonEditMode, GeoJsonEditAction } from './geojson-edit-mode'; +export declare class RotateMode extends GeoJsonEditMode { + _selectedEditHandle: EditHandleFeature | null | undefined; + _geometryBeingRotated: FeatureCollection | null | undefined; + _isRotating: boolean; + _isSinglePointGeometrySelected: (geometry: FeatureCollection) => boolean; + getIsRotating: () => boolean; + getGuides(props: ModeProps): any; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + updateCursor(props: ModeProps): void; + getRotateAction(startDragPoint: Position, currentPoint: Position, editType: string, props: ModeProps): GeoJsonEditAction | null | undefined; +} +//# sourceMappingURL=rotate-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/rotate-mode.d.ts.map b/lib/modules/edit-modes/src/lib/rotate-mode.d.ts.map new file mode 100644 index 000000000..4f9c77abd --- /dev/null +++ b/lib/modules/edit-modes/src/lib/rotate-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/rotate-mode.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAGlG,qBAAa,UAAW,SAAQ,eAAe;IAC7C,mBAAmB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1D,qBAAqB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5D,WAAW,UAAS;IAEpB,8BAA8B,2CAQ5B;IAEF,aAAa,gBAA0B;IAEvC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAqD7C,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAkBxE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAY9E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAOlF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAoBhF,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAShD,eAAe,CACb,cAAc,EAAE,QAAQ,EACxB,YAAY,EAAE,QAAQ,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAClC,iBAAiB,GAAG,IAAI,GAAG,SAAS;CA6BxC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/rotate-mode.js b/lib/modules/edit-modes/src/lib/rotate-mode.js new file mode 100644 index 000000000..62a9a7abd --- /dev/null +++ b/lib/modules/edit-modes/src/lib/rotate-mode.js @@ -0,0 +1,157 @@ +import { __extends } from "tslib"; +/* eslint-disable prettier/prettier */ +import turfBuffer from '@turf/buffer'; +import bbox from '@turf/bbox'; +import turfCentroid from '@turf/centroid'; +import turfBearing from '@turf/bearing'; +import bboxPolygon from '@turf/bbox-polygon'; +import turfDistance from '@turf/distance'; +import { coordEach } from '@turf/meta'; +import { getGeom } from '@turf/invariant'; +import { point, featureCollection, lineString } from '@turf/helpers'; +import turfTransformRotate from '@turf/transform-rotate'; +import { getPickedEditHandle } from '../utils'; +import { GeoJsonEditMode, getIntermediatePosition } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var RotateMode = /** @class */ (function (_super) { + __extends(RotateMode, _super); + function RotateMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._isRotating = false; + _this._isSinglePointGeometrySelected = function (geometry) { + var features = (geometry || {}).features; + if (Array.isArray(features) && features.length === 1) { + // @ts-ignore + var type = getGeom(features[0]).type; + return type === 'Point'; + } + return false; + }; + _this.getIsRotating = function () { return _this._isRotating; }; + return _this; + } + RotateMode.prototype.getGuides = function (props) { + var selectedGeometry = this._geometryBeingRotated || this.getSelectedFeaturesAsFeatureCollection(props); + if (this._isRotating) { + // Display rotate pivot + return featureCollection([turfCentroid(selectedGeometry)]); + } + // Add buffer to the enveloping box if a single Point feature is selected + var featureWithBuffer = this._isSinglePointGeometrySelected(selectedGeometry) + ? // eslint-disable-next-line + // @ts-ignore + turfBuffer(selectedGeometry, 1) + : selectedGeometry; + var boundingBox = bboxPolygon(bbox(featureWithBuffer)); + var previousCoord = null; + var topEdgeMidpointCoords = null; + var longestEdgeLength = 0; + coordEach(boundingBox, function (coord, coordIndex) { + if (previousCoord) { + // @ts-ignore + var edgeMidpoint = getIntermediatePosition(coord, previousCoord); + if (!topEdgeMidpointCoords || edgeMidpoint[1] > topEdgeMidpointCoords[1]) { + // Get the top edge midpoint of the enveloping box + topEdgeMidpointCoords = edgeMidpoint; + } + // Get the length of the longest edge of the enveloping box + var edgeDistance = turfDistance(coord, previousCoord); + longestEdgeLength = Math.max(longestEdgeLength, edgeDistance); + } + previousCoord = coord; + }); + // Scale the length of the line between the rotate handler and the enveloping box + // relative to the length of the longest edge of the enveloping box + var rotateHandleCoords = topEdgeMidpointCoords && [ + topEdgeMidpointCoords[0], + topEdgeMidpointCoords[1] + longestEdgeLength / 1000, + ]; + var lineFromEnvelopeToRotateHandle = lineString([topEdgeMidpointCoords, rotateHandleCoords]); + var rotateHandle = point(rotateHandleCoords, { + guideType: 'editHandle', + editHandleType: 'rotate', + }); + // @ts-ignore + return featureCollection([boundingBox, rotateHandle, lineFromEnvelopeToRotateHandle]); + }; + RotateMode.prototype.handleDragging = function (event, props) { + if (!this._isRotating) { + return; + } + var rotateAction = this.getRotateAction(event.pointerDownMapCoords, event.mapCoords, 'rotating', props); + if (rotateAction) { + props.onEdit(rotateAction); + } + event.cancelPan(); + }; + RotateMode.prototype.handlePointerMove = function (event, props) { + if (!this._isRotating) { + var selectedEditHandle = getPickedEditHandle(event.picks); + this._selectedEditHandle = + selectedEditHandle && selectedEditHandle.properties.editHandleType === 'rotate' + ? selectedEditHandle + : null; + } + this.updateCursor(props); + }; + RotateMode.prototype.handleStartDragging = function (event, props) { + if (this._selectedEditHandle) { + this._isRotating = true; + this._geometryBeingRotated = this.getSelectedFeaturesAsFeatureCollection(props); + } + }; + RotateMode.prototype.handleStopDragging = function (event, props) { + if (this._isRotating) { + // Rotate the geometry + var rotateAction = this.getRotateAction(event.pointerDownMapCoords, event.mapCoords, 'rotated', props); + if (rotateAction) { + props.onEdit(rotateAction); + } + this._geometryBeingRotated = null; + this._selectedEditHandle = null; + this._isRotating = false; + } + }; + RotateMode.prototype.updateCursor = function (props) { + if (this._selectedEditHandle) { + // TODO: look at doing SVG cursors to get a better "rotate" cursor + props.onUpdateCursor('crosshair'); + } + else { + props.onUpdateCursor(null); + } + }; + RotateMode.prototype.getRotateAction = function (startDragPoint, currentPoint, editType, props) { + if (!this._geometryBeingRotated) { + return null; + } + var centroid = turfCentroid(this._geometryBeingRotated); + var angle = getRotationAngle(centroid, startDragPoint, currentPoint); + // @ts-ignore + var rotatedFeatures = turfTransformRotate(this._geometryBeingRotated, angle, { + pivot: centroid, + }); + var updatedData = new ImmutableFeatureCollection(props.data); + var selectedIndexes = props.selectedIndexes; + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = rotatedFeatures.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return { + updatedData: updatedData.getObject(), + editType: editType, + editContext: { + featureIndexes: selectedIndexes, + }, + }; + }; + return RotateMode; +}(GeoJsonEditMode)); +export { RotateMode }; +function getRotationAngle(centroid, startDragPoint, currentPoint) { + var bearing1 = turfBearing(centroid, startDragPoint); + var bearing2 = turfBearing(centroid, currentPoint); + return bearing2 - bearing1; +} +//# sourceMappingURL=rotate-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/rotate-mode.js.map b/lib/modules/edit-modes/src/lib/rotate-mode.js.map new file mode 100644 index 000000000..30efd2276 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/rotate-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/rotate-mode.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,YAAY,MAAM,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Aa,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YACzC,IAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjD,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;SACjF;QAED,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE;YACpC,QAAQ,UAAA;YACR,WAAW,EAAE;gBACX,cAAc,EAAE,eAAe;aAChC;SACF,CAAC;IACJ,CAAC;IACH,iBAAC;AAAD,CAAC,AA1KD,CAAgC,eAAe,GA0K9C;;AAED,SAAS,gBAAgB,CAAC,QAAkB,EAAE,cAAwB,EAAE,YAAsB;IAC5F,IAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACvD,IAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrD,OAAO,QAAQ,GAAG,QAAQ,CAAC;AAC7B,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/scale-mode.d.ts b/lib/modules/edit-modes/src/lib/scale-mode.d.ts new file mode 100644 index 000000000..741349847 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/scale-mode.d.ts @@ -0,0 +1,40 @@ +import { FeatureCollection, Position } from '../geojson-types'; +import { ModeProps, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, EditHandleFeature } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class ScaleMode extends GeoJsonEditMode { + _geometryBeingScaled: FeatureCollection | null | undefined; + _selectedEditHandle: EditHandleFeature | null | undefined; + _cornerGuidePoints: Array; + _cursor: string | null | undefined; + _isScaling: boolean; + _isSinglePointGeometrySelected: (geometry: FeatureCollection) => boolean; + _getOppositeScaleHandle: (selectedHandle: import("../geojson-types").FeatureWithProps) => import("../geojson-types").FeatureWithProps; + _getUpdatedData: (props: ModeProps, editedData: FeatureCollection) => FeatureCollection; + isEditHandleSelcted: () => boolean; + getScaleAction: (startDragPoint: Position, currentPoint: Position, editType: string, props: ModeProps) => { + updatedData: FeatureCollection; + editType: string; + editContext: { + featureIndexes: number[]; + }; + }; + updateCursor: (props: ModeProps) => void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + getGuides(props: ModeProps): any; +} +//# sourceMappingURL=scale-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/scale-mode.d.ts.map b/lib/modules/edit-modes/src/lib/scale-mode.d.ts.map new file mode 100644 index 000000000..f16eb9514 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/scale-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/scale-mode.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,SAAU,SAAQ,eAAe;IAC5C,oBAAoB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3D,mBAAmB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1D,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,UAAU,UAAS;IAEnB,8BAA8B,2CAQ5B;IAEF,uBAAuB;;;;;;;;;;;;OAkBrB;IAEF,eAAe,4FASb;IAEF,mBAAmB,gBAAoD;IAEvE,cAAc;;;;;;MA6BZ;IAEF,YAAY,gDAyBV;IAEF,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAY9E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAOlF,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAkBxE,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAoBhF,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CA+B9C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/scale-mode.js b/lib/modules/edit-modes/src/lib/scale-mode.js new file mode 100644 index 000000000..88800e616 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/scale-mode.js @@ -0,0 +1,180 @@ +import { __extends, __read, __spread } from "tslib"; +/* eslint-disable prettier/prettier */ +import turfBuffer from '@turf/buffer'; +import bbox from '@turf/bbox'; +import turfCentroid from '@turf/centroid'; +import turfBearing from '@turf/bearing'; +import bboxPolygon from '@turf/bbox-polygon'; +import { point, featureCollection } from '@turf/helpers'; +import { coordEach } from '@turf/meta'; +import turfDistance from '@turf/distance'; +import turfTransformScale from '@turf/transform-scale'; +import { getCoord, getGeom } from '@turf/invariant'; +import { getPickedEditHandle } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var ScaleMode = /** @class */ (function (_super) { + __extends(ScaleMode, _super); + function ScaleMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._isScaling = false; + _this._isSinglePointGeometrySelected = function (geometry) { + var features = (geometry || {}).features; + if (Array.isArray(features) && features.length === 1) { + // @ts-ignore + var type = getGeom(features[0]).type; + return type === 'Point'; + } + return false; + }; + _this._getOppositeScaleHandle = function (selectedHandle) { + var selectedHandleIndex = selectedHandle && + selectedHandle.properties && + Array.isArray(selectedHandle.properties.positionIndexes) && + selectedHandle.properties.positionIndexes[0]; + if (typeof selectedHandleIndex !== 'number') { + return null; + } + var guidePointCount = _this._cornerGuidePoints.length; + var oppositeIndex = (selectedHandleIndex + guidePointCount / 2) % guidePointCount; + return _this._cornerGuidePoints.find(function (p) { + if (!Array.isArray(p.properties.positionIndexes)) { + return false; + } + return p.properties.positionIndexes[0] === oppositeIndex; + }); + }; + _this._getUpdatedData = function (props, editedData) { + var updatedData = new ImmutableFeatureCollection(props.data); + var selectedIndexes = props.selectedIndexes; + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = editedData.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return updatedData.getObject(); + }; + _this.isEditHandleSelcted = function () { return Boolean(_this._selectedEditHandle); }; + _this.getScaleAction = function (startDragPoint, currentPoint, editType, props) { + if (!_this._selectedEditHandle || + _this._isSinglePointGeometrySelected(_this._geometryBeingScaled)) { + return null; + } + var oppositeHandle = _this._getOppositeScaleHandle(_this._selectedEditHandle); + var origin = getCoord(oppositeHandle); + // @ts-ignore + var scaleFactor = getScaleFactor(origin, startDragPoint, currentPoint); + // @ts-ignore + var scaledFeatures = turfTransformScale(_this._geometryBeingScaled, scaleFactor, { + origin: origin, + }); + return { + updatedData: _this._getUpdatedData(props, scaledFeatures), + editType: editType, + editContext: { + featureIndexes: props.selectedIndexes, + }, + }; + }; + _this.updateCursor = function (props) { + if (_this._selectedEditHandle) { + if (_this._cursor) { + props.onUpdateCursor(_this._cursor); + } + var cursorGeometry = _this.getSelectedFeaturesAsFeatureCollection(props); + // Get resize cursor direction from the hovered scale editHandle (e.g. nesw or nwse) + var centroid = turfCentroid(cursorGeometry); + var bearing = turfBearing(centroid, _this._selectedEditHandle); + var positiveBearing = bearing < 0 ? bearing + 180 : bearing; + if ((positiveBearing >= 0 && positiveBearing <= 90) || + (positiveBearing >= 180 && positiveBearing <= 270)) { + _this._cursor = 'nesw-resize'; + props.onUpdateCursor('nesw-resize'); + } + else { + _this._cursor = 'nwse-resize'; + props.onUpdateCursor('nwse-resize'); + } + } + else { + props.onUpdateCursor(null); + _this._cursor = null; + } + }; + return _this; + } + ScaleMode.prototype.handlePointerMove = function (event, props) { + if (!this._isScaling) { + var selectedEditHandle = getPickedEditHandle(event.picks); + this._selectedEditHandle = + selectedEditHandle && selectedEditHandle.properties.editHandleType === 'scale' + ? selectedEditHandle + : null; + } + this.updateCursor(props); + }; + ScaleMode.prototype.handleStartDragging = function (event, props) { + if (this._selectedEditHandle) { + this._isScaling = true; + this._geometryBeingScaled = this.getSelectedFeaturesAsFeatureCollection(props); + } + }; + ScaleMode.prototype.handleDragging = function (event, props) { + if (!this._isScaling) { + return; + } + var scaleAction = this.getScaleAction(event.pointerDownMapCoords, event.mapCoords, 'scaling', props); + if (scaleAction) { + props.onEdit(scaleAction); + } + event.cancelPan(); + }; + ScaleMode.prototype.handleStopDragging = function (event, props) { + if (this._isScaling) { + // Scale the geometry + var scaleAction = this.getScaleAction(event.pointerDownMapCoords, event.mapCoords, 'scaled', props); + if (scaleAction) { + props.onEdit(scaleAction); + } + this._geometryBeingScaled = null; + this._selectedEditHandle = null; + this._cursor = null; + this._isScaling = false; + } + }; + ScaleMode.prototype.getGuides = function (props) { + this._cornerGuidePoints = []; + var selectedGeometry = this.getSelectedFeaturesAsFeatureCollection(props); + // Add buffer to the enveloping box if a single Point feature is selected + var featureWithBuffer = this._isSinglePointGeometrySelected(selectedGeometry) + ? // eslint-disable-next-line + // @ts-ignore + turfBuffer(selectedGeometry, 1) + : selectedGeometry; + var boundingBox = bboxPolygon(bbox(featureWithBuffer)); + boundingBox.properties.mode = 'scale'; + var cornerGuidePoints = []; + coordEach(boundingBox, function (coord, coordIndex) { + if (coordIndex < 4) { + // Get corner midpoint guides from the enveloping box + var cornerPoint = point(coord, { + guideType: 'editHandle', + editHandleType: 'scale', + positionIndexes: [coordIndex], + }); + cornerGuidePoints.push(cornerPoint); + } + }); + this._cornerGuidePoints = cornerGuidePoints; + // @ts-ignore + return featureCollection(__spread([boundingBox], this._cornerGuidePoints)); + }; + return ScaleMode; +}(GeoJsonEditMode)); +export { ScaleMode }; +function getScaleFactor(centroid, startDragPoint, currentPoint) { + var startDistance = turfDistance(centroid, startDragPoint); + var endDistance = turfDistance(centroid, currentPoint); + return endDistance / startDistance; +} +//# sourceMappingURL=scale-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/scale-mode.js.map b/lib/modules/edit-modes/src/lib/scale-mode.js.map new file mode 100644 index 000000000..99c9a63e7 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/scale-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/scale-mode.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAUpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;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EAAE,YAAY,CAAC,CAAC;IACzD,OAAO,WAAW,GAAG,aAAa,CAAC;AACrC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/snappable-mode.d.ts b/lib/modules/edit-modes/src/lib/snappable-mode.d.ts new file mode 100644 index 000000000..505de9c47 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/snappable-mode.d.ts @@ -0,0 +1,22 @@ +import { Feature, FeatureCollection } from '../geojson-types'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps, Pick, GuideFeatureCollection, EditHandleFeature } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +declare type MovementTypeEvent = PointerMoveEvent | StartDraggingEvent | StopDraggingEvent | DraggingEvent; +export declare class SnappableMode extends GeoJsonEditMode { + _handler: GeoJsonEditMode; + constructor(handler: GeoJsonEditMode); + _getSnappedMouseEvent(event: T, snapSource: EditHandleFeature, snapTarget: EditHandleFeature): T; + _getPickedSnapTarget(picks: Pick[]): EditHandleFeature | null | undefined; + _getPickedSnapSource(pointerDownPicks: Pick[] | null | undefined): EditHandleFeature | null | undefined; + _getUpdatedSnapSourceHandle(snapSourceHandle: EditHandleFeature, data: FeatureCollection): EditHandleFeature; + _getSnapTargets(props: ModeProps): Feature[]; + _getSnapTargetHandles(props: ModeProps): EditHandleFeature[]; + getGuides(props: ModeProps): GuideFeatureCollection; + _getSnapAwareEvent(event: T, props: ModeProps): T; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +export {}; +//# sourceMappingURL=snappable-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/snappable-mode.d.ts.map b/lib/modules/edit-modes/src/lib/snappable-mode.d.ts.map new file mode 100644 index 000000000..59c99ecc6 --- /dev/null +++ b/lib/modules/edit-modes/src/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AC,SAAS,iBAAiB,EAC5C,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAClC,CAAC;IASJ,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAIlF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAIhF,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAIxE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/snappable-mode.js b/lib/modules/edit-modes/src/lib/snappable-mode.js new file mode 100644 index 000000000..ac1879601 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/snappable-mode.js @@ -0,0 +1,122 @@ +import { __assign, __extends, __read, __spread, __values } from "tslib"; +import { getPickedSnapSourceEditHandle, getPickedEditHandles, getEditHandlesForGeometry, } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var SnappableMode = /** @class */ (function (_super) { + __extends(SnappableMode, _super); + function SnappableMode(handler) { + var _this = _super.call(this) || this; + _this._handler = handler; + return _this; + } + SnappableMode.prototype._getSnappedMouseEvent = function (event, snapSource, snapTarget) { + return Object.assign(event, { + mapCoords: snapTarget.geometry.coordinates, + pointerDownMapCoords: snapSource && snapSource.geometry.coordinates, + }); + }; + SnappableMode.prototype._getPickedSnapTarget = function (picks) { + return getPickedEditHandles(picks).find(function (handle) { return handle.properties.editHandleType === 'snap-target'; }); + }; + SnappableMode.prototype._getPickedSnapSource = function (pointerDownPicks) { + return getPickedSnapSourceEditHandle(pointerDownPicks); + }; + SnappableMode.prototype._getUpdatedSnapSourceHandle = function (snapSourceHandle, data) { + var _a = snapSourceHandle.properties, featureIndex = _a.featureIndex, positionIndexes = _a.positionIndexes; + if (!Array.isArray(positionIndexes)) { + return snapSourceHandle; + } + var snapSourceFeature = data.features[featureIndex]; + // $FlowFixMe + var snapSourceCoordinates = positionIndexes.reduce(function (a, b) { return a[b]; }, snapSourceFeature.geometry.coordinates); + return __assign(__assign({}, snapSourceHandle), { geometry: { + type: 'Point', + coordinates: snapSourceCoordinates, + } }); + }; + // If additionalSnapTargets is present in modeConfig and is populated, this + // method will return those features along with the features + // that live in the current layer. Otherwise, this method will simply return the + // features from the current layer + SnappableMode.prototype._getSnapTargets = function (props) { + var additionalSnapTargets = (props.modeConfig || {}).additionalSnapTargets; + additionalSnapTargets = additionalSnapTargets || []; + var features = __spread(props.data.features, additionalSnapTargets); + return features; + }; + SnappableMode.prototype._getSnapTargetHandles = function (props) { + var handles = []; + var features = this._getSnapTargets(props); + for (var i = 0; i < features.length; i++) { + // Filter out the currently selected feature(s) + var isCurrentIndexFeatureNotSelected = !props.selectedIndexes.includes(i); + if (isCurrentIndexFeatureNotSelected) { + var geometry = features[i].geometry; + handles.push.apply(handles, __spread(getEditHandlesForGeometry(geometry, i, 'snap-target'))); + } + } + return handles; + }; + // If no snap handle has been picked, only display the edit handles of the + // selected feature. If a snap handle has been picked, display said snap handle + // along with all snappable points on all non-selected features. + SnappableMode.prototype.getGuides = function (props) { + var _a, e_1, _b, _c; + var modeConfig = props.modeConfig, lastPointerMoveEvent = props.lastPointerMoveEvent; + var enableSnapping = (modeConfig || {}).enableSnapping; + var guides = { + type: 'FeatureCollection', + features: __spread(this._handler.getGuides(props).features), + }; + if (!enableSnapping) { + return guides; + } + var snapSourceHandle = lastPointerMoveEvent && this._getPickedSnapSource(lastPointerMoveEvent.pointerDownPicks); + // They started dragging a handle + // So render the picked handle (in its updated location) and all possible snap targets + if (snapSourceHandle) { + (_a = guides.features).push.apply(_a, __spread(this._getSnapTargetHandles(props), [this._getUpdatedSnapSourceHandle(snapSourceHandle, props.data)])); + return guides; + } + // Render the possible snap source handles + var features = props.data.features; + try { + for (var _d = __values(props.selectedIndexes), _e = _d.next(); !_e.done; _e = _d.next()) { + var index = _e.value; + if (index < features.length) { + var geometry = features[index].geometry; + (_c = guides.features).push.apply(_c, __spread(getEditHandlesForGeometry(geometry, index, 'snap-source'))); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_e && !_e.done && (_b = _d.return)) _b.call(_d); + } + finally { if (e_1) throw e_1.error; } + } + return guides; + }; + SnappableMode.prototype._getSnapAwareEvent = function (event, props) { + var snapSource = this._getPickedSnapSource(props.lastPointerMoveEvent.pointerDownPicks); + var snapTarget = this._getPickedSnapTarget(event.picks); + return snapSource && snapTarget + ? this._getSnappedMouseEvent(event, snapSource, snapTarget) + : event; + }; + SnappableMode.prototype.handleStartDragging = function (event, props) { + this._handler.handleStartDragging(event, props); + }; + SnappableMode.prototype.handleStopDragging = function (event, props) { + this._handler.handleStopDragging(this._getSnapAwareEvent(event, props), props); + }; + SnappableMode.prototype.handleDragging = function (event, props) { + this._handler.handleDragging(this._getSnapAwareEvent(event, props), props); + }; + SnappableMode.prototype.handlePointerMove = function (event, props) { + this._handler.handlePointerMove(this._getSnapAwareEvent(event, props), props); + }; + return SnappableMode; +}(GeoJsonEditMode)); +export { SnappableMode }; +//# sourceMappingURL=snappable-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/snappable-mode.js.map b/lib/modules/edit-modes/src/lib/snappable-mode.js.map new file mode 100644 index 000000000..1c0c72d11 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/snappable-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"snappable-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/snappable-mode.ts"],"names":[],"mappings":";AAWA,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD;IAAmC,iCAAe;IAGhD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mB,KAAwB,EAAE,KAAmC;QAC9E,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;IAED,sCAAc,GAAd,UAAe,KAAoB,EAAE,KAAmC;QACtE,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAED,yCAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAChF,CAAC;IACH,oBAAC;AAAD,CAAC,AAzJD,CAAmC,eAAe,GAyJjD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts b/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts new file mode 100644 index 000000000..1cf29509e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts @@ -0,0 +1,11 @@ +import { FeatureCollection } from '../geojson-types'; +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection, TentativeFeature } from '../types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class SplitPolygonMode extends GeoJsonEditMode { + calculateMapCoords(clickSequence: any, mapCoords: any, props: ModeProps): any; + getGuides(props: ModeProps): GuideFeatureCollection; + handleClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + splitPolygon(tentativeFeature: TentativeFeature, props: ModeProps): import("../types").EditAction; +} +//# sourceMappingURL=split-polygon-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts.map b/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts.map new file mode 100644 index 000000000..b81704786 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/split-polygon-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"split-polygon-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/split-polygon-mode.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AAGzE,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,kBAAkB,CAAC,aAAa,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAgD1F,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IA6BtE,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA0ClE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAI9E,YAAY,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAsDrF"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/split-polygon-mode.js b/lib/modules/edit-modes/src/lib/split-polygon-mode.js new file mode 100644 index 000000000..29e7781d2 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/split-polygon-mode.js @@ -0,0 +1,173 @@ +import { __extends, __read, __spread } from "tslib"; +import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; +import turfDifference from '@turf/difference'; +import turfBuffer from '@turf/buffer'; +import lineIntersect from '@turf/line-intersect'; +import { lineString } from '@turf/helpers'; +import turfBearing from '@turf/bearing'; +import turfDistance from '@turf/distance'; +import turfDestination from '@turf/destination'; +import turfPolygonToLine from '@turf/polygon-to-line'; +import nearestPointOnLine from '@turf/nearest-point-on-line'; +import { generatePointsParallelToLinePoints } from '../utils'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var SplitPolygonMode = /** @class */ (function (_super) { + __extends(SplitPolygonMode, _super); + function SplitPolygonMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + SplitPolygonMode.prototype.calculateMapCoords = function (clickSequence, mapCoords, props) { + var modeConfig = props.modeConfig; + if (!modeConfig || !modeConfig.lock90Degree || !clickSequence.length) { + return mapCoords; + } + if (clickSequence.length === 1) { + // if first point is clicked, then find closest polygon point and build ~90deg vector + var firstPoint_1 = clickSequence[0]; + var selectedGeometry = this.getSelectedGeometry(props); + // @ts-ignore + var feature = turfPolygonToLine(selectedGeometry); + var lines = feature.type === 'FeatureCollection' ? feature.features : [feature]; + var minDistance_1 = Number.MAX_SAFE_INTEGER; + var closestPoint_1 = null; + // If Multipolygon, then we should find nearest polygon line and stick split to it. + lines.forEach(function (line) { + var snapPoint = nearestPointOnLine(line, firstPoint_1); + var distanceFromOrigin = turfDistance(snapPoint, firstPoint_1); + if (minDistance_1 > distanceFromOrigin) { + minDistance_1 = distanceFromOrigin; + closestPoint_1 = snapPoint; + } + }); + if (closestPoint_1) { + // closest point is used as 90degree entry to the polygon + var lastBearing = turfBearing(firstPoint_1, closestPoint_1); + var currentDistance = turfDistance(firstPoint_1, mapCoords, { units: 'meters' }); + return turfDestination(firstPoint_1, currentDistance, lastBearing, { + units: 'meters', + }).geometry.coordinates; + } + return mapCoords; + } + // Allow only 90 degree turns + var lastPoint = clickSequence[clickSequence.length - 1]; + var _a = __read(generatePointsParallelToLinePoints(clickSequence[clickSequence.length - 2], lastPoint, mapCoords), 1), approximatePoint = _a[0]; + // align point with current ground + var nearestPt = nearestPointOnLine(lineString([lastPoint, approximatePoint]), mapCoords) + .geometry.coordinates; + return nearestPt; + }; + SplitPolygonMode.prototype.getGuides = function (props) { + var clickSequence = this.getClickSequence(); + var guides = { + type: 'FeatureCollection', + features: [], + }; + if (clickSequence.length === 0 || !props.lastPointerMoveEvent) { + // nothing to do yet + return guides; + } + var mapCoords = props.lastPointerMoveEvent.mapCoords; + guides.features.push({ + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, [this.calculateMapCoords(clickSequence, mapCoords, props)]), + }, + }); + return guides; + }; + SplitPolygonMode.prototype.handleClick = function (event, props) { + var tentativeFeature = this.getTentativeGuide(props); + var selectedGeometry = this.getSelectedGeometry(props); + if (!selectedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('A polygon must be selected for splitting'); + return; + } + var clickSequence = this.getClickSequence(); + if (tentativeFeature && tentativeFeature.geometry.type === 'LineString') { + clickSequence.push(tentativeFeature.geometry.coordinates[tentativeFeature.geometry.coordinates.length - 1]); + } + else { + this.addClickSequence(event); + } + var pt = { + type: 'Point', + coordinates: clickSequence[clickSequence.length - 1], + }; + // @ts-ignore + var isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry); + if (clickSequence.length > 1 && tentativeFeature && !isPointInPolygon) { + this.resetClickSequence(); + // @ts-ignore + var isLineInterectingWithPolygon = lineIntersect(tentativeFeature, selectedGeometry); + if (isLineInterectingWithPolygon.features.length === 0) { + return; + } + var editAction = this.splitPolygon(tentativeFeature, props); + if (editAction) { + props.onEdit(editAction); + } + } + }; + SplitPolygonMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + SplitPolygonMode.prototype.splitPolygon = function (tentativeFeature, props) { + var selectedGeometry = this.getSelectedGeometry(props); + var featureIndex = props.selectedIndexes[0]; + var modeConfig = props.modeConfig || {}; + // Default gap in between the polygon + var _a = modeConfig.gap, gap = _a === void 0 ? 0.1 : _a, _b = modeConfig.units, units = _b === void 0 ? 'centimeters' : _b; + if (gap === 0) { + gap = 0.1; + units = 'centimeters'; + } + var buffer = turfBuffer(tentativeFeature, gap, { units: units }); + // @ts-ignore + var updatedGeometry = turfDifference(selectedGeometry, buffer); + if (!updatedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('Canceling edit. Split Polygon erased'); + return null; + } + var _c = updatedGeometry.geometry, type = _c.type, coordinates = _c.coordinates; + var updatedCoordinates = []; + if (type === 'Polygon') { + // Update the coordinates as per Multipolygon + // @ts-ignore + updatedCoordinates = coordinates.map(function (c) { return [c]; }); + } + else { + // Handle Case when Multipolygon has holes + // @ts-ignore + updatedCoordinates = coordinates.reduce(function (agg, prev) { + prev.forEach(function (p) { + agg.push([p]); + }); + return agg; + }, []); + } + // Update the type to Mulitpolygon + var updatedData = new ImmutableFeatureCollection(props.data).replaceGeometry(featureIndex, { + type: 'MultiPolygon', + coordinates: updatedCoordinates, + }); + var editAction = { + updatedData: updatedData.getObject(), + editType: 'split', + editContext: { + featureIndexes: [featureIndex], + }, + }; + return editAction; + }; + return SplitPolygonMode; +}(GeoJsonEditMode)); +export { SplitPolygonMode }; +//# sourceMappingURL=split-polygon-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/split-polygon-mode.js.map b/lib/modules/edit-modes/src/lib/split-polygon-mode.js.map new file mode 100644 index 000000000..502f8d47e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/split-polygon-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"split-polygon-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/split-polygon-mode.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AACnE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM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AI,EAAE,4BAAwC,CAAC;QACvD,IAAI,kBAAkB,GAAG,EAAE,CAAC;QAC5B,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,6CAA6C;YAC7C,aAAa;YACb,kBAAkB,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAC;SAClD;aAAM;YACL,0CAA0C;YAC1C,aAAa;YACb,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,IAAI;gBAChD,IAAI,CAAC,OAAO,CAAC,UAAC,CAAC;oBACb,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChB,CAAC,CAAC,CAAC;gBACH,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAE,CAAC,CAAC;SACR;QAED,kCAAkC;QAClC,IAAM,WAAW,GAAG,IAAI,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,YAAY,EAAE;YAC3F,IAAI,EAAE,cAAc;YACpB,WAAW,EAAE,kBAAkB;SAChC,CAAC,CAAC;QAEH,IAAM,UAAU,GAAsB;YACpC,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE;YACpC,QAAQ,EAAE,OAAO;YACjB,WAAW,EAAE;gBACX,cAAc,EAAE,CAAC,YAAY,CAAC;aAC/B;SACF,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;IACH,uBAAC;AAAD,CAAC,AAlLD,CAAsC,eAAe,GAkLpD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts new file mode 100644 index 000000000..dce34187e --- /dev/null +++ b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts @@ -0,0 +1,10 @@ +import { ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { Position, Polygon, FeatureOf, FeatureCollection } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class ThreeClickPolygonMode extends GeoJsonEditMode { + handleClick(event: ClickEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; + getThreeClickPolygon(coord1: Position, coord2: Position, coord3: Position, modeConfig: any): FeatureOf | null | undefined; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=three-click-polygon-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts.map b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts.map new file mode 100644 index 000000000..6747dcff7 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"three-click-polygon-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/three-click-polygon-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAmBlE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IAgDtE,oBAAoB,CAClB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,GAAG,GACd,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS;IAIxC,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js new file mode 100644 index 000000000..5878e0b61 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js @@ -0,0 +1,69 @@ +import { __extends } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var ThreeClickPolygonMode = /** @class */ (function (_super) { + __extends(ThreeClickPolygonMode, _super); + function ThreeClickPolygonMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + ThreeClickPolygonMode.prototype.handleClick = function (event, props) { + this.addClickSequence(event); + var clickSequence = this.getClickSequence(); + var tentativeFeature = this.getTentativeGuide(props); + if (clickSequence.length > 2 && + tentativeFeature && + tentativeFeature.geometry.type === 'Polygon') { + var editAction = this.getAddFeatureOrBooleanPolygonAction(tentativeFeature.geometry, props); + this.resetClickSequence(); + if (editAction) { + props.onEdit(editAction); + } + } + }; + ThreeClickPolygonMode.prototype.getGuides = function (props) { + var lastPointerMoveEvent = props.lastPointerMoveEvent, modeConfig = props.modeConfig; + var clickSequence = this.getClickSequence(); + var guides = { + type: 'FeatureCollection', + features: [], + }; + if (clickSequence.length === 0) { + // nothing to do yet + return guides; + } + var hoveredCoord = lastPointerMoveEvent.mapCoords; + if (clickSequence.length === 1) { + guides.features.push({ + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: { + type: 'LineString', + coordinates: [clickSequence[0], hoveredCoord], + }, + }); + } + else { + var polygon = this.getThreeClickPolygon(clickSequence[0], clickSequence[1], hoveredCoord, modeConfig); + if (polygon) { + guides.features.push({ + type: 'Feature', + properties: { + guideType: 'tentative', + }, + geometry: polygon.geometry, + }); + } + } + return guides; + }; + ThreeClickPolygonMode.prototype.getThreeClickPolygon = function (coord1, coord2, coord3, modeConfig) { + return null; + }; + ThreeClickPolygonMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + return ThreeClickPolygonMode; +}(GeoJsonEditMode)); +export { ThreeClickPolygonMode }; +//# sourceMappingURL=three-click-polygon-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js.map b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js.map new file mode 100644 index 000000000..50cf20e2d --- /dev/null +++ b/lib/modules/edit-modes/src/lib/three-click-polygon-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"three-click-polygon-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/three-click-polygon-mode.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAA2C,yCAAe;IAA1D;;IAgFA,CAAC;IA/EC,2CAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QAChE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAEvD,IACE,aAAa,CAAC,MAAM,GAAG,CAAC;YACxB,gBAAgB;YAChB,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAC5C;YACA,IAAM,UAAU,GAAG,IAAI,CAAC,mCAAmC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC9F,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAE1B,IAAI,UAAU,EAAE;gBACd,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aAC1B;SACF;IACH,CAAC;IAED,yCAAS,GAAT,UAAU,KAAmC;QACnC,IAAA,iDAAoB,EAAE,6BAAU,CAAW;QACnD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAM,MAAM,GAA2B;YACrC,IAAI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/lib/transform-mode.d.ts new file mode 100644 index 000000000..957d6c341 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/transform-mode.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent, ModeProps, StartDraggingEvent } from '../types'; +import { FeatureCollection } from '../geojson-types'; +import { CompositeMode } from './composite-mode'; +export declare class TransformMode extends CompositeMode { + constructor(); + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + getGuides(props: ModeProps): import("../types").GuideFeatureCollection; +} +//# sourceMappingURL=transform-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/transform-mode.d.ts.map b/lib/modules/edit-modes/src/lib/transform-mode.d.ts.map new file mode 100644 index 000000000..b6044ee81 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/transform-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"transform-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/transform-mode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,aAAc,SAAQ,aAAa;;IAK9C,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAW9E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA2BlF,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAoB9C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/transform-mode.js b/lib/modules/edit-modes/src/lib/transform-mode.js new file mode 100644 index 000000000..2a0a0a48b --- /dev/null +++ b/lib/modules/edit-modes/src/lib/transform-mode.js @@ -0,0 +1,65 @@ +import { __assign, __extends } from "tslib"; +import { featureCollection } from '@turf/helpers'; +import { TranslateMode } from './translate-mode'; +import { ScaleMode } from './scale-mode'; +import { RotateMode } from './rotate-mode'; +import { CompositeMode } from './composite-mode'; +var TransformMode = /** @class */ (function (_super) { + __extends(TransformMode, _super); + function TransformMode() { + return _super.call(this, [new TranslateMode(), new ScaleMode(), new RotateMode()]) || this; + } + TransformMode.prototype.handlePointerMove = function (event, props) { + var updatedCursor = null; + _super.prototype.handlePointerMove.call(this, event, __assign(__assign({}, props), { onUpdateCursor: function (cursor) { + updatedCursor = cursor || updatedCursor; + } })); + props.onUpdateCursor(updatedCursor); + }; + TransformMode.prototype.handleStartDragging = function (event, props) { + var scaleMode = null; + var translateMode = null; + var filteredModes = []; + // If the user selects a scaling edit handle that overlaps with part of the selected feature, + // it is possible for both scale and translate actions to be triggered. This logic prevents + // this simultaneous action trigger from happening by putting a higher priority on scaling + // since the user needs to be more precise to hover over a scaling edit handle. + this._modes.forEach(function (mode) { + if (mode instanceof TranslateMode) { + translateMode = mode; + } + else { + if (mode instanceof ScaleMode) { + scaleMode = mode; + } + filteredModes.push(mode); + } + }); + if (scaleMode instanceof ScaleMode && !scaleMode.isEditHandleSelcted()) { + filteredModes.push(translateMode); + } + filteredModes.filter(Boolean).forEach(function (mode) { return mode.handleStartDragging(event, props); }); + }; + TransformMode.prototype.getGuides = function (props) { + var compositeGuides = _super.prototype.getGuides.call(this, props); + var rotateMode = (this._modes || []).find(function (mode) { return mode instanceof RotateMode; }); + if (rotateMode instanceof RotateMode) { + var nonEnvelopeGuides = compositeGuides.features.filter(function (guide) { + var _a = guide.properties || {}, editHandleType = _a.editHandleType, mode = _a.mode; + // Both scale and rotate modes have the same enveloping box as a guide - only need one + var guidesToFilterOut = [mode]; + // Do not render scaling edit handles if rotating + if (rotateMode.getIsRotating()) { + guidesToFilterOut.push(editHandleType); + } + return !guidesToFilterOut.includes('scale'); + }); + // @ts-ignore + compositeGuides = featureCollection(nonEnvelopeGuides); + } + return compositeGuides; + }; + return TransformMode; +}(CompositeMode)); +export { TransformMode }; +//# sourceMappingURL=transform-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/transform-mode.js.map b/lib/modules/edit-modes/src/lib/transform-mode.js.map new file mode 100644 index 000000000..eef045b50 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/transform-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"transform-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/transform-mode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;IAAmC,iCAAa;IAC9C;eACE,kBAAM,CAAC,IAAI,aAAa,EAAE,EAAE,IAAI,SAAS,EAAE,EAAE,IAAI,UAAU,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,yCAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,iBAAM,iBAAiB,YAAC,KAAK,wBACxB,KAAK,KACR,cAAc,EAAE,UAAC,MAAM;gBACrB,aAAa,GAAG,MAAM,IAAI,aAAa,CAAC;YAC1C,CAAC,IACD,CAAC;QACH,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC;IAED,2CAAmB,GAAnB,UAAoB,KAAyB,EAAE,KAAmC;QAChF,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,IAAM,aAAa,GAAG,EAAE,CAAC;QAEzB,6FAA6F;QAC7F,2FAA2F;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AAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;YACH,aAAa;YACb,eAAe,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;SACxD;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACH,oBAAC;AAAD,CAAC,AA/DD,CAAmC,aAAa,GA+D/C"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/translate-mode.d.ts b/lib/modules/edit-modes/src/lib/translate-mode.d.ts new file mode 100644 index 000000000..828f9b104 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/translate-mode.d.ts @@ -0,0 +1,14 @@ +import { FeatureCollection, Position } from '../geojson-types'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps } from '../types'; +import { GeoJsonEditMode, GeoJsonEditAction } from './geojson-edit-mode'; +export declare class TranslateMode extends GeoJsonEditMode { + _geometryBeforeTranslate: FeatureCollection | null | undefined; + _isTranslatable: boolean; + handleDragging(event: DraggingEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + updateCursor(props: ModeProps): void; + getTranslateAction(startDragPoint: Position, currentPoint: Position, editType: string, props: ModeProps): GeoJsonEditAction | null | undefined; +} +//# sourceMappingURL=translate-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/translate-mode.d.ts.map b/lib/modules/edit-modes/src/lib/translate-mode.d.ts.map new file mode 100644 index 000000000..36e7d39b2 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/translate-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/translate-mode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,qBAAa,aAAc,SAAQ,eAAe;IAChD,wBAAwB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/D,eAAe,EAAE,OAAO,CAAC;IAEzB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAwBxE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAM9E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAQlF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAkBhF,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAQhD,kBAAkB,CAChB,cAAc,EAAE,QAAQ,EACxB,YAAY,EAAE,QAAQ,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAClC,iBAAiB,GAAG,IAAI,GAAG,SAAS;CAkCxC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/translate-mode.js b/lib/modules/edit-modes/src/lib/translate-mode.js new file mode 100644 index 000000000..562c17579 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/translate-mode.js @@ -0,0 +1,85 @@ +import { __extends } from "tslib"; +import turfBearing from '@turf/bearing'; +import turfDistance from '@turf/distance'; +import turfTransformTranslate from '@turf/transform-translate'; +import { point } from '@turf/helpers'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +import { ImmutableFeatureCollection } from './immutable-feature-collection'; +var TranslateMode = /** @class */ (function (_super) { + __extends(TranslateMode, _super); + function TranslateMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + TranslateMode.prototype.handleDragging = function (event, props) { + if (!this._isTranslatable) { + // Nothing to do + return; + } + if (this._geometryBeforeTranslate) { + // Translate the geometry + var editAction = this.getTranslateAction(event.pointerDownMapCoords, event.mapCoords, 'translating', props); + if (editAction) { + props.onEdit(editAction); + } + } + // cancel map panning + event.cancelPan(); + }; + TranslateMode.prototype.handlePointerMove = function (event, props) { + this._isTranslatable = this.isSelectionPicked(event.pointerDownPicks || event.picks, props); + this.updateCursor(props); + }; + TranslateMode.prototype.handleStartDragging = function (event, props) { + if (!this._isTranslatable) { + return; + } + this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(props); + }; + TranslateMode.prototype.handleStopDragging = function (event, props) { + if (this._geometryBeforeTranslate) { + // Translate the geometry + var editAction = this.getTranslateAction(event.pointerDownMapCoords, event.mapCoords, 'translated', props); + if (editAction) { + props.onEdit(editAction); + } + this._geometryBeforeTranslate = null; + } + }; + TranslateMode.prototype.updateCursor = function (props) { + if (this._isTranslatable) { + props.onUpdateCursor('move'); + } + else { + props.onUpdateCursor(null); + } + }; + TranslateMode.prototype.getTranslateAction = function (startDragPoint, currentPoint, editType, props) { + if (!this._geometryBeforeTranslate) { + return null; + } + var p1 = point(startDragPoint); + var p2 = point(currentPoint); + var distanceMoved = turfDistance(p1, p2); + var direction = turfBearing(p1, p2); + var movedFeatures = turfTransformTranslate( + // @ts-ignore + this._geometryBeforeTranslate, distanceMoved, direction); + var updatedData = new ImmutableFeatureCollection(props.data); + var selectedIndexes = props.selectedIndexes; + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = movedFeatures.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return { + updatedData: updatedData.getObject(), + editType: editType, + editContext: { + featureIndexes: selectedIndexes, + }, + }; + }; + return TranslateMode; +}(GeoJsonEditMode)); +export { TranslateMode }; +//# sourceMappingURL=translate-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/translate-mode.js.map b/lib/modules/edit-modes/src/lib/translate-mode.js.map new file mode 100644 index 000000000..7a27a2511 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/translate-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/translate-mode.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAStC,OAAO,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAE5E;IAAmC,iCAAe;IAAlD;;IA2GA,CAAC;IAvGC,sCAAc,GAAd,UAAe,KAAoB,EAAE,KAAmC;QACtE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,gBAAgB;YAChB,OAAO;SACR;QAED,IAAI,IAAI,CAAC,wBAAwB,EAAE;YACjC,yBAAyB;YACzB,IAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CACxC,KAAK,CAAC,oBAAoB,EAC1B,KAAK,CAAC,SAAS,EACf,aAAa,EACb,KAAK,CACN,CAAC;YAEF,IAAI,UAAU,EAAE;gBACd,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aAC1B;SACF;QAED,qBAAqB;QACrB,KAAK,CAAC,SAAS,EAAE,CAAC;IACpB,CAAC;IAED,yCAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,C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aAAa,GAAG,sBAAsB;QAC1C,aAAa;QACb,IAAI,CAAC,wBAAwB,EAC7B,aAAa,EACb,SAAS,CACV,CAAC;QAEF,IAAI,WAAW,GAAG,IAAI,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE7D,IAAM,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;QAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YACzC,IAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC/C,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;SACjF;QAED,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE;YACpC,QAAQ,UAAA;YACR,WAAW,EAAE;gBACX,cAAc,EAAE,eAAe;aAChC;SACF,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AA3GD,CAAmC,eAAe,GA2GjD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts new file mode 100644 index 000000000..510f1c5ea --- /dev/null +++ b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts @@ -0,0 +1,13 @@ +import { ClickEvent, StartDraggingEvent, StopDraggingEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection } from '../types'; +import { Polygon, FeatureCollection, FeatureOf, Position } from '../geojson-types'; +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class TwoClickPolygonMode extends GeoJsonEditMode { + handleClick(event: ClickEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + checkAndFinishPolygon(props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection; + getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf | null | undefined; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; +} +//# sourceMappingURL=two-click-polygon-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts.map b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts.map new file mode 100644 index 000000000..ff036ff25 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"two-click-polygon-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/two-click-polygon-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAWlE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAUzF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAUvF,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IA6BzD,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB;IAgCtE,kBAAkB,CAChB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,GAAG,GACd,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS;IAIxC,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;CAG/E"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js new file mode 100644 index 000000000..70eedf9a2 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js @@ -0,0 +1,90 @@ +import { __extends } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var TwoClickPolygonMode = /** @class */ (function (_super) { + __extends(TwoClickPolygonMode, _super); + function TwoClickPolygonMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + TwoClickPolygonMode.prototype.handleClick = function (event, props) { + if (props.modeConfig && props.modeConfig.dragToDraw) { + // handled in drag handlers + return; + } + this.addClickSequence(event); + this.checkAndFinishPolygon(props); + }; + TwoClickPolygonMode.prototype.handleStartDragging = function (event, props) { + if (!props.modeConfig || !props.modeConfig.dragToDraw) { + // handled in click handlers + return; + } + this.addClickSequence(event); + event.cancelPan(); + }; + TwoClickPolygonMode.prototype.handleStopDragging = function (event, props) { + if (!props.modeConfig || !props.modeConfig.dragToDraw) { + // handled in click handlers + return; + } + this.addClickSequence(event); + this.checkAndFinishPolygon(props); + }; + TwoClickPolygonMode.prototype.checkAndFinishPolygon = function (props) { + var clickSequence = this.getClickSequence(); + var tentativeFeature = this.getTentativeGuide(props); + if (clickSequence.length > 1 && + tentativeFeature && + tentativeFeature.geometry.type === 'Polygon') { + var feature = { + type: 'Feature', + properties: { + shape: tentativeFeature.properties.shape, + }, + geometry: { + type: 'Polygon', + coordinates: tentativeFeature.geometry.coordinates, + }, + }; + var editAction = this.getAddFeatureOrBooleanPolygonAction(feature, props); + this.resetClickSequence(); + if (editAction) { + props.onEdit(editAction); + } + } + }; + TwoClickPolygonMode.prototype.getGuides = function (props) { + var lastPointerMoveEvent = props.lastPointerMoveEvent, modeConfig = props.modeConfig; + var clickSequence = this.getClickSequence(); + var guides = { + type: 'FeatureCollection', + features: [], + }; + if (clickSequence.length === 0) { + // nothing to do yet + return guides; + } + var corner1 = clickSequence[0]; + var corner2 = lastPointerMoveEvent.mapCoords; + var polygon = this.getTwoClickPolygon(corner1, corner2, modeConfig); + if (polygon) { + guides.features.push({ + type: 'Feature', + properties: { + shape: polygon.properties && polygon.properties.shape, + guideType: 'tentative', + }, + geometry: polygon.geometry, + }); + } + return guides; + }; + TwoClickPolygonMode.prototype.getTwoClickPolygon = function (coord1, coord2, modeConfig) { + return null; + }; + TwoClickPolygonMode.prototype.handlePointerMove = function (event, props) { + props.onUpdateCursor('cell'); + }; + return TwoClickPolygonMode; +}(GeoJsonEditMode)); +export { TwoClickPolygonMode }; +//# sourceMappingURL=two-click-polygon-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js.map b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js.map new file mode 100644 index 000000000..a722b6752 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/two-click-polygon-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"two-click-polygon-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/two-click-polygon-mode.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAAyC,uCAAe;IAAxD;;IAwGA,CAAC;IAvGC,yCAAW,GAAX,UAAY,KAAiB,EAAE,KAAmC;QAChE,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE;YACnD,2BAA2B;YAC3B,OAAO;SACR;QAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,iD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CAAC,CAAC;aAC1B;SACF;IACH,CAAC;IAED,uCAAS,GAAT,UAAU,KAAmC;QACnC,IAAA,iDAAoB,EAAE,6BAAU,CAAW;QACnD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAM,MAAM,GAA2B;YACrC,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,EAAE;SACb,CAAC;QAEF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACjC,IAAM,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC;QAE/C,IAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACtE,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,KAAK,EAAE,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK;oBACrD,SAAS,EAAE,WAAW;iBACvB;gBACD,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,gDAAkB,GAAlB,UACE,MAAgB,EAChB,MAAgB,EAChB,UAAe;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+CAAiB,GAAjB,UAAkB,KAAuB,EAAE,KAAmC;QAC5E,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACH,0BAAC;AAAD,CAAC,AAxGD,CAAyC,eAAe,GAwGvD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/view-mode.d.ts b/lib/modules/edit-modes/src/lib/view-mode.d.ts new file mode 100644 index 000000000..87d332729 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/view-mode.d.ts @@ -0,0 +1,4 @@ +import { GeoJsonEditMode } from './geojson-edit-mode'; +export declare class ViewMode extends GeoJsonEditMode { +} +//# sourceMappingURL=view-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/view-mode.d.ts.map b/lib/modules/edit-modes/src/lib/view-mode.d.ts.map new file mode 100644 index 000000000..63e8c5f14 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/view-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"view-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/view-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,QAAS,SAAQ,eAAe;CAAG"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/view-mode.js b/lib/modules/edit-modes/src/lib/view-mode.js new file mode 100644 index 000000000..36442c47d --- /dev/null +++ b/lib/modules/edit-modes/src/lib/view-mode.js @@ -0,0 +1,11 @@ +import { __extends } from "tslib"; +import { GeoJsonEditMode } from './geojson-edit-mode'; +var ViewMode = /** @class */ (function (_super) { + __extends(ViewMode, _super); + function ViewMode() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ViewMode; +}(GeoJsonEditMode)); +export { ViewMode }; +//# sourceMappingURL=view-mode.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/lib/view-mode.js.map b/lib/modules/edit-modes/src/lib/view-mode.js.map new file mode 100644 index 000000000..45abca7a5 --- /dev/null +++ b/lib/modules/edit-modes/src/lib/view-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"view-mode.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/src/lib/view-mode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;IAA8B,4BAAe;IAA7C;;IAA+C,CAAC;IAAD,eAAC;AAAD,CAAC,AAAhD,CAA8B,eAAe,GAAG"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/memoize.d.ts b/lib/modules/edit-modes/src/memoize.d.ts new file mode 100644 index 000000000..04905ab7d --- /dev/null +++ b/lib/modules/edit-modes/src/memoize.d.ts @@ -0,0 +1,7 @@ +/** + * Speed up consecutive function calls by caching the result of calls with identical input + * https://en.wikipedia.org/wiki/Memoization + * @param {function} compute - the function to be memoized + */ +export default function memoize(compute: Function): (args: any) => any; +//# sourceMappingURL=memoize.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/memoize.d.ts.map b/lib/modules/edit-modes/src/memoize.d.ts.map new file mode 100644 index 000000000..54b8f650c --- /dev/null +++ b/lib/modules/edit-modes/src/memoize.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/src/memoize.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,EAAE,QAAQ,sBAchD"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/memoize.js b/lib/modules/edit-modes/src/memoize.js new file mode 100644 index 000000000..32b2ec2c4 --- /dev/null +++ b/lib/modules/edit-modes/src/memoize.js @@ -0,0 +1,41 @@ +// port from @deck.gl/core +function isEqual(a, b) { + if (a === b) { + return true; + } + if (Array.isArray(a)) { + // Special treatment for arrays: compare 1-level deep + // This is to support equality of matrix/coordinate props + var len = a.length; + if (!b || b.length !== len) { + return false; + } + for (var i = 0; i < len; i++) { + if (a[i] !== b[i]) { + return false; + } + } + return true; + } + return false; +} +/** + * Speed up consecutive function calls by caching the result of calls with identical input + * https://en.wikipedia.org/wiki/Memoization + * @param {function} compute - the function to be memoized + */ +export default function memoize(compute) { + var cachedArgs = {}; + var cachedResult; + return function (args) { + for (var key in args) { + if (!isEqual(args[key], cachedArgs[key])) { + cachedResult = compute(args); + cachedArgs = args; + break; + } + } + return cachedResult; + }; +} +//# sourceMappingURL=memoize.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/memoize.js.map b/lib/modules/edit-modes/src/memoize.js.map new file mode 100644 index 000000000..2d83ae0a3 --- /dev/null +++ b/lib/modules/edit-modes/src/memoize.js.map @@ -0,0 +1 @@ +{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../../../modules/edit-modes/src/memoize.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,SAAS,OAAO,CAAC,CAAM,EAAE,CAAM;IAC7B,IAAI,CAAC,KAAK,CAAC,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACpB,qDAAqD;QACrD,yDAAyD;QACzD,IAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;QACrB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;YAC1B,OAAO,KAAK,CAAC;SACd;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBACjB,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAiB;IAC/C,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,YAAY,CAAC;IAEjB,OAAO,UAAC,IAAS;QACf,KAAK,IAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;gBACxC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC7B,UAAU,GAAG,IAAI,CAAC;gBAClB,MAAM;aACP;SACF;QACD,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/types.d.ts b/lib/modules/edit-modes/src/types.d.ts new file mode 100644 index 000000000..3f55884db --- /dev/null +++ b/lib/modules/edit-modes/src/types.d.ts @@ -0,0 +1,87 @@ +import { Position, Point, Geometry, FeatureWithProps } from './geojson-types'; +export declare type ScreenCoordinates = [number, number]; +export declare type EditAction = { + updatedData: TData; + editType: string; + editContext: any; +}; +export declare type Pick = { + object: any; + index: number; + isGuide: boolean; +}; +export declare type Viewport = { + width: number; + height: number; + longitude: number; + latitude: number; + zoom: number; + bearing?: number; + pitch?: number; +}; +export declare type BasePointerEvent = { + picks: Pick[]; + screenCoords: ScreenCoordinates; + mapCoords: Position; + sourceEvent: any; +}; +export declare type ClickEvent = BasePointerEvent; +export declare type DoubleClickEvent = { + mapCoords: Position; + sourceEvent: any; +}; +export declare type StartDraggingEvent = BasePointerEvent & { + pointerDownPicks?: Pick[] | null | undefined; + pointerDownScreenCoords: ScreenCoordinates; + pointerDownMapCoords: Position; + cancelPan: () => void; +}; +export declare type StopDraggingEvent = BasePointerEvent & { + pointerDownPicks?: Pick[] | null | undefined; + pointerDownScreenCoords: ScreenCoordinates; + pointerDownMapCoords: Position; +}; +export declare type DraggingEvent = BasePointerEvent & { + pointerDownPicks?: Pick[] | null | undefined; + pointerDownScreenCoords: ScreenCoordinates; + pointerDownMapCoords: Position; + cancelPan: () => void; +}; +export declare type PointerMoveEvent = BasePointerEvent & { + pointerDownPicks?: Pick[] | null | undefined; + pointerDownScreenCoords?: ScreenCoordinates | null | undefined; + pointerDownMapCoords?: Position | null | undefined; + cancelPan: () => void; +}; +export declare type Tooltip = { + position: Position; + text: string; +}; +export declare type EditHandleType = 'existing' | 'intermediate' | 'snap-source' | 'snap-target' | 'scale' | 'rotate'; +export declare type EditHandleFeature = FeatureWithProps; +export declare type TentativeFeature = FeatureWithProps; +export declare type GuideFeature = EditHandleFeature | TentativeFeature; +export declare type GuideFeatureCollection = { + type: 'FeatureCollection'; + features: Readonly[]; + properties?: {}; +}; +export declare type ModeProps = { + data: TData; + modeConfig: any; + selectedIndexes: number[]; + cursor: string | null | undefined; + lastPointerMoveEvent: PointerMoveEvent; + onEdit: (editAction: EditAction) => void; + onUpdateCursor: (cursor: string | null | undefined) => void; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/types.d.ts.map b/lib/modules/edit-modes/src/types.d.ts.map new file mode 100644 index 000000000..616821193 --- /dev/null +++ b/lib/modules/edit-modes/src/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,oBAAY,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAGjD,oBAAY,UAAU,CAAC,KAAK,IAAI;IAC9B,WAAW,EAAE,KAAK,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAGF,oBAAY,IAAI,GAAG;IACjB,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd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,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,cAAc,GACtB,UAAU,GACV,cAAc,GACd,aAAa,GACb,aAAa,GACb,OAAO,GACP,QAAQ,CAAC;AAEb,oBAAY,iBAAiB,GAAG,gBAAgB,CAC9C,KAAK,EACL;IACE,SAAS,EAAE,YAAY,CAAC;IACxB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CACF,CAAC;AAEF,oBAAY,gBAAgB,GAAG,gBAAgB,CAC7C,QAAQ,EACR;IACE,SAAS,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CACF,CAAC;AAEF,oBAAY,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAEhE,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;IACnC,UAAU,CAAC,EAAE,EAAE,CAAC;CACjB,CAAC;AAEF,oBAAY,SAAS,CAAC,KAAK,IAAI;IAE7B,IAAI,EAAE,KAAK,CAAC;IAGZ,UAAU,EAAE,GAAG,CAAC;IAGhB,eAAe,EAAE,MAAM,EAAE,CAAC;IAG1B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAGlC,oBAAoB,EAAE,gBAAgB,CAAC;IAGvC,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAGhD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;CAC7D,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/types.js b/lib/modules/edit-modes/src/types.js new file mode 100644 index 000000000..5b2306a4c --- /dev/null +++ b/lib/modules/edit-modes/src/types.js @@ -0,0 +1 @@ +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/types.js.map b/lib/modules/edit-modes/src/types.js.map new file mode 100644 index 000000000..47454b84e --- /dev/null +++ b/lib/modules/edit-modes/src/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../modules/edit-modes/src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/utils.d.ts b/lib/modules/edit-modes/src/utils.d.ts new file mode 100644 index 000000000..6b82ad2da --- /dev/null +++ b/lib/modules/edit-modes/src/utils.d.ts @@ -0,0 +1,20 @@ +import { Viewport, Pick, EditHandleFeature, EditHandleType } from './types'; +import { Geometry, Position, Point, LineString, FeatureOf, FeatureWithProps } from './geojson-types'; +export declare type NearestPointType = FeatureWithProps; +export declare function toDeckColor(color?: [number, number, number, number] | number, defaultColor?: [number, number, number, number]): [number, number, number, number]; +export declare function recursivelyTraverseNestedArrays(array: Array, prefix: Array, fn: Function): boolean; +export declare function generatePointsParallelToLinePoints(p1: Position, p2: Position, mapCoords: Position): Position[]; +export declare function distance2d(x1: number, y1: number, x2: number, y2: number): number; +export declare function mix(a: number, b: number, ratio: number): number; +export declare function nearestPointOnProjectedLine(line: FeatureOf, inPoint: FeatureOf, viewport: Viewport): NearestPointType; +export declare function getPickedEditHandle(picks: Pick[] | null | undefined): EditHandleFeature | null | undefined; +export declare function getPickedSnapSourceEditHandle(picks: Pick[] | null | undefined): EditHandleFeature | null | undefined; +export declare function getNonGuidePicks(picks: Pick[]): Pick[]; +export declare function getPickedExistingEditHandle(picks: Pick[] | null | undefined): EditHandleFeature | null | undefined; +export declare function getPickedIntermediateEditHandle(picks: Pick[] | null | undefined): EditHandleFeature | null | undefined; +export declare function getPickedEditHandles(picks: Pick[] | null | undefined): EditHandleFeature[]; +export declare function getEditHandlesForGeometry(geometry: Geometry, featureIndex: number, editHandleType?: EditHandleType): EditHandleFeature[]; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/utils.d.ts.map b/lib/modules/edit-modes/src/utils.d.ts.map new file mode 100644 index 000000000..80500617b --- /dev/null +++ b/lib/modules/edit-modes/src/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/src/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAEzB,oBAAY,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExF,wBAAgB,WAAW,CACzB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EACjD,YAAY,GAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAoB,GAChE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAKlC;AA2BD,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,EAAE,EAAE,QAAQ,WAYb;AAED,wBAAgB,kCAAkC,CAChD,EAAE,EAAE,QAAQ,EACZ,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,QAAQ,GAClB,QAAQ,EAAE,CAwBZ;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,EAC3B,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,QAAQ,GACjB,gBAAgB,CA+DlB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/B,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAGtC;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/B,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAGtC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAEtD;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/B,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAKtC;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/B,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAKtC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,iBAAiB,EAAE,CAS1F;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,cAA2B,GAC1C,iBAAiB,EAAE,CAmErB"} \ No newline at end of file diff --git a/lib/modules/edit-modes/src/utils.js b/lib/modules/edit-modes/src/utils.js new file mode 100644 index 000000000..c3fde1d97 --- /dev/null +++ b/lib/modules/edit-modes/src/utils.js @@ -0,0 +1,246 @@ +import { __read, __spread } from "tslib"; +import destination from '@turf/destination'; +import bearing from '@turf/bearing'; +import pointToLineDistance from '@turf/point-to-line-distance'; +import { point } from '@turf/helpers'; +import WebMercatorViewport from 'viewport-mercator-project'; +export function toDeckColor(color, defaultColor) { + if (defaultColor === void 0) { defaultColor = [255, 0, 0, 255]; } + if (!Array.isArray(color)) { + return defaultColor; + } + return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]; +} +// +// a GeoJSON helper function that calls the provided function with +// an argument that is the most deeply-nested array having elements +// that are arrays of primitives as an argument, e.g. +// +// { +// "type": "MultiPolygon", +// "coordinates": [ +// [ +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// ], +// [ +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// ] +// ] +// } +// +// the function would be called on: +// +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// +// and +// +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// +export function recursivelyTraverseNestedArrays(array, prefix, fn) { + if (!Array.isArray(array[0])) { + return true; + } + for (var i = 0; i < array.length; i++) { + if (recursivelyTraverseNestedArrays(array[i], __spread(prefix, [i]), fn)) { + fn(array, prefix); + break; + } + } + return false; +} +export function generatePointsParallelToLinePoints(p1, p2, mapCoords) { + var lineString = { + type: 'LineString', + coordinates: [p1, p2], + }; + var pt = point(mapCoords); + var ddistance = pointToLineDistance(pt, lineString); + var lineBearing = bearing(p1, p2); + // Check if current point is to the left or right of line + // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y) + // then (x−x1)(y2−y1)−(y−y1)(x2−x1) + var isPointToLeftOfLine = (mapCoords[0] - p1[0]) * (p2[1] - p1[1]) - (mapCoords[1] - p1[1]) * (p2[0] - p1[0]); + // Bearing to draw perpendicular to the line string + var orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270; + // Get coordinates for the point p3 and p4 which are perpendicular to the lineString + // Add the distance as the current position moves away from the lineString + var p3 = destination(p2, ddistance, orthogonalBearing); + var p4 = destination(p1, ddistance, orthogonalBearing); + return [p3.geometry.coordinates, p4.geometry.coordinates]; +} +export function distance2d(x1, y1, x2, y2) { + var dx = x1 - x2; + var dy = y1 - y2; + return Math.sqrt(dx * dx + dy * dy); +} +export function mix(a, b, ratio) { + return b * ratio + a * (1 - ratio); +} +export function nearestPointOnProjectedLine(line, inPoint, viewport) { + var wmViewport = new WebMercatorViewport(viewport); + // Project the line to viewport, then find the nearest point + var coordinates = line.geometry.coordinates; + var projectedCoords = coordinates.map(function (_a) { + var _b = __read(_a, 3), x = _b[0], y = _b[1], _c = _b[2], z = _c === void 0 ? 0 : _c; + return wmViewport.project([x, y, z]); + }); + //@ts-ignore + var _a = __read(wmViewport.project(inPoint.geometry.coordinates), 2), x = _a[0], y = _a[1]; + // console.log('projectedCoords', JSON.stringify(projectedCoords)); + var minDistance = Infinity; + var minPointInfo = {}; + projectedCoords.forEach(function (_a, index) { + var _b = __read(_a, 2), x2 = _b[0], y2 = _b[1]; + if (index === 0) { + return; + } + var _c = __read(projectedCoords[index - 1], 2), x1 = _c[0], y1 = _c[1]; + // line from projectedCoords[index - 1] to projectedCoords[index] + // convert to Ax + By + C = 0 + var A = y1 - y2; + var B = x2 - x1; + var C = x1 * y2 - x2 * y1; + // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line + var div = A * A + B * B; + var distance = Math.abs(A * x + B * y + C) / Math.sqrt(div); + // TODO: Check if inside bounds + if (distance < minDistance) { + minDistance = distance; + minPointInfo = { + index: index, + x0: (B * (B * x - A * y) - A * C) / div, + y0: (A * (-B * x + A * y) - B * C) / div, + }; + } + }); + //@ts-ignore + var index = minPointInfo.index, x0 = minPointInfo.x0, y0 = minPointInfo.y0; + var _b = __read(projectedCoords[index - 1], 3), x1 = _b[0], y1 = _b[1], _c = _b[2], z1 = _c === void 0 ? 0 : _c; + var _d = __read(projectedCoords[index], 3), x2 = _d[0], y2 = _d[1], _e = _d[2], z2 = _e === void 0 ? 0 : _e; + // calculate what ratio of the line we are on to find the proper z + var lineLength = distance2d(x1, y1, x2, y2); + var startToPointLength = distance2d(x1, y1, x0, y0); + var ratio = startToPointLength / lineLength; + var z0 = mix(z1, z2, ratio); + return { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: wmViewport.unproject([x0, y0, z0]), + }, + properties: { + // TODO: calculate the distance in proper units + dist: minDistance, + index: index - 1, + }, + }; +} +export function getPickedEditHandle(picks) { + var handles = getPickedEditHandles(picks); + return handles.length ? handles[0] : null; +} +export function getPickedSnapSourceEditHandle(picks) { + var handles = getPickedEditHandles(picks); + return handles.find(function (handle) { return handle.properties.editHandleType === 'snap-source'; }); +} +export function getNonGuidePicks(picks) { + return picks && picks.filter(function (pick) { return !pick.isGuide; }); +} +export function getPickedExistingEditHandle(picks) { + var handles = getPickedEditHandles(picks); + return handles.find(function (_a) { + var properties = _a.properties; + return properties.featureIndex >= 0 && properties.editHandleType === 'existing'; + }); +} +export function getPickedIntermediateEditHandle(picks) { + var handles = getPickedEditHandles(picks); + return handles.find(function (_a) { + var properties = _a.properties; + return properties.featureIndex >= 0 && properties.editHandleType === 'intermediate'; + }); +} +export function getPickedEditHandles(picks) { + var handles = (picks && + picks + .filter(function (pick) { return pick.isGuide && pick.object.properties.guideType === 'editHandle'; }) + .map(function (pick) { return pick.object; })) || + []; + return handles; +} +export function getEditHandlesForGeometry(geometry, featureIndex, editHandleType) { + if (editHandleType === void 0) { editHandleType = 'existing'; } + var handles = []; + switch (geometry.type) { + case 'Point': + // positions are not nested + handles = [ + { + type: 'Feature', + properties: { + guideType: 'editHandle', + editHandleType: editHandleType, + positionIndexes: [], + featureIndex: featureIndex, + }, + geometry: { + type: 'Point', + coordinates: geometry.coordinates, + }, + }, + ]; + break; + case 'MultiPoint': + case 'LineString': + // positions are nested 1 level + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates, [], featureIndex, editHandleType)); + break; + case 'Polygon': + case 'MultiLineString': + // positions are nested 2 levels + for (var a = 0; a < geometry.coordinates.length; a++) { + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates[a], [a], featureIndex, editHandleType)); + if (geometry.type === 'Polygon') { + // Don't repeat the first/last handle for Polygons + handles = handles.slice(0, -1); + } + } + break; + case 'MultiPolygon': + // positions are nested 3 levels + for (var a = 0; a < geometry.coordinates.length; a++) { + for (var b = 0; b < geometry.coordinates[a].length; b++) { + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates[a][b], [a, b], featureIndex, editHandleType)); + // Don't repeat the first/last handle for Polygons + handles = handles.slice(0, -1); + } + } + break; + default: + //@ts-ignore + throw Error("Unhandled geometry type: " + geometry.type); + } + return handles; +} +function getEditHandlesForCoordinates(coordinates, positionIndexPrefix, featureIndex, editHandleType) { + if (editHandleType === void 0) { editHandleType = 'existing'; } + var editHandles = []; + for (var i = 0; i < coordinates.length; i++) { + var position = coordinates[i]; + editHandles.push({ + type: 'Feature', + properties: { + guideType: 'editHandle', + positionIndexes: __spread(positionIndexPrefix, [i]), + featureIndex: featureIndex, + editHandleType: editHandleType, + }, + geometry: { + type: 'Point', + coordinates: position, + }, + }); + } + return editHandles; +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/src/utils.js.map b/lib/modules/edit-modes/src/utils.js.map new file mode 100644 index 000000000..73b25072f --- /dev/null +++ b/lib/modules/edit-modes/src/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../modules/edit-modes/src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,mBAAmB,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAa5D,MAAM,UAAU,WAAW,CACzB,KAAiD,EACjD,YAAiE;I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,IAAM,CAAC,CAAC;KAC5D;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,4BAA4B,CACnC,WAAkB,EAClB,mBAA6B,EAC7B,YAAoB,EACpB,cAA2C;IAA3C,+BAAA,EAAA,2BAA2C;IAE3C,IAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACV,SAAS,EAAE,YAAY;gBACvB,eAAe,WAAM,mBAAmB,GAAE,CAAC,EAAC;gBAC5C,YAAY,cAAA;gBACZ,cAAc,gBAAA;aACf;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,QAAQ;aACtB;SACF,CAAC,CAAC;KACJ;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts b/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts new file mode 100644 index 000000000..c12a35047 --- /dev/null +++ b/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=immutable-feature-collection.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts.map b/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts.map new file mode 100644 index 000000000..8726a4b52 --- /dev/null +++ b/lib/modules/edit-modes/test/immutable-feature-collection.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"immutable-feature-collection.test.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/test/immutable-feature-collection.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/immutable-feature-collection.test.js b/lib/modules/edit-modes/test/immutable-feature-collection.test.js new file mode 100644 index 000000000..1e886794f --- /dev/null +++ b/lib/modules/edit-modes/test/immutable-feature-collection.test.js @@ -0,0 +1,776 @@ +/* eslint-env jest */ +import { ImmutableFeatureCollection } from '../src/lib/immutable-feature-collection'; +var pointFeature; +var lineStringFeature; +var polygonFeature; +var multiPointFeature; +var multiLineStringFeature; +var multiPolygonFeature; +var featureCollection; +beforeEach(function () { + pointFeature = { + type: 'Feature', + properties: {}, + geometry: { type: 'Point', coordinates: [1, 2] }, + }; + lineStringFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2], + [2, 3], + [3, 4], + ], + }, + }; + polygonFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + // exterior ring + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + }, + }; + multiPointFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPoint', + coordinates: [ + [1, 2], + [3, 4], + ], + }, + }; + multiLineStringFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + [ + [5, 6], + [6, 7], + [7, 8], + ], + ], + }, + }; + multiPolygonFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + // exterior ring polygon 1 + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole polygon 1 + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + [ + // exterior ring polygon 2 + [ + [2, -1], + [4, -1], + [4, 1], + [2, 1], + [2, -1], + ], + ], + ], + }, + }; + featureCollection = { + type: 'FeatureCollection', + features: [ + pointFeature, + lineStringFeature, + polygonFeature, + multiPointFeature, + multiLineStringFeature, + multiPolygonFeature, + ], + }; +}); +describe('getObject()', function () { + it('can get real object', function () { + var editable = new ImmutableFeatureCollection(featureCollection); + expect(editable.getObject()).toBe(featureCollection); + }); +}); +describe('replacePosition()', function () { + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [pointFeature], + }); + var updatedFeatures = features.replacePosition(0, [], [10, 20]); + expect(updatedFeatures).not.toBe(features); + expect(pointFeature.geometry.coordinates).toEqual([1, 2]); + }); + it('replaces position in Point', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [pointFeature], + }); + var updatedFeatures = features.replacePosition(0, [], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [10, 20]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('replaces first position in LineString', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.replacePosition(0, [0], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [10, 20], + [2, 3], + [3, 4], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('replaces middle position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features + .replacePosition(0, [0, 1], [1.1, -1.1]) + .replacePosition(0, [1, 2], [0.6, 0.6]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1, -1], + [1.1, -1.1], + [1, 1], + [-1, 1], + [-1, -1], + ], + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.6, 0.6], + [0.5, -0.5], + [-0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('replaces last position when replacing first position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.replacePosition(0, [0, 0], [-1.1, -1.1]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1.1, -1.1], + [1, -1], + [1, 1], + [-1, 1], + [-1.1, -1.1], + ], + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('replaces first position when replacing last position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.replacePosition(0, [0, 4], [-1.1, -1.1]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1.1, -1.1], + [1, -1], + [1, 1], + [-1, 1], + [-1.1, -1.1], + ], + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); +}); +describe('removePosition()', function () { + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.removePosition(0, [0]); + expect(updatedFeatures).not.toBe(features); + expect(lineStringFeature.geometry.coordinates).toEqual([ + [1, 2], + [2, 3], + [3, 4], + ]); + }); + it('throws exception when attempting to remove Point', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [pointFeature], + }); + expect(function () { return features.removePosition(0, [0]); }).toThrow("Can't remove a position from a Point or there'd be nothing left"); + }); + it('removes first position in LineString', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.removePosition(0, [0]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [2, 3], + [3, 4], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('removes middle position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.removePosition(0, [0, 1]).removePosition(0, [1, 3]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [-0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('changes last position when removing first position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.removePosition(0, [1, 0]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + [ + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, 0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('changes first position when removing last position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.removePosition(0, [1, 4]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + [ + [0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('throws exception when LineString has only 2 positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [ + [0, 1], + [2, 3], + ], + }, + }, + ], + }); + expect(function () { return features.removePosition(0, [0]); }).toThrow("Can't remove position. LineString must have at least two positions"); + }); + it('throws exception when Polygon outer ring has only 4 positions (triangle)', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + features = features + // Convert from quadrilateral to triangle + .removePosition(0, [0, 1]); + expect(function () { return features.removePosition(0, [0, 1]); }).toThrow("Can't remove position. Polygon's outer ring must have at least four positions"); + }); + it('removes hole from Polygon when it has less than four positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features.removePosition(0, [1, 1]).removePosition(0, [1, 1]); + var actualGeometry = updatedFeatures.getObject().features[0].geometry; + var expectedGeometry = { + type: 'Polygon', + coordinates: [ + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + ], + }; + expect(actualGeometry).toEqual(expectedGeometry); + }); + it('removes LineString from MultiLineString when it has only one position', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiLineStringFeature], + }); + var updatedFeatures = features.removePosition(0, [1, 0]).removePosition(0, [1, 0]); + var actualGeometry = updatedFeatures.getObject().features[0].geometry; + var expectedGeometry = { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + ], + }; + expect(actualGeometry).toEqual(expectedGeometry); + }); + it('throws exception when MultiLineString has only 2 positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiLineStringFeature], + }); + features = features + // remove one of the LineStrings + .removePosition(0, [0, 0]) + .removePosition(0, [0, 0]) + // shrink the remaining LineString to two positions + .removePosition(0, [0, 0]); + expect(function () { return features.removePosition(0, [0, 0]); }).toThrow("Can't remove position. MultiLineString must have at least two positions"); + }); + it('removes Polygon from MultiPolygon when outer ring has less than four positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPolygonFeature], + }); + var updatedFeatures = features.removePosition(0, [1, 0, 0]).removePosition(0, [1, 0, 0]); + var actualGeometry = updatedFeatures.getObject().features[0].geometry; + var expectedGeometry = { + type: 'MultiPolygon', + coordinates: [multiPolygonFeature.geometry.coordinates[0]], + }; + expect(actualGeometry).toEqual(expectedGeometry); + }); + it('removes hole from MultiPolygon when it has less than four positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPolygonFeature], + }); + var updatedFeatures = features.removePosition(0, [0, 1, 0]).removePosition(0, [0, 1, 0]); + var actualGeometry = updatedFeatures.getObject().features[0].geometry; + var expectedGeometry = { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + ], + [ + [ + [2, -1], + [4, -1], + [4, 1], + [2, 1], + [2, -1], + ], + ], + ], + }; + expect(actualGeometry).toEqual(expectedGeometry); + }); + it('throws exception when MultiPolygon outer ring has only 4 positions', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPolygonFeature], + }); + features = features + // Remove the second polygon + .removePosition(0, [1, 0, 0]) + .removePosition(0, [1, 0, 0]) + // Remove positions from outer ring + .removePosition(0, [0, 0, 1]); + expect(function () { return features.removePosition(0, [0, 0, 1]); }).toThrow("Can't remove position. MultiPolygon's outer ring must have at least four positions"); + }); +}); +describe('addPosition()', function () { + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.addPosition(0, [1], [2, 3]); + expect(updatedFeatures).not.toBe(features); + expect(lineStringFeature.geometry.coordinates).toEqual([ + [1, 2], + [2, 3], + [3, 4], + ]); + }); + it('throws exception when attempting to add position to Point', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [pointFeature], + }); + expect(function () { return features.addPosition(0, [], [3, 4]); }).toThrow('Unable to add a position to a Point feature'); + }); + it('adds position to beginning of LineString', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.addPosition(0, [0], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [10, 20], + [1, 2], + [2, 3], + [3, 4], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('adds position to middle of LineString', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.addPosition(0, [1], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [1, 2], + [10, 20], + [2, 3], + [3, 4], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('adds position to end of LineString', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [lineStringFeature], + }); + var updatedFeatures = features.addPosition(0, [3], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [1, 2], + [2, 3], + [3, 4], + [10, 20], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('adds position in Polygon', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [polygonFeature], + }); + var updatedFeatures = features + .addPosition(0, [0, 1], [0, -1]) + .addPosition(0, [1, 4], [0, -0.5]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [ + [-1, -1], + [0, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [0, -0.5], + [-0.5, -0.5], + ], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); +}); +describe('addFeature()', function () { + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + features.addFeature(pointFeature); + expect(features.getObject().features.length).toEqual(0); + }); + it('adds feature to empty array', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + var actualFeatures = features.addFeature(pointFeature).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [pointFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); + it('adds feature to end of array', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature], + }); + var actualFeatures = features.addFeature(multiLineStringFeature).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [multiPointFeature, multiLineStringFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); +}); +describe('addFeatures()', function () { + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + features.addFeatures([multiPointFeature, pointFeature]); + expect(features.getObject().features.length).toEqual(0); + }); + it('adds features to empty array', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + var actualFeatures = features.addFeatures([multiPointFeature, pointFeature]).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [multiPointFeature, pointFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); + it('adds features to end of array', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature], + }); + var actualFeatures = features.addFeatures([multiLineStringFeature]).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [multiPointFeature, multiLineStringFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); +}); +describe('deleteFeature()', function () { + it("Do nothing when empty array", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + features.deleteFeature(0); + expect(features.getObject().features.length).toEqual(0); + }); + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature], + }); + features.deleteFeature(0); + expect(features.getObject().features.length).toEqual(1); + }); + it('delete feature', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature, multiLineStringFeature], + }); + var actualFeatures = features.deleteFeature(1).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [multiPointFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); +}); +describe('deleteFeatures()', function () { + it("Do nothing when empty array", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }); + features.deleteFeatures([0, 1]); + expect(features.getObject().features.length).toEqual(0); + }); + it("doesn't mutate original", function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature], + }); + features.deleteFeatures([0]); + expect(features.getObject().features.length).toEqual(1); + }); + it('delete single feature', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature, multiLineStringFeature], + }); + var actualFeatures = features.deleteFeatures([1]).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [multiPointFeature], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); + it('delete multiple features', function () { + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [multiPointFeature, multiLineStringFeature], + }); + var actualFeatures = features.deleteFeatures([0, 1]).getObject(); + var expectedFeatures = { + type: 'FeatureCollection', + features: [], + }; + expect(actualFeatures).toEqual(expectedFeatures); + }); +}); +describe('replacePosition() with elevation', function () { + it('replaces position in Point', function () { + var elevatedPointFeature = { + type: 'Feature', + properties: {}, + geometry: { type: 'Point', coordinates: [1, 2, 1000] }, + }; + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + // @ts-ignore + features: [elevatedPointFeature], + }); + var updatedFeatures = features.replacePosition(0, [], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [10, 20, 1000]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); + it('replaces first position in LineString', function () { + var elevatedLineStringFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2, 1000], + [2, 3, 2000], + [3, 4, 3000], + ], + }, + }; + var features = new ImmutableFeatureCollection({ + type: 'FeatureCollection', + // @ts-ignore + features: [elevatedLineStringFeature], + }); + var updatedFeatures = features.replacePosition(0, [0], [10, 20]); + var actualCoordinates = updatedFeatures.getObject().features[0].geometry.coordinates; + var expectedCoordinates = [ + [10, 20, 1000], + [2, 3, 2000], + [3, 4, 3000], + ]; + expect(actualCoordinates).toEqual(expectedCoordinates); + }); +}); +//# sourceMappingURL=immutable-feature-collection.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/immutable-feature-collection.test.js.map b/lib/modules/edit-modes/test/immutable-feature-collection.test.js.map new file mode 100644 index 000000000..14b02b339 --- /dev/null +++ b/lib/modules/edit-modes/test/immutable-feature-collection.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"immutable-feature-collection.test.js","sourceRoot":"","sources":["../../../../modules/edit-modes/test/immutable-feature-collection.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,IAAI,YAAY,CAAC;AACjB,IAAI,iBAAiB,CAAC;AACtB,IAAI,cAAc,CAAC;AACnB,IAAI,iBAAiB,CAAC;AACtB,IAAI,sBAAsB,CAAC;AAC3B,IAAI,mBAAmB,CAAC;AACxB,IAAI,iBAAiB,CAAC;AAEtB,UAAU,CAAC;IACT,YAAY,GAAG;QACb,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;KACjD,CAAC;IAEF,iBAAiB,GAAG;QAClB,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE;gBACX,CAAC,CAAC,EAAE,CAAC,CAAC;gBACN,CAAC,CAAC,EAAE,CAAC,CAAC;gBACN,CAAC,CAAC,EAAE,CAAC,CAAC;aACP;SACF;KACF,CAAC;IAEF,cAAc,GAAG;QACf,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YAC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,yBAAyB,CAAC;SACtC,CAAC,CAAC;QACH,IAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEnE,IAAM,iBAAiB,GAAG,eAAe,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;QACvF,IAAM,mBAAmB,GAAG;YAC1B,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC;YACd,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;YACZ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;SACb,CAAC;QAEF,MAAM,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts new file mode 100644 index 000000000..8a0319a37 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=draw-circle-by-diameter-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts.map new file mode 100644 index 000000000..41b4f8df6 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-diameter-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js new file mode 100644 index 000000000..21eb6052b --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js @@ -0,0 +1,55 @@ +/* eslint-env jest */ +import { DrawCircleByDiameterMode } from '../../src/lib/draw-circle-by-diameter-mode'; +import { createFeatureCollectionProps, createFeatureCollection, createClickEvent, createPointerMoveEvent, } from '../test-utils'; +var featureCollection; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + // @ts-ignore + featureCollection = createFeatureCollection(); + var makeFlowHappy = featureCollection.features.find(function (f) { return f.geometry.type === 'Polygon'; }); + if (!makeFlowHappy) { + throw new Error("Need a Polygon in my setup"); + } +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +describe('dragToDraw=false', function () { + it('sets tentative feature to a Polygon after first click', function () { + var mode = new DrawCircleByDiameterMode(); + var props = createFeatureCollectionProps(); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleClick(createClickEvent([1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + var tentativeFeature = mode.getTentativeGuide(props); + if (!tentativeFeature) { + throw new Error('Should have tentative feature'); + } + expect(tentativeFeature.geometry.type).toEqual('Polygon'); + // @ts-ignore + expect(tentativeFeature.geometry.coordinates[0].length).toEqual(65); + }); + it('adds a new feature after two clicks', function () { + var mode = new DrawCircleByDiameterMode(); + var props = createFeatureCollectionProps(); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleClick(createClickEvent([1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + mode.handleClick(createClickEvent([2, 3]), props); + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + var result = props.onEdit.mock.calls[0][0]; + expect(result.editType).toEqual('addFeature'); + expect(result.editContext.featureIndexes).toEqual([featureCollection.features.length]); + var resultFeatures = result.updatedData.features; + var newFeature = resultFeatures[resultFeatures.length - 1]; + expect(newFeature.properties.shape).toEqual('Circle'); + expect(newFeature.geometry.type).toEqual('Polygon'); + expect(newFeature.geometry.coordinates[0].length).toEqual(65); + }); +}); +//# sourceMappingURL=draw-circle-by-diameter-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js.map b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js.map new file mode 100644 index 000000000..42ddd1d5a --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-diameter-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-circle-by-diameter-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,IAAI,iBAAoC,CAAC;AAEzC,IAAI,UAAU,CAAC;AACf,UAAU,CAAC;IACT,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,sBAAsB;IACjD,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,cAAa,CAAC,CAAC,CAAC,sBAAsB;IACrD,aAAa;IACb,iBAAiB,GAAG,uBAAuB,EAAE,CAAC;IAE9C,IAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAA7B,CAA6B,CAAC,CAAC;IAC5F,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC/C;AACH,CAAC,CAAC,CAAC;AAEH,SAAS,CA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ib/draw-line-string-mode.test.d.ts new file mode 100644 index 000000000..d1bcb8f06 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=draw-line-string-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.d.ts.map new file mode 100644 index 000000000..1de77cd2e --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-line-string-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js new file mode 100644 index 000000000..32e619103 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js @@ -0,0 +1,68 @@ +/* eslint-env jest */ +import { DrawLineStringMode } from '../../src/lib/draw-line-string-mode'; +import { createFeatureCollectionProps, createClickEvent } from '../test-utils'; +var props; +beforeAll(function () { + var mode = new DrawLineStringMode(); + props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [], + }, + }); + mode.handleClick(createClickEvent([1, 2]), props); + mode.handleClick(createClickEvent([3, 4]), props); + mode.handleClick(createClickEvent([5, 6]), props); + mode.handleClick(createClickEvent([5.0000001, 6.0000001], [ + { + index: -1, + isGuide: true, + object: { + properties: { + guideType: 'editHandle', + positionIndexes: [2], + }, + }, + }, + ]), props); +}); +describe('while tentative', function () { + it('calls onEdit', function () { + expect(props.onEdit).toHaveBeenCalledTimes(4); + expect(props.onEdit.mock.calls[0][0].editType).toEqual('addTentativePosition'); + expect(props.onEdit.mock.calls[0][0].editContext.position).toEqual([1, 2]); + expect(props.onEdit.mock.calls[1][0].editType).toEqual('addTentativePosition'); + expect(props.onEdit.mock.calls[1][0].editContext.position).toEqual([3, 4]); + expect(props.onEdit.mock.calls[2][0].editType).toEqual('addTentativePosition'); + expect(props.onEdit.mock.calls[2][0].editContext.position).toEqual([5, 6]); + }); + it("doesn't change the data", function () { + var expectedData = { + type: 'FeatureCollection', + features: [], + }; + expect(props.onEdit.mock.calls[0][0].updatedData).toEqual(expectedData); + expect(props.onEdit.mock.calls[1][0].updatedData).toEqual(expectedData); + expect(props.onEdit.mock.calls[2][0].updatedData).toEqual(expectedData); + }); +}); +describe('after double-clicking', function () { + it('calls onEdit with an added feature', function () { + expect(props.onEdit.mock.calls[3][0].editType).toEqual('addFeature'); + expect(props.onEdit.mock.calls[3][0].updatedData.features).toEqual([ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2], + [3, 4], + [5, 6], + ], + }, + }, + ]); + }); +}); +//# sourceMappingURL=draw-line-string-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js.map b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js.map new file mode 100644 index 000000000..7793e88b7 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-line-string-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-line-string-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE/E,IAAI,KAAK,CAAC;AAEV,SAAS,CAAC;IACR,IAAM,IAAI,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACtC,KAAK,GAAG,4BAA4B,CAAC;QACnC,IAAI,EAAE;YACJ,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CA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BAAuB,EAAE;IAChC,EAAE,CAAC,oCAAoC,EAAE;QACvC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACrE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;YACjE;gBACE,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE;wBACX,CAAC,CAAC,EAAE,CAAC,CAAC;wBACN,CAAC,CAAC,EAAE,CAAC,CAAC;wBACN,CAAC,CAAC,EAAE,CAAC,CAAC;qBACP;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts new file mode 100644 index 000000000..8a127c50f --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=draw-rectangle-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts.map new file mode 100644 index 000000000..67fd9be12 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-rectangle-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js new file mode 100644 index 000000000..390a1feb8 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js @@ -0,0 +1,221 @@ +/* eslint-env jest */ +import { __assign, __read, __spread } from "tslib"; +import turfArea from '@turf/area'; +import { DrawRectangleMode } from '../../src/lib/draw-rectangle-mode'; +import { createFeatureCollectionProps, createFeatureCollection, createClickEvent, createPointerMoveEvent, createStartDraggingEvent, createStopDraggingEvent, } from '../test-utils'; +var featureCollection; +var polygonFeature; +var polygonFeatureIndex; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + // @ts-ignore + featureCollection = createFeatureCollection(); + var makeFlowHappy = featureCollection.features.find(function (f) { return f.geometry.type === 'Polygon'; }); + if (!makeFlowHappy) { + throw new Error("Need a Polygon in my setup"); + } + polygonFeature = makeFlowHappy; + polygonFeatureIndex = featureCollection.features.indexOf(polygonFeature); +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +describe('dragToDraw=false', function () { + it('sets tentative feature to a Polygon after first click', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps(); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleClick(createClickEvent([1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + var tentativeFeature = mode.getTentativeGuide(props); + if (!tentativeFeature) { + throw new Error('Should have tentative feature'); + } + expect(tentativeFeature.geometry).toEqual({ + type: 'Polygon', + coordinates: [ + [ + [1, 2], + [2, 2], + [2, 3], + [1, 3], + [1, 2], + ], + ], + }); + }); + it('adds a new feature after two clicks', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps(); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleClick(createClickEvent([1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + mode.handleClick(createClickEvent([2, 3]), props); + var expectedAction2 = { + editType: 'addFeature', + updatedData: __assign(__assign({}, props.data), { features: __spread(props.data.features, [ + { + type: 'Feature', + properties: { + shape: 'Rectangle', + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [1, 2], + [2, 2], + [2, 3], + [1, 3], + [1, 2], + ], + ], + }, + }, + ]) }), + editContext: { + featureIndexes: [featureCollection.features.length], + }, + }; + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + expect(props.onEdit.mock.calls[0][0]).toEqual(expectedAction2); + }); +}); +describe('dragToDraw=true', function () { + it('sets tentative feature to a Polygon after start dragging', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps({ + modeConfig: { + dragToDraw: true, + }, + }); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleStartDragging(createStartDraggingEvent([1, 2], [1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + var tentativeFeature = mode.getTentativeGuide(props); + if (!tentativeFeature) { + throw new Error('Should have tentative feature'); + } + expect(tentativeFeature.geometry).toEqual({ + type: 'Polygon', + coordinates: [ + [ + [1, 2], + [2, 2], + [2, 3], + [1, 3], + [1, 2], + ], + ], + }); + }); + it('adds a new feature after stop dragging', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps({ + modeConfig: { + dragToDraw: true, + }, + }); + props.lastPointerMoveEvent = createPointerMoveEvent([1, 2]); + mode.handleStartDragging(createStartDraggingEvent([1, 2], [1, 2]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 3]); + mode.handleStopDragging(createStopDraggingEvent([2, 3], [2, 3]), props); + var expectedAction2 = { + editType: 'addFeature', + updatedData: __assign(__assign({}, props.data), { features: __spread(props.data.features, [ + { + type: 'Feature', + properties: { + shape: 'Rectangle', + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [1, 2], + [2, 2], + [2, 3], + [1, 3], + [1, 2], + ], + ], + }, + }, + ]) }), + editContext: { + featureIndexes: [featureCollection.features.length], + }, + }; + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + expect(props.onEdit.mock.calls[0][0]).toEqual(expectedAction2); + }); +}); +describe('modeConfig.booleanOperation', function () { + describe('union', function () { + test('unions shapes', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps({ + selectedIndexes: [polygonFeatureIndex], + modeConfig: { booleanOperation: 'union' }, + }); + // @ts-ignore + var areaBefore = turfArea(featureCollection.features[polygonFeatureIndex]); + props.lastPointerMoveEvent = createPointerMoveEvent([0, 0]); + mode.handleClick(createClickEvent([0, 0]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 2]); + mode.handleClick(createClickEvent([2, 2]), props); + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + var action = props.onEdit.mock.calls[0][0]; + var areaAfter = turfArea(action.updatedData.features[polygonFeatureIndex]); + expect(areaAfter).toBeGreaterThan(areaBefore); + }); + }); + describe('difference', function () { + test('subtracts geometry', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps({ + selectedIndexes: [polygonFeatureIndex], + modeConfig: { booleanOperation: 'difference' }, + }); + // @ts-ignore + var areaBefore = turfArea(featureCollection.features[polygonFeatureIndex]); + props.lastPointerMoveEvent = createPointerMoveEvent([0, 0]); + mode.handleClick(createClickEvent([0, 0]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 2]); + mode.handleClick(createClickEvent([2, 2]), props); + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + var action = props.onEdit.mock.calls[0][0]; + var areaAfter = turfArea(action.updatedData.features[polygonFeatureIndex]); + expect(areaAfter).toBeLessThan(areaBefore); + }); + }); + describe('intersection', function () { + test('subtracts geometry', function () { + var mode = new DrawRectangleMode(); + var props = createFeatureCollectionProps({ + selectedIndexes: [polygonFeatureIndex], + modeConfig: { booleanOperation: 'intersection' }, + }); + // @ts-ignore + var areaBefore = turfArea(featureCollection.features[polygonFeatureIndex]); + props.lastPointerMoveEvent = createPointerMoveEvent([0, 0]); + mode.handleClick(createClickEvent([0, 0]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([2, 2]); + mode.handleClick(createClickEvent([2, 2]), props); + expect(props.onEdit).toHaveBeenCalledTimes(1); + // @ts-ignore + var action = props.onEdit.mock.calls[0][0]; + var areaAfter = turfArea(action.updatedData.features[polygonFeatureIndex]); + expect(areaAfter).toBeLessThan(areaBefore); + }); + }); +}); +//# sourceMappingURL=draw-rectangle-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js.map b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js.map new file mode 100644 index 000000000..3c06db593 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/draw-rectangle-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/draw-rectangle-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;;AAErB,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,IAAI,iBAAoC,CAAC;AACzC,IAAI,cAAuB,CAAC;AAC5B,IAAI,mBAA2B,CAAC;AAEhC,IAAI,UAAU,CAAC;AACf,UAAU,CAAC;IACT,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,sBAAsB;IACjD,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,cAAa,CAAC,CAAC,CAAC,sBAAsB;IACrD,aAAa;IACb,iBAAiB,GAAG,uBAAuB,EAAE,CAAC;IAE9C,IAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ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AM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;YAE7E,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts new file mode 100644 index 000000000..50c99800c --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=measure-angle-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts.map new file mode 100644 index 000000000..180c45059 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-angle-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-angle-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js new file mode 100644 index 000000000..f183a90e7 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js @@ -0,0 +1,51 @@ +/* eslint-env jest */ +import { __assign } from "tslib"; +import { MeasureAngleMode } from '../../src/lib/measure-angle-mode'; +import { createFeatureCollectionProps, createClickEvent, createPointerMoveEvent, } from '../test-utils'; +describe('move without click', function () { + var mode; + beforeEach(function () { + mode = new MeasureAngleMode(); + mode.handlePointerMove(createPointerMoveEvent(), createFeatureCollectionProps()); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('one click', function () { + var mode; + beforeEach(function () { + mode = new MeasureAngleMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('three clicks + pointer move', function () { + var mode; + var props; + beforeEach(function () { + mode = new MeasureAngleMode(); + props = createFeatureCollectionProps(); + mode.handleClick(createClickEvent([1, 1]), props); + mode.handleClick(createClickEvent([-1, 1]), props); + mode.handleClick(createClickEvent([-1, -1]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([1, -1]); + }); + it('tooltip contains angle', function () { + var tooltips = mode.getTooltips(props); + expect(tooltips).toMatchSnapshot(); + }); + it('can measure degrees', function () { + var tooltips = mode.getTooltips(props); + expect(tooltips[0].text).toContain('deg'); + }); + it('can format angle', function () { + var tooltips = mode.getTooltips(__assign(__assign({}, props), { modeConfig: { formatTooltip: function (angle) { return String(Math.round(angle)); } } })); + expect(tooltips[0].text).toEqual('45'); + }); +}); +//# sourceMappingURL=measure-angle-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js.map b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js.map new file mode 100644 index 000000000..5ac50aaaa --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-angle-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-angle-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-angle-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,oBA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C,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACpD,KAAK,CAAC,oBAAoB,GAAG,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE;QAC3B,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE;QACxB,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kBAAkB,EAAE;QACrB,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,uBAC5B,KAAK,KACR,UAAU,EAAE,EAAE,aAAa,EAAE,UAAC,KAAK,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAzB,CAAyB,EAAE,IACnE,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts b/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts new file mode 100644 index 000000000..ffc43446d --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=measure-area-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts.map new file mode 100644 index 000000000..2cbe7eddf --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-area-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-area-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-area-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-area-mode.test.js b/lib/modules/edit-modes/test/lib/measure-area-mode.test.js new file mode 100644 index 000000000..e6e4afd4e --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-area-mode.test.js @@ -0,0 +1,51 @@ +/* eslint-env jest */ +import { __assign } from "tslib"; +import { MeasureAreaMode } from '../../src/lib/measure-area-mode'; +import { createFeatureCollectionProps, createClickEvent, createPointerMoveEvent, } from '../test-utils'; +describe('move without click', function () { + var mode; + beforeEach(function () { + mode = new MeasureAreaMode(); + mode.handlePointerMove(createPointerMoveEvent(), createFeatureCollectionProps()); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('one click', function () { + var mode; + beforeEach(function () { + mode = new MeasureAreaMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('three clicks + pointer move', function () { + var mode; + var props; + beforeEach(function () { + mode = new MeasureAreaMode(); + props = createFeatureCollectionProps(); + mode.handleClick(createClickEvent([1, 1]), props); + mode.handleClick(createClickEvent([-1, 1]), props); + mode.handleClick(createClickEvent([-1, -1]), props); + props.lastPointerMoveEvent = createPointerMoveEvent([1, -1]); + }); + it('tooltip contains area', function () { + var tooltips = mode.getTooltips(props); + expect(tooltips).toMatchSnapshot(); + }); + it('can measure square meters', function () { + var tooltips = mode.getTooltips(props); + expect(tooltips[0].text).toContain('sq. m'); + }); + it('can format area', function () { + var tooltips = mode.getTooltips(__assign(__assign({}, props), { modeConfig: { formatTooltip: function (area) { return String(Math.round(area)); } } })); + expect(tooltips[0].text).toEqual('49565599608'); + }); +}); +//# sourceMappingURL=measure-area-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-area-mode.test.js.map b/lib/modules/edit-modes/test/lib/measure-area-mode.test.js.map new file mode 100644 index 000000000..f161d145b --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-area-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-area-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-area-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;;AAErB,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,oBAAoB,EAAE;IAC7B,IAAI,IAAI,CAAC;IACT,UAAU,CAAC;QACT,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;QAC7B,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,EAAE,4BAA4B,EAAE,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE;QACvB,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,EAAE;IACpB,IAAI,IAAI,CAAC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C;IAEH,EAAE,CAAC,2BAA2B,EAAE;QAC9B,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,uBAC5B,KAAK,KACR,UAAU,EAAE,EAAE,aAAa,EAAE,UAAC,IAAI,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAxB,CAAwB,EAAE,IACjE,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts new file mode 100644 index 000000000..23a30d228 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=measure-distance-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts.map new file mode 100644 index 000000000..00a7e7f9f --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-distance-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-distance-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js new file mode 100644 index 000000000..3d1f415f8 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js @@ -0,0 +1,95 @@ +/* eslint-env jest */ +import { MeasureDistanceMode } from '../../src/lib/measure-distance-mode'; +import { createFeatureCollectionProps, createClickEvent, createPointerMoveEvent, } from '../test-utils'; +describe('move without click', function () { + var mode; + beforeEach(function () { + mode = new MeasureDistanceMode(); + mode.handlePointerMove(createPointerMoveEvent(), createFeatureCollectionProps()); + }); + it('guides are empty', function () { + var guides = mode.getGuides(createFeatureCollectionProps()); + expect(guides).toEqual({ type: 'FeatureCollection', features: [] }); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('one click', function () { + var mode; + beforeEach(function () { + mode = new MeasureDistanceMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + }); + it('guides are a single point', function () { + var guides = mode.getGuides(createFeatureCollectionProps()); + expect(guides).toMatchSnapshot(); + }); + it('tooltips are empty', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toEqual([]); + }); +}); +describe('one click + pointer move', function () { + var mode; + beforeEach(function () { + mode = new MeasureDistanceMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + mode.handlePointerMove(createPointerMoveEvent([3, 4]), createFeatureCollectionProps()); + }); + it('guides are two points + line string', function () { + var guides = mode.getGuides(createFeatureCollectionProps()); + expect(guides).toMatchSnapshot(); + }); + it('tooltip contains distance', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toMatchSnapshot(); + }); +}); +describe('two clicks', function () { + var mode; + beforeEach(function () { + mode = new MeasureDistanceMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + mode.handleClick(createClickEvent([3, 4]), createFeatureCollectionProps()); + }); + it('guides are two points + line string', function () { + var guides = mode.getGuides(createFeatureCollectionProps()); + expect(guides).toMatchSnapshot(); + }); + it('tooltip contains distance', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toMatchSnapshot(); + }); + it('can measure kilometers', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips[0].text).toContain('kilometers'); + }); + it('can measure miles', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps({ modeConfig: { turfOptions: { units: 'miles' } } })); + expect(tooltips[0].text).toContain('miles'); + }); + it('can format distance', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps({ modeConfig: { formatTooltip: String } })); + expect(tooltips[0].text).toEqual('314.28368918020476'); + }); +}); +describe('two clicks + pointer move', function () { + var mode; + beforeEach(function () { + mode = new MeasureDistanceMode(); + mode.handleClick(createClickEvent([1, 2]), createFeatureCollectionProps()); + mode.handleClick(createClickEvent([3, 4]), createFeatureCollectionProps()); + mode.handlePointerMove(createPointerMoveEvent([4, 5]), createFeatureCollectionProps()); + }); + it('ending point is clicked point not hovered point', function () { + var guides = mode.getGuides(createFeatureCollectionProps()); + expect(guides.features[1].geometry.coordinates).toEqual([3, 4]); + }); + it('tooltip contains distance', function () { + var tooltips = mode.getTooltips(createFeatureCollectionProps()); + expect(tooltips).toMatchSnapshot(); + }); +}); +//# sourceMappingURL=measure-distance-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js.map b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js.map new file mode 100644 index 000000000..e809e4a82 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/measure-distance-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"measure-distance-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/measure-distance-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,eAAe,C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IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,2BAA2B,EAAE;IACpC,IAAI,IAAI,CAAC;IACT,UAAU,CAAC;QACT,IAAI,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,4BAA4B,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,4BAA4B,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,4BAA4B,EAAE,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE;QACpD,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,4BAA4B,EAAE,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE;QAC9B,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts b/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts new file mode 100644 index 000000000..3a961641c --- /dev/null +++ b/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=modify-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts.map new file mode 100644 index 000000000..eadd6148c --- /dev/null +++ b/lib/modules/edit-modes/test/lib/modify-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/modify-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/modify-mode.test.js b/lib/modules/edit-modes/test/lib/modify-mode.test.js new file mode 100644 index 000000000..c86eb81ac --- /dev/null +++ b/lib/modules/edit-modes/test/lib/modify-mode.test.js @@ -0,0 +1,352 @@ +/* eslint-env jest */ +import { ModifyMode } from '../../src/lib/modify-mode'; +import { createFeatureCollectionProps } from '../test-utils'; +var pointFeature; +var lineStringFeature; +var polygonFeature; +var multiPointFeature; +var multiLineStringFeature; +var multiPolygonFeature; +beforeEach(function () { + pointFeature = { + type: 'Feature', + properties: {}, + geometry: { type: 'Point', coordinates: [1, 2] }, + }; + lineStringFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2], + [2, 3], + [3, 4], + ], + }, + }; + polygonFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + // exterior ring + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + }, + }; + multiPointFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPoint', + coordinates: [ + [1, 2], + [3, 4], + ], + }, + }; + multiLineStringFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + [ + [5, 6], + [6, 7], + [7, 8], + ], + ], + }, + }; + multiPolygonFeature = { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + // exterior ring polygon 1 + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole polygon 1 + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + [ + // exterior ring polygon 2 + [ + [2, -1], + [4, -1], + [4, 1], + [2, 1], + [2, -1], + ], + ], + ], + }, + }; +}); +describe('getGuides()', function () { + it('gets edit handles for Point', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [pointFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for LineString', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineStringFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for Polygon', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [polygonFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for MultiPoint', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [multiPointFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for MultiLineString', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [multiLineStringFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for MultiPolygon', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [multiPolygonFeature], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + it('gets edit handles for all selected features in collection', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineStringFeature, pointFeature, multiPointFeature], + }, + selectedIndexes: [0, 2], + }); + var guides = mode.getGuides(props); + expect(guides).toMatchSnapshot(); + }); + var lineString = { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [ + [-122.40880966186523, 37.783536601521924], + [-122.43893623352051, 37.779669924659004], + [-122.43515968322752, 37.7624370109886], + [-122.42348670959471, 37.77180027337861], + [-122.4250316619873, 37.778584505321376], + [-122.42314338684082, 37.778652344496926], + [-122.42357254028322, 37.77987343901049], + [-122.41198539733887, 37.78109451335266], + ], + }, + }; + var point = { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [-122.40880966186523, 37.783536601521924], + }, + }; + var pick = { + object: lineString, + isGuide: false, + index: 0, + }; + var mapCoords = [-122.43862233312133, 37.77767798407437]; + it('includes an intermediate edit handle', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineString], + }, + selectedIndexes: [0], + lastPointerMoveEvent: { + picks: [pick], + mapCoords: mapCoords, + screenCoords: [42, 42], + cancelPan: jest.fn(), + sourceEvent: null, + }, + }); + var guides = mode.getGuides(props); + var intermediate = guides.features.find(function (_a) { + var properties = _a.properties; + return properties.guideType === 'editHandle' && properties.editHandleType === 'intermediate'; + }); + expect(intermediate).toMatchSnapshot(); + }); + it('does not add intermeidate edit handle when no picks provided', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineString], + }, + selectedIndexes: [0], + }); + var guides = mode.getGuides(props); + var intermediate = guides.features.find(function (_a) { + var properties = _a.properties; + return properties.guideType === 'editHandle' && properties.editHandleType === 'intermediate'; + }); + expect(intermediate).toBeUndefined(); + }); + it('does not add intermeidate edit handle when too close to existing edit handle', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineString], + }, + selectedIndexes: [0], + lastPointerMoveEvent: { + picks: [ + pick, + { + isGuide: true, + index: 42, + object: { + properties: { guideType: 'editHandle', editHandleType: 'existing', featureIndex: 0 }, + geometry: { coordinates: [] }, + }, + }, + ], + mapCoords: mapCoords, + screenCoords: [42, 42], + cancelPan: jest.fn(), + sourceEvent: null, + }, + }); + var guides = mode.getGuides(props); + var intermediate = guides.features.find(function (_a) { + var properties = _a.properties; + return properties.guideType === 'editHandle' && properties.editHandleType === 'intermediate'; + }); + expect(intermediate).toBeUndefined(); + }); + it('does not add intermeidate edit handle when pick is not a selected feature', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [lineString], + }, + }); + var guides = mode.getGuides(props); + var intermediate = guides.features.find(function (_a) { + var properties = _a.properties; + return properties.guideType === 'editHandle' && properties.editHandleType === 'intermediate'; + }); + expect(intermediate).toBeUndefined(); + }); + it('does not add intermeidate edit handle when pick is a Point / MultiPoint', function () { + var mode = new ModifyMode(); + var props = createFeatureCollectionProps({ + data: { + type: 'FeatureCollection', + features: [point], + }, + selectedIndexes: [0], + lastPointerMoveEvent: { + picks: [ + { + isGuide: false, + index: 0, + object: point, + }, + ], + mapCoords: mapCoords, + screenCoords: [42, 42], + cancelPan: jest.fn(), + sourceEvent: null, + }, + }); + var guides = mode.getGuides(props); + var intermediate = guides.features.find(function (_a) { + var properties = _a.properties; + return properties.guideType === 'editHandle' && properties.editHandleType === 'intermediate'; + }); + expect(intermediate).toBeUndefined(); + }); +}); +//# sourceMappingURL=modify-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/modify-mode.test.js.map b/lib/modules/edit-modes/test/lib/modify-mode.test.js.map new file mode 100644 index 000000000..bdaecd995 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/modify-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/modify-mode.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAG7D,IAAI,YAA8B,CAAC;AACnC,IAAI,iBAAwC,CAAC;AAC7C,IAAI,cAAc,CAAC;AACnB,IAAI,iBAAiB,CAAC;AACtB,IAAI,sBAAsB,CAAC;AAC3B,IAAI,mBAAmB,CAAC;AAExB,UAAU,CAAC;IACT,YAAY,GAAG;QACb,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;KACjD,CAAC;IAEF,iBAAiB,GAAG;QAClB,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE;gBACX,CAAC,CAAC,EAAE,CAAC,CAAC;gBACN,CAAC,CAAC,EAAE,CAAC,CAAC;gBACN,CAAC,CAAC,EAAE,CAAC,CAAC;aACP;SACF;KACF,CAAC;IAEF,cAAc,GAAG;QACf,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,WAAW,EAAE;gBACX,gBAAgB;gBAChB;oBACE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACR,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,EAAE,CAAC,CAAC;oBACN,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACT;gBACD,OAAO;gBACP;oBACE,CAAC,CAAC,GAAG,EAAE,CAAC,GAA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4B,CAAC;YACzC,IAAI,EAAE;gBACJ,IAAI,EAAE,mBAAmB;gBACzB,QAAQ,EAAE,CAAC,KAAK,CAAC;aACG;YACtB,eAAe,EAAE,CAAC,CAAC,CAAC;YACpB,oBAAoB,EAAE;gBACpB,KAAK,EAAE;oBACL;wBACE,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,CAAC;wBACR,MAAM,EAAE,KAAK;qBACd;iBACF;gBACD,SAAS,WAAA;gBACT,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;gBACtB,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;gBACpB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC,CAAC;QACH,IAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,IAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CACvC,UAAC,EAAc;gBAAZ,0BAAU;YACX,OAAA,UAAU,CAAC,SAAS,KAAK,YAAY,IAAI,UAAU,CAAC,cAAc,KAAK,cAAc;QAArF,CAAqF,CACxF,CAAC;QACF,MAAM,CAAC,YAAY,CAAC,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts b/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts new file mode 100644 index 000000000..20442497f --- /dev/null +++ b/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=rotate-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts.map new file mode 100644 index 000000000..07ff7c1b0 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/rotate-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/rotate-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/rotate-mode.test.js b/lib/modules/edit-modes/test/lib/rotate-mode.test.js new file mode 100644 index 000000000..46825b739 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/rotate-mode.test.js @@ -0,0 +1,56 @@ +import { RotateMode } from '../../src/lib/rotate-mode'; +import { createFeatureCollectionProps, createPointerMoveEvent, createStartDraggingEvent, createStopDraggingEvent, } from '../test-utils'; +var rotateMode; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + rotateMode = new RotateMode(); +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +var mockRotate = function (picks, props) { + rotateMode.getGuides(props); + var moveEvent = createPointerMoveEvent([-1, -1], picks); + rotateMode.handlePointerMove(moveEvent, props); + var startDragEvent = createStartDraggingEvent([-1, -1], [-1, -1], picks); + rotateMode.handleStartDragging(startDragEvent, props); + var stopDragEvent = createStopDraggingEvent([2, 3], [-1, -1], picks); + rotateMode.handleStopDragging(stopDragEvent, props); +}; +test('Selected polygon feature can be rotated', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + var mockPicks = [ + { + index: 2, + isGuide: true, + object: { + type: 'Feature', + geometry: { type: 'Point', coordinates: [-2, -2] }, + properties: { guideType: 'editHandle', editHandleType: 'rotate' }, + }, + }, + ]; + mockRotate(mockPicks, props); + expect(mockOnEdit).toHaveBeenCalledTimes(1); + var scaledFeature = mockOnEdit.mock.calls[0][0].updatedData.features[2]; + expect(scaledFeature).toMatchSnapshot(); + expect(props.data.features[2]).not.toEqual(scaledFeature); +}); +test('Selected polygon feature without edit handle picks cannot be rotated', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + mockRotate([], props); + expect(mockOnEdit).toHaveBeenCalledTimes(0); +}); +//# sourceMappingURL=rotate-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/rotate-mode.test.js.map b/lib/modules/edit-modes/test/lib/rotate-mode.test.js.map new file mode 100644 index 000000000..194f9aba3 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/rotate-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/rotate-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAIvB,IAAI,UAAsB,CAAC;AAE3B,IAAI,UAAU,CAAC;AACf,UAAU,CAAC;IACT,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,sBAAsB;IACjD,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,cAAa,CAAC,CAAC,CAAC,sBAAsB;IACrD,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC;IACR,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,sBAAsB;AACnD,CAAC,CAAC,CAAC;AAEH,IAAM,UAAU,GAAG,UAAC,KAAa,EAAE,KAAmC;IACpE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE5B,IAAM,SAAS,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1D,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE/C,IAAM,cAAc,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CA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IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sEAAsE,EAAE;IAC3E,IAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC7B,IAAM,KAAK,GAAG,4BAA4B,CAAC;QACzC,eAAe,EAAE,CAAC,CAAC,CAAC;QACpB,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;IAEH,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACtB,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts b/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts new file mode 100644 index 000000000..47e165126 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=scale-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts.map new file mode 100644 index 000000000..728b77a64 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/scale-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/scale-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/scale-mode.test.js b/lib/modules/edit-modes/test/lib/scale-mode.test.js new file mode 100644 index 000000000..a2f89455e --- /dev/null +++ b/lib/modules/edit-modes/test/lib/scale-mode.test.js @@ -0,0 +1,56 @@ +import { TransformMode } from '../../src/lib/transform-mode'; +import { createFeatureCollectionProps, createPointerMoveEvent, createStartDraggingEvent, createStopDraggingEvent, } from '../test-utils'; +var transformMode; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + transformMode = new TransformMode(); +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +var mockScale = function (picks, props) { + transformMode.getGuides(props); + var moveEvent = createPointerMoveEvent([-1, -1], picks); + transformMode.handlePointerMove(moveEvent, props); + var startDragEvent = createStartDraggingEvent([-1, -1], [-1, -1], picks); + transformMode.handleStartDragging(startDragEvent, props); + var stopDragEvent = createStopDraggingEvent([2, 3], [-1, -1], picks); + transformMode.handleStopDragging(stopDragEvent, props); +}; +test('Selected polygon feature can be scaled', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + var mockPicks = [ + { + index: 2, + isGuide: true, + object: { + type: 'Feature', + geometry: { type: 'Point', coordinates: [-2, -2] }, + properties: { guideType: 'editHandle', editHandleType: 'scale', positionIndexes: [0] }, + }, + }, + ]; + mockScale(mockPicks, props); + expect(mockOnEdit).toHaveBeenCalledTimes(1); + var scaledFeature = mockOnEdit.mock.calls[0][0].updatedData.features[2]; + expect(scaledFeature).toMatchSnapshot(); + expect(props.data.features[2]).not.toEqual(scaledFeature); +}); +test('Selected polygon feature without edit handle picks cannot be scaled', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + mockScale([], props); + expect(mockOnEdit).toHaveBeenCalledTimes(0); +}); +//# sourceMappingURL=scale-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/scale-mode.test.js.map b/lib/modules/edit-modes/test/lib/scale-mode.test.js.map new file mode 100644 index 000000000..30e027e3f --- /dev/null +++ b/lib/modules/edit-modes/test/lib/scale-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/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KACnB,CAAC,CAAC;IAEH,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACrB,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts b/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts new file mode 100644 index 000000000..e50217eea --- /dev/null +++ b/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=transform-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts.map new file mode 100644 index 000000000..c90708456 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/transform-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"transform-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/transform-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/transform-mode.test.js b/lib/modules/edit-modes/test/lib/transform-mode.test.js new file mode 100644 index 000000000..24f375a05 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/transform-mode.test.js @@ -0,0 +1,42 @@ +import { TransformMode } from '../../src/lib/transform-mode'; +import { createFeatureCollectionProps, createPointerMoveEvent } from '../test-utils'; +var transformMode; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + transformMode = new TransformMode(); +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +test('onUpdateCursor is only set to null once', function () { + var mockOnUpdateCursor = jest.fn(); + var moveEvent = createPointerMoveEvent([-1, -1], []); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onUpdateCursor: mockOnUpdateCursor, + }); + transformMode.handlePointerMove(moveEvent, props); + expect(mockOnUpdateCursor).toHaveBeenCalledTimes(1); + expect(mockOnUpdateCursor).toBeCalledWith(null); +}); +test('Transform mode correctly renders composited guides', function () { + var props = createFeatureCollectionProps({ selectedIndexes: [2] }); + var guides = transformMode.getGuides(props).features; + var scaleGuides = guides.filter(function (guide) { return guide.properties.editHandleType === 'scale'; }); + expect(scaleGuides.length).toEqual(4); + expect(scaleGuides).toMatchSnapshot(); + var rotateGuide = guides.filter(function (guide) { return guide.properties.editHandleType === 'rotate'; }); + expect(rotateGuide.length).toEqual(1); + expect(rotateGuide).toMatchSnapshot(); + var envelopingBox = guides.filter(function (guide) { return guide.geometry.type === 'Polygon'; }); + expect(envelopingBox.length).toEqual(1); + expect(envelopingBox).toMatchSnapshot(); + var rotateLineGuide = guides.filter(function (guide) { return guide.geometry.type === 'LineString'; }); + expect(rotateLineGuide.length).toEqual(1); + expect(rotateLineGuide).toMatchSnapshot(); +}); +//# sourceMappingURL=transform-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/transform-mode.test.js.map b/lib/modules/edit-modes/test/lib/transform-mode.test.js.map new file mode 100644 index 000000000..0b481d1c1 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/transform-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"transform-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/transform-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAErF,IAAI,aAA4B,CAAC;AAEjC,IAAI,UAAU,CAAC;AACf,UAAU,CAAC;IACT,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,sBAAsB;IACjD,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,cAAa,CAAC,CAAC,CAAC,sBAAsB;IACrD,aAAa,GAAG,IAAI,aAAa,EAAE,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AK,CAAC,UAAU,CAAC,cAAc,KAAK,QAAQ,EAA5C,CAA4C,CAAC,CAAC;IAC3F,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,WAAW,CAAC,CAAC,eAAe,EAAE,CAAC;IAEtC,IAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAjC,CAAiC,CAAC,CAAC;IAClF,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,aAAa,CAAC,CAAC,eAAe,EAAE,CAAC;IAExC,IAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAApC,CAAoC,CAAC,CAAC;IACvF,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,eAAe,CAAC,CAAC,eAAe,EAAE,CAAC;AAC5C,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts b/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts new file mode 100644 index 000000000..e1d5a41be --- /dev/null +++ b/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=translate-mode.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts.map b/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts.map new file mode 100644 index 000000000..f4a7c53c5 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/translate-mode.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-mode.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/translate-mode.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/translate-mode.test.js b/lib/modules/edit-modes/test/lib/translate-mode.test.js new file mode 100644 index 000000000..78d94b1d7 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/translate-mode.test.js @@ -0,0 +1,53 @@ +import { TransformMode } from '../../src/lib/transform-mode'; +import { createFeatureCollectionProps, createPointerMoveEvent, createStartDraggingEvent, createStopDraggingEvent, } from '../test-utils'; +var transformMode; +var warnBefore; +beforeEach(function () { + warnBefore = console.warn; // eslint-disable-line + // $FlowFixMe + console.warn = function () { }; // eslint-disable-line + transformMode = new TransformMode(); +}); +afterEach(function () { + // $FlowFixMe + console.warn = warnBefore; // eslint-disable-line +}); +var mockMove = function (picks, props) { + var moveEvent = createPointerMoveEvent([-1, -1], picks); + transformMode.handlePointerMove(moveEvent, props); + var startDragEvent = createStartDraggingEvent([-1, -1], [-1, -1], picks); + transformMode.handleStartDragging(startDragEvent, props); + var stopDragEvent = createStopDraggingEvent([2, 3], [-1, -1], picks); + transformMode.handleStopDragging(stopDragEvent, props); +}; +test('Selected polygon feature can be translated', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + mockMove([{ index: 2, isGuide: false, object: null }], props); + expect(mockOnEdit).toHaveBeenCalledTimes(1); + var movedFeature = mockOnEdit.mock.calls[0][0].updatedData.features[2]; + expect(movedFeature).toMatchSnapshot(); + expect(props.data.features[2]).not.toEqual(movedFeature); +}); +test('Non-picked selected polygon feature cannnot be translated', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [2], + onEdit: mockOnEdit, + }); + mockMove([], props); + expect(mockOnEdit).toHaveBeenCalledTimes(0); +}); +test('Picked non-selected polygon feature cannnot be translated', function () { + var mockOnEdit = jest.fn(); + var props = createFeatureCollectionProps({ + selectedIndexes: [0], + onEdit: mockOnEdit, + }); + mockMove([{ index: 2, isGuide: false, object: null }], props); + expect(mockOnEdit).toHaveBeenCalledTimes(0); +}); +//# sourceMappingURL=translate-mode.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/translate-mode.test.js.map b/lib/modules/edit-modes/test/lib/translate-mode.test.js.map new file mode 100644 index 000000000..8942e26bc --- /dev/null +++ b/lib/modules/edit-modes/test/lib/translate-mode.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-mode.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/translate-mode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAIvB,IAAI,aAA4B,CAAC;AAEjC,IAAI,UAAU,CAAC;AACf,UAAU,CAAC;IACT,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,sBAAsB;IACjD,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,cAAa,CAAC,CAAC,CAAC,sBAAsB;IACrD,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC;IACR,aAAa;IACb,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,sBAAsB;AACnD,CAAC,CAAC,CAAC;AAEH,IAAM,QAAQ,GAAG,UAAC,KAAa,EAAE,KAAmC;IAClE,IAAM,SAAS,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1D,aAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAElD,IAAM,cAAc,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAA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AC;QACpB,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACpB,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2DAA2D,EAAE;IAChE,IAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC7B,IAAM,KAAK,GAAG,4BAA4B,CAAC;QACzC,eAAe,EAAE,CAAC,CAAC,CAAC;QACpB,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/utils.test.d.ts b/lib/modules/edit-modes/test/lib/utils.test.d.ts new file mode 100644 index 000000000..c727c85cb --- /dev/null +++ b/lib/modules/edit-modes/test/lib/utils.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=utils.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/utils.test.d.ts.map b/lib/modules/edit-modes/test/lib/utils.test.d.ts.map new file mode 100644 index 000000000..042cd90c1 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/utils.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/utils.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/utils.test.js b/lib/modules/edit-modes/test/lib/utils.test.js new file mode 100644 index 000000000..95e6c0306 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/utils.test.js @@ -0,0 +1,191 @@ +import { __read } from "tslib"; +import { toDeckColor, recursivelyTraverseNestedArrays, generatePointsParallelToLinePoints, distance2d, mix, nearestPointOnProjectedLine, } from '../../src/utils'; +var Point = { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [102.0, 0.5], + }, +}; +var LineString = { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [ + [102.0, 0.0], + [103.0, 1.0], + [104.0, 0.0], + [105.0, 1.0], + ], + }, +}; +var Polygon = { + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [35, 10], + [45, 45], + [15, 40], + [10, 20], + [35, 10], + ], + [ + [20, 30], + [35, 35], + [30, 20], + [20, 30], + ], + ], + }, +}; +var MultiPolygon = { + type: 'Feature', + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [40, 40], + [20, 45], + [45, 30], + [40, 40], + ], + ], + [ + [ + [20, 35], + [10, 30], + [10, 10], + [30, 5], + [45, 20], + [20, 35], + ], + [ + [30, 20], + [20, 15], + [20, 25], + [30, 20], + ], + ], + ], + }, +}; +describe('toDeckColor()', function () { + it('toDeckColor() - positive case', function () { + var deckColor = toDeckColor([100, 90, 255, 1]); + var expectedResult = [25500, 22950, 65025, 255]; + expect(deckColor).toEqual(expectedResult); + }); + it('toDeckColor() - invalid color', function () { + var deckColor = toDeckColor(123123); + var expectedDefaultDeckColor = [255, 0, 0, 255]; + expect(deckColor).toEqual(expectedDefaultDeckColor); + }); +}); +describe('recursivelyTraverseNestedArrays()', function () { + it('should not call function for point', function () { + var callCount = 0; + var callback = function (array, prefix) { return callCount++; }; + recursivelyTraverseNestedArrays(Point.geometry.coordinates, [], callback); + expect(callCount).toBe(0); + }); + it('should work for LineString', function () { + var results = []; + recursivelyTraverseNestedArrays(LineString.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(1); + expect(JSON.stringify(results[0].array)).toBe('[[102,0],[103,1],[104,0],[105,1]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[]'); + }); + it('should work for Polygon', function () { + var results = []; + recursivelyTraverseNestedArrays(Polygon.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(2); + expect(JSON.stringify(results[0].array)).toBe('[[35,10],[45,45],[15,40],[10,20],[35,10]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[0]'); + expect(JSON.stringify(results[1].array)).toBe('[[20,30],[35,35],[30,20],[20,30]]'); + expect(JSON.stringify(results[1].prefix)).toBe('[1]'); + }); + it('should work for MultiPolygon', function () { + var results = []; + recursivelyTraverseNestedArrays(MultiPolygon.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(3); + expect(JSON.stringify(results[0].array)).toBe('[[40,40],[20,45],[45,30],[40,40]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[0,0]'); + expect(JSON.stringify(results[1].array)).toBe('[[20,35],[10,30],[10,10],[30,5],[45,20],[20,35]]'); + expect(JSON.stringify(results[1].prefix)).toBe('[1,0]'); + expect(JSON.stringify(results[2].array)).toBe('[[30,20],[20,15],[20,25],[30,20]]'); + expect(JSON.stringify(results[2].prefix)).toBe('[1,1]'); + }); +}); +describe('generatePointsParallelToLinePoints()', function () { + it('generate Points Parallel to Line Points -- empty points', function () { + var p1 = [0, 0]; + var p2 = [0, 0]; + // @ts-ignore + var _a = __read(generatePointsParallelToLinePoints(p1, p2, [0, 0]), 2), p3 = _a[0], p4 = _a[1]; + expect(p3).toEqual([0, 0]); + expect(p4).toEqual([0, 0]); + }); + it('generate Points Parallel to Line Points -- valid points', function () { + var p1 = [-122.32, 37.81800998554937]; + var p2 = [-122.37, 37.83386913944292]; + var _a = __read(generatePointsParallelToLinePoints(p1, p2, [-124.5, 37.9]), 2), p3 = _a[0], p4 = _a[1]; + expect(p3).toEqual([-123.14819346449626, 36.26988514860277]); + expect(p4).toEqual([-123.09803547871964, 36.254027457172775]); + }); +}); +describe('nearestPointOnProjectedLine() and related functions', function () { + it('distance2d()', function () { + expect(distance2d(0, 0, 0, 0)).toEqual(0); + expect(distance2d(0, 1, 0, 0)).toEqual(1); + }); + it('mix()', function () { + expect(mix(1, 2, 0)).toEqual(1); + expect(mix(1, 2, 1)).toEqual(2); + }); + it('nearestPointOnProjectedLine()', function () { + var line = { + geometry: { + coordinates: [ + [0, 0, 0], + [1, 1, 1], + ], + }, + }; + var inPoint = { + geometry: { + coordinates: [0.5, 0.5], + }, + }; + var viewport = { + project: function (x) { return x; }, + unproject: function (x) { return x; }, + }; + // @ts-ignore + var result = nearestPointOnProjectedLine(line, inPoint, viewport); + expect(result.geometry.type).toEqual('Point'); + expect(result.geometry.coordinates.length).toEqual(3); + expect(result.geometry.coordinates[0]).toBeCloseTo(0.5, 3); + expect(result.geometry.coordinates[1]).toBeCloseTo(0.5, 3); + expect(result.geometry.coordinates[2]).toBeCloseTo(0.5, 3); + expect(result.properties.index).toEqual(0); + }); +}); +//# sourceMappingURL=utils.test.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/lib/utils.test.js.map b/lib/modules/edit-modes/test/lib/utils.test.js.map new file mode 100644 index 000000000..3ad2e9068 --- /dev/null +++ b/lib/modules/edit-modes/test/lib/utils.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../modules/edit-modes/test/lib/utils.test.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,kCAAkC,EAClC,UAAU,EACV,GAAG,EACH,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,IAAM,KAAK,GAAG;IACZ,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC;KAC1B;CACF,CAAC;AAEF,IAAM,UAAU,GAAG;IACjB,IAAI,EAAE,SAAS;IACf,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AW,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/test-utils.d.ts b/lib/modules/edit-modes/test/test-utils.d.ts new file mode 100644 index 000000000..1f3dcdb9a --- /dev/null +++ b/lib/modules/edit-modes/test/test-utils.d.ts @@ -0,0 +1,61 @@ +import { Position, FeatureCollection } from '@nebula.gl/edit-modes'; +import { ModeProps, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, Pick } from '../src/types'; +export declare const FeatureType: { + POINT: string; + LINE_STRING: string; + POLYGON: string; + MULTI_POINT: string; + MULTI_LINE_STRING: string; + MULTI_POLYGON: string; +}; +export declare const featuresForSnappingTests: FeatureCollection; +export declare const mockPickedHandle: { + featureIndex: number; + position: number[]; + positionIndexes: number[]; + type: string; +}; +export declare const mockNonPickedHandle: { + featureIndex: number; + position: number[]; + positionIndexes: number[]; + type: string; +}; +export declare const mockedGeoJsonProperties: { + testString: string; + testNumber: number; +}; +export declare function createPointFeature(options?: { + [K: string]: any; +}): any; +export declare function createLineStringFeature(options?: { + [K: string]: any; +}): any; +export declare function createPolygonFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiPointFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiLineStringFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiPolygonFeature(options?: { + [K: string]: any; +}): any; +export declare function getFeatureCollectionFeatures(options?: { + [K: string]: any; +}): any[]; +export declare function createFeatureCollection(options?: { + [K: string]: any; +}): { + type: string; + features: any[]; +}; +export declare function getMockFeatureDetails(featureType: string): any; +export declare function createClickEvent(mapCoords: Position, picks?: Pick[]): ClickEvent; +export declare function createStartDraggingEvent(mapCoords: Position, pointerDownMapCoords: Position, picks?: Pick[]): StartDraggingEvent; +export declare function createStopDraggingEvent(mapCoords: Position, pointerDownMapCoords: Position, picks?: Pick[]): StopDraggingEvent; +export declare function createPointerMoveEvent(mapCoords?: Position, picks?: Pick[]): PointerMoveEvent; +export declare function createFeatureCollectionProps(overrides?: Partial>): ModeProps; +//# sourceMappingURL=test-utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/test-utils.d.ts.map b/lib/modules/edit-modes/test/test-utils.d.ts.map new file mode 100644 index 000000000..30bb84b98 --- /dev/null +++ b/lib/modules/edit-modes/test/test-utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/test/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,IAAI,EACL,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAoIF,eAAO,MAAM,wBAAwB,EAAE,iBA4EtC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;CAAuC,CAAC;AAW5E,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAA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,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAW7F;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,GAAE,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAM,GACpD,SAAS,CAAC,iBAAiB,CAAC,CAY9B"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/test-utils.js b/lib/modules/edit-modes/test/test-utils.js new file mode 100644 index 000000000..32c7b1f61 --- /dev/null +++ b/lib/modules/edit-modes/test/test-utils.js @@ -0,0 +1,332 @@ +/* eslint-env jest */ +import { __assign } from "tslib"; +export var FeatureType = { + POINT: 'Point', + LINE_STRING: 'LineString', + POLYGON: 'Polygon', + MULTI_POINT: 'MultiPoint', + MULTI_LINE_STRING: 'MultiLineString', + MULTI_POLYGON: 'MultiPolygon', +}; +var mockFeatures = { + Point: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { type: 'Point', coordinates: [1, 2] }, + }, + clickCoords: [1, 2], + }, + LineString: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2], + [2, 3], + [3, 4], + ], + }, + }, + clickCoords: [1, 2], + }, + Polygon: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + // exterior ring + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + }, + }, + clickCoords: [-0.5, -0.5], + }, + MultiPoint: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPoint', + coordinates: [ + [1, 2], + [3, 4], + ], + }, + }, + clickCoords: [3, 4], + }, + MultiLineString: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + [ + [5, 6], + [6, 7], + [7, 8], + ], + ], + }, + }, + clickCoords: [6, 7], + }, + MultiPolygon: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + // exterior ring polygon 1 + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole polygon 1 + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + [ + // exterior ring polygon 2 + [ + [2, -1], + [4, -1], + [4, 1], + [2, 1], + [2, -1], + ], + ], + ], + }, + }, + clickCoords: [1, 1], + }, +}; +export var featuresForSnappingTests = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.49485401280788, 37.987923255302974], + [-122.44252582524939, 37.987923255302974], + [-122.44252847887157, 37.93873205786406], + [-122.49485666643005, 37.93873205786406], + [-122.49485401280788, 37.987923255302974], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40814940182412, 37.97528325161274], + [-122.37737022011595, 37.97528325161274], + [-122.37737142575622, 37.952934704562644], + [-122.40815060746439, 37.952934704562644], + [-122.40814940182412, 37.97528325161274], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Point', + coordinates: [-122.28103267622373, 37.98843664327903], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40908525092362, 37.85902221692065], + [-122.34432261530361, 37.85902221692065], + [-122.3442469760231, 37.8157115979288], + [-122.40900961164311, 37.8157115979288], + [-122.40908525092362, 37.85902221692065], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40682264287454, 38.13330760982133], + [-122.34143228624993, 38.13330760982133], + [-122.34144710122638, 38.08906337516829], + [-122.40683745785105, 38.08906337516829], + [-122.40682264287454, 38.13330760982133], + ], + ], + }, + }, + ], +}; +export var mockPickedHandle = { + featureIndex: 0, + position: [-122.49485401280788, 37.987923255302974], + positionIndexes: [0, 0], + type: 'snap', +}; +export var mockNonPickedHandle = { + featureIndex: 1, + position: [-122.37737022011595, 37.97528325161274], + positionIndexes: [0, 1], + type: 'intermediate', +}; +export var mockedGeoJsonProperties = { testString: 'hi', testNumber: 10 }; +function createFeature(featureType, options) { + var feature = mockFeatures[featureType].geoJson; + var mockGeoJsonProperties = (options || {}).mockGeoJsonProperties; + if (mockGeoJsonProperties) { + feature.properties = mockedGeoJsonProperties; + } + return feature; +} +export function createPointFeature(options) { + return createFeature(FeatureType.POINT, options); +} +export function createLineStringFeature(options) { + return createFeature(FeatureType.LINE_STRING, options); +} +export function createPolygonFeature(options) { + return createFeature(FeatureType.POLYGON, options); +} +export function createMultiPointFeature(options) { + return createFeature(FeatureType.MULTI_POINT, options); +} +export function createMultiLineStringFeature(options) { + return createFeature(FeatureType.MULTI_LINE_STRING, options); +} +export function createMultiPolygonFeature(options) { + return createFeature(FeatureType.MULTI_POLYGON, options); +} +export function getFeatureCollectionFeatures(options) { + return [ + createPointFeature(options), + createLineStringFeature(options), + createPolygonFeature(options), + createMultiPointFeature(options), + createMultiLineStringFeature(options), + createMultiPolygonFeature(options), + ]; +} +export function createFeatureCollection(options) { + return { + type: 'FeatureCollection', + features: getFeatureCollectionFeatures(options), + }; +} +export function getMockFeatureDetails(featureType) { + var featureCollectionIndex = getFeatureCollectionFeatures().findIndex(function (feature) { return feature.geometry.type === featureType; }); + var featureDetails = mockFeatures[featureType]; + featureDetails.index = featureCollectionIndex; + return featureDetails; +} +export function createClickEvent(mapCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + mapCoords: mapCoords, + picks: picks, + sourceEvent: null, + }; +} +export function createStartDraggingEvent(mapCoords, pointerDownMapCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + mapCoords: mapCoords, + picks: picks, + pointerDownPicks: null, + pointerDownScreenCoords: [-1, -1], + pointerDownMapCoords: pointerDownMapCoords, + cancelPan: jest.fn(), + sourceEvent: null, + }; +} +export function createStopDraggingEvent(mapCoords, pointerDownMapCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + mapCoords: mapCoords, + picks: picks, + pointerDownPicks: null, + pointerDownScreenCoords: [-1, -1], + pointerDownMapCoords: pointerDownMapCoords, + sourceEvent: null, + }; +} +export function createPointerMoveEvent(mapCoords, picks) { + return { + screenCoords: [-1, -1], + mapCoords: mapCoords, + picks: picks || [], + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownMapCoords: null, + cancelPan: jest.fn(), + sourceEvent: null, + }; +} +export function createFeatureCollectionProps(overrides) { + if (overrides === void 0) { overrides = {}; } + return __assign({ + // @ts-ignore + data: createFeatureCollection(), selectedIndexes: [], + // @ts-ignore + lastPointerMoveEvent: createPointerMoveEvent(), modeConfig: null, onEdit: jest.fn(), onUpdateCursor: jest.fn() }, overrides); +} +//# sourceMappingURL=test-utils.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/test-utils.js.map b/lib/modules/edit-modes/test/test-utils.js.map new file mode 100644 index 000000000..0281fb394 --- /dev/null +++ b/lib/modules/edit-modes/test/test-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../../modules/edit-modes/test/test-utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;;AAYrB,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,YAAY;IACzB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,YAAY;IACzB,iBAAiB,EAAE,iBAAiB;IACpC,aAAa,EAAE,cAAc;CAC9B,CAAC;AAEF,IAAM,YAAY,GAAG;IACnB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAA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AAE,EAAE;QACpB,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,SAAmB,EACnB,oBAA8B,EAC9B,KAAkB;IAAlB,sBAAA,EAAA,UAAkB;IAElB,OAAO;QACL,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACtB,SAAS,WAAA;QACT,KAAK,OAAA;QACL,gBAAgB,EAAE,IAAI;QACtB,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,oBAAoB,sBAAA;QACpB,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,SAAoB,EAAE,KAAc;IACzE,OAAO;QACL,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACtB,SAAS,WAAA;QACT,KAAK,EAAE,KAAK,IAAI,EAAE;QAClB,gBAAgB,EAAE,IAAI;QACtB,uBAAuB,EAAE,IAAI;QAC7B,oBAAoB,EAAE,IAAI;QAC1B,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;QACpB,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,SAAqD;IAArD,0BAAA,EAAA,cAAqD;IAErD;QACE,aAAa;QACb,IAAI,EAAE,uBAAuB,EAAE,EAC/B,eAAe,EAAE,EAAE;QACnB,aAAa;QACb,oBAAoB,EAAE,sBAAsB,EAAE,EAC9C,UAAU,EAAE,IAAI,EAChB,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,EACjB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE,IACtB,SAAS,EACZ;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/types.d.ts b/lib/modules/edit-modes/test/types.d.ts new file mode 100644 index 000000000..78236ddc0 --- /dev/null +++ b/lib/modules/edit-modes/test/types.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/types.d.ts.map b/lib/modules/edit-modes/test/types.d.ts.map new file mode 100644 index 000000000..3d7686bb6 --- /dev/null +++ b/lib/modules/edit-modes/test/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../modules/edit-modes/test/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/edit-modes/test/types.js b/lib/modules/edit-modes/test/types.js new file mode 100644 index 000000000..833acd17a --- /dev/null +++ b/lib/modules/edit-modes/test/types.js @@ -0,0 +1,51 @@ +/* eslint-disable no-unused-vars, prefer-const */ +var point = { + type: 'Point', + coordinates: [1, 2], +}; +var lineString = { + type: 'LineString', + coordinates: [ + [1, 2], + [3, 4], + ], +}; +var polygonSolid = { + type: 'Polygon', + coordinates: [lineString.coordinates], +}; +var polygonWithHole = { + type: 'Polygon', + coordinates: [lineString.coordinates, lineString.coordinates], +}; +var multiPolygon = { + type: 'MultiPolygon', + coordinates: [polygonSolid.coordinates, polygonWithHole.coordinates], +}; +var pointFeature = { + type: 'Feature', + geometry: point, +}; +var lineStringFeature = { + type: 'Feature', + geometry: lineString, +}; +var anyFeature = { + type: 'Feature', + geometry: multiPolygon, +}; +if (Math.random() > 0.5) { + anyFeature = pointFeature; +} +else { + anyFeature = lineStringFeature; +} +var anyGeometry = anyFeature.geometry; +if (anyGeometry.type === 'LineString') { + lineStringFeature.geometry = anyGeometry; +} +if (anyGeometry.type === 'Point') { + // @ts-ignore + lineStringFeature.geometry = anyGeometry; +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/modules/edit-modes/test/types.js.map b/lib/modules/edit-modes/test/types.js.map new file mode 100644 index 000000000..1fd09d979 --- /dev/null +++ b/lib/modules/edit-modes/test/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../modules/edit-modes/test/types.ts"],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AAI,KAAK,OAAO,EAAE;IAChC,aAAa;IACb,iBAAiB,CAAC,QAAQ,GAAG,WAAW,CAAC;CAC1C"} \ No newline at end of file diff --git a/lib/modules/editor/src/editor-modal.d.ts b/lib/modules/editor/src/editor-modal.d.ts new file mode 100644 index 000000000..412736b8e --- /dev/null +++ b/lib/modules/editor/src/editor-modal.d.ts @@ -0,0 +1,8 @@ +export declare const Button: import("styled-components").StyledComponent<"button", any, {}, never>; +export declare type ModalProps = { + title: any; + content: any; + onClose: () => unknown; +}; +export declare function EditorModal(props: ModalProps): JSX.Element; +//# sourceMappingURL=editor-modal.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/editor-modal.d.ts.map b/lib/modules/editor/src/editor-modal.d.ts.map new file mode 100644 index 000000000..672e0b855 --- /dev/null +++ b/lib/modules/editor/src/editor-modal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"editor-modal.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/editor-modal.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,MAAM,uEAUlB,CAAC;AA6CF,oBAAY,UAAU,GAAG;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,eAwB5C"} \ No newline at end of file diff --git a/lib/modules/editor/src/editor-modal.js b/lib/modules/editor/src/editor-modal.js new file mode 100644 index 000000000..da760f59e --- /dev/null +++ b/lib/modules/editor/src/editor-modal.js @@ -0,0 +1,28 @@ +/* eslint-env browser */ +import { __makeTemplateObject, __read } from "tslib"; +import * as React from 'react'; +import Modal, { ModalProvider } from 'styled-react-modal'; +import styled from 'styled-components'; +export var Button = styled.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: inline-block;\n color: #fff;\n background-color: rgb(90, 98, 94);\n font-size: 1em;\n margin: 0.25em;\n padding: 0.375em 0.75em;\n border: 1px solid transparent;\n border-radius: 0.25em;\n display: block;\n"], ["\n display: inline-block;\n color: #fff;\n background-color: rgb(90, 98, 94);\n font-size: 1em;\n margin: 0.25em;\n padding: 0.375em 0.75em;\n border: 1px solid transparent;\n border-radius: 0.25em;\n display: block;\n"]))); +var StyledModal = Modal.styled(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n display: block;\n width: 50rem;\n height: auto;\n max-width: 500px;\n margin: 1.75rem auto;\n box-sizing: border-box;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n font-size: 1rem;\n font-weight: 400;\n color: rgb(21, 25, 29);\n line-height: 1.5;\n text-align: left;\n"], ["\n position: relative;\n display: block;\n width: 50rem;\n height: auto;\n max-width: 500px;\n margin: 1.75rem auto;\n box-sizing: border-box;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n font-size: 1rem;\n font-weight: 400;\n color: rgb(21, 25, 29);\n line-height: 1.5;\n text-align: left;\n"]))); +var Content = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n pointer-events: auto;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 0.3rem;\n outline: 0;\n"], ["\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n pointer-events: auto;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 0.3rem;\n outline: 0;\n"]))); +var HeaderRow = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 0.75rem 0.75rem;\n border-bottom: 1px solid rgb(222, 226, 230);\n"], ["\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 0.75rem 0.75rem;\n border-bottom: 1px solid rgb(222, 226, 230);\n"]))); +var Header = styled.h5(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-size: 1.25rem;\n font-weight: 500;\n margin: 0;\n"], ["\n font-size: 1.25rem;\n font-weight: 500;\n margin: 0;\n"]))); +export function EditorModal(props) { + var _a = __read(React.useState(true), 2), isOpen = _a[0], setIsOpen = _a[1]; + function toggleModal() { + if (isOpen) { + props.onClose(); + } + setIsOpen(!isOpen); + } + return (React.createElement(React.Fragment, null, + React.createElement(ModalProvider, null, + React.createElement(StyledModal, { isOpen: isOpen, onBackgroundClick: toggleModal, onEscapeKeydown: toggleModal }, + React.createElement(Content, null, + React.createElement(HeaderRow, null, + React.createElement(Header, null, props.title)), + props.content))))); +} +var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5; +//# sourceMappingURL=editor-modal.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/editor-modal.js.map b/lib/modules/editor/src/editor-modal.js.map new file mode 100644 index 000000000..d40b84d5e --- /dev/null +++ b/lib/modules/editor/src/editor-modal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editor-modal.js","sourceRoot":"","sources":["../../../../modules/editor/src/editor-modal.tsx"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,IAAM,MAAM,GAAG,MAAM,CAAC,MAAM,wSAAA,qOAUlC,IAAA,CAAC;AAEF,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,+hBAAA,4dAc/B,IAAA,CAAC;AAEF,IAAM,OAAO,GAAG,MAAM,CAAC,GAAG,kUAAA,+PAWzB,IAAA,CAAC;AAEF,IAAM,SAAS,GAAG,MAAM,CAAC,GAAG,qOAAA,kKAM3B,IAAA,CAAC;AAEF,IAAM,MAAM,GAAG,MAAM,CAAC,EAAE,iIAAA,8DAIvB,IAAA,CAAC;AAQF,MAAM,UAAU,WAAW,CAAC,KAAiB;IACrC,IAAA,oCAA0C,EAAzC,cAAM,EAAE,iBAAiC,CAAC;IAEjD,SAAS,WAAW;QAClB,IAAI,MAAM,EAAE;YACV,KAAK,CAAC,OAAO,EAAE,CAAC;SACjB;QACD,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,CACL;QACE,oBAAC,aAAa;YACZ,oBAAC,WAAW,IAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW;gBACvF,oBAAC,OAAO;oBACN,oBAAC,SAAS;wBACR,oBAAC,MAAM,QAAE,KAAK,CAAC,KAAK,CAAU,CACpB;oBACX,KAAK,CAAC,OAAO,CACN,CACE,CACA,CACf,CACJ,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/export-component.d.ts b/lib/modules/editor/src/export-component.d.ts new file mode 100644 index 000000000..4b13c2aad --- /dev/null +++ b/lib/modules/editor/src/export-component.d.ts @@ -0,0 +1,6 @@ +export declare type ExportComponentProps = { + features: any; + onClose: () => unknown; +}; +export declare function ExportComponent(props: ExportComponentProps): JSX.Element; +//# sourceMappingURL=export-component.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/export-component.d.ts.map b/lib/modules/editor/src/export-component.d.ts.map new file mode 100644 index 000000000..4a8da4bd7 --- /dev/null +++ b/lib/modules/editor/src/export-component.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"export-component.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/export-component.tsx"],"names":[],"mappings":"AA2CA,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA8E1D"} \ No newline at end of file diff --git a/lib/modules/editor/src/export-component.js b/lib/modules/editor/src/export-component.js new file mode 100644 index 000000000..1c01918a9 --- /dev/null +++ b/lib/modules/editor/src/export-component.js @@ -0,0 +1,58 @@ +/* eslint-env browser */ +import { __makeTemplateObject, __read } from "tslib"; +import * as React from 'react'; +import copy from 'clipboard-copy'; +import downloadjs from 'downloadjs'; +import styled from 'styled-components'; +import { toGeoJson, toKml, toWkt } from './lib/exporter'; +import { Button } from './editor-modal'; +var FormatSelect = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n padding: 0.75rem 0.75rem 0rem 0.75rem;\n"], ["\n display: flex;\n padding: 0.75rem 0.75rem 0rem 0.75rem;\n"]))); +var ExportArea = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n width: auto;\n height: auto;\n min-height: 300px;\n padding: 0rem 1rem;\n"], ["\n box-sizing: border-box;\n display: block;\n width: auto;\n height: auto;\n min-height: 300px;\n padding: 0rem 1rem;\n"]))); +var ExportData = styled.textarea(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0px;\n width: 100%;\n resize: vertical;\n min-height: 300px;\n max-height: 500px;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n font-family: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"], ["\n padding: 0px;\n width: 100%;\n resize: vertical;\n min-height: 300px;\n max-height: 500px;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n font-family: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"]))); +var FooterRow = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n padding: 0.75rem 0.75rem;\n"], ["\n display: flex;\n justify-content: flex-end;\n padding: 0.75rem 0.75rem;\n"]))); +export function ExportComponent(props) { + var geojson = props.features; + var _a = __read(React.useState(toGeoJson(geojson)), 2), exportParams = _a[0], setExportParams = _a[1]; + var _b = __read(React.useState('geoJson'), 2), format = _b[0], setFormat = _b[1]; + var tooMuch = exportParams.data.length > 500000; + function copyData() { + copy(exportParams.data).then(function () { return props.onClose(); }); + // TODO Design and add in a notifications banner for errors in the modal. + // .catch(err => {alert(`Error copying to clipboard: `, err)}) + } + function downloadData() { + downloadjs(new Blob([exportParams.data]), exportParams.filename, exportParams.mimetype); + props.onClose(); + } + return (React.createElement(React.Fragment, null, + React.createElement(FormatSelect, null, + React.createElement("strong", { style: { padding: '0.5rem 0.25rem' } }, "Format:"), + React.createElement(Button, { style: { + backgroundColor: format === 'geoJson' ? 'rgb(0, 105, 217)' : 'rgb(90, 98, 94)', + }, onClick: function () { + setExportParams(toGeoJson(geojson)); + setFormat('geoJson'); + } }, "GeoJson"), + React.createElement(Button, { style: { + backgroundColor: format === 'kml' ? 'rgb(0, 105, 217)' : 'rgb(90, 98, 94)', + }, onClick: function () { + setExportParams(toKml(geojson)); + setFormat('kml'); + } }, "KML"), + React.createElement(Button, { style: { + backgroundColor: format === 'wkt' ? 'rgb(0, 105, 217)' : 'rgb(90, 98, 94)', + }, onClick: function () { + setExportParams(toWkt(geojson)); + setFormat('wkt'); + } }, "WKT")), + React.createElement(ExportArea, null, + React.createElement(ExportData, { readOnly: true, style: tooMuch ? { fontStyle: 'italic', padding: '0.75rem 0rem' } : {}, value: tooMuch + ? 'Too much data to display. Download or Copy to clipboard instead.' + : exportParams.data })), + React.createElement(FooterRow, null, + React.createElement(Button, { style: { backgroundColor: 'rgb(0, 105, 217)' }, onClick: downloadData }, "Download"), + React.createElement(Button, { style: { backgroundColor: 'rgb(0, 105, 217)' }, onClick: copyData }, "Copy"), + React.createElement(Button, { onClick: props.onClose }, "Cancel")))); +} +var templateObject_1, templateObject_2, templateObject_3, templateObject_4; +//# sourceMappingURL=export-component.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/export-component.js.map b/lib/modules/editor/src/export-component.js.map new file mode 100644 index 000000000..a0ca15cb5 --- /dev/null +++ b/lib/modules/editor/src/export-component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"export-component.js","sourceRoot":"","sources":["../../../../modules/editor/src/export-component.tsx"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,IAAM,YAAY,GAAG,MAAM,CAAC,GAAG,mIAAA,gEAG9B,IAAA,CAAC;AAEF,IAAM,UAAU,GAAG,MAAM,CAAC,GAAG,mMAAA,gIAO5B,IAAA,CAAC;AAEF,IAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,wdAAA,qZAYjC,IAAA,CAAC;AAEF,IAAM,SAAS,GAAG,MAAM,CAAC,GAAG,oJAAA,iFAI3B,IAAA,CAAC;AAOF,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,IAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;IACzB,IAAA,kDAAoE,EAAnE,oBAAY,EAAE,uBAAqD,CAAC;IACrE,IAAA,yCAA+C,EAA9C,cAAM,EAAE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EAAE;oBACP,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;oBAChC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC,UAGM,CACI;QACf,oBAAC,UAAU;YACT,oBAAC,UAAU,IACT,QAAQ,EAAE,IAAI,EACd,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EACtE,KAAK,EACH,OAAO;oBACL,CAAC,CAAC,kEAAkE;oBACpE,CAAC,CAAC,YAAY,CAAC,IAAI,GAEvB,CACS;QACb,oBAAC,SAAS;YACR,oBAAC,MAAM,IAAC,KAAK,EAAE,EAAE,eAAe,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,YAAY,eAEpE;YACT,oBAAC,MAAM,IAAC,KAAK,EAAE,EAAE,eAAe,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,QAAQ,WAEhE;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,KAAK,CAAC,OAAO,aAAiB,CACrC,CACX,CACJ,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/export-modal.d.ts b/lib/modules/editor/src/export-modal.d.ts new file mode 100644 index 000000000..39b244e09 --- /dev/null +++ b/lib/modules/editor/src/export-modal.d.ts @@ -0,0 +1,7 @@ +import { AnyGeoJson } from '@nebula.gl/edit-modes'; +export declare type ExportModalProps = { + features: AnyGeoJson; + onClose: () => unknown; +}; +export declare function ExportModal(props: ExportModalProps): JSX.Element; +//# sourceMappingURL=export-modal.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/export-modal.d.ts.map b/lib/modules/editor/src/export-modal.d.ts.map new file mode 100644 index 000000000..4fbcb33d3 --- /dev/null +++ b/lib/modules/editor/src/export-modal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"export-modal.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/export-modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,EAAE,MAAM,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAQlD"} \ No newline at end of file diff --git a/lib/modules/editor/src/export-modal.js b/lib/modules/editor/src/export-modal.js new file mode 100644 index 000000000..fccc0f1ec --- /dev/null +++ b/lib/modules/editor/src/export-modal.js @@ -0,0 +1,8 @@ +/* eslint-env browser */ +import * as React from 'react'; +import { EditorModal } from './editor-modal'; +import { ExportComponent } from './export-component'; +export function ExportModal(props) { + return (React.createElement(EditorModal, { onClose: props.onClose, title: 'Export', content: React.createElement(ExportComponent, { features: props.features, onClose: props.onClose }) })); +} +//# sourceMappingURL=export-modal.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/export-modal.js.map b/lib/modules/editor/src/export-modal.js.map new file mode 100644 index 000000000..a74ded8ed --- /dev/null +++ b/lib/modules/editor/src/export-modal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"export-modal.js","sourceRoot":"","sources":["../../../../modules/editor/src/export-modal.tsx"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAOrD,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,CACL,oBAAC,WAAW,IACV,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,oBAAC,eAAe,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,GAAI,GAC9E,CACH,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/import-component.d.ts b/lib/modules/editor/src/import-component.d.ts new file mode 100644 index 000000000..83dbef736 --- /dev/null +++ b/lib/modules/editor/src/import-component.d.ts @@ -0,0 +1,9 @@ +import * as React from 'react'; +export declare type ImportComponentProps = { + onImport: (arg0: any) => unknown; + onValidate?: (arg0: any) => unknown; + onCancel: () => unknown; + additionalInputs?: React.ReactNode; +}; +export declare function ImportComponent(props: ImportComponentProps): JSX.Element; +//# sourceMappingURL=import-component.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/import-component.d.ts.map b/lib/modules/editor/src/import-component.d.ts.map new file mode 100644 index 000000000..007b73a14 --- /dev/null +++ b/lib/modules/editor/src/import-component.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"import-component.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/import-component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA6E/B,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACpC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAiK1D"} \ No newline at end of file diff --git a/lib/modules/editor/src/import-component.js b/lib/modules/editor/src/import-component.js new file mode 100644 index 000000000..50ec715b7 --- /dev/null +++ b/lib/modules/editor/src/import-component.js @@ -0,0 +1,120 @@ +/* eslint-env browser */ +import { __assign, __awaiter, __generator, __makeTemplateObject, __read } from "tslib"; +import * as React from 'react'; +import Dropzone from 'react-dropzone'; +import styled from 'styled-components'; +import { Button } from './editor-modal'; +import { parseImport } from './lib/importer'; +var ImportComponentContent = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n pointer-events: auto;\n background-color: #fff;\n background-clip: padding-box;\n border-radius: 0.3rem;\n outline: 0;\n"], ["\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n pointer-events: auto;\n background-color: #fff;\n background-clip: padding-box;\n border-radius: 0.3rem;\n outline: 0;\n"]))); +var ImportContent = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: auto;\n height: auto;\n"], ["\n width: auto;\n height: auto;\n"]))); +var ImportSelect = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n padding: 0.75rem 0.75rem 0rem 0.75rem;\n"], ["\n display: flex;\n padding: 0.75rem 0.75rem 0rem 0.75rem;\n"]))); +var ImportArea = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n box-sizing: border-box;\n display: block;\n width: auto;\n height: auto;\n min-height: 300px;\n padding: 0rem 1rem;\n"], ["\n box-sizing: border-box;\n display: block;\n width: auto;\n height: auto;\n min-height: 300px;\n padding: 0rem 1rem;\n"]))); +var ImportTextArea = styled.textarea(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: 0px;\n width: 100%;\n resize: vertical;\n min-height: 250px;\n max-height: 450px;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n font-family: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"], ["\n padding: 0px;\n width: 100%;\n resize: vertical;\n min-height: 250px;\n max-height: 450px;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n font-family: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"]))); +var ImportDropArea = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0px;\n width: 100%;\n min-height: 250px;\n height: 100%;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n fontfamily: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,\n 'Noto Sans' sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',\n 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"], ["\n padding: 0px;\n width: 100%;\n min-height: 250px;\n height: 100%;\n border: 1px solid rgb(206, 212, 218);\n border-radius: 0.3rem;\n fontfamily: -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,\n 'Noto Sans' sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',\n 'Noto Color Emoji';\n font-size: 1rem;\n font-weight: 400;\n"]))); +var ImportInfo = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: block;\n padding: 0rem 1rem;\n"], ["\n display: block;\n padding: 0rem 1rem;\n"]))); +var FooterRow = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-end;\n padding: 0.75rem 0.75rem;\n border-top: 1px solid rgb(222, 226, 230);\n"], ["\n display: flex;\n justify-content: flex-end;\n padding: 0.75rem 0.75rem;\n border-top: 1px solid rgb(222, 226, 230);\n"]))); +export function ImportComponent(props) { + var _a = __read(React.useState(true), 2), isImportText = _a[0], setIsImportText = _a[1]; + var _b = __read(React.useState(''), 2), text = _b[0], setText = _b[1]; + var _c = __read(React.useState(null), 2), importFile = _c[0], setImportFile = _c[1]; + var _d = __read(React.useState({ + valid: false, + validationErrors: [], + }), 2), parseResult = _d[0], setParseResult = _d[1]; + React.useEffect(function () { + function parseData() { + return __awaiter(this, void 0, void 0, function () { + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!isImportText) return [3 /*break*/, 2]; + _a = setParseResult; + return [4 /*yield*/, parseImport(text)]; + case 1: + _a.apply(void 0, [_c.sent()]); + return [3 /*break*/, 4]; + case 2: + if (!(importFile !== null)) return [3 /*break*/, 4]; + _b = setParseResult; + return [4 /*yield*/, parseImport(importFile)]; + case 3: + _b.apply(void 0, [_c.sent()]); + _c.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); + } + parseData(); + }, [isImportText, text, importFile]); + function flush() { + setImportFile(null); + setText(''); + props.onCancel(); + } + function isDataSet() { + return (isImportText && text) || (!isImportText && importFile); + } + // Check validity (and call custom validation callback if present) + var valid = isDataSet() && + parseResult.valid && + (!props.onValidate || props.onValidate(parseResult.features)); + return (React.createElement(ImportComponentContent, null, + React.createElement(ImportContent, null, + React.createElement(ImportSelect, null, + React.createElement(Button, { style: { + backgroundColor: isImportText ? 'rgb(0, 105, 217)' : 'rgb(90, 98, 94)', + }, onClick: function () { + setIsImportText(true); + } }, "Import From Text"), + React.createElement(Button, { style: { + backgroundColor: isImportText ? 'rgb(90, 98, 94)' : 'rgb(0, 105, 217)', + }, onClick: function () { + setIsImportText(false); + } }, "Import From File")), + React.createElement(ImportArea, null, + isImportText && (React.createElement(ImportTextArea, { style: isDataSet() && !parseResult.valid ? { borderColor: 'rgb(220, 53, 69)' } : {}, onChange: function (event) { return setText(event.target.value); }, value: text })), + !isImportText && (React.createElement(Dropzone, { onDrop: function (importFiles) { return setImportFile(importFiles[0]); } }, function (_a) { + var getRootProps = _a.getRootProps, getInputProps = _a.getInputProps; + return (React.createElement(ImportDropArea, __assign({ style: isDataSet() && !parseResult.valid ? { borderColor: 'rgb(220, 53, 69)' } : {} }, getRootProps()), + React.createElement("input", __assign({}, getInputProps())), + importFile ? (React.createElement("p", null, + !parseResult.valid ? 'Invalid' : '', + " Selected File: ", + importFile.name, + ".", + React.createElement("br", null), + "Drag 'n' drop or click again to change the file.")) : (React.createElement("p", null, "Drag 'n' drop your file here, or click to select a file.")))); + })), + React.createElement(ImportInfo, { style: { color: 'rgb(133, 100, 4)', backgroundColor: 'rgb(255, 243, 205)' } }, isDataSet() && + !parseResult.valid && + // @ts-ignore + parseResult.validationErrors.map(function (err, i) { return React.createElement("div", { key: i }, err); }))), + React.createElement(ImportInfo, null, + "Supported formats:", + React.createElement("ul", { style: { marginTop: '0' } }, + React.createElement("li", { key: "geojson" }, + React.createElement("a", { href: "https://tools.ietf.org/html/rfc7946", target: "_blank", rel: "noopener noreferrer", title: "GeoJSON Specification" }, "GeoJSON")), + React.createElement("li", { key: "kml" }, + React.createElement("a", { href: "https://developers.google.com/kml/", target: "_blank", rel: "noopener noreferrer", title: "KML Specification" }, "KML")), + React.createElement("li", { key: "wkt" }, + React.createElement("a", { href: "https://en.wikipedia.org/wiki/Well-known_text", target: "_blank", rel: "noopener noreferrer", title: "WKT" }, "WKT"))))), + props.additionalInputs || null, + React.createElement(FooterRow, null, + React.createElement(Button, { style: isDataSet() + ? { backgroundColor: valid ? 'rgb(0, 105, 217)' : 'rgb(220, 53, 69)' } + : { backgroundColor: 'rgb(206, 212, 218)' }, disabled: !valid, onClick: function () { + props.onImport({ + type: 'FeatureCollection', + properties: {}, + // $FlowFixMe - can't be clicked if it is invalid, so features will be there + //@ts-ignore + features: parseResult.features, + }); + flush(); + } }, "Import Geometry"), + React.createElement(Button, { onClick: flush }, "Cancel")))); +} +var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8; +//# sourceMappingURL=import-component.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/import-component.js.map b/lib/modules/editor/src/import-component.js.map new file mode 100644 index 000000000..f7ef7f6f2 --- /dev/null +++ b/lib/modules/editor/src/import-component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"import-component.js","sourceRoot":"","sources":["../../../../modules/editor/src/import-component.tsx"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,QA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AE,GAAG,EAAE;oBAC3B,4BAAI,GAAG,EAAC,SAAS;wBACf,2BACE,IAAI,EAAC,qCAAqC,EAC1C,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,KAAK,EAAC,uBAAuB,cAG3B,CACD;oBACL,4BAAI,GAAG,EAAC,KAAK;wBACX,2BACE,IAAI,EAAC,oCAAoC,EACzC,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,KAAK,EAAC,mBAAmB,UAGvB,CACD;oBACL,4BAAI,GAAG,EAAC,KAAK;wBACX,2BACE,IAAI,EAAC,+CAA+C,EACpD,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,KAAK,EAAC,KAAK,UAGT,CACD,CACF,CACM,CACC;QACf,KAAK,CAAC,gBAAgB,IAAI,IAAI;QAC/B,oBAAC,SAAS;YACR,oBAAC,MAAM,IACL,KAAK,EACH,SAAS,EAAE;oBACT,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EAAE;oBACtE,CAAC,CAAC,EAAE,eAAe,EAAE,oBAAoB,EAAE,EAE/C,QAAQ,EAAE,CAAC,KAAK,EAChB,OAAO,EAAE;oBACP,KAAK,CAAC,QAAQ,CAAC;wBACb,IAAI,EAAE,mBAAmB;wBACzB,UAAU,EAAE,EAAE;wBACd,4EAA4E;wBAC5E,YAAY;wBACZ,QAAQ,EAAE,WAAW,CAAC,QAAQ;qBAC/B,CAAC,CAAC;oBACH,KAAK,EAAE,CAAC;gBACV,CAAC,sBAGM;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,KAAK,aAAiB,CAC7B,CACW,CAC1B,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/import-modal.d.ts b/lib/modules/editor/src/import-modal.d.ts new file mode 100644 index 000000000..4b478e7a6 --- /dev/null +++ b/lib/modules/editor/src/import-modal.d.ts @@ -0,0 +1,8 @@ +import * as React from 'react'; +export declare type ImportModalProps = { + onImport: (arg0: any) => unknown; + onClose: () => unknown; + additionalInputs?: React.ReactNode; +}; +export declare function ImportModal(props: ImportModalProps): JSX.Element; +//# sourceMappingURL=import-modal.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/import-modal.d.ts.map b/lib/modules/editor/src/import-modal.d.ts.map new file mode 100644 index 000000000..98e224402 --- /dev/null +++ b/lib/modules/editor/src/import-modal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"import-modal.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/import-modal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IACjC,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAclD"} \ No newline at end of file diff --git a/lib/modules/editor/src/import-modal.js b/lib/modules/editor/src/import-modal.js new file mode 100644 index 000000000..4bfb390f1 --- /dev/null +++ b/lib/modules/editor/src/import-modal.js @@ -0,0 +1,8 @@ +/* eslint-env browser */ +import * as React from 'react'; +import { ImportComponent } from './import-component'; +import { EditorModal } from './editor-modal'; +export function ImportModal(props) { + return (React.createElement(EditorModal, { onClose: props.onClose, title: 'Import', content: React.createElement(ImportComponent, { onImport: props.onImport, onCancel: props.onClose, additionalInputs: props.additionalInputs }) })); +} +//# sourceMappingURL=import-modal.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/import-modal.js.map b/lib/modules/editor/src/import-modal.js.map new file mode 100644 index 000000000..f0c7184d0 --- /dev/null +++ b/lib/modules/editor/src/import-modal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"import-modal.js","sourceRoot":"","sources":["../../../../modules/editor/src/import-modal.tsx"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,CACL,oBAAC,WAAW,IACV,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,QAAQ,EACf,OAAO,EACL,oBAAC,eAAe,IACd,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,KAAK,CAAC,OAAO,EACvB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GACxC,GAEJ,CACH,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/index.d.ts b/lib/modules/editor/src/index.d.ts new file mode 100644 index 000000000..a045da593 --- /dev/null +++ b/lib/modules/editor/src/index.d.ts @@ -0,0 +1,5 @@ +export { Toolbox } from './toolbox'; +export { ExportModal } from './export-modal'; +export { ImportModal } from './import-modal'; +export { ImportComponent } from './import-component'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/index.d.ts.map b/lib/modules/editor/src/index.d.ts.map new file mode 100644 index 000000000..bdfeb587f --- /dev/null +++ b/lib/modules/editor/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/index.js b/lib/modules/editor/src/index.js new file mode 100644 index 000000000..66c1045f6 --- /dev/null +++ b/lib/modules/editor/src/index.js @@ -0,0 +1,5 @@ +export { Toolbox } from './toolbox'; +export { ExportModal } from './export-modal'; +export { ImportModal } from './import-modal'; +export { ImportComponent } from './import-component'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/index.js.map b/lib/modules/editor/src/index.js.map new file mode 100644 index 000000000..2c190d246 --- /dev/null +++ b/lib/modules/editor/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/editor/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/lib/exporter.d.ts b/lib/modules/editor/src/lib/exporter.d.ts new file mode 100644 index 000000000..3e20c7edb --- /dev/null +++ b/lib/modules/editor/src/lib/exporter.d.ts @@ -0,0 +1,12 @@ +import { AnyGeoJson } from '@nebula.gl/edit-modes'; +export declare const UNNAMED = "__unnamed_feature__"; +export declare type ExportParameters = { + data: string; + filename: string; + mimetype: string; +}; +export declare function toGeoJson(geojson: AnyGeoJson): ExportParameters; +export declare function toKml(geojson: AnyGeoJson): ExportParameters; +export declare function toWkt(geojson: AnyGeoJson): ExportParameters; +export declare function toStats(geojson: AnyGeoJson): ExportParameters; +//# sourceMappingURL=exporter.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/lib/exporter.d.ts.map b/lib/modules/editor/src/lib/exporter.d.ts.map new file mode 100644 index 000000000..427df2deb --- /dev/null +++ b/lib/modules/editor/src/lib/exporter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../../../../modules/editor/src/lib/exporter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,UAAU,EAA+B,MAAM,uBAAuB,CAAC;AAEzF,eAAO,MAAM,OAAO,wBAAwB,CAAC;AAE7C,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAS/D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAqB3D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAyB3D;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAiC7D"} \ No newline at end of file diff --git a/lib/modules/editor/src/lib/exporter.js b/lib/modules/editor/src/lib/exporter.js new file mode 100644 index 000000000..d4dba6cb1 --- /dev/null +++ b/lib/modules/editor/src/lib/exporter.js @@ -0,0 +1,182 @@ +/* eslint-env browser */ +import { __assign, __values } from "tslib"; +import tokml from '@maphubs/tokml'; +import { stringify as stringifyWkt } from 'wellknown'; +export var UNNAMED = '__unnamed_feature__'; +export function toGeoJson(geojson) { + var filename = getFilename(geojson) + ".geojson"; + var prepped = prepareGeoJsonForExport(geojson); + return { + data: JSON.stringify(prepped, null, 2), + filename: filename, + mimetype: 'application/json', + }; +} +export function toKml(geojson) { + var filename = getFilename(geojson) + ".kml"; + var prepped = prepareGeoJsonForExport(geojson); + // For some reason, google maps doesn't surface id unless it is in the properties + // So, put it also in properties + if (prepped.type === 'FeatureCollection') { + prepped.features.forEach(function (f) { + f.properties = f.properties || {}; + }); + } + var kmlString = tokml(prepped); + // kmlString = addIdToKml(prepped, kmlString); + return { + data: kmlString, + filename: filename, + mimetype: 'application/xml', + }; +} +export function toWkt(geojson) { + var e_1, _a; + var filename = getFilename(geojson) + ".wkt"; + var prepped = prepareGeoJsonForExport(geojson); + var wkt = ''; + if (prepped.type === 'Feature') { + // @ts-ignore + wkt = stringifyWkt(prepped); + } + else { + // feature collection + wkt = ''; + try { + for (var _b = __values(prepped.features), _c = _b.next(); !_c.done; _c = _b.next()) { + var feature = _c.value; + // @ts-ignore + wkt += stringifyWkt(feature) + "\n"; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + if (wkt.length > 0) { + wkt = wkt.substring(0, wkt.length - 1); + } + } + return { + data: wkt, + filename: filename, + mimetype: 'text/plain', + }; +} +export function toStats(geojson) { + var e_2, _a; + var filename = getFilename(geojson) + ".txt"; + var prepped = prepareGeoJsonForExport(geojson); + var pointCount = 0; + var ringCount = 0; + var polygonCount = 0; + var featureCount = 0; + if (prepped.type === 'Feature') { + var polygonStats = getPolygonalStats(prepped.geometry); + (pointCount = polygonStats.pointCount, ringCount = polygonStats.ringCount, polygonCount = polygonStats.polygonCount); + featureCount = 1; + } + else { + try { + for (var _b = __values(prepped.features), _c = _b.next(); !_c.done; _c = _b.next()) { + var feature = _c.value; + var polygonStats = getPolygonalStats(feature.geometry); + pointCount += polygonStats.pointCount; + ringCount += polygonStats.ringCount; + polygonCount += polygonStats.polygonCount; + featureCount++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + } + var stats = "Features: " + featureCount + "\nPolygons: " + polygonCount + "\nRings: " + ringCount + "\nPoints: " + pointCount; + return { + data: stats, + filename: filename, + mimetype: 'text/plain', + }; +} +function getPolygonalStats(geometry) { + var e_3, _a, e_4, _b; + if (geometry.type !== 'Polygon' && geometry.type !== 'MultiPolygon') { + return { + pointCount: -1, + ringCount: -1, + polygonCount: -1, + }; + } + var polygonal = geometry; + var pointCount = 0; + var ringCount = 0; + var polygonCount = 0; + try { + for (var _c = __values(polygonal.coordinates), _d = _c.next(); !_d.done; _d = _c.next()) { + var ringOrPolygon = _d.value; + if (geometry.type === 'Polygon') { + polygonCount = 1; + ringCount++; + pointCount += ringOrPolygon.length; + } + else if (geometry.type === 'MultiPolygon') { + polygonCount++; + try { + for (var ringOrPolygon_1 = (e_4 = void 0, __values(ringOrPolygon)), ringOrPolygon_1_1 = ringOrPolygon_1.next(); !ringOrPolygon_1_1.done; ringOrPolygon_1_1 = ringOrPolygon_1.next()) { + var ring = ringOrPolygon_1_1.value; + ringCount++; + pointCount += ring.length; + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (ringOrPolygon_1_1 && !ringOrPolygon_1_1.done && (_b = ringOrPolygon_1.return)) _b.call(ringOrPolygon_1); + } + finally { if (e_4) throw e_4.error; } + } + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_3) throw e_3.error; } + } + return { + pointCount: pointCount, + ringCount: ringCount, + polygonCount: polygonCount, + }; +} +function getFilename(geojson) { + var filename = 'geojsonFeatures'; + if (geojson.type === 'Feature') { + filename = geojson.properties.name || UNNAMED; + } + return filename; +} +function prepareGeoJsonForExport(geojson) { + var forExport; + if (geojson.type === 'FeatureCollection') { + forExport = __assign(__assign({}, geojson), { features: geojson.features.map(prepareFeatureForExport) }); + } + else { + forExport = prepareFeatureForExport(geojson); + } + return forExport; +} +function prepareFeatureForExport(feature) { + var prepped = __assign(__assign({}, feature), { properties: __assign(__assign({}, feature.properties), { name: feature.properties.name || UNNAMED, description: feature.properties.description || '' }) }); + return prepped; +} +//# sourceMappingURL=exporter.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/lib/exporter.js.map b/lib/modules/editor/src/lib/exporter.js.map new file mode 100644 index 000000000..b9fa797b6 --- /dev/null +++ b/lib/modules/editor/src/lib/exporter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"exporter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AAa,CAAA,CAAA,4CAAA,uEAAE;wBAA7B,IAAM,IAAI,0BAAA;wBACb,SAAS,EAAE,CAAC;wBACZ,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC;qBAC3B;;;;;;;;;aACF;SACF;;;;;;;;;IACD,OAAO;QACL,UAAU,YAAA;QACV,SAAS,WAAA;QACT,YAAY,cAAA;KACb,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,OAAO;IAC1B,IAAI,QAAQ,GAAG,iBAAiB,CAAC;IACjC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;QAC9B,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,OAAO,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAmB;IAClD,IAAI,SAAS,CAAC;IACd,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAmB,EAAE;QACxC,SAAS,yBACJ,OAAO,KACV,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,uBAAuB,CAAC,GACxD,CAAC;KACH;SAAM;QACL,SAAS,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;KAC9C;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAC/C,IAAM,OAAO,yBACR,OAAO,KACV,UAAU,wBACL,OAAO,CAAC,UAAU,KACrB,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,OAAO,EACxC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,MAEpD,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/lib/importer.d.ts b/lib/modules/editor/src/lib/importer.d.ts new file mode 100644 index 000000000..3f95cc926 --- /dev/null +++ b/lib/modules/editor/src/lib/importer.d.ts @@ -0,0 +1,13 @@ +import { Feature } from '@nebula.gl/edit-modes'; +export declare type ValidImportData = { + valid: true; + type: 'GeoJSON' | 'KML' | 'WKT'; + features: Feature[]; +}; +export declare type InvalidImportData = { + valid: false; + validationErrors: string[]; +}; +export declare type ImportData = ValidImportData | InvalidImportData; +export declare function parseImport(data: string | File): Promise; +//# sourceMappingURL=importer.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/lib/importer.d.ts.map b/lib/modules/editor/src/lib/importer.d.ts.map new file mode 100644 index 000000000..0b438d797 --- /dev/null +++ b/lib/modules/editor/src/lib/importer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../../../../modules/editor/src/lib/importer.ts"],"names":[],"mappings":"AAUA,OAAO,EAAc,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE5D,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;IAChC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,oBAAY,UAAU,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAwL7D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAKpE"} \ No newline at end of file diff --git a/lib/modules/editor/src/lib/importer.js b/lib/modules/editor/src/lib/importer.js new file mode 100644 index 000000000..71233369d --- /dev/null +++ b/lib/modules/editor/src/lib/importer.js @@ -0,0 +1,188 @@ +/* eslint-env browser */ +import { kml } from '@tmcw/togeojson'; +import { parseSync } from '@loaders.gl/core'; +import { WKTLoader } from '@loaders.gl/wkt'; +function shouldTryGeoJson(data) { + return data.startsWith('{'); +} +function shouldTryKml(data) { + return data.startsWith('<'); +} +function shouldTryWkt(data) { + return (data.startsWith('POINT') || + data.startsWith('LINESTRING') || + data.startsWith('POLYGON') || + data.startsWith('MULTIPOINT') || + data.startsWith('MULTILINESTRING') || + data.startsWith('MULTIPOLYGON')); +} +function getCleanedFeatures(geojson) { + if (geojson.type !== 'FeatureCollection' && geojson.type !== 'Feature') { + throw Error("GeoJSON must have type of 'Feature' or 'FeatureCollection'"); + } + var features = geojson.type === 'FeatureCollection' ? geojson.features : [geojson]; + return features.map(getCleanedFeature); +} +function getCleanedFeature(feature) { + var geometry = feature.geometry; + // reduce null-checking + var properties = feature.properties || {}; + // @ts-ignore + if (geometry.type === 'GeometryCollection' && geometry.geometries.length === 1) { + // There's only one geometry + // @ts-ignore + geometry = geometry.geometries[0]; + // @ts-ignore + } + else if (geometry.type === 'GeometryCollection' && geometry.geometries.length > 1) { + // @ts-ignore + var types = new Set(geometry.geometries.map(function (g) { return g.type; })); + if (types.size === 1) { + // See if it can be combined into a Multi* geometry + var type = types.values().next().value; + if (type === 'Polygon') { + // Combine all the polygons into a single MultiPolygon + geometry = { + type: 'MultiPolygon', + // @ts-ignore + coordinates: geometry.geometries.map(function (g) { return g.coordinates; }), + }; + } + else if (type === 'LineString') { + // Combine all the polygons into a single MultiPolygon + geometry = { + type: 'MultiLineString', + // @ts-ignore + coordinates: geometry.geometries.map(function (g) { return g.coordinates; }), + }; + } + } + else { + // Mixed geometry types, we don't yet handle it + throw Error('GeometryCollection geometry type not yet supported'); + } + } + // @ts-ignore + return { + type: 'Feature', + geometry: geometry, + properties: properties, + }; +} +function parseImportString(data) { + data = data.trim(); + var validData; + var validationErrors = []; + if (shouldTryGeoJson(data)) { + // Parse as GeoJSON + try { + var parsed = JSON.parse(data); + validData = { + valid: true, + type: 'GeoJSON', + features: getCleanedFeatures(parsed), + }; + } + catch (err) { + validationErrors.push('Error parsing GeoJSON'); + validationErrors.push(err.toString()); + } + } + else if (shouldTryKml(data)) { + // Parse as KML + var xml = new DOMParser().parseFromString(data, 'text/xml'); + try { + var parsed = kml(xml); + /* + TODO: Revisit using loaders.gl/kml for this later + const parsed_ = parseSync(data, KMLasGeoJsonLoader); + // This is changing the coordinates to floats, because in loaders.gl/kml 2.1.1 they are returned as strings. + const parsed = { + ...parsed_, + features: parsed_.features.map(f => ({ + ...f, + geometry: { + ...f.geometry, + coordinates: f.geometry.coordinates.map(coords => coords.map(triple => triple.map(s => Number.parseFloat(s)))) + } + })) + }; + */ + var isFeature = parsed && parsed.type === 'Feature'; + var isFeatureCollectionWithFeatures = parsed && parsed.type === 'FeatureCollection' && parsed.features.length > 0; + var isValid = isFeature || isFeatureCollectionWithFeatures; + if (isValid) { + validData = { + valid: true, + type: 'KML', + features: getCleanedFeatures(parsed), + }; + } + else { + validationErrors.push('Invalid KML'); + } + } + catch (err) { + validationErrors.push('Error parsing KML'); + validationErrors.push(err.toString()); + } + } + else if (shouldTryWkt(data)) { + try { + var parsed = parseSync(data, WKTLoader); + if (parsed) { + validData = { + valid: true, + type: 'WKT', + features: [ + { + type: 'Feature', + properties: {}, + geometry: parsed, + }, + ], + }; + } + else { + validationErrors.push('Invalid WKT'); + } + } + catch (err) { + validationErrors.push('Error parsing WKT'); + validationErrors.push(err.toString()); + } + } + else { + validationErrors.push('Unknown data format'); + } + if (validData) { + return Promise.resolve(validData); + } + return Promise.resolve({ + valid: false, + validationErrors: validationErrors, + }); +} +function parseImportFile(file) { + return new Promise(function (resolve, reject) { + var reader = new FileReader(); + reader.onload = function () { + var fileAsString = reader.result; + resolve(parseImportString(fileAsString)); + }; + reader.onabort = function () { + reject(Error('file reading was aborted')); + }; + reader.onerror = function () { + reject(Error('file reading has failed')); + }; + reader.readAsText(file); + }); +} +export function parseImport(data) { + if (typeof data === 'string') { + return parseImportString(data); + } + return parseImportFile(data); +} +//# sourceMappingURL=importer.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/lib/importer.js.map b/lib/modules/editor/src/lib/importer.js.map new file mode 100644 index 000000000..821dbcd32 --- /dev/null +++ b/lib/modules/editor/src/lib/importer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AAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG;YACd,IAAM,YAAY,GAAQ,MAAM,CAAC,MAAM,CAAC;YACxC,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG;YACf,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG;YACf,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC;QAEF,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;KAChC;IACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/src/toolbox.d.ts b/lib/modules/editor/src/toolbox.d.ts new file mode 100644 index 000000000..70fe64511 --- /dev/null +++ b/lib/modules/editor/src/toolbox.d.ts @@ -0,0 +1,8 @@ +export declare type Props = { + mode: any; + features: any; + onSetMode: (arg0: any) => unknown; + onImport: (arg0: any) => unknown; +}; +export declare function Toolbox(props: Props): JSX.Element; +//# sourceMappingURL=toolbox.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/src/toolbox.d.ts.map b/lib/modules/editor/src/toolbox.d.ts.map new file mode 100644 index 000000000..f177ba94f --- /dev/null +++ b/lib/modules/editor/src/toolbox.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"toolbox.d.ts","sourceRoot":"","sources":["../../../../modules/editor/src/toolbox.tsx"],"names":[],"mappings":"AA4BA,oBAAY,KAAK,GAAG;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;CAClC,CAAC;AASF,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,eAqCnC"} \ No newline at end of file diff --git a/lib/modules/editor/src/toolbox.js b/lib/modules/editor/src/toolbox.js new file mode 100644 index 000000000..e05b81013 --- /dev/null +++ b/lib/modules/editor/src/toolbox.js @@ -0,0 +1,35 @@ +import { __makeTemplateObject, __read } from "tslib"; +import * as React from 'react'; +import { ViewMode, DrawPointMode, DrawPolygonMode } from '@nebula.gl/edit-modes'; +import styled from 'styled-components'; +import { ImportModal } from './import-modal'; +import { ExportModal } from './export-modal'; +var Tools = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n display: flex;\n flex-direction: column;\n top: 10px;\n right: 10px;\n"], ["\n position: absolute;\n display: flex;\n flex-direction: column;\n top: 10px;\n right: 10px;\n"]))); +var Button = styled.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: #fff;\n background-color: rgb(90, 98, 94);\n font-size: 1em;\n font-weight: 400;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,\n 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',\n 'Noto Color Emoji';\n border: 1px solid transparent;\n border-radius: 0.25em;\n margin: 0.05em;\n padding: 0.1em 0.2em;\n"], ["\n color: #fff;\n background-color: rgb(90, 98, 94);\n font-size: 1em;\n font-weight: 400;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,\n 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',\n 'Noto Color Emoji';\n border: 1px solid transparent;\n border-radius: 0.25em;\n margin: 0.05em;\n padding: 0.1em 0.2em;\n"]))); +var MODE_BUTTONS = [ + // TODO: change these to icons + { mode: ViewMode, content: 'View' }, + { mode: DrawPointMode, content: 'Draw Point' }, + { mode: DrawPolygonMode, content: 'Draw Polygon' }, +]; +export function Toolbox(props) { + // Initialize to zero index on load as nothing is active. + var _a = __read(React.useState(false), 2), showImport = _a[0], setShowImport = _a[1]; + var _b = __read(React.useState(false), 2), showExport = _b[0], setShowExport = _b[1]; + return (React.createElement(React.Fragment, null, + React.createElement(Tools, null, + MODE_BUTTONS.map(function (modeButton, i) { return (React.createElement(Button, { key: i, style: { + backgroundColor: props.mode === modeButton.mode ? 'rgb(0, 105, 217)' : 'rgb(90, 98, 94)', + }, onClick: function () { + props.onSetMode(function () { return modeButton.mode; }); + } }, modeButton.content)); }), + React.createElement(Button, { onClick: function () { return setShowImport(true); } }, " Import Geometry "), + React.createElement(Button, { onClick: function () { return setShowExport(true); } }, " Export Geometry ")), + showImport && (React.createElement(ImportModal, { onImport: function (geojson) { + props.onImport(geojson); + setShowImport(false); + }, onClose: function () { return setShowImport(false); } })), + showExport && React.createElement(ExportModal, { features: props.features, onClose: function () { return setShowExport(false); } }))); +} +var templateObject_1, templateObject_2; +//# sourceMappingURL=toolbox.js.map \ No newline at end of file diff --git a/lib/modules/editor/src/toolbox.js.map b/lib/modules/editor/src/toolbox.js.map new file mode 100644 index 000000000..18b7b514d --- /dev/null +++ b/lib/modules/editor/src/toolbox.js.map @@ -0,0 +1 @@ +{"version":3,"file":"toolbox.js","sourceRoot":"","sources":["../../../../modules/editor/src/toolbox.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,W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AC,EAAnB,CAAmB,wBAA4B,CAChE;QACP,UAAU,IAAI,CACb,oBAAC,WAAW,IACV,QAAQ,EAAE,UAAC,OAAO;gBAChB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACxB,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC,EACD,OAAO,EAAE,cAAM,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB,GACnC,CACH;QACA,UAAU,IAAI,oBAAC,WAAW,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAM,OAAA,aAAa,CAAC,KAAK,CAAC,EAApB,CAAoB,GAAI,CAC5F,CACJ,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/test/exporter.test.d.ts b/lib/modules/editor/test/exporter.test.d.ts new file mode 100644 index 000000000..c2de21813 --- /dev/null +++ b/lib/modules/editor/test/exporter.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=exporter.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/test/exporter.test.d.ts.map b/lib/modules/editor/test/exporter.test.d.ts.map new file mode 100644 index 000000000..a94b05995 --- /dev/null +++ b/lib/modules/editor/test/exporter.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"exporter.test.d.ts","sourceRoot":"","sources":["../../../../modules/editor/test/exporter.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/editor/test/exporter.test.js b/lib/modules/editor/test/exporter.test.js new file mode 100644 index 000000000..2bd649003 --- /dev/null +++ b/lib/modules/editor/test/exporter.test.js @@ -0,0 +1,252 @@ +/* eslint-env jest */ +import { toGeoJson, toKml, toWkt, toStats, UNNAMED } from '../src/lib/exporter'; +import { createRandomFeature } from './utils/test-features'; +var unsavedNamedFeature; +var unsavedUnnamedFeature; +var featureCollection; +beforeEach(function () { + unsavedNamedFeature = createRandomFeature(); + unsavedNamedFeature.properties.name = 'hamster'; + unsavedNamedFeature.properties.description = 'i am a hamster geofence'; + unsavedUnnamedFeature = createRandomFeature(); + delete unsavedUnnamedFeature.properties.name; + featureCollection = { + type: 'FeatureCollection', + properties: {}, + features: [unsavedNamedFeature, unsavedUnnamedFeature], + }; +}); +describe('toGeoJson()', function () { + test('when unsaved, named Feature', function () { + var expectedFilename = unsavedNamedFeature.properties.name + ".geojson"; + var expectedMimeType = 'application/json'; + var actual = toGeoJson(unsavedNamedFeature); + var actualParsed = JSON.parse(actual.data); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actualParsed.properties.name).toEqual(unsavedNamedFeature.properties.name); + expect(actualParsed.properties.description).toEqual(unsavedNamedFeature.properties.description); + }); + test('when unsaved, unnamed Feature', function () { + var expectedFilename = UNNAMED + ".geojson"; + var expectedMimeType = 'application/json'; + var actual = toGeoJson(unsavedUnnamedFeature); + var actualParsed = JSON.parse(actual.data); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actualParsed.properties.name).toEqual(UNNAMED); + expect(actualParsed.properties.description).toEqual(''); + expect(actualParsed.id).toBeUndefined(); + }); + test('when feature collection', function () { + var expectedFilename = "geojsonFeatures.geojson"; + var expectedMimeType = 'application/json'; + var actual = toGeoJson(featureCollection); + var actualParsed = JSON.parse(actual.data); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actualParsed.features[0].properties.name).toEqual(featureCollection.features[0].properties.name); + expect(actualParsed.features[1].properties.name).toEqual(UNNAMED); + }); +}); +describe('toKml()', function () { + test('when unsaved, named Feature', function () { + var expectedFilename = unsavedNamedFeature.properties.name + ".kml"; + var expectedMimeType = 'application/xml'; + var actual = toKml(unsavedNamedFeature); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toContain("" + unsavedNamedFeature.properties.name + ""); + expect(actual.data).toContain("" + unsavedNamedFeature.properties.description + ""); + }); + test('when unsaved, unnamed Feature', function () { + var expectedFilename = UNNAMED + ".kml"; + var expectedMimeType = 'application/xml'; + var actual = toKml(unsavedUnnamedFeature); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toContain("" + UNNAMED + ""); + }); +}); +describe('toWkt()', function () { + test('when feature', function () { + var expectedFilename = "llamallama.wkt"; + var expectedMimeType = 'text/plain'; + var expectedData = 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))'; + var actual = toWkt({ + type: 'Feature', + properties: { name: 'llamallama' }, + id: 'abc', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [30, 10], + [40, 40], + [20, 40], + [10, 20], + [30, 10], + ], + ], + }, + }); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toEqual(expectedData); + }); + test('when feature collection', function () { + var expectedFilename = "geojsonFeatures.wkt"; + var expectedMimeType = 'text/plain'; + var expectedData = 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))\nPOLYGON ((3 1, 4 4, 2 4, 1 2, 3 1))'; + var actual = toWkt({ + type: 'FeatureCollection', + properties: {}, + features: [ + { + type: 'Feature', + properties: { name: 'llamallama1' }, + id: 'abc', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [30, 10], + [40, 40], + [20, 40], + [10, 20], + [30, 10], + ], + ], + }, + }, + { + type: 'Feature', + properties: { name: 'llamallama2' }, + id: 'def', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [3, 1], + [4, 4], + [2, 4], + [1, 2], + [3, 1], + ], + ], + }, + }, + ], + }); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toEqual(expectedData); + }); + test('when empty feature collection', function () { + var expectedFilename = "geojsonFeatures.wkt"; + var expectedMimeType = 'text/plain'; + var expectedData = ''; + var actual = toWkt({ + type: 'FeatureCollection', + properties: {}, + features: [], + }); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toEqual(expectedData); + }); +}); +describe('toStats()', function () { + test('when feature', function () { + var expectedFilename = "llamallama.txt"; + var expectedMimeType = 'text/plain'; + var expectedData = 'Features: 1\nPolygons: 1\nRings: 1\nPoints: 5'; + var actual = toStats({ + type: 'Feature', + properties: { name: 'llamallama' }, + id: 'abc', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [30, 10], + [40, 40], + [20, 40], + [10, 20], + [30, 10], + ], + ], + }, + }); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toEqual(expectedData); + }); + test('when feature collection', function () { + var expectedFilename = "geojsonFeatures.txt"; + var expectedMimeType = 'text/plain'; + var expectedData = 'Features: 2\nPolygons: 3\nRings: 4\nPoints: 20'; + var actual = toStats({ + type: 'FeatureCollection', + properties: {}, + features: [ + { + type: 'Feature', + properties: { name: 'llamallama1' }, + id: 'abc', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [30, 10], + [40, 40], + [20, 40], + [10, 20], + [30, 10], + ], + ], + }, + }, + { + type: 'Feature', + properties: { name: 'llamallama2' }, + id: 'def', + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [3, 1], + [4, 4], + [2, 4], + [1, 2], + [3, 1], + ], + [ + [3.5, 3.5], + [2, 3.5], + [1.5, 2], + [2.5, 1.5], + [3.5, 3.5], + ], + ], + [ + [ + [13, 11], + [14, 14], + [12, 14], + [11, 12], + [13, 11], + ], + ], + ], + }, + }, + ], + }); + expect(actual.filename).toEqual(expectedFilename); + expect(actual.mimetype).toEqual(expectedMimeType); + expect(actual.data).toEqual(expectedData); + }); +}); +//# sourceMappingURL=exporter.test.js.map \ No newline at end of file diff --git a/lib/modules/editor/test/exporter.test.js.map b/lib/modules/editor/test/exporter.test.js.map new file mode 100644 index 000000000..edd54a099 --- /dev/null +++ b/lib/modules/editor/test/exporter.test.js.map @@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,CAAC,EAAE,CAAC,CAAC;oCACN,CAAC,CAAC,EAAE,CAAC,CAAC;iCACP;gCACD;oCACE,CAAC,GAAG,EAAE,GAAG,CAAC;oCACV,CAAC,CAAC,EAAE,GAAG,CAAC;oCACR,CAAC,GAAG,EAAE,CAAC,CAAC;oCACR,CAAC,GAAG,EAAE,GAAG,CAAC;oCACV,CAAC,GAAG,EAAE,GAAG,CAAC;iCACX;6BACF;4BACD;gCACE;oCACE,CAAC,EAAE,EAAE,EAAE,CAAC;oCACR,CAAC,EAAE,EAAE,EAAE,CAAC;oCACR,CAAC,EAAE,EAAE,EAAE,CAAC;oCACR,CAAC,EAAE,EAAE,EAAE,CAAC;oCACR,CAAC,EAAE,EAAE,EAAE,CAAC;iCACT;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/test/importer.test.d.ts b/lib/modules/editor/test/importer.test.d.ts new file mode 100644 index 000000000..8779c649d --- /dev/null +++ b/lib/modules/editor/test/importer.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=importer.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/test/importer.test.d.ts.map b/lib/modules/editor/test/importer.test.d.ts.map new file mode 100644 index 000000000..2791ce43c --- /dev/null +++ b/lib/modules/editor/test/importer.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"importer.test.d.ts","sourceRoot":"","sources":["../../../../modules/editor/test/importer.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/editor/test/importer.test.js b/lib/modules/editor/test/importer.test.js new file mode 100644 index 000000000..69e424c9f --- /dev/null +++ b/lib/modules/editor/test/importer.test.js @@ -0,0 +1,414 @@ +/* eslint-disable max-nested-callbacks */ +/* eslint-env jest, browser */ +import { __awaiter, __generator, __values } from "tslib"; +import sinon from 'sinon'; +import { parseImport } from '../src/lib/importer'; +import { toKml, UNNAMED } from '../src/lib/exporter'; +import { createRandomFeature, createRandomPolygon, createRandomMultiPolygon, createRandomLineString, createRandomMultiLineString, } from './utils/test-features'; +var unsavedFeature; +var featureCollection; +beforeEach(function () { + unsavedFeature = createRandomFeature(); + featureCollection = { + type: 'FeatureCollection', + properties: {}, + features: [unsavedFeature], + }; +}); +describe('parseImport()', function () { + describe('GeoJSON Feature string', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport(JSON.stringify(unsavedFeature))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('parses feature', function () { + expect(importData.valid).toEqual(true); + expect(importData.type).toEqual('GeoJSON'); + expect(importData.features[0].properties.name).toEqual(unsavedFeature.properties.name); + }); + }); + describe('GeoJSON FeatureCollection string', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport(JSON.stringify(featureCollection))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('parses features', function () { + expect(importData.valid).toEqual(true); + expect(importData.type).toEqual('GeoJSON'); + expect(importData.features.map(function (f) { return f.properties.name; })).toEqual(featureCollection.features.map(function (f) { return f.properties.name; })); + expect(importData.features.map(function (f) { return f.geometry; })).toEqual(featureCollection.features.map(function (f) { return f.geometry; })); + }); + test('removes protected properties', function () { + var e_1, _a; + try { + for (var _b = __values(importData.features), _c = _b.next(); !_c.done; _c = _b.next()) { + var feature = _c.value; + expect(feature.properties.entity_type).toBeUndefined(); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + }); + }); + describe('KML string', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport(toKml(featureCollection).data)]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('parses features', function () { + expect(importData.valid).toEqual(true); + expect(importData.type).toEqual('KML'); + expect(importData.features.map(function (f) { return f.properties.name; })).toEqual(featureCollection.features.map(function (f) { return f.properties.name || UNNAMED; })); + expect(importData.features.map(function (f) { return f.geometry; })).toEqual(featureCollection.features.map(function (f) { return f.geometry; })); + }); + }); + describe('WKT string', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('parses features', function () { + expect(importData.valid).toEqual(true); + expect(importData.type).toEqual('WKT'); + expect(importData.features.length).toEqual(1); + expect(importData.features[0].properties).toEqual({}); + expect(importData.features[0].geometry).toEqual({ + type: 'Polygon', + coordinates: [ + [ + [30, 10], + [40, 40], + [20, 40], + [10, 20], + [30, 10], + ], + ], + }); + }); + }); + describe('GeoJSON file', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var file; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + file = new File([JSON.stringify(unsavedFeature)], 'my.geojson', { + type: 'text/plain;charset=utf-8;', + }); + return [4 /*yield*/, parseImport(file)]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('parses feature', function () { + expect(importData.valid).toEqual(true); + expect(importData.type).toEqual('GeoJSON'); + expect(importData.features[0].properties.name).toEqual(unsavedFeature.properties.name); + }); + }); + describe('GeometryCollection', function () { + describe('only single geometry', function () { + var polygon; + var geometryCollection; + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var feature; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + polygon = createRandomPolygon(); + geometryCollection = { + type: 'GeometryCollection', + geometries: [polygon], + }; + feature = { type: 'Feature', geometry: geometryCollection }; + return [4 /*yield*/, parseImport(JSON.stringify(feature))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('obtains single geometry', function () { + expect(importData.valid).toEqual(true); + expect(importData.features.length).toEqual(1); + expect(importData.features[0].geometry).toEqual(polygon); + }); + }); + describe('only Polygons', function () { + var multiPolygon; + var geometryCollection; + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var feature; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + multiPolygon = createRandomMultiPolygon(); + geometryCollection = { + type: 'GeometryCollection', + geometries: multiPolygon.coordinates.map(function (c) { return ({ + type: 'Polygon', + coordinates: c, + }); }), + }; + feature = { type: 'Feature', geometry: geometryCollection }; + return [4 /*yield*/, parseImport(JSON.stringify(feature))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('combines into MultiPolygon', function () { + expect(importData.valid).toEqual(true); + expect(importData.features.length).toEqual(1); + expect(importData.features[0].geometry).toEqual(multiPolygon); + }); + }); + describe('only LineString', function () { + var multiLineString; + var geometryCollection; + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var feature; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + multiLineString = createRandomMultiLineString(); + geometryCollection = { + type: 'GeometryCollection', + geometries: multiLineString.coordinates.map(function (c) { return ({ + type: 'LineString', + coordinates: c, + }); }), + }; + feature = { type: 'Feature', geometry: geometryCollection }; + return [4 /*yield*/, parseImport(JSON.stringify(feature))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('combines into MultiLineString', function () { + expect(importData.valid).toEqual(true); + expect(importData.features.length).toEqual(1); + expect(importData.features[0].geometry).toEqual(multiLineString); + }); + }); + }); + describe('negative tests', function () { + describe('Invalid JSON', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport('{abc')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual([ + 'Error parsing GeoJSON', + 'SyntaxError: Unexpected token a in JSON at position 1', + ]); + }); + }); + describe('Invalid GeoJSON', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport('{}')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual([ + 'Error parsing GeoJSON', + "Error: GeoJSON must have type of 'Feature' or 'FeatureCollection'", + ]); + }); + }); + describe('Invalid KML: togeojson throws', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var togeojson; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + togeojson = require('@tmcw/togeojson'); + sinon.replace(togeojson, 'kml', sinon.fake.throws(Error('barf'))); + return [4 /*yield*/, parseImport('')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + afterEach(function () { + sinon.restore(); + }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual(['Invalid KML']); + }); + }); + describe('Invalid KML: togeojson returns blank FeatureCollection', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var togeojson; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + togeojson = require('@tmcw/togeojson'); + sinon.replace(togeojson, 'kml', sinon.fake.returns({ type: 'FeatureCollection', features: [] })); + return [4 /*yield*/, parseImport('')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + afterEach(function () { + sinon.restore(); + }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual(['Invalid KML']); + }); + }); + describe('Invalid WKT', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport('POLYGON(zzz)')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual(['Invalid WKT']); + }); + }); + describe('Unknown type', function () { + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, parseImport('abc')]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('reports error', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual(["Unknown data format"]); + }); + }); + describe('GeometryCollection with mixed types', function () { + var geometryCollection; + var importData; + beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () { + var feature; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + geometryCollection = { + type: 'GeometryCollection', + geometries: [createRandomLineString(), createRandomPolygon()], + }; + feature = { type: 'Feature', geometry: geometryCollection }; + return [4 /*yield*/, parseImport(JSON.stringify(feature))]; + case 1: + importData = _a.sent(); + return [2 /*return*/]; + } + }); + }); }); + test('combines into MultiPolygon', function () { + expect(importData.valid).toEqual(false); + expect(importData.validationErrors).toEqual([ + 'Error parsing GeoJSON', + 'Error: GeometryCollection geometry type not yet supported', + ]); + }); + }); + }); +}); +//# sourceMappingURL=importer.test.js.map \ No newline at end of file diff --git a/lib/modules/editor/test/importer.test.js.map b/lib/modules/editor/test/importer.test.js.map new file mode 100644 index 000000000..16830e263 --- /dev/null +++ b/lib/modules/editor/test/importer.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"importer.test.js","sourceRoot":"","sources":["../../../../modules/editor/test/importer.test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,8BAA8B;;AAE9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,IAAI,cAAuB,CAAC;AAC5B,IAAI,iBAAoC,CAAC;AAEzC,UAAU,CAAC;IACT,cAAc,GAAG,mBAAmB,EAAE,CAAC;IAEvC,iBAAiB,GAAG;QAClB,IAAI,EAAE,mBAAmB;QACzB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,CAAC,cAAc,CAAC;KAC3B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE;IACxB,QAAQ,CAAC,wBAAwB,EAAE;QACjC,IAAI,UAAe,CAAC;QACpB,UAAU,CAAC;;;4BACI,qBAAM,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,EAAA;;wBAA9D,UAAU,GAAG,SAAiD,CAAC;;;;aAChE,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,EAAE;YACrB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,cAAc,CA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AE,CAAC;4BAErD,qBAAM,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAA;;4BAAvD,UAAU,GAAG,SAA0C,CAAC;;;;iBACzD,CAAC,CAAC;YAEH,IAAI,CAAC,4BAA4B,EAAE;gBACjC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACxC,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;oBAC1C,uBAAuB;oBACvB,2DAA2D;iBAC5D,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/editor/test/utils/test-features.d.ts b/lib/modules/editor/test/utils/test-features.d.ts new file mode 100644 index 000000000..b8c28d12e --- /dev/null +++ b/lib/modules/editor/test/utils/test-features.d.ts @@ -0,0 +1,13 @@ +import { Polygonal, Geometry, Polygon, MultiPolygon, LineString, MultiLineString, Feature, FeatureCollection } from '@nebula.gl/edit-modes'; +export declare function createPolygonAroundNullIsland(): Polygon; +export declare function createPolygonRightOfNullIsland(): Polygon; +export declare function createPolygonFarRightOfNullIsland(): Polygon; +export declare function createRandomPolygonal(): Polygonal; +export declare function createRandomPolygon(): Polygon; +export declare function createRandomMultiPolygon(): MultiPolygon; +export declare function createRandomLineString(): LineString; +export declare function createRandomMultiLineString(): MultiLineString; +export declare function wrapInFeature(geometry: Geometry): Feature; +export declare function createRandomFeature(): Feature; +export declare function createRandomFeatureCollection(): FeatureCollection; +//# sourceMappingURL=test-features.d.ts.map \ No newline at end of file diff --git a/lib/modules/editor/test/utils/test-features.d.ts.map b/lib/modules/editor/test/utils/test-features.d.ts.map new file mode 100644 index 000000000..623c48c5d --- /dev/null +++ b/lib/modules/editor/test/utils/test-features.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"test-features.d.ts","sourceRoot":"","sources":["../../../../../modules/editor/test/utils/test-features.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,UAAU,EACV,eAAe,EACf,OAAO,EACP,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AA0F/B,wBAAgB,6BAA6B,IAAI,OAAO,CAavD;AAED,wBAAgB,8BAA8B,IAAI,OAAO,CAaxD;AAED,wBAAgB,iCAAiC,IAAI,OAAO,CAa3D;AAED,wBAAgB,qBAAqB,IAAI,SAAS,CAEjD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED,wBAAgB,wBAAwB,IAAI,YAAY,CAEvD;AAED,wBAAgB,sBAAsB,IAAI,UAAU,CAQnD;AAED,wBAAgB,2BAA2B,IAAI,eAAe,CAe7D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAMzD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAM7C;AAED,wBAAgB,6BAA6B,IAAI,iBAAiB,CAyGjE"} \ No newline at end of file diff --git a/lib/modules/editor/test/utils/test-features.js b/lib/modules/editor/test/utils/test-features.js new file mode 100644 index 000000000..f5eb25d85 --- /dev/null +++ b/lib/modules/editor/test/utils/test-features.js @@ -0,0 +1,284 @@ +/* istanbul ignore file */ +function getPacManMultiPolygon() { + return { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [24.509897232055664, 70.43510308193534], + [24.512774742872846, 70.43377246860858], + [24.516506195068356, 70.43415455749883], + [24.518051147460938, 70.43610904442177], + [24.51444625854492, 70.43711495721077], + [24.51023091718955, 70.43659663127778], + [24.510509443918508, 70.43773315572952], + [24.52198759777441, 70.43993098279594], + [24.530351969222917, 70.43979023142828], + [24.540882110595703, 70.4375747865055], + [24.541053771972656, 70.42898001001919], + [24.536590576171875, 70.4300150246936], + [24.531955718994137, 70.4290375122142], + [24.526805877685547, 70.43047501433419], + [24.520397743119403, 70.4288568086563], + [24.51496124267578, 70.43007252396679], + [24.510159571030567, 70.42876569452596], + [24.509897232055664, 70.43510308193534], + ], + [ + [24.52646255493164, 70.43708621753503], + [24.526634216308594, 70.43610904442177], + [24.527664184570312, 70.43484439783438], + [24.530067443847653, 70.43472942606802], + [24.532299041748047, 70.43472942606802], + [24.534187316894528, 70.43501685426682], + [24.535045623779297, 70.43576414859652], + [24.535388946533203, 70.43628149014363], + [24.53521728515625, 70.43708621753503], + [24.534358978271484, 70.43760352549158], + [24.53144073486328, 70.43812082030453], + [24.53075408935547, 70.43806334375216], + [24.52646255493164, 70.43708621753503], + ], + ], + [ + [ + [24.434452056884766, 70.43858062688211], + [24.435197322726804, 70.44421917386198], + [24.449372330164838, 70.44991233297016], + [24.475994110107422, 70.44949798144461], + [24.492816925048828, 70.44283334545445], + [24.46208953857422, 70.44119557930743], + [24.482173919677734, 70.4325448391651], + [24.46349686309326, 70.4308843242287], + [24.446296691894528, 70.43248734687127], + [24.434452056884766, 70.43858062688211], + ], + ], + [ + [ + [24.475650787353512, 70.4397300978937], + [24.483890533447266, 70.44007492654139], + [24.485607147216797, 70.43789091312142], + [24.478740692138672, 70.43708621753503], + [24.475650787353512, 70.4397300978937], + ], + ], + ], + }; +} +function getPacManPolygon() { + return { + type: 'Polygon', + coordinates: [ + [ + [24.434452, 70.43858], + [24.435198, 70.44422], + [24.449373, 70.44991], + [24.475994, 70.4495], + [24.492817, 70.44283], + [24.46209, 70.44119], + [24.482174, 70.43255], + [24.463497, 70.430885], + [24.446297, 70.43249], + [24.434452, 70.43858], + ], + ], + }; +} +export function createPolygonAroundNullIsland() { + return { + type: 'Polygon', + coordinates: [ + [ + [1, 1], + [-1, 1], + [-1, -1], + [1, -1], + [1, 1], + ], + ], + }; +} +export function createPolygonRightOfNullIsland() { + return { + type: 'Polygon', + coordinates: [ + [ + [2, 2], + [0, 2], + [0, -2], + [2, -2], + [2, 2], + ], + ], + }; +} +export function createPolygonFarRightOfNullIsland() { + return { + type: 'Polygon', + coordinates: [ + [ + [4, 1], + [2, 1], + [2, -1], + [4, -1], + [4, 1], + ], + ], + }; +} +export function createRandomPolygonal() { + return Math.random() > 0.5 ? getPacManMultiPolygon() : getPacManPolygon(); +} +export function createRandomPolygon() { + return getPacManPolygon(); +} +export function createRandomMultiPolygon() { + return getPacManMultiPolygon(); +} +export function createRandomLineString() { + return { + type: 'LineString', + coordinates: [ + [1, 2], + [2, 3], + ], + }; +} +export function createRandomMultiLineString() { + return { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + [ + [4, 5], + [5, 6], + ], + ], + }; +} +export function wrapInFeature(geometry) { + return { + type: 'Feature', + properties: { name: "name-" + Math.round(Math.random() * 100) }, + geometry: geometry, + }; +} +export function createRandomFeature() { + return { + type: 'Feature', + properties: {}, + geometry: createRandomPolygon(), + }; +} +export function createRandomFeatureCollection() { + return { + type: 'FeatureCollection', + properties: { + name: 'Pac-Man Group', + }, + features: [ + { + type: 'Feature', + properties: { + name: 'Pac-Man 1', + }, + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [24.435197322726804, 70.44421917386198], + [24.449372330164838, 70.44991233297016], + [24.475994110107422, 70.44949798144461], + [24.492816925048828, 70.44283334545445], + [24.46208953857422, 70.44119557930743], + [24.435197322726804, 70.44421917386198], + ], + ], + [ + [ + [24.475650787353512, 70.4397300978937], + [24.483890533447266, 70.44007492654139], + [24.485607147216797, 70.43789091312142], + [24.478740692138672, 70.43708621753503], + [24.475650787353512, 70.4397300978937], + ], + ], + ], + }, + }, + { + type: 'Feature', + properties: { + name: 'Pac-Man Ghost', + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [24.509897232055664, 70.43510308193534], + [24.512774742872846, 70.43377246860858], + [24.516506195068356, 70.43415455749883], + [24.518051147460938, 70.43610904442177], + [24.51444625854492, 70.43711495721077], + [24.51023091718955, 70.43659663127778], + [24.510509443918508, 70.43773315572952], + [24.52198759777441, 70.43993098279594], + [24.530351969222917, 70.43979023142828], + [24.540882110595703, 70.4375747865055], + [24.541053771972656, 70.42898001001919], + [24.536590576171875, 70.4300150246936], + [24.531955718994137, 70.4290375122142], + [24.526805877685547, 70.43047501433419], + [24.520397743119403, 70.4288568086563], + [24.51496124267578, 70.43007252396679], + [24.510159571030567, 70.42876569452596], + [24.509897232055664, 70.43510308193534], + ], + [ + [24.52646255493164, 70.43708621753503], + [24.526634216308594, 70.43610904442177], + [24.527664184570312, 70.43484439783438], + [24.530067443847653, 70.43472942606802], + [24.532299041748047, 70.43472942606802], + [24.534187316894528, 70.43501685426682], + [24.535045623779297, 70.43576414859652], + [24.535388946533203, 70.43628149014363], + [24.53521728515625, 70.43708621753503], + [24.534358978271484, 70.43760352549158], + [24.53144073486328, 70.43812082030453], + [24.53075408935547, 70.43806334375216], + [24.52646255493164, 70.43708621753503], + ], + ], + }, + }, + { + type: 'Feature', + properties: { + name: 'Pac-Man 2', + }, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [24.434452056884766, 70.43858062688211], + [24.435197322726804, 70.44421917386198], + [24.46208953857422, 70.44119557930743], + [24.482173919677734, 70.4325448391651], + [24.46349686309326, 70.4308843242287], + [24.446296691894528, 70.43248734687127], + [24.434452056884766, 70.43858062688211], + ], + ], + }, + }, + ], + }; +} +//# sourceMappingURL=test-features.js.map \ No newline at end of file diff --git a/lib/modules/editor/test/utils/test-features.js.map b/lib/modules/editor/test/utils/test-features.js.map new file mode 100644 index 000000000..2ef5be62f --- /dev/null +++ b/lib/modules/editor/test/utils/test-features.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-features.js","sourceRoot":"","sources":["../../../../../modules/editor/test/utils/test-features.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAa1B,SAAS,qBAAqB;IAC5B,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE;YACX;gBACE;oBACE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;oBACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;oBACvC,CA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iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;yBACxC;wBACD;4BACE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;4BACtC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;4BACtC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;4BACtC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;4BACtC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;yBACvC;qBACF;iBACF;aACF;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,IAAI,EAAE,WAAW;iBAClB;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE;wBACX;4BACE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;4BACtC,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;4BACtC,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;4BACrC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;4BACvC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;yBACxC;qBACF;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/curve-utils.d.ts b/lib/modules/layers/src/curve-utils.d.ts new file mode 100644 index 000000000..577938bc7 --- /dev/null +++ b/lib/modules/layers/src/curve-utils.d.ts @@ -0,0 +1,3 @@ +import { Feature, MultiLineString, LineString } from 'geojson'; +export declare function generateCurveFromControlPoints(line: Feature): Feature; +//# sourceMappingURL=curve-utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/curve-utils.d.ts.map b/lib/modules/layers/src/curve-utils.d.ts.map new file mode 100644 index 000000000..9d64298c5 --- /dev/null +++ b/lib/modules/layers/src/curve-utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"curve-utils.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/curve-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAW/D,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,GAC7B,OAAO,CAAC,UAAU,CAAC,CA0DrB"} \ No newline at end of file diff --git a/lib/modules/layers/src/curve-utils.js b/lib/modules/layers/src/curve-utils.js new file mode 100644 index 000000000..ad761f7f1 --- /dev/null +++ b/lib/modules/layers/src/curve-utils.js @@ -0,0 +1,60 @@ +import hermite from 'cubic-hermite-spline'; +import turfDistance from '@turf/distance'; +import { lineString } from '@turf/helpers'; +var INTERPOLATION_INTERVAL = 0.005; +var INTERPOLATION_THRESHOLD = 0.001; +function calculateSingleTangent(p0, p1, d) { + var x = (p1[0] - p0[0]) / d; + var y = (p1[1] - p0[1]) / d; + return [x, y]; +} +export function generateCurveFromControlPoints(line) { + // calculate knots + var knots = [0]; + var prev = null; + var totalDistance = 0; + var coords = line.geometry.coordinates; + for (var i = 0; i < coords.length; i++) { + var cur = coords[i]; + if (prev !== null) { + totalDistance += turfDistance(prev, cur); + knots.push(totalDistance); + } + prev = cur; + } + // calculate tangents + var tangents = []; + // first tangent + // @ts-ignore + tangents.push(calculateSingleTangent(coords[0], coords[1], knots[1] - knots[0])); + // second to before last + for (var i = 1; i < coords.length - 1; i++) { + // @ts-ignore + var A = calculateSingleTangent(coords[i], coords[i + 1], knots[i + 1] - knots[i]); + // @ts-ignore + var B = calculateSingleTangent(coords[i - 1], coords[i], knots[i] - knots[i - 1]); + var x = (A[0] + B[0]) / 2.0; + var y = (A[1] + B[1]) / 2.0; + tangents.push([x, y]); + } + // last tangent + var last = coords.length - 1; + tangents.push( + // @ts-ignore + calculateSingleTangent(coords[last - 1], coords[last], knots[last] - knots[last - 1])); + // generate curve + var result = []; + for (var i = 0; i < coords.length; i++) { + // add control point + result.push(coords[i]); + // add interpolated values + for (var t = knots[i] + INTERPOLATION_INTERVAL; t < knots[i + 1]; t += INTERPOLATION_INTERVAL) { + if (knots[i + 1] - t > INTERPOLATION_THRESHOLD) { + // Only add if not too close to a control point (knot = control point) + result.push(hermite(t, coords, tangents, knots)); + } + } + } + return lineString(result); +} +//# sourceMappingURL=curve-utils.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/curve-utils.js.map b/lib/modules/layers/src/curve-utils.js.map new file mode 100644 index 000000000..9c2db7b07 --- /dev/null +++ b/lib/modules/layers/src/curve-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"curve-utils.js","sourceRoot":"","sources":["../../../../modules/layers/src/curve-utils.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,IAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,IAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC,SAAS,sBAAsB,CAAC,EAAoB,EAAE,EAAoB,EAAE,CAAS;IACnF,IAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,C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AE;gBAC9C,sEAAsE;gBACtE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;aAClD;SACF;KACF;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/event-types.d.ts b/lib/modules/layers/src/event-types.d.ts new file mode 100644 index 000000000..578dd3ba2 --- /dev/null +++ b/lib/modules/layers/src/event-types.d.ts @@ -0,0 +1,43 @@ +import { Position } from '@nebula.gl/edit-modes'; +export declare type DeckGLPick = { + index: number; + object: any; + isEditingHandle: boolean | null | undefined; +}; +export declare type ClickEvent = { + picks: DeckGLPick[]; + screenCoords: Position; + groundCoords: Position; + sourceEvent: any; +}; +export declare type DoubleClickEvent = { + groundCoords: Position; + sourceEvent: any; +}; +export declare type StartDraggingEvent = { + picks: DeckGLPick[]; + screenCoords: Position; + groundCoords: Position; + pointerDownScreenCoords: Position; + pointerDownGroundCoords: Position; + sourceEvent: any; +}; +export declare type StopDraggingEvent = { + picks: DeckGLPick[]; + screenCoords: Position; + groundCoords: Position; + pointerDownScreenCoords: Position; + pointerDownGroundCoords: Position; + sourceEvent: any; +}; +export declare type PointerMoveEvent = { + screenCoords: Position; + groundCoords: Position; + picks: DeckGLPick[]; + isDragging: boolean; + pointerDownPicks: DeckGLPick[] | null | undefined; + pointerDownScreenCoords: Position | null | undefined; + pointerDownGroundCoords: Position | null | undefined; + sourceEvent: any; +}; +//# sourceMappingURL=event-types.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/event-types.d.ts.map b/lib/modules/layers/src/event-types.d.ts.map new file mode 100644 index 000000000..30e6e5e6a --- /dev/null +++ b/lib/modules/layers/src/event-types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/event-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,E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IAAI,GAAG,SAAS,CAAC;IACrD,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/event-types.js b/lib/modules/layers/src/event-types.js new file mode 100644 index 000000000..3cb7d0eac --- /dev/null +++ b/lib/modules/layers/src/event-types.js @@ -0,0 +1 @@ +//# sourceMappingURL=event-types.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/event-types.js.map b/lib/modules/layers/src/event-types.js.map new file mode 100644 index 000000000..bc492d764 --- /dev/null +++ b/lib/modules/layers/src/event-types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"event-types.js","sourceRoot":"","sources":["../../../../modules/layers/src/event-types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/src/index.d.ts b/lib/modules/layers/src/index.d.ts new file mode 100644 index 000000000..a421d6a49 --- /dev/null +++ b/lib/modules/layers/src/index.d.ts @@ -0,0 +1,10 @@ +export { ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS } from './style'; +export { default as EditableGeoJsonLayer } from './layers/editable-geojson-layer'; +export { default as SelectionLayer } from './layers/selection-layer'; +export { default as ElevatedEditHandleLayer } from './layers/elevated-edit-handle-layer'; +export { default as PathOutlineLayer } from './layers/path-outline-layer/path-outline-layer'; +export { default as PathMarkerLayer } from './layers/path-marker-layer/path-marker-layer'; +export { default as JunctionScatterplotLayer } from './layers/junction-scatterplot-layer'; +export { toDeckColor } from './utils'; +export type { Color, Viewport } from './types'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/index.d.ts.map b/lib/modules/layers/src/index.d.ts.map new file mode 100644 index 000000000..74acdfc84 --- /dev/null +++ b/lib/modules/layers/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAGzF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAG1F,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/index.js b/lib/modules/layers/src/index.js new file mode 100644 index 000000000..892bf7c21 --- /dev/null +++ b/lib/modules/layers/src/index.js @@ -0,0 +1,12 @@ +export { ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS } from './style'; +// Layers +export { default as EditableGeoJsonLayer } from './layers/editable-geojson-layer'; +export { default as SelectionLayer } from './layers/selection-layer'; +export { default as ElevatedEditHandleLayer } from './layers/elevated-edit-handle-layer'; +// Layers moved from deck.gl +export { default as PathOutlineLayer } from './layers/path-outline-layer/path-outline-layer'; +export { default as PathMarkerLayer } from './layers/path-marker-layer/path-marker-layer'; +export { default as JunctionScatterplotLayer } from './layers/junction-scatterplot-layer'; +// Utils +export { toDeckColor } from './utils'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/index.js.map b/lib/modules/layers/src/index.js.map new file mode 100644 index 000000000..bbb164b12 --- /dev/null +++ b/lib/modules/layers/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/layers/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElE,SAAS;AACT,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEzF,4BAA4B;AAC5B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAE1F,QAAQ;AACR,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-geojson-layer.d.ts b/lib/modules/layers/src/layers/editable-geojson-layer.d.ts new file mode 100644 index 000000000..d61189c0b --- /dev/null +++ b/lib/modules/layers/src/layers/editable-geojson-layer.d.ts @@ -0,0 +1,91 @@ +/// +import { GeoJsonLayer, TextLayer } from '@deck.gl/layers'; +import { DrawPolygonMode, EditAction, ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, PointerMoveEvent, GeoJsonEditModeType, FeatureCollection } from '@nebula.gl/edit-modes'; +import EditableLayer from './editable-layer'; +declare function getEditHandleColor(handle: any): number[]; +declare function getEditHandleOutlineColor(handle: any): number[]; +declare function getEditHandleRadius(handle: any): 3 | 5 | 7; +declare type Props = { + mode: string | GeoJsonEditModeType; + onEdit: (arg0: EditAction) => void; + [key: string]: any; +}; +export default class EditableGeoJsonLayer extends EditableLayer { + static layerName: string; + static defaultProps: { + mode: typeof DrawPolygonMode; + onEdit: () => void; + pickable: boolean; + pickingRadius: number; + pickingDepth: number; + fp64: boolean; + filled: boolean; + stroked: boolean; + lineWidthScale: number; + lineWidthMinPixels: number; + lineWidthMaxPixels: number; + lineWidthUnits: string; + lineJointRounded: boolean; + lineMiterLimit: number; + pointRadiusScale: number; + pointRadiusMinPixels: number; + pointRadiusMaxPixels: number; + getLineColor: (feature: any, isSelected: any, mode: any) => number[]; + getFillColor: (feature: any, isSelected: any, mode: any) => number[]; + getRadius: (f: any) => any; + getLineWidth: (f: any) => any; + getTentativeLineColor: (f: any) => number[]; + getTentativeFillColor: (f: any) => number[]; + getTentativeLineWidth: (f: any) => any; + editHandleType: string; + editHandlePointRadiusScale: number; + editHandlePointOutline: boolean; + editHandlePointStrokeWidth: number; + editHandlePointRadiusMinPixels: number; + editHandlePointRadiusMaxPixels: number; + getEditHandlePointColor: typeof getEditHandleColor; + getEditHandlePointOutlineColor: typeof getEditHandleOutlineColor; + getEditHandlePointRadius: typeof getEditHandleRadius; + editHandleIconAtlas: any; + editHandleIconMapping: any; + editHandleIconSizeScale: number; + getEditHandleIcon: (handle: any) => any; + getEditHandleIconSize: number; + getEditHandleIconColor: typeof getEditHandleColor; + getEditHandleIconAngle: number; + billboard: boolean; + }; + renderLayers(): any; + initializeState(): void; + shouldUpdateState(opts: any): any; + updateState({ props, oldProps, changeFlags, }: { + props: Props; + oldProps: Props; + changeFlags: any; + }): void; + getModeProps(props: Props): { + modeConfig: any; + data: any; + selectedIndexes: any; + lastPointerMoveEvent: any; + cursor: any; + onEdit: (editAction: EditAction) => void; + onUpdateCursor: (cursor: string) => void; + }; + selectionAwareAccessor(accessor: any): any; + isFeatureSelected(feature: Record): any; + getPickingInfo({ info, sourceLayer }: Record): any; + createGuidesLayers(): GeoJsonLayer[]; + createTooltipsLayers(): TextLayer[]; + onLayerClick(event: ClickEvent): void; + onStartDragging(event: StartDraggingEvent): void; + onDragging(event: DraggingEvent): void; + onStopDragging(event: StopDraggingEvent): void; + onPointerMove(event: PointerMoveEvent): void; + getCursor({ isDragging }: { + isDragging: boolean; + }): any; + getActiveMode(): GeoJsonEditModeType; +} +export {}; +//# sourceMappingURL=editable-geojson-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-geojson-layer.d.ts.map b/lib/modules/layers/src/layers/editable-geojson-layer.d.ts.map new file mode 100644 index 000000000..7b7d8af8a --- /dev/null +++ b/lib/modules/layers/src/layers/editable-geojson-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"editable-geojson-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/editable-geojson-layer.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAA+B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAYL,eAAe,EAWf,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAkC7C,iBAAS,kBAAkB,CAAC,MAAM,KAAA,YAUjC;AAED,iBAAS,yBAAyB,CAAC,MAAM,KAAA,YAExC;AAED,iBAAS,mBAAmB,CAAC,MAAM,KAAA,aAUlC;AA2FD,aAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAGtD,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AASF,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,aAAa;IAC7D,MAAM,CAAC,SAAS,SAA0B;IAC1C,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAgB;IAInC,YAAY;IA+CZ,eAAe;IAUf,iBAAiB,CAAC,IAAI,EAAE,GAAG;IAS3B,WAAW,CAAC,EACV,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,EAAE;QACD,KAAK,EAAE,KAAK,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC;QAChB,WAAW,EAAE,GAAG,CAAC;KAClB;IA4CD,YAAY,CAAC,KAAK,EAAE,KAAK;;;;;;;;;IAoBzB,sBAAsB,CAAC,QAAQ,EAAE,GAAG;IAQpC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAW9C,cAAc,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IASzD,kBAAkB;IAyDlB,oBAAoB;IAcpB,YAAY,CAAC,KAAK,EAAE,UAAU;IAI9B,eAAe,CAAC,KAAK,EAAE,kBAAkB;IAIzC,UAAU,CAAC,KAAK,EAAE,aAAa;IAI/B,cAAc,CAAC,KAAK,EAAE,iBAAiB;IAIvC,aAAa,CAAC,KAAK,EAAE,gBAAgB;IAKrC,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE;IASjD,aAAa,IAAI,mBAAmB;CAGrC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-geojson-layer.js b/lib/modules/layers/src/layers/editable-geojson-layer.js new file mode 100644 index 000000000..91594a207 --- /dev/null +++ b/lib/modules/layers/src/layers/editable-geojson-layer.js @@ -0,0 +1,386 @@ +/* eslint-env browser */ +import { __extends } from "tslib"; +import { GeoJsonLayer, ScatterplotLayer, IconLayer, TextLayer } from '@deck.gl/layers'; +import { ViewMode, ModifyMode, TranslateMode, ScaleMode, RotateMode, DuplicateMode, SplitPolygonMode, ExtrudeMode, ElevationMode, DrawPointMode, DrawLineStringMode, DrawPolygonMode, DrawRectangleMode, DrawCircleFromCenterMode, DrawCircleByDiameterMode, DrawEllipseByBoundingBoxMode, DrawRectangleUsingThreePointsMode, DrawEllipseUsingThreePointsMode, Draw90DegreePolygonMode, DrawPolygonByDraggingMode, SnappableMode, TransformMode, } from '@nebula.gl/edit-modes'; +import EditableLayer from './editable-layer'; +var DEFAULT_LINE_COLOR = [0x0, 0x0, 0x0, 0xff]; +var DEFAULT_FILL_COLOR = [0x0, 0x0, 0x0, 0x90]; +var DEFAULT_SELECTED_LINE_COLOR = [0x90, 0x90, 0x90, 0xff]; +var DEFAULT_SELECTED_FILL_COLOR = [0x90, 0x90, 0x90, 0x90]; +var DEFAULT_EDITING_EXISTING_POINT_COLOR = [0xc0, 0x0, 0x0, 0xff]; +var DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR = [0x0, 0x0, 0x0, 0x80]; +var DEFAULT_EDITING_SNAP_POINT_COLOR = [0x7c, 0x00, 0xc0, 0xff]; +var DEFAULT_EDITING_POINT_OUTLINE_COLOR = [0xff, 0xff, 0xff, 0xff]; +var DEFAULT_EDITING_EXISTING_POINT_RADIUS = 5; +var DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS = 3; +var DEFAULT_EDITING_SNAP_POINT_RADIUS = 7; +var DEFAULT_EDIT_MODE = DrawPolygonMode; +function guideAccessor(accessor) { + if (!accessor || typeof accessor !== 'function') { + return accessor; + } + return function (guideMaybeWrapped) { return accessor(unwrapGuide(guideMaybeWrapped)); }; +} +// The object handed to us from deck.gl is different depending on the version of deck.gl used, unwrap as necessary +function unwrapGuide(guideMaybeWrapped) { + if (guideMaybeWrapped.__source) { + return guideMaybeWrapped.__source.object; + } + else if (guideMaybeWrapped.sourceFeature) { + return guideMaybeWrapped.sourceFeature.feature; + } + // It is not wrapped, return as is + return guideMaybeWrapped; +} +function getEditHandleColor(handle) { + switch (handle.properties.editHandleType) { + case 'existing': + return DEFAULT_EDITING_EXISTING_POINT_COLOR; + case 'snap-source': + return DEFAULT_EDITING_SNAP_POINT_COLOR; + case 'intermediate': + default: + return DEFAULT_EDITING_INTERMEDIATE_POINT_COLOR; + } +} +function getEditHandleOutlineColor(handle) { + return DEFAULT_EDITING_POINT_OUTLINE_COLOR; +} +function getEditHandleRadius(handle) { + switch (handle.properties.editHandleType) { + case 'existing': + return DEFAULT_EDITING_EXISTING_POINT_RADIUS; + case 'snap': + return DEFAULT_EDITING_SNAP_POINT_RADIUS; + case 'intermediate': + default: + return DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS; + } +} +var defaultProps = { + mode: DrawPolygonMode, + // Edit and interaction events + onEdit: function () { }, + pickable: true, + pickingRadius: 10, + pickingDepth: 5, + fp64: false, + filled: true, + stroked: true, + lineWidthScale: 1, + lineWidthMinPixels: 1, + lineWidthMaxPixels: Number.MAX_SAFE_INTEGER, + lineWidthUnits: 'pixels', + lineJointRounded: false, + lineMiterLimit: 4, + pointRadiusScale: 1, + pointRadiusMinPixels: 2, + pointRadiusMaxPixels: Number.MAX_SAFE_INTEGER, + getLineColor: function (feature, isSelected, mode) { + return isSelected ? DEFAULT_SELECTED_LINE_COLOR : DEFAULT_LINE_COLOR; + }, + getFillColor: function (feature, isSelected, mode) { + return isSelected ? DEFAULT_SELECTED_FILL_COLOR : DEFAULT_FILL_COLOR; + }, + getRadius: function (f) { + return (f && f.properties && f.properties.radius) || (f && f.properties && f.properties.size) || 1; + }, + getLineWidth: function (f) { return (f && f.properties && f.properties.lineWidth) || 3; }, + // Tentative feature rendering + getTentativeLineColor: function (f) { return DEFAULT_SELECTED_LINE_COLOR; }, + getTentativeFillColor: function (f) { return DEFAULT_SELECTED_FILL_COLOR; }, + getTentativeLineWidth: function (f) { return (f && f.properties && f.properties.lineWidth) || 3; }, + editHandleType: 'point', + // point handles + editHandlePointRadiusScale: 1, + editHandlePointOutline: true, + editHandlePointStrokeWidth: 2, + editHandlePointRadiusMinPixels: 4, + editHandlePointRadiusMaxPixels: 8, + getEditHandlePointColor: getEditHandleColor, + getEditHandlePointOutlineColor: getEditHandleOutlineColor, + getEditHandlePointRadius: getEditHandleRadius, + // icon handles + editHandleIconAtlas: null, + editHandleIconMapping: null, + editHandleIconSizeScale: 1, + getEditHandleIcon: function (handle) { return handle.properties.editHandleType; }, + getEditHandleIconSize: 10, + getEditHandleIconColor: getEditHandleColor, + getEditHandleIconAngle: 0, + // misc + billboard: true, +}; +// Mapping of mode name to mode class (for legacy purposes) +var modeNameMapping = { + view: ViewMode, + // Alter modes + modify: ModifyMode, + translate: new SnappableMode(new TranslateMode()), + transform: new SnappableMode(new TransformMode()), + scale: ScaleMode, + rotate: RotateMode, + duplicate: DuplicateMode, + split: SplitPolygonMode, + extrude: ExtrudeMode, + elevation: ElevationMode, + // Draw modes + drawPoint: DrawPointMode, + drawLineString: DrawLineStringMode, + drawPolygon: DrawPolygonMode, + drawRectangle: DrawRectangleMode, + drawCircleFromCenter: DrawCircleFromCenterMode, + drawCircleByBoundingBox: DrawCircleByDiameterMode, + drawEllipseByBoundingBox: DrawEllipseByBoundingBoxMode, + drawRectangleUsing3Points: DrawRectangleUsingThreePointsMode, + drawEllipseUsing3Points: DrawEllipseUsingThreePointsMode, + draw90DegreePolygon: Draw90DegreePolygonMode, + drawPolygonByDragging: DrawPolygonByDraggingMode, +}; +// type State = { +// mode: GeoJsonEditMode, +// tentativeFeature: ?Feature, +// editHandles: any[], +// selectedFeatures: Feature[] +// }; +var EditableGeoJsonLayer = /** @class */ (function (_super) { + __extends(EditableGeoJsonLayer, _super); + function EditableGeoJsonLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + // props: Props; + // setState: ($Shape) => void; + EditableGeoJsonLayer.prototype.renderLayers = function () { + var subLayerProps = this.getSubLayerProps({ + id: 'geojson', + // Proxy most GeoJsonLayer props as-is + data: this.props.data, + fp64: this.props.fp64, + filled: this.props.filled, + stroked: this.props.stroked, + lineWidthScale: this.props.lineWidthScale, + lineWidthMinPixels: this.props.lineWidthMinPixels, + lineWidthMaxPixels: this.props.lineWidthMaxPixels, + lineWidthUnits: this.props.lineWidthUnits, + lineJointRounded: this.props.lineJointRounded, + lineMiterLimit: this.props.lineMiterLimit, + pointRadiusScale: this.props.pointRadiusScale, + pointRadiusMinPixels: this.props.pointRadiusMinPixels, + pointRadiusMaxPixels: this.props.pointRadiusMaxPixels, + getLineColor: this.selectionAwareAccessor(this.props.getLineColor), + getFillColor: this.selectionAwareAccessor(this.props.getFillColor), + getRadius: this.selectionAwareAccessor(this.props.getRadius), + getLineWidth: this.selectionAwareAccessor(this.props.getLineWidth), + _subLayerProps: { + 'line-strings': { + billboard: this.props.billboard, + }, + 'polygons-stroke': { + billboard: this.props.billboard, + }, + }, + updateTriggers: { + getLineColor: [this.props.selectedFeatureIndexes, this.props.mode], + getFillColor: [this.props.selectedFeatureIndexes, this.props.mode], + getRadius: [this.props.selectedFeatureIndexes, this.props.mode], + getLineWidth: [this.props.selectedFeatureIndexes, this.props.mode], + }, + }); + var layers = [new GeoJsonLayer(subLayerProps)]; + layers = layers.concat(this.createGuidesLayers(), this.createTooltipsLayers()); + return layers; + }; + EditableGeoJsonLayer.prototype.initializeState = function () { + _super.prototype.initializeState.call(this); + this.setState({ + selectedFeatures: [], + editHandles: [], + }); + }; + // TODO: is this the best way to properly update state from an outside event handler? + EditableGeoJsonLayer.prototype.shouldUpdateState = function (opts) { + // console.log( + // 'shouldUpdateState', + // opts.changeFlags.propsOrDataChanged, + // opts.changeFlags.stateChanged + // ); + return _super.prototype.shouldUpdateState.call(this, opts) || opts.changeFlags.stateChanged; + }; + EditableGeoJsonLayer.prototype.updateState = function (_a) { + var props = _a.props, oldProps = _a.oldProps, changeFlags = _a.changeFlags; + // @ts-ignore + _super.prototype.updateState.call(this, { props: props, changeFlags: changeFlags }); + var mode = this.state.mode; + if (changeFlags.propsOrDataChanged) { + if (props.mode !== oldProps.mode) { + if (typeof props.mode === 'string') { + // Lookup the mode based on its name (for legacy purposes) + mode = modeNameMapping[props.mode]; + // eslint-disable-next-line no-console + console.warn("Deprecated use of passing `mode` as a string. Pass the mode's class constructor instead."); + } + else { + mode = props.mode; + } + if (typeof mode === 'function') { + var ModeConstructor = mode; + mode = new ModeConstructor(); + } + if (!mode) { + console.warn("No mode configured for " + String(props.mode)); // eslint-disable-line no-console,no-undef + // Use default mode + mode = DEFAULT_EDIT_MODE; + } + if (mode !== this.state.mode) { + this.setState({ mode: mode, cursor: null }); + } + } + } + var selectedFeatures = []; + if (Array.isArray(props.selectedFeatureIndexes)) { + // TODO: needs improved testing, i.e. checking for duplicates, NaNs, out of range numbers, ... + selectedFeatures = props.selectedFeatureIndexes.map(function (elem) { return props.data.features[elem]; }); + } + this.setState({ selectedFeatures: selectedFeatures }); + }; + EditableGeoJsonLayer.prototype.getModeProps = function (props) { + var _this = this; + return { + modeConfig: props.modeConfig, + data: props.data, + selectedIndexes: props.selectedFeatureIndexes, + lastPointerMoveEvent: this.state.lastPointerMoveEvent, + cursor: this.state.cursor, + onEdit: function (editAction) { + // Force a re-render + // This supports double-click where we need to ensure that there's a re-render between the two clicks + // even though the data wasn't changed, just the internal tentative feature. + _this.setNeedsUpdate(); + props.onEdit(editAction); + }, + onUpdateCursor: function (cursor) { + _this.setState({ cursor: cursor }); + }, + }; + }; + EditableGeoJsonLayer.prototype.selectionAwareAccessor = function (accessor) { + var _this = this; + if (typeof accessor !== 'function') { + return accessor; + } + return function (feature) { + return accessor(feature, _this.isFeatureSelected(feature), _this.props.mode); + }; + }; + EditableGeoJsonLayer.prototype.isFeatureSelected = function (feature) { + if (!this.props.data || !this.props.selectedFeatureIndexes) { + return false; + } + if (!this.props.selectedFeatureIndexes.length) { + return false; + } + var featureIndex = this.props.data.features.indexOf(feature); + return this.props.selectedFeatureIndexes.includes(featureIndex); + }; + EditableGeoJsonLayer.prototype.getPickingInfo = function (_a) { + var info = _a.info, sourceLayer = _a.sourceLayer; + if (sourceLayer.id.endsWith('guides')) { + // If user is picking an editing handle, add additional data to the info + info.isGuide = true; + } + return info; + }; + EditableGeoJsonLayer.prototype.createGuidesLayers = function () { + var mode = this.getActiveMode(); + var guides = mode.getGuides(this.getModeProps(this.props)); + if (!guides || !guides.features.length) { + return []; + } + var pointLayerProps; + if (this.props.editHandleType === 'icon') { + pointLayerProps = { + type: IconLayer, + iconAtlas: this.props.editHandleIconAtlas, + iconMapping: this.props.editHandleIconMapping, + sizeScale: this.props.editHandleIconSizeScale, + getIcon: guideAccessor(this.props.getEditHandleIcon), + getSize: guideAccessor(this.props.getEditHandleIconSize), + getColor: guideAccessor(this.props.getEditHandleIconColor), + getAngle: guideAccessor(this.props.getEditHandleIconAngle), + }; + } + else { + pointLayerProps = { + type: ScatterplotLayer, + radiusScale: this.props.editHandlePointRadiusScale, + stroked: this.props.editHandlePointOutline, + getLineWidth: this.props.editHandlePointStrokeWidth, + radiusMinPixels: this.props.editHandlePointRadiusMinPixels, + radiusMaxPixels: this.props.editHandlePointRadiusMaxPixels, + getRadius: guideAccessor(this.props.getEditHandlePointRadius), + getFillColor: guideAccessor(this.props.getEditHandlePointColor), + getLineColor: guideAccessor(this.props.getEditHandlePointOutlineColor), + }; + } + var layer = new GeoJsonLayer(this.getSubLayerProps({ + id: "guides", + data: guides, + fp64: this.props.fp64, + _subLayerProps: { + points: pointLayerProps, + }, + lineWidthScale: this.props.lineWidthScale, + lineWidthMinPixels: this.props.lineWidthMinPixels, + lineWidthMaxPixels: this.props.lineWidthMaxPixels, + lineWidthUnits: this.props.lineWidthUnits, + lineJointRounded: this.props.lineJointRounded, + lineMiterLimit: this.props.lineMiterLimit, + getLineColor: guideAccessor(this.props.getTentativeLineColor), + getLineWidth: guideAccessor(this.props.getTentativeLineWidth), + getFillColor: guideAccessor(this.props.getTentativeFillColor), + })); + return [layer]; + }; + EditableGeoJsonLayer.prototype.createTooltipsLayers = function () { + var mode = this.getActiveMode(); + var tooltips = mode.getTooltips(this.getModeProps(this.props)); + var layer = new TextLayer(this.getSubLayerProps({ + id: "tooltips", + data: tooltips, + })); + return [layer]; + }; + EditableGeoJsonLayer.prototype.onLayerClick = function (event) { + this.getActiveMode().handleClick(event, this.getModeProps(this.props)); + }; + EditableGeoJsonLayer.prototype.onStartDragging = function (event) { + this.getActiveMode().handleStartDragging(event, this.getModeProps(this.props)); + }; + EditableGeoJsonLayer.prototype.onDragging = function (event) { + this.getActiveMode().handleDragging(event, this.getModeProps(this.props)); + }; + EditableGeoJsonLayer.prototype.onStopDragging = function (event) { + this.getActiveMode().handleStopDragging(event, this.getModeProps(this.props)); + }; + EditableGeoJsonLayer.prototype.onPointerMove = function (event) { + this.setState({ lastPointerMoveEvent: event }); + this.getActiveMode().handlePointerMove(event, this.getModeProps(this.props)); + }; + EditableGeoJsonLayer.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + var cursor = this.state.cursor; + if (!cursor) { + // default cursor + cursor = isDragging ? 'grabbing' : 'grab'; + } + return cursor; + }; + EditableGeoJsonLayer.prototype.getActiveMode = function () { + return this.state.mode; + }; + EditableGeoJsonLayer.layerName = 'EditableGeoJsonLayer'; + EditableGeoJsonLayer.defaultProps = defaultProps; + return EditableGeoJsonLayer; +}(EditableLayer)); +export default EditableGeoJsonLayer; +//# sourceMappingURL=editable-geojson-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-geojson-layer.js.map b/lib/modules/layers/src/layers/editable-geojson-layer.js.map new file mode 100644 index 000000000..1fdb5b96b --- /dev/null +++ b/lib/modules/layers/src/layers/editable-geojson-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editable-geojson-layer.js","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/editable-geojson-layer.ts"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,EACzB,aAAa,EACb,aAAa,GASd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,aAAa,MAAM,kBA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AAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,wCAAS,GAAT,UAAU,EAAuC;YAArC,0BAAU;QACd,IAAA,0BAAM,CAAgB;QAC5B,IAAI,CAAC,MAAM,EAAE;YACX,iBAAiB;YACjB,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;SAC3C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,4CAAa,GAAb;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAlRM,8BAAS,GAAG,sBAAsB,CAAC;IACnC,iCAAY,GAAG,YAAY,CAAC;IAkRrC,2BAAC;CAAA,AApRD,CAAkD,aAAa,GAoR9D;eApRoB,oBAAoB"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-layer.d.ts b/lib/modules/layers/src/layers/editable-layer.d.ts new file mode 100644 index 000000000..2d8ef42f2 --- /dev/null +++ b/lib/modules/layers/src/layers/editable-layer.d.ts @@ -0,0 +1,27 @@ +/// +import { CompositeLayer } from '@deck.gl/core'; +import { ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, PointerMoveEvent, DoubleClickEvent } from '@nebula.gl/edit-modes'; +export default class EditableLayer extends CompositeLayer { + static layerName: string; + onLayerClick(event: ClickEvent): void; + onDoubleClick(event: DoubleClickEvent): void; + onStartDragging(event: StartDraggingEvent): void; + onStopDragging(event: StopDraggingEvent): void; + onDragging(event: DraggingEvent): void; + onPointerMove(event: PointerMoveEvent): void; + initializeState(): void; + finalizeState(): void; + _addPointerHandlers(): void; + _removePointerHandlers(): void; + _forwardEventToCurrentLayer(event: any): void; + _onanyclick({ srcEvent }: any): void; + _ondblclick({ srcEvent }: any): void; + _onpanstart(event: any): void; + _onpanmove(event: any): void; + _onpanend({ srcEvent }: any): void; + _onpointermove(event: any): void; + getPicks(screenCoords: [number, number]): any; + getScreenCoords(pointerEvent: any): number[]; + getMapCoords(screenCoords: number[]): any; +} +//# sourceMappingURL=editable-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-layer.d.ts.map b/lib/modules/layers/src/layers/editable-layer.d.ts.map new file mode 100644 index 000000000..c6876b75c --- /dev/null +++ b/lib/modules/layers/src/layers/editable-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"editable-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/editable-layer.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc,CAAC,GAAG,CAAC;IAC5D,MAAM,CAAC,SAAS,SAAmB;IAEnC,YAAY,CAAC,KAAK,EAAE,UAAU;IAI9B,aAAa,CAAC,KAAK,EAAE,gBAAgB;IAIrC,eAAe,CAAC,KAAK,EAAE,kBAAkB;IAIzC,cAAc,CAAC,KAAK,EAAE,iBAAiB;IAIvC,UAAU,CAAC,KAAK,EAAE,aAAa;IAI/B,aAAa,CAAC,KAAK,EAAE,gBAAgB;IAGrC,eAAe;IAkBf,aAAa;IAIb,mBAAmB;IAanB,sBAAsB;IAatB,2BAA2B,CAAC,KAAK,EAAE,GAAG;IAYtC,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG;IAe7B,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG;IAe7B,WAAW,CAAC,KAAK,EAAE,GAAG;IA6BtB,UAAU,CAAC,KAAK,EAAE,GAAG;IA+BrB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG;IAiC3B,cAAc,CAAC,KAAK,EAAE,GAAG;IAyBzB,QAAQ,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IAWvC,eAAe,CAAC,YAAY,EAAE,GAAG;IASjC,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE;CAIpC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-layer.js b/lib/modules/layers/src/layers/editable-layer.js new file mode 100644 index 000000000..c498cc006 --- /dev/null +++ b/lib/modules/layers/src/layers/editable-layer.js @@ -0,0 +1,233 @@ +/* eslint-env browser */ +import { __assign, __extends, __values } from "tslib"; +import { CompositeLayer } from '@deck.gl/core'; +var EVENT_TYPES = ['anyclick', 'pointermove', 'panstart', 'panmove', 'panend', 'dblclick']; +var EditableLayer = /** @class */ (function (_super) { + __extends(EditableLayer, _super); + function EditableLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + // Overridable interaction event handlers + EditableLayer.prototype.onLayerClick = function (event) { + // default implementation - do nothing + }; + EditableLayer.prototype.onDoubleClick = function (event) { + // default implementation - do nothing + }; + EditableLayer.prototype.onStartDragging = function (event) { + // default implementation - do nothing + }; + EditableLayer.prototype.onStopDragging = function (event) { + // default implementation - do nothing + }; + EditableLayer.prototype.onDragging = function (event) { + // default implementation - do nothing + }; + EditableLayer.prototype.onPointerMove = function (event) { }; // default implementation - do nothing + // TODO: implement onCancelDragging (e.g. drag off screen) + EditableLayer.prototype.initializeState = function () { + this.setState({ + _editableLayerState: { + // Picked objects at the time the pointer went down + pointerDownPicks: null, + // Screen coordinates where the pointer went down + pointerDownScreenCoords: null, + // Ground coordinates where the pointer went down + pointerDownMapCoords: null, + // Keep track of the mjolnir.js event handler so it can be deregistered + eventHandler: this._forwardEventToCurrentLayer.bind(this), + }, + }); + this._addPointerHandlers(); + }; + EditableLayer.prototype.finalizeState = function () { + this._removePointerHandlers(); + }; + EditableLayer.prototype._addPointerHandlers = function () { + var e_1, _a; + // @ts-ignore + var eventManager = this.context.deck.eventManager; + var eventHandler = this.state._editableLayerState.eventHandler; + try { + for (var EVENT_TYPES_1 = __values(EVENT_TYPES), EVENT_TYPES_1_1 = EVENT_TYPES_1.next(); !EVENT_TYPES_1_1.done; EVENT_TYPES_1_1 = EVENT_TYPES_1.next()) { + var eventType = EVENT_TYPES_1_1.value; + eventManager.on(eventType, eventHandler, { + // give nebula a higher priority so that it can stop propagation to deck.gl's map panning handlers + priority: 100, + }); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (EVENT_TYPES_1_1 && !EVENT_TYPES_1_1.done && (_a = EVENT_TYPES_1.return)) _a.call(EVENT_TYPES_1); + } + finally { if (e_1) throw e_1.error; } + } + }; + EditableLayer.prototype._removePointerHandlers = function () { + var e_2, _a; + // @ts-ignore + var eventManager = this.context.deck.eventManager; + var eventHandler = this.state._editableLayerState.eventHandler; + try { + for (var EVENT_TYPES_2 = __values(EVENT_TYPES), EVENT_TYPES_2_1 = EVENT_TYPES_2.next(); !EVENT_TYPES_2_1.done; EVENT_TYPES_2_1 = EVENT_TYPES_2.next()) { + var eventType = EVENT_TYPES_2_1.value; + eventManager.off(eventType, eventHandler); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (EVENT_TYPES_2_1 && !EVENT_TYPES_2_1.done && (_a = EVENT_TYPES_2.return)) _a.call(EVENT_TYPES_2); + } + finally { if (e_2) throw e_2.error; } + } + }; + // A new layer instance is created on every render, so forward the event to the current layer + // This means that the first layer instance will stick around to be the event listener, but will forward the event + // to the latest layer instance. + EditableLayer.prototype._forwardEventToCurrentLayer = function (event) { + var currentLayer = this.getCurrentLayer(); + // Use a naming convention to find the event handling function for this event type + var func = currentLayer["_on" + event.type].bind(currentLayer); + if (!func) { + console.warn("no handler for mjolnir.js event " + event.type); // eslint-disable-line + return; + } + func(event); + }; + EditableLayer.prototype._onanyclick = function (_a) { + var srcEvent = _a.srcEvent; + var screenCoords = this.getScreenCoords(srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.onLayerClick({ + mapCoords: mapCoords, + // @ts-ignore + screenCoords: screenCoords, + picks: picks, + sourceEvent: srcEvent, + }); + }; + EditableLayer.prototype._ondblclick = function (_a) { + var srcEvent = _a.srcEvent; + var screenCoords = this.getScreenCoords(srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.onDoubleClick({ + mapCoords: mapCoords, + // @ts-ignore + screenCoords: screenCoords, + picks: picks, + sourceEvent: srcEvent, + }); + }; + EditableLayer.prototype._onpanstart = function (event) { + var screenCoords = this.getScreenCoords(event.srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.setState({ + _editableLayerState: __assign(__assign({}, this.state._editableLayerState), { pointerDownScreenCoords: screenCoords, pointerDownMapCoords: mapCoords, pointerDownPicks: picks }), + }); + this.onStartDragging({ + picks: picks, + // @ts-ignore + screenCoords: screenCoords, + // @ts-ignore + mapCoords: mapCoords, + // @ts-ignore + pointerDownScreenCoords: screenCoords, + pointerDownMapCoords: mapCoords, + cancelPan: event.stopImmediatePropagation, + sourceEvent: event.srcEvent, + }); + }; + EditableLayer.prototype._onpanmove = function (event) { + var srcEvent = event.srcEvent; + var screenCoords = this.getScreenCoords(srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + var _a = this.state._editableLayerState, pointerDownPicks = _a.pointerDownPicks, pointerDownScreenCoords = _a.pointerDownScreenCoords, pointerDownMapCoords = _a.pointerDownMapCoords; + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.onDragging({ + // @ts-ignore + screenCoords: screenCoords, + mapCoords: mapCoords, + picks: picks, + pointerDownPicks: pointerDownPicks, + pointerDownScreenCoords: pointerDownScreenCoords, + pointerDownMapCoords: pointerDownMapCoords, + sourceEvent: srcEvent, + cancelPan: event.stopImmediatePropagation, + }); + }; + EditableLayer.prototype._onpanend = function (_a) { + var srcEvent = _a.srcEvent; + var screenCoords = this.getScreenCoords(srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + var _b = this.state._editableLayerState, pointerDownPicks = _b.pointerDownPicks, pointerDownScreenCoords = _b.pointerDownScreenCoords, pointerDownMapCoords = _b.pointerDownMapCoords; + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.onStopDragging({ + picks: picks, + // @ts-ignore + screenCoords: screenCoords, + mapCoords: mapCoords, + pointerDownPicks: pointerDownPicks, + pointerDownScreenCoords: pointerDownScreenCoords, + pointerDownMapCoords: pointerDownMapCoords, + sourceEvent: srcEvent, + }); + this.setState({ + _editableLayerState: __assign(__assign({}, this.state._editableLayerState), { pointerDownScreenCoords: null, pointerDownMapCoords: null, pointerDownPicks: null }), + }); + }; + EditableLayer.prototype._onpointermove = function (event) { + var srcEvent = event.srcEvent; + var screenCoords = this.getScreenCoords(srcEvent); + var mapCoords = this.getMapCoords(screenCoords); + var _a = this.state._editableLayerState, pointerDownPicks = _a.pointerDownPicks, pointerDownScreenCoords = _a.pointerDownScreenCoords, pointerDownMapCoords = _a.pointerDownMapCoords; + // @ts-ignore + var picks = this.getPicks(screenCoords); + this.onPointerMove({ + // @ts-ignore + screenCoords: screenCoords, + mapCoords: mapCoords, + picks: picks, + pointerDownPicks: pointerDownPicks, + pointerDownScreenCoords: pointerDownScreenCoords, + pointerDownMapCoords: pointerDownMapCoords, + sourceEvent: srcEvent, + }); + }; + EditableLayer.prototype.getPicks = function (screenCoords) { + // @ts-ignore + return this.context.deck.pickMultipleObjects({ + x: screenCoords[0], + y: screenCoords[1], + layerIds: [this.props.id], + radius: this.props.pickingRadius, + depth: this.props.pickingDepth, + }); + }; + EditableLayer.prototype.getScreenCoords = function (pointerEvent) { + return [ + pointerEvent.clientX - + this.context.gl.canvas.getBoundingClientRect().x, + pointerEvent.clientY - + this.context.gl.canvas.getBoundingClientRect().y, + ]; + }; + EditableLayer.prototype.getMapCoords = function (screenCoords) { + // @ts-ignore + return this.context.viewport.unproject([screenCoords[0], screenCoords[1]]); + }; + EditableLayer.layerName = 'EditableLayer'; + return EditableLayer; +}(CompositeLayer)); +export default EditableLayer; +//# sourceMappingURL=editable-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/editable-layer.js.map b/lib/modules/layers/src/layers/editable-layer.js.map new file mode 100644 index 000000000..345208fd1 --- /dev/null +++ b/lib/modules/layers/src/layers/editable-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editable-layer.js","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/editable-layer.ts"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAU/C,IAAM,WAAW,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAE7F;IAA2C,iCAAmB;IAA9D;;IAkQA,CAAC;IAhQC,yCAAyC;IACzC,oCAAY,GAAZ,UAAa,KAAiB;QAC5B,sCAAsC;IACxC,CAAC;IAED,qCAAa,GAAb,UAAc,KAAuB;QACnC,sCAAsC;IACxC,CAAC;IAED,uCAAe,GAAf,UAAgB,KAAyB;QACvC,sCAAsC;IACxC,CAAC;IAED,sCAAc,GAAd,UAAe,KAAwB;QACrC,sCAAsC;IACxC,CAAC;IAED,kCAAU,GAAV,UAAW,KAAoB;QAC7B,sCAAsC;IACxC,CAAC;IAED,qCAAa,GAAb,UAAc,KAAuB,IAAG,CAAC,EAAC,sCAAsC;IAChF,0DAA0D;IAE1D,uCAAe,GAAf;QACE,IAAI,CAAC,QAAQ,CAAC;YACZ,mBAAmB,EAAE;gBACnB,mDAAmD;gBACnD,gBAAgB,EAAE,IAAI;gBACtB,iDAAiD;gBACjD,uBAAuB,EAAE,IAAI;gBAC7B,iDAAiD;gBACjD,oBAAoB,EAAE,IAAI;gBAE1B,uEAAuE;gBACvE,YAAY,EAAE,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC;aAC1D;SACF,CAAC,CAAC;QAEH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QAC/B,OAAO;YACL,YAAY,CAAC,OAAO;gBACjB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAA4B,CAAC,qBAAqB,EAAE,CAAC,CAAC;YACzE,YAAY,CAAC,OAAO;gBACjB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAA4B,CAAC,qBAAqB,EAAE,CAAC,CAAC;SAC1E,CAAC;IACJ,CAAC;IAED,oCAAY,GAAZ,UAAa,YAAsB;QACjC,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAhQM,uBAAS,GAAG,eAAe,CAAC;IAiQrC,oBAAC;CAAA,AAlQD,CAA2C,cAAc,GAkQxD;eAlQoB,aAAa"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts b/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts new file mode 100644 index 000000000..cccf423bc --- /dev/null +++ b/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts @@ -0,0 +1,9 @@ +/// +import { CompositeLayer } from '@deck.gl/core'; +import { ScatterplotLayer, LineLayer } from '@deck.gl/layers'; +export default class ElevatedEditHandleLayer extends CompositeLayer { + static layerName: string; + static defaultProps: {}; + renderLayers(): (ScatterplotLayer | LineLayer)[]; +} +//# sourceMappingURL=elevated-edit-handle-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts.map b/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts.map new file mode 100644 index 000000000..a12994ac8 --- /dev/null +++ b/lib/modules/layers/src/layers/elevated-edit-handle-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"elevated-edit-handle-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/elevated-edit-handle-layer.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,cAAc,CAAC,GAAG,CAAC;IACtE,MAAM,CAAC,SAAS,SAA6B;IAC7C,MAAM,CAAC,YAAY,KAAgB;IACnC,YAAY;CAsBb"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/elevated-edit-handle-layer.js b/lib/modules/layers/src/layers/elevated-edit-handle-layer.js new file mode 100644 index 000000000..e22838e15 --- /dev/null +++ b/lib/modules/layers/src/layers/elevated-edit-handle-layer.js @@ -0,0 +1,38 @@ +/* eslint-env browser */ +import { __extends } from "tslib"; +import { CompositeLayer } from '@deck.gl/core'; +import { ScatterplotLayer, LineLayer } from '@deck.gl/layers'; +var defaultProps = {}; +var ElevatedEditHandleLayer = /** @class */ (function (_super) { + __extends(ElevatedEditHandleLayer, _super); + function ElevatedEditHandleLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + ElevatedEditHandleLayer.prototype.renderLayers = function () { + var handles = new ScatterplotLayer(Object.assign({}, this.props, { + id: this.props.id + "-ScatterplotLayer", + data: this.props.data, + })); + var lines = new LineLayer(Object.assign({}, this.props, { + id: this.props.id + "-LineLayer", + data: this.props.data, + pickable: false, + getSourcePosition: function (_a) { + var position = _a.position; + return [position[0], position[1], 0]; + }, + getTargetPosition: function (_a) { + var position = _a.position; + return [position[0], position[1], position[2] || 0]; + }, + getColor: [150, 150, 150, 200], + getStrokeWidth: 3, + })); + return [handles, lines]; + }; + ElevatedEditHandleLayer.layerName = 'ElevatedEditHandleLayer'; + ElevatedEditHandleLayer.defaultProps = defaultProps; + return ElevatedEditHandleLayer; +}(CompositeLayer)); +export default ElevatedEditHandleLayer; +//# sourceMappingURL=elevated-edit-handle-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/elevated-edit-handle-layer.js.map b/lib/modules/layers/src/layers/elevated-edit-handle-layer.js.map new file mode 100644 index 000000000..283d87e73 --- /dev/null +++ b/lib/modules/layers/src/layers/elevated-edit-handle-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"elevated-edit-handle-layer.js","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/elevated-edit-handle-layer.ts"],"names":[],"mappings":"AAAA,wBAAwB;;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,IAAM,YAAY,GAAG,EAAE,CAAC;AAExB;IAAqD,2CAAmB;IAAxE;;IAyBA,CAAC;IAtBC,8CAAY,GAAZ;QACE,IAAM,OAAO,GAAG,IAAI,gBAAgB,CAClC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE;YAC5B,EAAE,EAAK,IAAI,CAAC,KAAK,CAAC,EAAE,sBAAmB;YACvC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;SACtB,CAAC,CACH,CAAC;QAEF,IAAM,KAAK,GAAG,IAAI,SAAS,CACzB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE;YAC5B,EAAE,EAAK,IAAI,CAAC,KAAK,CAAC,EAAE,eAAY;YAChC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,UAAC,EAAY;oBAAV,sBAAQ;gBAAO,OAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAA7B,CAA6B;YAClE,iBAAiB,EAAE,UAAC,EAAY;oBAAV,sBAAQ;gBAAO,OAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAA5C,CAA4C;YACjF,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;YAC9B,cAAc,EAAE,CAAC;SAClB,CAAC,CACH,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;IAvBM,iCAAS,GAAG,yBAAyB,CAAC;IACtC,oCAAY,GAAG,YAAY,CAAC;IAuBrC,8BAAC;CAAA,AAzBD,CAAqD,cAAc,GAyBlE;eAzBoB,uBAAuB"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts b/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts new file mode 100644 index 000000000..677297556 --- /dev/null +++ b/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts @@ -0,0 +1,9 @@ +/// +import { CompositeLayer } from '@deck.gl/core'; +import { ScatterplotLayer } from '@deck.gl/layers'; +export default class JunctionScatterplotLayer extends CompositeLayer { + static layerName: string; + static defaultProps: any; + renderLayers(): ScatterplotLayer[]; +} +//# sourceMappingURL=junction-scatterplot-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts.map b/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts.map new file mode 100644 index 000000000..d081f94d6 --- /dev/null +++ b/lib/modules/layers/src/layers/junction-scatterplot-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"junction-scatterplot-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/junction-scatterplot-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,cAAc,CAAC,GAAG,CAAC;IACvE,MAAM,CAAC,SAAS,SAA8B;IAC9C,MAAM,CAAC,YAAY,MAMjB;IAEF,YAAY;CA+Bb"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/junction-scatterplot-layer.js b/lib/modules/layers/src/layers/junction-scatterplot-layer.js new file mode 100644 index 000000000..1f26ffdeb --- /dev/null +++ b/lib/modules/layers/src/layers/junction-scatterplot-layer.js @@ -0,0 +1,23 @@ +import { __assign, __extends } from "tslib"; +import { CompositeLayer } from '@deck.gl/core'; +import { ScatterplotLayer } from '@deck.gl/layers'; +var JunctionScatterplotLayer = /** @class */ (function (_super) { + __extends(JunctionScatterplotLayer, _super); + function JunctionScatterplotLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + JunctionScatterplotLayer.prototype.renderLayers = function () { + var _a = this.props, id = _a.id, getFillColor = _a.getFillColor, getStrokeColor = _a.getStrokeColor, getInnerRadius = _a.getInnerRadius, updateTriggers = _a.updateTriggers; + // data needs to be passed explicitly after deck.gl 5.3 + return [ + // the full circles + new ScatterplotLayer(__assign(__assign({}, this.props), { id: id + "-full", data: this.props.data, getLineColor: getStrokeColor, updateTriggers: __assign(__assign({}, updateTriggers), { getStrokeColor: updateTriggers.getStrokeColor }) })), + new ScatterplotLayer(__assign(__assign({}, this.props), { id: id + "-inner", data: this.props.data, getFillColor: getFillColor, getRadius: getInnerRadius, pickable: false, updateTriggers: __assign(__assign({}, updateTriggers), { getFillColor: updateTriggers.getFillColor, getRadius: updateTriggers.getInnerRadius }) })), + ]; + }; + JunctionScatterplotLayer.layerName = 'JunctionScatterplotLayer'; + JunctionScatterplotLayer.defaultProps = __assign(__assign({}, ScatterplotLayer.defaultProps), { getFillColor: function (d) { return [0, 0, 0, 255]; }, getStrokeColor: function (d) { return [255, 255, 255, 255]; }, getInnerRadius: function (d) { return 1; } }); + return JunctionScatterplotLayer; +}(CompositeLayer)); +export default JunctionScatterplotLayer; +//# sourceMappingURL=junction-scatterplot-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/junction-scatterplot-layer.js.map b/lib/modules/layers/src/layers/junction-scatterplot-layer.js.map new file mode 100644 index 000000000..032c00366 --- /dev/null +++ b/lib/modules/layers/src/layers/junction-scatterplot-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"junction-scatterplot-layer.js","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/junction-scatterplot-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;IAAsD,4CAAmB;IAAzE;;IAyCA,CAAC;IA/BC,+CAAY,GAAZ;QACQ,IAAA,eAAiF,EAA/E,UAAE,EAAE,8BAAY,EAAE,kCAAc,EAAE,kCAAc,EAAE,kCAA6B,CAAC;QAExF,uDAAuD;QACvD,OAAO;YACL,mBAAmB;YACnB,IAAI,gBAAgB,uBACf,IAAI,CAAC,KAAK,KACb,EAAE,EAAK,EAAE,UAAO,EAChB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,YAAY,EAAE,cAAc,EAC5B,cAAc,wBACT,cAAc,KACjB,cAAc,EAAE,cAAc,CAAC,cAAc,OAE/C;YACF,IAAI,gBAAgB,uBACf,IAAI,CAAC,KAAK,KACb,EAAE,EAAK,EAAE,WAAQ,EACjB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,YAAY,cAAA,EACZ,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,KAAK,EACf,cAAc,wBACT,cAAc,KACjB,YAAY,EAAE,cAAc,CAAC,YAAY,EACzC,SAAS,EAAE,cAAc,CAAC,cAAc,OAE1C;SACH,CAAC;IACJ,CAAC;IAvCM,kCAAS,GAAG,0BAA0B,CAAC;IACvC,qCAAY,yBAEd,gBAAgB,CAAC,YAAY,KAChC,YAAY,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAd,CAAc,EACnC,cAAc,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAApB,CAAoB,EAC3C,cAAc,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,IACxB;IAiCJ,+BAAC;CAAA,AAzCD,CAAsD,cAAc,GAyCnE;eAzCoB,wBAAwB"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts new file mode 100644 index 000000000..12e4922ad --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts @@ -0,0 +1,6 @@ +/// +import { Geometry } from '@luma.gl/core'; +export default class Arrow2DGeometry extends Geometry { + constructor(opts?: {}); +} +//# sourceMappingURL=arrow-2d-geometry.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts.map b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts.map new file mode 100644 index 000000000..9d4d8b5ea --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"arrow-2d-geometry.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,QAAQ;gBACvC,IAAI,KAAK;CAOtB"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js new file mode 100644 index 000000000..e320fad77 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js @@ -0,0 +1,61 @@ +import { __extends } from "tslib"; +import { Geometry } from '@luma.gl/core'; +var Arrow2DGeometry = /** @class */ (function (_super) { + __extends(Arrow2DGeometry, _super); + function Arrow2DGeometry(opts) { + if (opts === void 0) { opts = {}; } + return _super.call(this, Object.assign({}, opts, { + attributes: getArrowAttributes(opts), + })) || this; + } + return Arrow2DGeometry; +}(Geometry)); +export default Arrow2DGeometry; +function getArrowAttributes(_a) { + var _b = _a.length, length = _b === void 0 ? 1 : _b, _c = _a.headSize, headSize = _c === void 0 ? 0.2 : _c, _d = _a.tailWidth, tailWidth = _d === void 0 ? 0.05 : _d, _e = _a.tailStart, tailStart = _e === void 0 ? 0.05 : _e; + var texCoords = [ + // HEAD + 0.5, + 1.0, + 0, + 0.5 - headSize / 2, + 1.0 - headSize, + 0, + 0.5 + headSize / 2, + 1.0 - headSize, + 0, + 0.5 - tailWidth / 2, + tailStart, + 0, + 0.5 + tailWidth / 2, + 1.0 - headSize, + 0, + 0.5 + tailWidth / 2, + tailStart, + 0, + 0.5 - tailWidth / 2, + tailStart, + 0, + 0.5 - tailWidth / 2, + 1.0 - headSize, + 0, + 0.5 + tailWidth / 2, + 1.0 - headSize, + 0, + ]; + var normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]; + // Center and scale + var positions = new Array(texCoords.length); + for (var i = 0; i < texCoords.length / 3; i++) { + var i3 = i * 3; + positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length; + positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length; + positions[i3 + 2] = 0; + } + return { + positions: new Float32Array(positions), + normals: new Float32Array(normals), + texCoords: new Float32Array(texCoords), + }; +} +//# sourceMappingURL=arrow-2d-geometry.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js.map b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js.map new file mode 100644 index 000000000..9641fa837 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.js.map @@ -0,0 +1 @@ +{"version":3,"file":"arrow-2d-geometry.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/arrow-2d-geometry.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;IAA6C,mCAAQ;IACnD,yBAAY,IAAS;QAAT,qBAAA,EAAA,SAAS;eACnB,kBACE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE;YACtB,UAAU,EAAE,kBAAkB,CAAC,IAAI,CAAC;SACrC,CAAC,CACH;IACH,CAAC;IACH,sBAAC;AAAD,CAAC,AARD,CAA6C,QAAQ,GAQpD;;AAED,SAAS,kBAAkB,CAAC,EAAkE;QAAhE,cAAU,EAAV,+BAAU,EAAE,gBAAc,EAAd,mCAAc,EAAE,iBAAgB,EAAhB,qCAAgB,EAAE,iBAAgB,EAAhB,qCAAgB;IAC1F,IAAM,SAAS,GAAG;QAChB,OAAO;QACP,GAAG;QACH,GAAG;QACH,CAAC;QACD,GAAG,GAAG,QAAQ,GAAG,CAAC;QAClB,GAAG,GAAG,QAAQ;QACd,CAAC;QACD,GAAG,GAAG,QAAQ,GAAG,CAAC;QAClB,GAAG,GAAG,QAAQ;QACd,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,SAAS;QACT,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,GAAG,GAAG,QAAQ;QACd,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,SAAS;QACT,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,SAAS;QACT,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,GAAG,GAAG,QAAQ;QACd,CAAC;QACD,GAAG,GAAG,SAAS,GAAG,CAAC;QACnB,GAAG,GAAG,QAAQ;QACd,CAAC;KACF,CAAC;IAEF,IAAM,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAElG,mBAAmB;IACnB,IAAM,SAAS,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7C,IAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;QACvD,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;QACvD,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;KACvB;IACD,OAAO;QACL,SAAS,EAAE,IAAI,YAAY,CAAC,SAAS,CAAC;QACtC,OAAO,EAAE,IAAI,YAAY,CAAC,OAAO,CAAC;QAClC,SAAS,EAAE,IAAI,YAAY,CAAC,SAAS,CAAC;KACvC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts new file mode 100644 index 000000000..e8bdca148 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts @@ -0,0 +1,9 @@ +export default function createPathMarkers({ data, getPath, getDirection, getColor, getMarkerPercentages, projectFlat, }: { + data: any; + getPath?: (x: any) => any; + getDirection?: (x: any) => any; + getColor?: (x: any) => number[]; + getMarkerPercentages?: (x: any) => number[]; + projectFlat: any; +}): any[]; +//# sourceMappingURL=create-path-markers.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts.map b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts.map new file mode 100644 index 000000000..1cd04c25a --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"create-path-markers.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/create-path-markers.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,IAAI,EACJ,OAAuB,EACvB,YAAiC,EACjC,QAA+B,EAC/B,oBAAmC,EACnC,WAAW,GACZ;;;;;;;CAAA,SA+CA"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js new file mode 100644 index 000000000..ac7e4a432 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js @@ -0,0 +1,96 @@ +import { __values } from "tslib"; +import { Vector2 } from 'math.gl'; +function getLineLength(vPoints) { + // calculate total length + var lineLength = 0; + for (var i = 0; i < vPoints.length - 1; i++) { + lineLength += vPoints[i].distance(vPoints[i + 1]); + } + return lineLength; +} +var DEFAULT_COLOR = [0, 0, 0, 255]; +var DEFAULT_DIRECTION = { forward: true, backward: false }; +export default function createPathMarkers(_a) { + var e_1, _b, e_2, _c; + var data = _a.data, _d = _a.getPath, getPath = _d === void 0 ? function (x) { return x.path; } : _d, _e = _a.getDirection, getDirection = _e === void 0 ? function (x) { return x.direction; } : _e, _f = _a.getColor, getColor = _f === void 0 ? function (x) { return DEFAULT_COLOR; } : _f, _g = _a.getMarkerPercentages, getMarkerPercentages = _g === void 0 ? function (x) { return [0.5]; } : _g, projectFlat = _a.projectFlat; + var markers = []; + try { + for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) { + var object = data_1_1.value; + var path = getPath(object); + var direction = getDirection(object) || DEFAULT_DIRECTION; + var color = getColor(object); + var vPoints = path.map(function (p) { return new Vector2(p); }); + var vPointsReverse = vPoints.slice(0).reverse(); + // calculate total length + var lineLength = getLineLength(vPoints); + // Ask for where to put markers + // @ts-ignore + var percentages = getMarkerPercentages(object, { lineLength: lineLength }); + try { + // Create the markers + for (var percentages_1 = (e_2 = void 0, __values(percentages)), percentages_1_1 = percentages_1.next(); !percentages_1_1.done; percentages_1_1 = percentages_1.next()) { + var percentage = percentages_1_1.value; + if (direction.forward) { + var marker = createMarkerAlongPath({ + path: vPoints, + percentage: percentage, + lineLength: lineLength, + color: color, + object: object, + projectFlat: projectFlat, + }); + markers.push(marker); + } + if (direction.backward) { + var marker = createMarkerAlongPath({ + path: vPointsReverse, + percentage: percentage, + lineLength: lineLength, + color: color, + object: object, + projectFlat: projectFlat, + }); + markers.push(marker); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (percentages_1_1 && !percentages_1_1.done && (_c = percentages_1.return)) _c.call(percentages_1); + } + finally { if (e_2) throw e_2.error; } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (data_1_1 && !data_1_1.done && (_b = data_1.return)) _b.call(data_1); + } + finally { if (e_1) throw e_1.error; } + } + return markers; +} +function createMarkerAlongPath(_a) { + var path = _a.path, percentage = _a.percentage, lineLength = _a.lineLength, color = _a.color, object = _a.object, projectFlat = _a.projectFlat; + var distanceAlong = lineLength * percentage; + var currentDistance = 0; + var previousDistance = 0; + var i = 0; + for (i = 0; i < path.length - 1; i++) { + currentDistance += path[i].distance(path[i + 1]); + if (currentDistance > distanceAlong) { + break; + } + previousDistance = currentDistance; + } + var vDirection = path[i + 1].clone().subtract(path[i]).normalize(); + var along = distanceAlong - previousDistance; + var vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]); + var vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i])); + var angle = (-vDirection2.verticalAngle() * 180) / Math.PI; + return { position: [vCenter.x, vCenter.y, 0], angle: angle, color: color, object: object }; +} +//# sourceMappingURL=create-path-markers.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js.map b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js.map new file mode 100644 index 000000000..be422049a --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/create-path-markers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"create-path-markers.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/create-path-markers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,SAAS,aAAa,CAAC,OAAO;IAC5B,yBAAyB;IACzB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3C,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACnD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,IAAM,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AACrC,IAAM,iBAAiB,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAE7D,MAAM,CAAC,OAAO,UAAU,iBAAi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C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpF,IAAM,WAAW,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,IAAM,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;IAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,CAAC;AACvE,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts new file mode 100644 index 000000000..4df84bd42 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts @@ -0,0 +1,42 @@ +/// +import { CompositeLayer } from '@deck.gl/core'; +import { SimpleMeshLayer } from '@deck.gl/mesh-layers'; +import Arrow2DGeometry from './arrow-2d-geometry'; +export default class PathMarkerLayer extends CompositeLayer { + static layerName: string; + static defaultProps: { + getZLevel: { + type: string; + value: number; + }; + } & { + MarkerLayer: typeof SimpleMeshLayer; + markerLayerProps: { + mesh: Arrow2DGeometry; + }; + sizeScale: number; + fp64: boolean; + hightlightIndex: number; + highlightPoint: any; + getPath: (x: any) => any; + getColor: (x: any) => any; + getMarkerColor: (x: any) => number[]; + getDirection: (x: any) => any; + getMarkerPercentages: (object: any, { lineLength }: { + lineLength: any; + }) => number[]; + }; + initializeState(): void; + projectFlat(xyz: any, viewport: any, coordinateSystem: any, coordinateOrigin: any): any; + updateState({ props, oldProps, changeFlags }: { + props: any; + oldProps: any; + changeFlags: any; + }): void; + _recalculateClosestPoint(): void; + getPickingInfo({ info }: { + info: any; + }): any; + renderLayers(): any[]; +} +//# sourceMappingURL=path-marker-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts.map b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts.map new file mode 100644 index 000000000..7dc954066 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"path-marker-layer.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/path-marker-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAkClD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,cAAc,CAAC,GAAG,CAAC;IAC9D,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;MAAgB;IAEnC,eAAe;IAQf,WAAW,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA,EAAE,gBAAgB,KAAA,EAAE,gBAAgB,KAAA;IAc7D,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE;;;;KAAA;IA+B5C,wBAAwB;IAgBxB,cAAc,CAAC,EAAE,IAAI,EAAE;;KAAA;IAOvB,YAAY;CAqCb"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js new file mode 100644 index 000000000..41d4f825a --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js @@ -0,0 +1,142 @@ +import { __extends, __read } from "tslib"; +import { CompositeLayer, COORDINATE_SYSTEM } from '@deck.gl/core'; +import { ScatterplotLayer } from '@deck.gl/layers'; +import { SimpleMeshLayer } from '@deck.gl/mesh-layers'; +import PathOutlineLayer from '../path-outline-layer/path-outline-layer'; +import Arrow2DGeometry from './arrow-2d-geometry'; +import createPathMarkers from './create-path-markers'; +import { getClosestPointOnPolyline } from './polyline'; +var DISTANCE_FOR_MULTI_ARROWS = 0.1; +var ARROW_HEAD_SIZE = 0.2; +var ARROW_TAIL_WIDTH = 0.05; +// const ARROW_CENTER_ADJUST = -0.8; +var DEFAULT_MARKER_LAYER = SimpleMeshLayer; +var DEFAULT_MARKER_LAYER_PROPS = { + mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH }), +}; +var defaultProps = Object.assign({}, PathOutlineLayer.defaultProps, { + MarkerLayer: DEFAULT_MARKER_LAYER, + markerLayerProps: DEFAULT_MARKER_LAYER_PROPS, + sizeScale: 100, + fp64: false, + hightlightIndex: -1, + highlightPoint: null, + getPath: function (x) { return x.path; }, + getColor: function (x) { return x.color; }, + getMarkerColor: function (x) { return [0, 0, 0, 255]; }, + getDirection: function (x) { return x.direction; }, + getMarkerPercentages: function (object, _a) { + var lineLength = _a.lineLength; + return lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]; + }, +}); +var PathMarkerLayer = /** @class */ (function (_super) { + __extends(PathMarkerLayer, _super); + function PathMarkerLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + PathMarkerLayer.prototype.initializeState = function () { + this.state = { + markers: [], + mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH }), + closestPoint: null, + }; + }; + // @ts-ignore + PathMarkerLayer.prototype.projectFlat = function (xyz, viewport, coordinateSystem, coordinateOrigin) { + if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) { + var _a = __read(viewport.metersToLngLatDelta(xyz), 2), dx = _a[0], dy = _a[1]; + var _b = __read(coordinateOrigin, 2), x = _b[0], y = _b[1]; + return viewport.projectFlat([x + dx, dy + y]); + } + else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) { + var _c = __read(xyz, 2), dx = _c[0], dy = _c[1]; + var _d = __read(coordinateOrigin, 2), x = _d[0], y = _d[1]; + return viewport.projectFlat([x + dx, dy + y]); + } + return viewport.projectFlat(xyz); + }; + PathMarkerLayer.prototype.updateState = function (_a) { + var _this = this; + var props = _a.props, oldProps = _a.oldProps, changeFlags = _a.changeFlags; + if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) { + var _b = this.props, data = _b.data, getPath = _b.getPath, getDirection = _b.getDirection, getMarkerColor = _b.getMarkerColor, getMarkerPercentages = _b.getMarkerPercentages, coordinateSystem_1 = _b.coordinateSystem, coordinateOrigin_1 = _b.coordinateOrigin; + // @ts-ignore + var viewport_1 = this.context.viewport; + var projectFlat = function (o) { return _this.projectFlat(o, viewport_1, coordinateSystem_1, coordinateOrigin_1); }; + this.state.markers = createPathMarkers({ + data: data, + getPath: getPath, + getDirection: getDirection, + getColor: getMarkerColor, + getMarkerPercentages: getMarkerPercentages, + projectFlat: projectFlat, + }); + this._recalculateClosestPoint(); + } + if (changeFlags.propsChanged) { + if (props.point !== oldProps.point) { + this._recalculateClosestPoint(); + } + } + }; + PathMarkerLayer.prototype._recalculateClosestPoint = function () { + var _a = this.props, highlightPoint = _a.highlightPoint, highlightIndex = _a.highlightIndex; + if (highlightPoint && highlightIndex >= 0) { + var object = this.props.data[highlightIndex]; + var points = this.props.getPath(object); + var point = getClosestPointOnPolyline({ points: points, p: highlightPoint }).point; + this.state.closestPoints = [ + { + position: point, + }, + ]; + } + else { + this.state.closestPoints = []; + } + }; + PathMarkerLayer.prototype.getPickingInfo = function (_a) { + var info = _a.info; + return Object.assign(info, { + // override object with picked feature + object: (info.object && info.object.path) || info.object, + }); + }; + PathMarkerLayer.prototype.renderLayers = function () { + return [ + new PathOutlineLayer(this.props, + // @ts-ignore + this.getSubLayerProps({ + id: 'paths', + // Note: data has to be passed explicitly like this to avoid being empty + data: this.props.data, + })), + new this.props.MarkerLayer(this.getSubLayerProps(Object.assign({}, this.props.markerLayerProps, { + id: 'markers', + data: this.state.markers, + getOrientation: function (x) { return [0, -x.angle, 0]; }, + getColor: function (x) { return x.color; }, + sizeScale: this.props.sizeScale, + fp64: this.props.fp64, + pickable: false, + parameters: { + blend: false, + depthTest: false, + }, + }))), + this.state.closestPoints && + new ScatterplotLayer({ + id: this.props.id + "-highlight", + data: this.state.closestPoints, + // @ts-ignore + fp64: this.props.fp64, + }), + ]; + }; + PathMarkerLayer.layerName = 'PathMarkerLayer'; + PathMarkerLayer.defaultProps = defaultProps; + return PathMarkerLayer; +}(CompositeLayer)); +export default PathMarkerLayer; +//# sourceMappingURL=path-marker-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js.map b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js.map new file mode 100644 index 000000000..f1cd38e7a --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/path-marker-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"path-marker-layer.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/path-marker-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,gBAAgB,MAAM,0CAA0C,CAAC;AACxE,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAElD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,IAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,IAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,IAAM,gBAAgB,GAAG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AAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;aACtB,CAAC,CACH;YACD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CACxB,IAAI,CAAC,gBAAgB,CACnB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC7C,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;gBACxB,cAAc,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAhB,CAAgB;gBACvC,QAAQ,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,KAAK,EAAP,CAAO;gBACxB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC/B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;gBACrB,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE;oBACV,KAAK,EAAE,KAAK;oBACZ,SAAS,EAAE,KAAK;iBACjB;aACF,CAAC,CACH,CACF;YACD,IAAI,CAAC,KAAK,CAAC,aAAa;gBACtB,IAAI,gBAAgB,CAAC;oBACnB,EAAE,EAAK,IAAI,CAAC,KAAK,CAAC,EAAE,eAAY;oBAChC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa;oBAC9B,aAAa;oBACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;iBACtB,CAAC;SACL,CAAC;IACJ,CAAC;IAnHM,yBAAS,GAAG,iBAAiB,CAAC;IAC9B,4BAAY,GAAG,YAAY,CAAC;IAmHrC,sBAAC;CAAA,AArHD,CAA6C,cAAc,GAqH1D;eArHoB,eAAe"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts b/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts new file mode 100644 index 000000000..a33846d91 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts @@ -0,0 +1,18 @@ +export declare function getClosestPointOnLine({ p, p1, p2, clampToLine }: { + p: any; + p1: any; + p2: any; + clampToLine?: boolean; +}): any; +export declare function getClosestPointOnPolyline({ p, points }: { + p: any; + points: any; +}): { + point: any; + index: number; + p1: any; + p2: any; + distanceSquared: number; + distance: number; +}; +//# sourceMappingURL=polyline.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts.map b/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts.map new file mode 100644 index 000000000..696d33b1c --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/polyline.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"polyline.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/polyline.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,WAAkB,EAAE;;;;;CAAA,OAStE;AAGD,wBAAgB,yBAAyB,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE;;;CAAA;;;;;;;EAwBtD"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/polyline.js b/lib/modules/layers/src/layers/path-marker-layer/polyline.js new file mode 100644 index 000000000..a441a0fb1 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/polyline.js @@ -0,0 +1,41 @@ +import { Vector3, clamp } from 'math.gl'; +// Return the closest point on a line segment +export function getClosestPointOnLine(_a) { + var p = _a.p, p1 = _a.p1, p2 = _a.p2, _b = _a.clampToLine, clampToLine = _b === void 0 ? true : _b; + var lineVector = new Vector3(p2).subtract(p1); + var pointVector = new Vector3(p).subtract(p1); + var dotProduct = lineVector.dot(pointVector); + if (clampToLine) { + dotProduct = clamp(dotProduct, 0, 1); + } + // @ts-ignore + return lineVector.lerp(dotProduct); +} +// Return the closest point on a line segment +export function getClosestPointOnPolyline(_a) { + var p = _a.p, points = _a.points; + p = new Vector3(p); + var pClosest = null; + var distanceSquared = Infinity; + var index = -1; + for (var i = 0; i < points.length - 1; ++i) { + var p1 = points[i]; + var p2 = points[i + 1]; + var pClosestOnLine = getClosestPointOnLine({ p: p, p1: p1, p2: p2 }); + var distanceToLineSquared = p.distanceSquared(pClosestOnLine); + if (distanceToLineSquared < distanceSquared) { + distanceSquared = distanceToLineSquared; + pClosest = pClosestOnLine; + index = i; + } + } + return { + point: pClosest, + index: index, + p1: points[index], + p2: points[index + 1], + distanceSquared: distanceSquared, + distance: Math.sqrt(distanceSquared), + }; +} +//# sourceMappingURL=polyline.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-marker-layer/polyline.js.map b/lib/modules/layers/src/layers/path-marker-layer/polyline.js.map new file mode 100644 index 000000000..53ed1e616 --- /dev/null +++ b/lib/modules/layers/src/layers/path-marker-layer/polyline.js.map @@ -0,0 +1 @@ +{"version":3,"file":"polyline.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-marker-layer/polyline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEzC,6CAA6C;AAC7C,MAAM,UAAU,qBAAqB,CAAC,EAAiC;QAA/B,QAAC,EAAE,UAAE,EAAE,UAAE,EAAE,mBAAkB,EAAlB,uCAAkB;IACnE,IAAM,UAAU,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChD,IAAM,WAAW,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChD,IAAI,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,WAAW,EAAE;QACf,UAAU,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KACtC;IACD,aAAa;IACb,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,yBAAyB,CAAC,EAAa;QAAX,QAAC,EAAE,kBAAM;IACnD,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,IAAI,eAAe,GAAG,QAAQ,CAAC;IAC/B,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAC1C,IAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,IAAM,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACzB,IAAM,cAAc,GAAG,qBAAqB,CAAC,EAAE,CAAC,GAAA,EAAE,EAAE,IAAA,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC;QAC5D,IAAM,qBAAqB,GAAG,CAAC,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAChE,IAAI,qBAAqB,GAAG,eAAe,EAAE;YAC3C,eAAe,GAAG,qBAAqB,CAAC;YACxC,QAAQ,GAAG,cAAc,CAAC;YAC1B,KAAK,GAAG,CAAC,CAAC;SACX;KACF;IACD,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,KAAK,OAAA;QACL,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACrB,eAAe,iBAAA;QACf,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;KACrC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts new file mode 100644 index 000000000..5e6493f39 --- /dev/null +++ b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts @@ -0,0 +1,21 @@ +/// +import { PathLayer } from '@deck.gl/layers'; +export default class PathOutlineLayer extends PathLayer { + static layerName: string; + static defaultProps: { + getZLevel: { + type: string; + value: number; + }; + }; + getShaders(): any; + initializeState(context: any): void; + draw({ moduleParameters, parameters, uniforms, context }: { + moduleParameters?: {}; + parameters: any; + uniforms: any; + context: any; + }): void; + calculateZLevels(attribute: any): void; +} +//# sourceMappingURL=path-outline-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts.map b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts.map new file mode 100644 index 000000000..74fde5cf4 --- /dev/null +++ b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"path-outline-layer.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/layers/path-outline-layer/path-outline-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAwB5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,SAAS,CAAC,GAAG,CAAC;IAC1D,MAAM,CAAC,SAAS,SAAsB;IACtC,MAAM,CAAC,YAAY;;;;;MAAgB;IAGnC,UAAU;IASV,eAAe,CAAC,OAAO,EAAE,GAAG;IAsB5B,IAAI,CAAC,EAAE,gBAAqB,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE;;;;;KAAA;IA6D7D,gBAAgB,CAAC,SAAS,KAAA;CAU3B"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js new file mode 100644 index 000000000..9d5af4029 --- /dev/null +++ b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js @@ -0,0 +1,113 @@ +import { __extends } from "tslib"; +import { PathLayer } from '@deck.gl/layers'; +import GL from '@luma.gl/constants'; +import { Framebuffer, Texture2D } from '@luma.gl/core'; +import outline from '../../shaderlib/outline/outline'; +// TODO - this should be built into assembleShaders +function injectShaderCode(_a) { + var source = _a.source, _b = _a.code, code = _b === void 0 ? '' : _b; + var INJECT_CODE = /}[^{}]*$/; + return source.replace(INJECT_CODE, code.concat('\n}\n')); +} +var VS_CODE = " outline_setUV(gl_Position);\n outline_setZLevel(instanceZLevel);\n"; +var FS_CODE = " gl_FragColor = outline_filterColor(gl_FragColor);\n"; +var defaultProps = { + getZLevel: { type: 'accessor', value: 0 }, +}; +var PathOutlineLayer = /** @class */ (function (_super) { + __extends(PathOutlineLayer, _super); + function PathOutlineLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + // Override getShaders to inject the outline module + PathOutlineLayer.prototype.getShaders = function () { + var shaders = _super.prototype.getShaders.call(this); + return Object.assign({}, shaders, { + modules: shaders.modules.concat([outline]), + vs: injectShaderCode({ source: shaders.vs, code: VS_CODE }), + fs: injectShaderCode({ source: shaders.fs, code: FS_CODE }), + }); + }; + PathOutlineLayer.prototype.initializeState = function (context) { + _super.prototype.initializeState.call(this, context); + // Create an outline "shadow" map + // TODO - we should create a single outlineMap for all layers + this.setState({ + outlineFramebuffer: new Framebuffer(context.gl), + dummyTexture: new Texture2D(context.gl), + }); + // Create an attribute manager + this.state.attributeManager.addInstanced({ + instanceZLevel: { + size: 1, + type: GL.UNSIGNED_BYTE, + update: this.calculateZLevels, + accessor: 'getZLevel', + }, + }); + }; + // Override draw to add render module + PathOutlineLayer.prototype.draw = function (_a) { + var _b = _a.moduleParameters, moduleParameters = _b === void 0 ? {} : _b, parameters = _a.parameters, uniforms = _a.uniforms, context = _a.context; + // Need to calculate same uniforms as base layer + var _c = this.props, rounded = _c.rounded, miterLimit = _c.miterLimit, widthScale = _c.widthScale, widthMinPixels = _c.widthMinPixels, widthMaxPixels = _c.widthMaxPixels, dashJustified = _c.dashJustified; + uniforms = Object.assign({}, uniforms, { + jointType: Number(rounded), + alignMode: Number(dashJustified), + widthScale: widthScale, + miterLimit: miterLimit, + widthMinPixels: widthMinPixels, + widthMaxPixels: widthMaxPixels, + }); + // Render the outline shadowmap (based on segment z orders) + var _d = this.state, outlineFramebuffer = _d.outlineFramebuffer, dummyTexture = _d.dummyTexture; + outlineFramebuffer.resize(); + outlineFramebuffer.clear({ color: true, depth: true }); + this.state.model.updateModuleSettings({ + outlineEnabled: true, + outlineRenderShadowmap: true, + outlineShadowmap: dummyTexture, + }); + this.state.model.draw({ + uniforms: Object.assign({}, uniforms, { + jointType: 0, + widthScale: this.props.widthScale * 1.3, + }), + parameters: { + depthTest: false, + // Biggest value needs to go into buffer + blendEquation: GL.MAX, + }, + framebuffer: outlineFramebuffer, + }); + // Now use the outline shadowmap to render the lines (with outlines) + this.state.model.updateModuleSettings({ + outlineEnabled: true, + outlineRenderShadowmap: false, + outlineShadowmap: outlineFramebuffer, + }); + this.state.model.draw({ + uniforms: Object.assign({}, uniforms, { + jointType: Number(rounded), + widthScale: this.props.widthScale, + }), + parameters: { + depthTest: false, + }, + }); + }; + PathOutlineLayer.prototype.calculateZLevels = function (attribute) { + var getZLevel = this.props.getZLevel; + var pathTesselator = this.state.pathTesselator; + attribute.value = pathTesselator._updateAttribute({ + target: attribute.value, + size: 1, + getValue: function (object, index) { return [getZLevel(object, index) || 0]; }, + }); + }; + PathOutlineLayer.layerName = 'PathOutlineLayer'; + PathOutlineLayer.defaultProps = defaultProps; + return PathOutlineLayer; +}(PathLayer)); +export default PathOutlineLayer; +//# sourceMappingURL=path-outline-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js.map b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js.map new file mode 100644 index 000000000..b089aed1b --- /dev/null +++ b/lib/modules/layers/src/layers/path-outline-layer/path-outline-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"path-outline-layer.js","sourceRoot":"","sources":["../../../../../../modules/layers/src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C7D,CAAC,CAAC;IACL,CAAC;IAzGM,0BAAS,GAAG,kBAAkB,CAAC;IAC/B,6BAAY,GAAG,YAAY,CAAC;IAyGrC,uBAAC;CAAA,AA3GD,CAA8C,SAAS,GA2GtD;eA3GoB,gBAAgB"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/selection-layer.d.ts b/lib/modules/layers/src/layers/selection-layer.d.ts new file mode 100644 index 000000000..0c31b5069 --- /dev/null +++ b/lib/modules/layers/src/layers/selection-layer.d.ts @@ -0,0 +1,21 @@ +/// +import { CompositeLayer } from '@deck.gl/core'; +import EditableGeoJsonLayer from './editable-geojson-layer'; +export declare const SELECTION_TYPE: { + NONE: any; + RECTANGLE: string; + POLYGON: string; +}; +export default class SelectionLayer extends CompositeLayer { + static layerName: string; + static defaultProps: { + selectionType: string; + layerIds: any[]; + onSelect: () => void; + }; + _selectRectangleObjects(coordinates: any): void; + _selectPolygonObjects(coordinates: any): void; + renderLayers(): EditableGeoJsonLayer[]; + shouldUpdateState({ changeFlags: { stateChanged, propsOrDataChanged } }: Record): any; +} +//# sourceMappingURL=selection-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/selection-layer.d.ts.map b/lib/modules/layers/src/layers/selection-layer.d.ts.map new file mode 100644 index 000000000..0f9304ee3 --- /dev/null +++ b/lib/modules/layers/src/layers/selection-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"selection-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/selection-layer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO/C,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAE5D,eAAO,MAAM,cAAc;;;;CAI1B,CAAC;AAgDF,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,cAAc,CAAC,GAAG,CAAC;IAC7D,MAAM,CAAC,SAAS,SAAoB;IACpC,MAAM,CAAC,YAAY;;;;MAAgB;IAEnC,uBAAuB,CAAC,WAAW,EAAE,GAAG;IAkBxC,qBAAqB,CAAC,WAAW,EAAE,GAAG;IAoDtC,YAAY;IA0DZ,iBAAiB,CAAC,EAAE,WAAW,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAG7F"} \ No newline at end of file diff --git a/lib/modules/layers/src/layers/selection-layer.js b/lib/modules/layers/src/layers/selection-layer.js new file mode 100644 index 000000000..ad48eaef7 --- /dev/null +++ b/lib/modules/layers/src/layers/selection-layer.js @@ -0,0 +1,175 @@ +var _a, _b; +import { __assign, __extends, __read, __spread } from "tslib"; +/* eslint-env browser */ +import { CompositeLayer } from '@deck.gl/core'; +import { PolygonLayer } from '@deck.gl/layers'; +import { polygon } from '@turf/helpers'; +import turfBuffer from '@turf/buffer'; +import turfDifference from '@turf/difference'; +import { DrawRectangleMode, DrawPolygonMode, ViewMode } from '@nebula.gl/edit-modes'; +import EditableGeoJsonLayer from './editable-geojson-layer'; +export var SELECTION_TYPE = { + NONE: null, + RECTANGLE: 'rectangle', + POLYGON: 'polygon', +}; +var MODE_MAP = (_a = {}, + _a[SELECTION_TYPE.RECTANGLE] = DrawRectangleMode, + _a[SELECTION_TYPE.POLYGON] = DrawPolygonMode, + _a); +var MODE_CONFIG_MAP = (_b = {}, + _b[SELECTION_TYPE.RECTANGLE] = { dragToDraw: true }, + _b); +var defaultProps = { + selectionType: SELECTION_TYPE.RECTANGLE, + layerIds: [], + onSelect: function () { }, +}; +var EMPTY_DATA = { + type: 'FeatureCollection', + features: [], +}; +var EXPANSION_KM = 50; +var LAYER_ID_GEOJSON = 'selection-geojson'; +var LAYER_ID_BLOCKER = 'selection-blocker'; +var PASS_THROUGH_PROPS = [ + 'lineWidthScale', + 'lineWidthMinPixels', + 'lineWidthMaxPixels', + 'lineWidthUnits', + 'lineJointRounded', + 'lineMiterLimit', + 'pointRadiusScale', + 'pointRadiusMinPixels', + 'pointRadiusMaxPixels', + 'lineDashJustified', + 'getLineColor', + 'getFillColor', + 'getRadius', + 'getLineWidth', + 'getLineDashArray', + 'getTentativeLineDashArray', + 'getTentativeLineColor', + 'getTentativeFillColor', + 'getTentativeLineWidth', +]; +var SelectionLayer = /** @class */ (function (_super) { + __extends(SelectionLayer, _super); + function SelectionLayer() { + return _super !== null && _super.apply(this, arguments) || this; + } + SelectionLayer.prototype._selectRectangleObjects = function (coordinates) { + var _a = this.props, layerIds = _a.layerIds, onSelect = _a.onSelect; + // @ts-ignore + var _b = __read(this.context.viewport.project(coordinates[0][0]), 2), x1 = _b[0], y1 = _b[1]; + // @ts-ignore + var _c = __read(this.context.viewport.project(coordinates[0][2]), 2), x2 = _c[0], y2 = _c[1]; + // @ts-ignore + var pickingInfos = this.context.deck.pickObjects({ + x: Math.min(x1, x2), + y: Math.min(y1, y2), + width: Math.abs(x2 - x1), + height: Math.abs(y2 - y1), + layerIds: layerIds, + }); + onSelect({ pickingInfos: pickingInfos }); + }; + SelectionLayer.prototype._selectPolygonObjects = function (coordinates) { + var _this = this; + var _a = this.props, layerIds = _a.layerIds, onSelect = _a.onSelect; + // @ts-ignore + var mousePoints = coordinates[0].map(function (c) { return _this.context.viewport.project(c); }); + var allX = mousePoints.map(function (mousePoint) { return mousePoint[0]; }); + var allY = mousePoints.map(function (mousePoint) { return mousePoint[1]; }); + var x = Math.min.apply(Math, __spread(allX)); + var y = Math.min.apply(Math, __spread(allY)); + var maxX = Math.max.apply(Math, __spread(allX)); + var maxY = Math.max.apply(Math, __spread(allY)); + // Use a polygon to hide the outside, because pickObjects() + // does not support polygons + var landPointsPoly = polygon(coordinates); + var bigBuffer = turfBuffer(landPointsPoly, EXPANSION_KM); + var bigPolygon; + try { + // turfDifference throws an exception if the polygon + // intersects with itself (TODO: check if true in all versions) + bigPolygon = turfDifference(bigBuffer, landPointsPoly); + } + catch (e) { + // invalid selection polygon + console.log('turfDifference() error', e); // eslint-disable-line + return; + } + this.setState({ + pendingPolygonSelection: { + bigPolygon: bigPolygon, + }, + }); + var blockerId = this.props.id + "-" + LAYER_ID_BLOCKER; + // HACK, find a better way + setTimeout(function () { + // @ts-ignore + var pickingInfos = _this.context.deck.pickObjects({ + x: x, + y: y, + width: maxX - x, + height: maxY - y, + layerIds: __spread([blockerId], layerIds), + }); + onSelect({ + pickingInfos: pickingInfos.filter(function (item) { return item.layer.id !== _this.props.id; }), + }); + }, 250); + }; + SelectionLayer.prototype.renderLayers = function () { + var _this = this; + var pendingPolygonSelection = this.state.pendingPolygonSelection; + var mode = MODE_MAP[this.props.selectionType] || ViewMode; + var modeConfig = MODE_CONFIG_MAP[this.props.selectionType]; + var inheritedProps = {}; + PASS_THROUGH_PROPS.forEach(function (p) { + if (_this.props[p] !== undefined) + inheritedProps[p] = _this.props[p]; + }); + var layers = [ + new EditableGeoJsonLayer(this.getSubLayerProps(__assign({ id: LAYER_ID_GEOJSON, pickable: true, mode: mode, + modeConfig: modeConfig, selectedFeatureIndexes: [], data: EMPTY_DATA, onEdit: function (_a) { + var updatedData = _a.updatedData, editType = _a.editType; + if (editType === 'addFeature') { + var coordinates = updatedData.features[0].geometry.coordinates; + if (_this.props.selectionType === SELECTION_TYPE.RECTANGLE) { + _this._selectRectangleObjects(coordinates); + } + else if (_this.props.selectionType === SELECTION_TYPE.POLYGON) { + _this._selectPolygonObjects(coordinates); + } + } + } }, inheritedProps))), + ]; + if (pendingPolygonSelection) { + var bigPolygon = pendingPolygonSelection.bigPolygon; + layers.push(new PolygonLayer( + // @ts-ignore + this.getSubLayerProps({ + id: LAYER_ID_BLOCKER, + pickable: true, + stroked: false, + opacity: 1.0, + data: [bigPolygon], + getLineColor: function (obj) { return [0, 0, 0, 1]; }, + getFillColor: function (obj) { return [0, 0, 0, 1]; }, + getPolygon: function (o) { return o.geometry.coordinates; }, + }))); + } + return layers; + }; + SelectionLayer.prototype.shouldUpdateState = function (_a) { + var _b = _a.changeFlags, stateChanged = _b.stateChanged, propsOrDataChanged = _b.propsOrDataChanged; + return stateChanged || propsOrDataChanged; + }; + SelectionLayer.layerName = 'SelectionLayer'; + SelectionLayer.defaultProps = defaultProps; + return SelectionLayer; +}(CompositeLayer)); +export default SelectionLayer; +//# sourceMappingURL=selection-layer.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/layers/selection-layer.js.map b/lib/modules/layers/src/layers/selection-layer.js.map new file mode 100644 index 000000000..bc1c7bd85 --- /dev/null +++ b/lib/modules/layers/src/layers/selection-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"selection-layer.js","sourceRoot":"","sources":["../../../../../modules/layers/src/layers/selection-layer.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAErF,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,IAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,IAAM,QAAQ;IACZ,GAAC,cAAc,CAAC,SAAS,IAAG,iBAAiB;IAC7C,GAAC,cAAc,CAAC,OAAO,IAAG,eAAe;OAC1C,CAAC;AAEF,IAAM,eAAe;IACnB,GAAC,cAAc,CAAC,SAAS,IAAG,EAAE,UAAU,EAAE,IAAI,EAAE;OACjD,CAAC;AAEF,IAAM,YAAY,GAAG;IACnB,aAAa,EAAE,cAAc,CAAC,SAAS;IACvC,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,cAAO,CAAC;CACnB,CAAC;AAEF,IAAM,UAAU,GA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C;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,0CAAiB,GAAjB,UAAkB,EAA0E;YAAxE,mBAAiD,EAAlC,8BAAY,EAAE,0CAAkB;QACjE,OAAO,YAAY,IAAI,kBAAkB,CAAC;IAC5C,CAAC;IArIM,wBAAS,GAAG,gBAAgB,CAAC;IAC7B,2BAAY,GAAG,YAAY,CAAC;IAqIrC,qBAAC;CAAA,AAvID,CAA4C,cAAc,GAuIzD;eAvIoB,cAAc"} \ No newline at end of file diff --git a/lib/modules/layers/src/math.d.ts b/lib/modules/layers/src/math.d.ts new file mode 100644 index 000000000..83a573812 --- /dev/null +++ b/lib/modules/layers/src/math.d.ts @@ -0,0 +1,12 @@ +import { Position } from 'geojson'; +export declare function toDegree(radian: number): number; +export declare function toRadian(angle: number): number; +/** + * Converts an array of latitudes, longitudes in E7 format to a list of points in degrees. + * + * @param {[]} array: An E7 array [lat_e7, lng_e7, lat_e7, lng_e7, ...] + * @return {[]} An array of points in degrees + * [ [lng_degrees, lat_degrees], [lng_degrees, lat_degrees], ...] + */ +export declare function convertE7Array(array: number[]): Position[]; +//# sourceMappingURL=math.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/math.d.ts.map b/lib/modules/layers/src/math.d.ts.map new file mode 100644 index 000000000..bf37fce71 --- /dev/null +++ b/lib/modules/layers/src/math.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAQ1D"} \ No newline at end of file diff --git a/lib/modules/layers/src/math.js b/lib/modules/layers/src/math.js new file mode 100644 index 000000000..06c796510 --- /dev/null +++ b/lib/modules/layers/src/math.js @@ -0,0 +1,23 @@ +export function toDegree(radian) { + return (radian * 180) / Math.PI; +} +export function toRadian(angle) { + return (angle * Math.PI) / 180; +} +/** + * Converts an array of latitudes, longitudes in E7 format to a list of points in degrees. + * + * @param {[]} array: An E7 array [lat_e7, lng_e7, lat_e7, lng_e7, ...] + * @return {[]} An array of points in degrees + * [ [lng_degrees, lat_degrees], [lng_degrees, lat_degrees], ...] + */ +export function convertE7Array(array) { + var points = []; + for (var i = 0; i < array.length; i += 2) { + var lat = array[i] * 1e-7; + var lng = array[i + 1] * 1e-7; + points.push([lng, lat]); + } + return points; +} +//# sourceMappingURL=math.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/math.js.map b/lib/modules/layers/src/math.js.map new file mode 100644 index 000000000..19f099a0d --- /dev/null +++ b/lib/modules/layers/src/math.js.map @@ -0,0 +1 @@ +{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../../modules/layers/src/math.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,IAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACxC,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC5B,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;KACzB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts b/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts new file mode 100644 index 000000000..f2ed163af --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts @@ -0,0 +1,25 @@ +import { FeatureCollection, Feature, Position } from '@nebula.gl/edit-modes'; +import { ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { ModeHandler, EditAction, EditHandle } from './mode-handler'; +export declare class CompositeModeHandler extends ModeHandler { + handlers: Array; + options: Record; + constructor(handlers: Array, options?: Record); + _coalesce(callback: (arg0: ModeHandler) => T, resultEval?: (arg0: T) => boolean | null | undefined): T; + setFeatureCollection(featureCollection: FeatureCollection): void; + setModeConfig(modeConfig: any): void; + setSelectedFeatureIndexes(indexes: number[]): void; + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getTentativeFeature(): Feature | null | undefined; + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; +} +//# sourceMappingURL=composite-mode-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts.map new file mode 100644 index 000000000..010b683c2 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/composite-mode-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"composite-mode-handler.d.ts","sourceRoot":"","sources":["../../../../../modules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SAAS;IAI3E,mBAAmB,IAAI,OAAO,GAAG,IAAI,GAAG,SAAS;IAIjD,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,EAAE;IAUzF,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;CAG3D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/composite-mode-handler.js b/lib/modules/layers/src/mode-handlers/composite-mode-handler.js new file mode 100644 index 000000000..d02c5d7c9 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/composite-mode-handler.js @@ -0,0 +1,61 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var CompositeModeHandler = /** @class */ (function (_super) { + __extends(CompositeModeHandler, _super); + function CompositeModeHandler(handlers, options) { + if (options === void 0) { options = {}; } + var _this = _super.call(this) || this; + _this.handlers = handlers; + _this.options = options; + return _this; + } + CompositeModeHandler.prototype._coalesce = function (callback, resultEval) { + if (resultEval === void 0) { resultEval = null; } + var result; + for (var i = 0; i < this.handlers.length; i++) { + result = callback(this.handlers[i]); + if (resultEval ? resultEval(result) : result) { + break; + } + } + return result; + }; + CompositeModeHandler.prototype.setFeatureCollection = function (featureCollection) { + this.handlers.forEach(function (handler) { return handler.setFeatureCollection(featureCollection); }); + }; + CompositeModeHandler.prototype.setModeConfig = function (modeConfig) { + this.handlers.forEach(function (handler) { return handler.setModeConfig(modeConfig); }); + }; + CompositeModeHandler.prototype.setSelectedFeatureIndexes = function (indexes) { + this.handlers.forEach(function (handler) { return handler.setSelectedFeatureIndexes(indexes); }); + }; + CompositeModeHandler.prototype.handleClick = function (event) { + return this._coalesce(function (handler) { return handler.handleClick(event); }); + }; + CompositeModeHandler.prototype.handlePointerMove = function (event) { + return this._coalesce(function (handler) { return handler.handlePointerMove(event); }, function (result) { return result && Boolean(result.editAction); }); + }; + CompositeModeHandler.prototype.handleStartDragging = function (event) { + return this._coalesce(function (handler) { return handler.handleStartDragging(event); }); + }; + CompositeModeHandler.prototype.handleStopDragging = function (event) { + return this._coalesce(function (handler) { return handler.handleStopDragging(event); }); + }; + CompositeModeHandler.prototype.getTentativeFeature = function () { + return this._coalesce(function (handler) { return handler.getTentativeFeature(); }); + }; + CompositeModeHandler.prototype.getEditHandles = function (picks, groundCoords) { + // TODO: Combine the handles *BUT* make sure if none of the results have + // changed to return the same object so that "editHandles !== this.state.editHandles" + // in editable-geojson-layer works. + return this._coalesce(function (handler) { return handler.getEditHandles(picks, groundCoords); }, function (handles) { return Array.isArray(handles) && handles.length > 0; }); + }; + CompositeModeHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + return this._coalesce(function (handler) { return handler.getCursor({ isDragging: isDragging }); }); + }; + return CompositeModeHandler; +}(ModeHandler)); +export { CompositeModeHandler }; +//# sourceMappingURL=composite-mode-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/composite-mode-handler.js.map b/lib/modules/layers/src/mode-handlers/composite-mode-handler.js.map new file mode 100644 index 000000000..61eee3b2e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/composite-mode-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"composite-mode-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/composite-mode-handler.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAA0B,MAAM,gBAAgB,CAAC;AAErE,mEAAmE;AACnE;IAA0C,wCAAW;IAInD,8BAAY,QAA4B,EAAE,OAAiC;QAAjC,wBAAA,EAAA,YAAiC;QAA3E,YACE,iBAAO,SAGR;QAFC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IAED,wCAAS,GAAT,UACE,QA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4EpD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts new file mode 100644 index 000000000..6f3ee82e1 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts @@ -0,0 +1,14 @@ +import { Position } from '@nebula.gl/edit-modes'; +import { ClickEvent, PointerMoveEvent } from '../event-types'; +import { EditAction, EditHandle, ModeHandler } from './mode-handler'; +export declare class Draw90DegreePolygonHandler extends ModeHandler { + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; + handlePointerMove({ groundCoords, }: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleClick(event: ClickEvent): EditAction | null | undefined; + finalizedCoordinates(coords: Position[]): Position[][]; + getIntermediatePoint(coordinates: Position[]): any; +} +//# sourceMappingURL=draw-90degree-polygon-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts.map new file mode 100644 index 000000000..80dd5500e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-90degree-polygon-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-90degree-polygon-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAGxB,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,EAAE;IAmBzF,iBAAiB,CAAC,EAChB,YAAY,GACb,EAAE,gBAAgB,GAAG;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAkD1F,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IA+C7D,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE;IAmBvC,oBAAoB,CAAC,WAAW,EAAE,QAAQ,EAAE;CA0C7C"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js new file mode 100644 index 000000000..668ced421 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js @@ -0,0 +1,180 @@ +import { __extends, __read, __spread } from "tslib"; +import destination from '@turf/destination'; +import bearing from '@turf/bearing'; +import lineIntersect from '@turf/line-intersect'; +import turfDistance from '@turf/distance'; +import { point, lineString } from '@turf/helpers'; +import { generatePointsParallelToLinePoints } from '../utils'; +import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry, } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var Draw90DegreePolygonHandler = /** @class */ (function (_super) { + __extends(Draw90DegreePolygonHandler, _super); + function Draw90DegreePolygonHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + Draw90DegreePolygonHandler.prototype.getEditHandles = function (picks, groundCoords) { + var handles = _super.prototype.getEditHandles.call(this, picks, groundCoords); + var tentativeFeature = this.getTentativeFeature(); + if (tentativeFeature) { + handles = handles.concat(getEditHandlesForGeometry(tentativeFeature.geometry, -1)); + // Slice off the handles that are are next to the pointer + if (tentativeFeature && tentativeFeature.geometry.type === 'LineString') { + // Remove the last existing handle + handles = handles.slice(0, -1); + } + else if (tentativeFeature && tentativeFeature.geometry.type === 'Polygon') { + // Remove the last existing handle + handles = handles.slice(0, -1); + } + } + return handles; + }; + Draw90DegreePolygonHandler.prototype.handlePointerMove = function (_a) { + var _b; + var groundCoords = _a.groundCoords; + var clickSequence = this.getClickSequence(); + var result = { editAction: null, cancelMapPan: false }; + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var tentativeFeature = this.getTentativeFeature(); + if (tentativeFeature && tentativeFeature.geometry.type === 'Polygon') { + clickSequence[clickSequence.length - 1] = + tentativeFeature.geometry.coordinates[0][clickSequence.length - 1]; + } + else if (tentativeFeature && tentativeFeature.geometry.type === 'LineString') { + clickSequence[clickSequence.length - 1] = + tentativeFeature.geometry.coordinates[clickSequence.length - 1]; + } + var p3; + if (clickSequence.length === 1) { + p3 = groundCoords; + } + else { + var p1 = clickSequence[clickSequence.length - 2]; + var p2 = clickSequence[clickSequence.length - 1]; + _b = __read(generatePointsParallelToLinePoints(p1, p2, groundCoords), 1), p3 = _b[0]; + } + if (clickSequence.length < 3) { + // Draw a LineString connecting all the clicked points with the hovered point + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, [p3]), + }, + }); + } + else { + // Draw a Polygon connecting all the clicked points with the hovered point + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [__spread(clickSequence, [p3, clickSequence[0]])], + }, + }); + } + return result; + }; + Draw90DegreePolygonHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, event); + var picks = event.picks; + var tentativeFeature = this.getTentativeFeature(); + var editAction = null; + var clickedEditHandle = getPickedEditHandle(picks); + if (tentativeFeature && tentativeFeature.geometry.type === 'Polygon') { + var polygon = tentativeFeature.geometry; + if (clickedEditHandle && + clickedEditHandle.featureIndex === -1 && + (clickedEditHandle.positionIndexes[1] === 0 || + clickedEditHandle.positionIndexes[1] === polygon.coordinates[0].length - 3)) { + // They clicked the first or last point (or double-clicked), so complete the polygon + var polygonToAdd = { + type: 'Polygon', + coordinates: this.finalizedCoordinates(__spread(polygon.coordinates[0])), + }; + this.resetClickSequence(); + this._setTentativeFeature(null); + editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd); + } + } + // Trigger pointer move right away in order for it to update edit handles (to support double-click) + var fakePointerMoveEvent = { + screenCoords: [-1, -1], + groundCoords: event.groundCoords, + picks: [], + isDragging: false, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownGroundCoords: null, + sourceEvent: null, + }; + // @ts-ignore + this.handlePointerMove(fakePointerMoveEvent); + return editAction; + }; + Draw90DegreePolygonHandler.prototype.finalizedCoordinates = function (coords) { + // Remove the hovered position + var coordinates = [__spread(coords.slice(0, -2), [coords[0]])]; + var pt = this.getIntermediatePoint(__spread(coords)); + if (!pt) { + // if intermediate point with 90 degree not available + // try remove the last clicked point and get the intermediate point. + var tc = __spread(coords); + tc.splice(-3, 1); + pt = this.getIntermediatePoint(__spread(tc)); + if (pt) { + coordinates = [__spread(coords.slice(0, -3), [pt, coords[0]])]; + } + } + else { + coordinates = [__spread(coords.slice(0, -2), [pt, coords[0]])]; + } + return coordinates; + }; + Draw90DegreePolygonHandler.prototype.getIntermediatePoint = function (coordinates) { + var pt; + if (coordinates.length > 4) { + var _a = __read(__spread(coordinates), 2), p1_1 = _a[0], p2 = _a[1]; + var angle1_1 = bearing(p1_1, p2); + var p3_1 = coordinates[coordinates.length - 3]; + var p4 = coordinates[coordinates.length - 4]; + var angle2_1 = bearing(p3_1, p4); + var angles_1 = { first: [], second: [] }; + // calculate 3 right angle points for first and last points in lineString + [1, 2, 3].forEach(function (factor) { + var newAngle1 = angle1_1 + factor * 90; + // convert angles to 0 to -180 for anti-clock and 0 to 180 for clock wise + angles_1.first.push(newAngle1 > 180 ? newAngle1 - 360 : newAngle1); + var newAngle2 = angle2_1 + factor * 90; + angles_1.second.push(newAngle2 > 180 ? newAngle2 - 360 : newAngle2); + }); + var distance_1 = turfDistance(point(p1_1), point(p3_1)); + // Draw imaginary right angle lines for both first and last points in lineString + // If there is intersection point for any 2 lines, will be the 90 degree point. + [0, 1, 2].forEach(function (indexFirst) { + var line1 = lineString([ + p1_1, + destination(p1_1, distance_1, angles_1.first[indexFirst]).geometry.coordinates, + ]); + [0, 1, 2].forEach(function (indexSecond) { + var line2 = lineString([ + p3_1, + destination(p3_1, distance_1, angles_1.second[indexSecond]).geometry.coordinates, + ]); + var fc = lineIntersect(line1, line2); + if (fc && fc.features.length) { + // found the intersect point + pt = fc.features[0].geometry.coordinates; + } + }); + }); + } + return pt; + }; + return Draw90DegreePolygonHandler; +}(ModeHandler)); +export { Draw90DegreePolygonHandler }; +//# sourceMappingURL=draw-90degree-polygon-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js.map new file mode 100644 index 000000000..875cb61e6 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-90degree-polygon-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-90degree-polygon-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-90degree-polygon-handler.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,mEAAmE;AACnE;IAAgD,8CAAW;IAA3D;;IAoLA,CAAC;IAnLC,mDAAc,GAAd,UAAe,KAAkC,EAAE,YAAuB;QACxE,IAAI,OAAO,GAAG,iBAAM,cAAc,YAAC,KAAK,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AC3E,CAAC,CAAC;oBACH,IAAM,EAAE,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;oBACvC,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE;wBAC5B,4BAA4B;wBAC5B,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;qBAC1C;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,iCAAC;AAAD,CAAC,AApLD,CAAgD,WAAW,GAoL1D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts new file mode 100644 index 000000000..023a04a67 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +export declare class DrawCircleByBoundingBoxHandler extends TwoClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-circle-by-bounding-box-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts.map new file mode 100644 index 000000000..b5abc73e4 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-bounding-box-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAA2B,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qBAAa,8BAA+B,SAAQ,sBAAsB;IACxE,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CA0BxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js new file mode 100644 index 000000000..d1ff2eaea --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js @@ -0,0 +1,36 @@ +import { __extends } from "tslib"; +import circle from '@turf/circle'; +import distance from '@turf/distance'; +import { getIntermediatePosition } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawCircleByBoundingBoxHandler = /** @class */ (function (_super) { + __extends(DrawCircleByBoundingBoxHandler, _super); + function DrawCircleByBoundingBoxHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawCircleByBoundingBoxHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var modeConfig = this.getModeConfig() || {}; + // Default turf value for circle is 64 + var _a = modeConfig.steps, steps = _a === void 0 ? 64 : _a; + var options = { steps: steps }; + if (steps < 4) { + console.warn("Minimum steps to draw a circle is 4 "); // eslint-disable-line no-console,no-undef + options.steps = 4; + } + var firstClickedPoint = clickSequence[0]; + var centerCoordinates = getIntermediatePosition(firstClickedPoint, event.groundCoords); + var radius = Math.max(distance(firstClickedPoint, centerCoordinates), 0.001); + this._setTentativeFeature(circle(centerCoordinates, radius, options)); + return result; + }; + return DrawCircleByBoundingBoxHandler; +}(TwoClickPolygonHandler)); +export { DrawCircleByBoundingBoxHandler }; +//# sourceMappingURL=draw-circle-by-bounding-box-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js.map new file mode 100644 index 000000000..a0f2e545e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-by-bounding-box-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-circle-by-bounding-box-handler.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAc,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,mEAAmE;AACnE;IAAoD,kDAAsB;IAA1E;;IA6BA,CAAC;IA5BC,0DAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;QAC9C,sCAAsC;QAC9B,IAAA,qBAAU,EAAV,+BAAU,CAAgB;QAClC,IAAM,OAAO,GAAG,EAAE,KAAK,OAAA,EAAE,CAAC;QAE1B,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC,0CAA0C;YAChG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;SACnB;QAED,IAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QACzF,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,KAAK,CAAC,CAAC;QAC/E,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAEtE,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,qCAAC;AAAD,CAAC,AA7BD,CAAoD,sBAAsB,GA6BzE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts new file mode 100644 index 000000000..c6fa5e1ad --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +export declare class DrawCircleFromCenterHandler extends TwoClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-circle-from-center-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts.map new file mode 100644 index 000000000..06ee6c965 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-from-center-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-circle-from-center-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qBAAa,2BAA4B,SAAQ,sBAAsB;IACrE,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CAyBxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js new file mode 100644 index 000000000..c4a1b30a8 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js @@ -0,0 +1,34 @@ +import { __extends } from "tslib"; +import circle from '@turf/circle'; +import distance from '@turf/distance'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawCircleFromCenterHandler = /** @class */ (function (_super) { + __extends(DrawCircleFromCenterHandler, _super); + function DrawCircleFromCenterHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawCircleFromCenterHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var modeConfig = this.getModeConfig() || {}; + // Default turf value for circle is 64 + var _a = modeConfig.steps, steps = _a === void 0 ? 64 : _a; + var options = { steps: steps }; + if (steps < 4) { + console.warn("Minimum steps to draw a circle is 4 "); // eslint-disable-line no-console,no-undef + options.steps = 4; + } + var centerCoordinates = clickSequence[0]; + var radius = Math.max(distance(centerCoordinates, event.groundCoords), 0.001); + this._setTentativeFeature(circle(centerCoordinates, radius, options)); + return result; + }; + return DrawCircleFromCenterHandler; +}(TwoClickPolygonHandler)); +export { DrawCircleFromCenterHandler }; +//# sourceMappingURL=draw-circle-from-center-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js.map new file mode 100644 index 000000000..42fb858d4 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-circle-from-center-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-circle-from-center-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-circle-from-center-handler.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,mEAAmE;AACnE;IAAiD,+CAAsB;IAAvE;;IA4BA,CAAC;IA3BC,uDAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;QAC9C,sCAAsC;QAC9B,IAAA,qBAAU,EAAV,+BAAU,CAAgB;QAClC,IAAM,OAAO,GAAG,EAAE,KAAK,OAAA,EAAE,CAAC;QAE1B,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC,0CAA0C;YAChG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;SACnB;QAED,IAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;QAChF,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAEtE,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,kCAAC;AAAD,CAAC,AA5BD,CAAiD,sBAAsB,GA4BtE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts new file mode 100644 index 000000000..9bcff5960 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +export declare class DrawEllipseByBoundingBoxHandler extends TwoClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-ellipse-by-bounding-box-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts.map new file mode 100644 index 000000000..72b0f0079 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-by-bounding-box-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAA2B,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qBAAa,+BAAgC,SAAQ,sBAAsB;IACzE,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CA2BxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js new file mode 100644 index 000000000..cca5e2a75 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js @@ -0,0 +1,38 @@ +import { __extends } from "tslib"; +import bboxPolygon from '@turf/bbox-polygon'; +import distance from '@turf/distance'; +import ellipse from '@turf/ellipse'; +import { point } from '@turf/helpers'; +import { getIntermediatePosition } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawEllipseByBoundingBoxHandler = /** @class */ (function (_super) { + __extends(DrawEllipseByBoundingBoxHandler, _super); + function DrawEllipseByBoundingBoxHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawEllipseByBoundingBoxHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var corner1 = clickSequence[0]; + var corner2 = event.groundCoords; + var minX = Math.min(corner1[0], corner2[0]); + var minY = Math.min(corner1[1], corner2[1]); + var maxX = Math.max(corner1[0], corner2[0]); + var maxY = Math.max(corner1[1], corner2[1]); + var polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0]; + var centerCoordinates = getIntermediatePosition(corner1, corner2); + var xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001); + var ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001); + // @ts-ignore + this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis)); + return result; + }; + return DrawEllipseByBoundingBoxHandler; +}(TwoClickPolygonHandler)); +export { DrawEllipseByBoundingBoxHandler }; +//# sourceMappingURL=draw-ellipse-by-bounding-box-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js.map new file mode 100644 index 000000000..5ca162327 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-by-bounding-box-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAc,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,mEAAmE;AACnE;IAAqD,mDAAsB;IAA3E;;IA8BA,CAAC;IA7BC,2DAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACjC,IAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAA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BAAsB,GA8B1E"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts new file mode 100644 index 000000000..ce8252be2 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { ThreeClickPolygonHandler } from './three-click-polygon-handler'; +export declare class DrawEllipseUsingThreePointsHandler extends ThreeClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-ellipse-using-three-points-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts.map new file mode 100644 index 000000000..deb3bb45b --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-using-three-points-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAA2B,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,qBAAa,kCAAmC,SAAQ,wBAAwB;IAC9E,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CAgCxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js new file mode 100644 index 000000000..63eccec92 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js @@ -0,0 +1,45 @@ +import { __extends, __read } from "tslib"; +import distance from '@turf/distance'; +import ellipse from '@turf/ellipse'; +import bearing from '@turf/bearing'; +import { point } from '@turf/helpers'; +import { getIntermediatePosition } from './mode-handler'; +import { ThreeClickPolygonHandler } from './three-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawEllipseUsingThreePointsHandler = /** @class */ (function (_super) { + __extends(DrawEllipseUsingThreePointsHandler, _super); + function DrawEllipseUsingThreePointsHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawEllipseUsingThreePointsHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var groundCoords = event.groundCoords; + if (clickSequence.length === 1) { + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [clickSequence[0], groundCoords], + }, + }); + } + else if (clickSequence.length === 2) { + var _a = __read(clickSequence, 2), p1 = _a[0], p2 = _a[1]; + var centerCoordinates = getIntermediatePosition(p1, p2); + var xSemiAxis = Math.max(distance(centerCoordinates, point(groundCoords)), 0.001); + var ySemiAxis = Math.max(distance(p1, p2), 0.001) / 2; + var options = { angle: bearing(p1, p2) }; + // @ts-ignore + this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options)); + } + return result; + }; + return DrawEllipseUsingThreePointsHandler; +}(ThreeClickPolygonHandler)); +export { DrawEllipseUsingThreePointsHandler }; +//# sourceMappingURL=draw-ellipse-using-three-points-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js.map new file mode 100644 index 000000000..b41db13ba --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-ellipse-using-three-points-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-ellipse-using-three-points-handler.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAc,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,mEAAmE;AACnE;IAAwD,sDAAwB;IAAhF;;IAmCA,CAAC;IAlCC,8DAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAExC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,oBAAoB,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;iBAC9C;aACF,CAAC,CAAC;SACJ;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,IAAA,6BAAwB,EAAvB,UAAE,EAAE,UAAmB,CAAC;YAE/B,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1D,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YACpF,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACxD,IAAM,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;YAC3C,aAAa;YACb,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;SACtF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,yCAAC;AAAD,CAAC,AAnCD,CAAwD,wBAAwB,GAmC/E"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts new file mode 100644 index 000000000..2e9571936 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts @@ -0,0 +1,10 @@ +import { ClickEvent, PointerMoveEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class DrawLineStringHandler extends ModeHandler { + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-line-string-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts.map new file mode 100644 index 000000000..03087f8f4 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-line-string-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,qBAAsB,SAAQ,WAAW;IACpD,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAuD7D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CA2CxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js new file mode 100644 index 000000000..7ba4e6e1c --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js @@ -0,0 +1,91 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawLineStringHandler = /** @class */ (function (_super) { + __extends(DrawLineStringHandler, _super); + function DrawLineStringHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawLineStringHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, event); + var editAction = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var selectedGeometry = this.getSelectedGeometry(); + var tentativeFeature = this.getTentativeFeature(); + var clickSequence = this.getClickSequence(); + if (selectedFeatureIndexes.length > 1 || + (selectedGeometry && selectedGeometry.type !== 'LineString')) { + console.warn("drawLineString mode only supported for single LineString selection"); // eslint-disable-line + this.resetClickSequence(); + return null; + } + if (selectedGeometry && selectedGeometry.type === 'LineString') { + // Extend the LineString + var lineString = selectedGeometry; + var positionIndexes = [lineString.coordinates.length]; + var modeConfig = this.getModeConfig(); + if (modeConfig && modeConfig.drawAtFront) { + positionIndexes = [0]; + } + var featureIndex = selectedFeatureIndexes[0]; + var updatedData = this.getImmutableFeatureCollection() + .addPosition(featureIndex, positionIndexes, event.groundCoords) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'addPosition', + featureIndexes: [featureIndex], + editContext: { + positionIndexes: positionIndexes, + position: event.groundCoords, + }, + }; + this.resetClickSequence(); + } + else if (clickSequence.length === 2 && tentativeFeature) { + // Add a new LineString + var geometry = tentativeFeature.geometry; + editAction = this.getAddFeatureAction(geometry); + this.resetClickSequence(); + } + return editAction; + }; + DrawLineStringHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + var groundCoords = event.groundCoords; + var startPosition = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var selectedGeometry = this.getSelectedGeometry(); + if (selectedFeatureIndexes.length > 1 || + (selectedGeometry && selectedGeometry.type !== 'LineString')) { + // unsupported + return result; + } + if (selectedGeometry && selectedGeometry.type === 'LineString') { + // Draw an extension line starting from one end of the selected LineString + startPosition = selectedGeometry.coordinates[selectedGeometry.coordinates.length - 1]; + var modeConfig = this.getModeConfig(); + if (modeConfig && modeConfig.drawAtFront) { + startPosition = selectedGeometry.coordinates[0]; + } + } + else if (clickSequence.length === 1) { + startPosition = clickSequence[0]; + } + if (startPosition) { + this._setTentativeFeature({ + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [startPosition, groundCoords], + }, + }); + } + return result; + }; + return DrawLineStringHandler; +}(ModeHandler)); +export { DrawLineStringHandler }; +//# sourceMappingURL=draw-line-string-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js.map new file mode 100644 index 000000000..2a0fe6ce1 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-line-string-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-line-string-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-line-string-handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAA2C,yCAAW;IAAtD;;IAqGA,CAAC;IApGC,2CAAW,GAAX,UAAY,KAAiB;QAC3B,iBAAM,WAAW,YAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,UAAU,GAAkC,IAAI,CAAC;QACrD,IAAM,sBAAsB,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChE,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IACE,sBAAsB,CAAC,MAAM,GAAG,CAAC;YACjC,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,IAAI,KAAK,YAAY,CAAC,EAC5D;YACA,OAAO,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC,CAAC,sBAAsB;YAC1G,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;SACb;QAED,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,IAAI,KAAK,YAAY,EAAE;YAC9D,wBAAwB;YACxB,IAAM,UAAU,GAAe,gBAAgB,CAAC;YAEhD,IAAI,eAAe,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAEtD,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE;gBACxC,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC;aACvB;YACD,IAAM,YAAY,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAM,WAAW,GAAG,IAAI,CAAC,6BAA6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E;YAC1E,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAEtF,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,IAAI,UAAU,IAAI,UAAU,CAAC,WAAW,EAAE;gBACxC,aAAa,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;aACjD;SACF;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YACrC,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;SAClC;QAED,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,oBAAoB,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;iBAC3C;aACF,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,4BAAC;AAAD,CAAC,AArGD,CAA2C,WAAW,GAqGrD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts new file mode 100644 index 000000000..38e75bbbc --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts @@ -0,0 +1,6 @@ +import { ClickEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class DrawPointHandler extends ModeHandler { + handleClick({ groundCoords }: ClickEvent): EditAction | null | undefined; +} +//# sourceMappingURL=draw-point-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts.map new file mode 100644 index 000000000..4f9950a12 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-point-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-point-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-point-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,WAAW,CAAC,EAAE,YAAY,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;CAQzE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-point-handler.js b/lib/modules/layers/src/mode-handlers/draw-point-handler.js new file mode 100644 index 000000000..e64e18275 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-point-handler.js @@ -0,0 +1,21 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawPointHandler = /** @class */ (function (_super) { + __extends(DrawPointHandler, _super); + function DrawPointHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawPointHandler.prototype.handleClick = function (_a) { + var groundCoords = _a.groundCoords; + var geometry = { + type: 'Point', + coordinates: groundCoords, + }; + // @ts-ignore + return this.getAddFeatureAction(geometry); + }; + return DrawPointHandler; +}(ModeHandler)); +export { DrawPointHandler }; +//# sourceMappingURL=draw-point-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-point-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-point-handler.js.map new file mode 100644 index 000000000..66ca8b87c --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-point-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-point-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-point-handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAAsC,oCAAW;IAAjD;;IASA,CAAC;IARC,sCAAW,GAAX,UAAY,EAA4B;YAA1B,8BAAY;QACxB,IAAM,QAAQ,GAAG;YACf,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,YAAY;SAC1B,CAAC;QACF,aAAa;QACb,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACH,uBAAC;AAAD,CAAC,AATD,CAAsC,WAAW,GAShD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts new file mode 100644 index 000000000..733669fd9 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts @@ -0,0 +1,12 @@ +import { Position } from '@nebula.gl/edit-modes'; +import { ClickEvent, PointerMoveEvent } from '../event-types'; +import { EditAction, EditHandle, ModeHandler } from './mode-handler'; +export declare class DrawPolygonHandler extends ModeHandler { + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove({ groundCoords, }: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-polygon-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts.map new file mode 100644 index 000000000..8d6292f2d --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-polygon-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAGxB,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,EAAE;IAkBzF,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAwD7D,iBAAiB,CAAC,EAChB,YAAY,GACb,EAAE,gBAAgB,GAAG;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CA+B3F"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js new file mode 100644 index 000000000..1a6b8d08a --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js @@ -0,0 +1,102 @@ +import { __extends, __read, __spread } from "tslib"; +import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry, } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawPolygonHandler = /** @class */ (function (_super) { + __extends(DrawPolygonHandler, _super); + function DrawPolygonHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawPolygonHandler.prototype.getEditHandles = function (picks, groundCoords) { + var handles = _super.prototype.getEditHandles.call(this, picks, groundCoords); + if (this._tentativeFeature) { + handles = handles.concat(getEditHandlesForGeometry(this._tentativeFeature.geometry, -1)); + // Slice off the handles that are are next to the pointer + if (this._tentativeFeature && this._tentativeFeature.geometry.type === 'LineString') { + // Remove the last existing handle + handles = handles.slice(0, -1); + } + else if (this._tentativeFeature && this._tentativeFeature.geometry.type === 'Polygon') { + // Remove the last existing handle + handles = handles.slice(0, -1); + } + } + return handles; + }; + DrawPolygonHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, event); + var picks = event.picks; + var tentativeFeature = this.getTentativeFeature(); + var editAction = null; + var clickedEditHandle = getPickedEditHandle(picks); + if (clickedEditHandle) { + // User clicked an edit handle. + // Remove it from the click sequence, so it isn't added as a new point. + var clickSequence = this.getClickSequence(); + clickSequence.splice(clickSequence.length - 1, 1); + } + if (tentativeFeature && tentativeFeature.geometry.type === 'Polygon') { + var polygon = tentativeFeature.geometry; + if (clickedEditHandle && + clickedEditHandle.featureIndex === -1 && + (clickedEditHandle.positionIndexes[1] === 0 || + clickedEditHandle.positionIndexes[1] === polygon.coordinates[0].length - 3)) { + // They clicked the first or last point (or double-clicked), so complete the polygon + // Remove the hovered position + var polygonToAdd = { + type: 'Polygon', + coordinates: [__spread(polygon.coordinates[0].slice(0, -2), [polygon.coordinates[0][0]])], + }; + this.resetClickSequence(); + this._setTentativeFeature(null); + editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd); + } + } + // Trigger pointer move right away in order for it to update edit handles (to support double-click) + var fakePointerMoveEvent = { + screenCoords: [-1, -1], + groundCoords: event.groundCoords, + picks: [], + isDragging: false, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownGroundCoords: null, + sourceEvent: null, + }; + // @ts-ignore + this.handlePointerMove(fakePointerMoveEvent); + return editAction; + }; + DrawPolygonHandler.prototype.handlePointerMove = function (_a) { + var groundCoords = _a.groundCoords; + var clickSequence = this.getClickSequence(); + var result = { editAction: null, cancelMapPan: false }; + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + if (clickSequence.length < 3) { + // Draw a LineString connecting all the clicked points with the hovered point + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, [groundCoords]), + }, + }); + } + else { + // Draw a Polygon connecting all the clicked points with the hovered point + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [__spread(clickSequence, [groundCoords, clickSequence[0]])], + }, + }); + } + return result; + }; + return DrawPolygonHandler; +}(ModeHandler)); +export { DrawPolygonHandler }; +//# sourceMappingURL=draw-polygon-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js.map new file mode 100644 index 000000000..67e2e765f --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-polygon-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-polygon-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-polygon-handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,mEAAmE;AACnE;IAAwC,sCAAW;IAAnD;;IA4GA,CAAC;IA3GC,2CAAc,GAAd,UAAe,KAAkC,EAAE,YAAuB;QACxE,IAAI,OAAO,GAAG,iBAAM,cAAc,YAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAExD,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACzF,yDAAyD;YACzD,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE;gBACnF,kCAAkC;gBAClC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;aAChC;iBAAM,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;gBACvF,kCAAkC;gBAClC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;aAChC;SACF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,wCAAW,G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ACH,yBAAC;AAAD,CAAC,AA5GD,CAAwC,WAAW,GA4GlD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts new file mode 100644 index 000000000..2723538db --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +export declare class DrawRectangleHandler extends TwoClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-rectangle-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts.map new file mode 100644 index 000000000..b4f84646e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-rectangle-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CAgBxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js new file mode 100644 index 000000000..cc37746e2 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js @@ -0,0 +1,26 @@ +import { __extends } from "tslib"; +import bboxPolygon from '@turf/bbox-polygon'; +import { TwoClickPolygonHandler } from './two-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawRectangleHandler = /** @class */ (function (_super) { + __extends(DrawRectangleHandler, _super); + function DrawRectangleHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawRectangleHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var corner1 = clickSequence[0]; + var corner2 = event.groundCoords; + // @ts-ignore + this._setTentativeFeature(bboxPolygon([corner1[0], corner1[1], corner2[0], corner2[1]])); + return result; + }; + return DrawRectangleHandler; +}(TwoClickPolygonHandler)); +export { DrawRectangleHandler }; +//# sourceMappingURL=draw-rectangle-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js.map new file mode 100644 index 000000000..18597ab8a --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-rectangle-handler.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,mEAAmE;AACnE;IAA0C,wCAAsB;IAAhE;;IAmBA,CAAC;IAlBC,gDAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACjC,IAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC;QACnC,aAAa;QACb,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,2BAAC;AAAD,CAAC,AAnBD,CAA0C,sBAAsB,GAmB/D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts new file mode 100644 index 000000000..ce30b7f91 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts @@ -0,0 +1,10 @@ +import { PointerMoveEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { ThreeClickPolygonHandler } from './three-click-polygon-handler'; +export declare class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandler { + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +//# sourceMappingURL=draw-rectangle-using-three-points-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts.map new file mode 100644 index 000000000..82169fadc --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-using-three-points-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,qBAAa,oCAAqC,SAAQ,wBAAwB;IAChF,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CAgDxE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js new file mode 100644 index 000000000..1eb48fef9 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js @@ -0,0 +1,53 @@ +import { __extends, __read, __spread } from "tslib"; +import { generatePointsParallelToLinePoints } from '../utils'; +import { ThreeClickPolygonHandler } from './three-click-polygon-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DrawRectangleUsingThreePointsHandler = /** @class */ (function (_super) { + __extends(DrawRectangleUsingThreePointsHandler, _super); + function DrawRectangleUsingThreePointsHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DrawRectangleUsingThreePointsHandler.prototype.handlePointerMove = function (event) { + var result = { editAction: null, cancelMapPan: false }; + var clickSequence = this.getClickSequence(); + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + var groundCoords = event.groundCoords; + if (clickSequence.length === 1) { + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [clickSequence[0], groundCoords], + }, + }); + } + else if (clickSequence.length === 2) { + var lineString = { + type: 'LineString', + coordinates: clickSequence, + }; + var _a = __read(clickSequence, 2), p1 = _a[0], p2 = _a[1]; + var _b = __read(generatePointsParallelToLinePoints(p1, p2, groundCoords), 2), p3 = _b[0], p4 = _b[1]; + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [ + __spread(lineString.coordinates, [ + p3, + p4, + p1, + ]), + ], + }, + }); + } + return result; + }; + return DrawRectangleUsingThreePointsHandler; +}(ThreeClickPolygonHandler)); +export { DrawRectangleUsingThreePointsHandler }; +//# sourceMappingURL=draw-rectangle-using-three-points-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js.map b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js.map new file mode 100644 index 000000000..1f1d2836e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"draw-rectangle-using-three-points-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/draw-rectangle-using-three-points-handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAG9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,mEAAmE;AACnE;IAA0D,wDAAwB;IAAlF;;IAmDA,CAAC;IAlDC,gEAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACzD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,oBAAoB;YACpB,OAAO,MAAM,CAAC;SACf;QAED,IAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAExC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,IAAI,CAAC,oBAAoB,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;iBAC9C;aACF,CAAC,CAAC;SACJ;aAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YACrC,IAAM,UAAU,GAAe;gBAC7B,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,aAAa;aAC3B,CAAC;YACI,IAAA,6BAAwB,EAAvB,UAAE,EAAE,UAAmB,CAAC;YACzB,IAAA,wEAAmE,EAAlE,UAAE,EAAE,UAA8D,CAAC;YAE1E,IAAI,CAAC,oBAAoB,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE;oBACR,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE;iCAKN,UAAU,CAAC,WAAW;4BACzB,EAAE;4BACF,EAAE;4BACF,EAAE;;qBAEL;iBACF;aACF,CAAC,CAAC;SACJ;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,2CAAC;AAAD,CAAC,AAnDD,CAA0D,wBAAwB,GAmDjF"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts b/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts new file mode 100644 index 000000000..79e9f6f42 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts @@ -0,0 +1,10 @@ +import { StartDraggingEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { TranslateHandler } from './translate-handler'; +export declare class DuplicateHandler extends TranslateHandler { + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; +} +//# sourceMappingURL=duplicate-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts.map new file mode 100644 index 000000000..744194236 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/duplicate-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"duplicate-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/duplicate-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAY7E,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;CAM3D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/duplicate-handler.js b/lib/modules/layers/src/mode-handlers/duplicate-handler.js new file mode 100644 index 000000000..043acea15 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/duplicate-handler.js @@ -0,0 +1,28 @@ +import { __extends } from "tslib"; +import { TranslateHandler } from './translate-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var DuplicateHandler = /** @class */ (function (_super) { + __extends(DuplicateHandler, _super); + function DuplicateHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + DuplicateHandler.prototype.handleStartDragging = function (event) { + if (!this._isTranslatable) { + return null; + } + this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(); + return this._geometryBeforeTranslate + ? this.getAddManyFeaturesAction(this._geometryBeforeTranslate) + : null; + }; + DuplicateHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + if (this._isTranslatable) { + return 'copy'; + } + return isDragging ? 'grabbing' : 'grab'; + }; + return DuplicateHandler; +}(TranslateHandler)); +export { DuplicateHandler }; +//# sourceMappingURL=duplicate-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/duplicate-handler.js.map b/lib/modules/layers/src/mode-handlers/duplicate-handler.js.map new file mode 100644 index 000000000..b502b7948 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/duplicate-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"duplicate-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/duplicate-handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,mEAAmE;AACnE;IAAsC,oCAAgB;IAAtD;;IAmBA,CAAC;IAlBC,8CAAmB,GAAnB,UAAoB,KAAyB;QAC3C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QAED,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,sCAAsC,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,wBAAwB;YAClC,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,wBAAwB,CAAC;YAC9D,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED,oCAAS,GAAT,UAAU,EAAuC;YAArC,0BAAU;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;IACH,uBAAC;AAAD,CAAC,AAnBD,CAAsC,gBAAgB,GAmBrD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts b/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts new file mode 100644 index 000000000..8ef21d117 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts @@ -0,0 +1,20 @@ +import { Position } from '@nebula.gl/edit-modes'; +import { PointerMoveEvent, StopDraggingEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { ModifyHandler } from './modify-handler'; +export declare class ElevationHandler extends ModifyHandler { + makeElevatedEvent(event: PointerMoveEvent | StopDraggingEvent, position: Position): Record; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor(params: { + isDragging: boolean; + }): string; + static calculateElevationChangeWithViewport(viewport: any, { pointerDownScreenCoords, screenCoords, }: { + pointerDownScreenCoords: Position; + screenCoords: Position; + }): number; +} +//# sourceMappingURL=elevation-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts.map new file mode 100644 index 000000000..2d6661fc5 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/elevation-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"elevation-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/elevation-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAajD,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,EAC3C,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA2BtB,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAOvE,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAO3E,SAAS,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAQlD,MAAM,CAAC,oCAAoC,CACzC,QAAQ,EAAE,GAAG,EACb,EACE,uBAAuB,EACvB,YAAY,GACb,EAAE;QACD,uBAAuB,EAAE,QAAQ,CAAC;QAClC,YAAY,EAAE,QAAQ,CAAC;KACxB,GACA,MAAM;CAOV"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/elevation-handler.js b/lib/modules/layers/src/mode-handlers/elevation-handler.js new file mode 100644 index 000000000..cbce1a7c2 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/elevation-handler.js @@ -0,0 +1,60 @@ +import { __extends } from "tslib"; +import { getPickedEditHandle } from './mode-handler'; +import { ModifyHandler } from './modify-handler'; +function defaultCalculateElevationChange(_a) { + var pointerDownScreenCoords = _a.pointerDownScreenCoords, screenCoords = _a.screenCoords; + return 10 * (pointerDownScreenCoords[1] - screenCoords[1]); +} +// TODO edit-modes: delete handlers once EditMode fully implemented +var ElevationHandler = /** @class */ (function (_super) { + __extends(ElevationHandler, _super); + function ElevationHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ElevationHandler.prototype.makeElevatedEvent = function (event, position) { + if (!event.pointerDownScreenCoords) { + return event; + } + var _a = this._modeConfig || {}, _b = _a.minElevation, minElevation = _b === void 0 ? 0 : _b, _c = _a.maxElevation, maxElevation = _c === void 0 ? 20000 : _c, _d = _a.calculateElevationChange, calculateElevationChange = _d === void 0 ? defaultCalculateElevationChange : _d; + // $FlowFixMe - really, I know it has something at index 2 + var elevation = position.length === 3 ? position[2] : 0; + // calculateElevationChange is configurable becase (at this time) modes are not aware of the viewport + elevation += calculateElevationChange({ + pointerDownScreenCoords: event.pointerDownScreenCoords, + screenCoords: event.screenCoords, + }); + elevation = Math.min(elevation, maxElevation); + elevation = Math.max(elevation, minElevation); + return Object.assign({}, event, { + groundCoords: [position[0], position[1], elevation], + }); + }; + ElevationHandler.prototype.handlePointerMove = function (event) { + var editHandle = getPickedEditHandle(event.pointerDownPicks); + var position = editHandle ? editHandle.position : event.groundCoords; + // @ts-ignore + return _super.prototype.handlePointerMove.call(this, this.makeElevatedEvent(event, position)); + }; + ElevationHandler.prototype.handleStopDragging = function (event) { + var editHandle = getPickedEditHandle(event.picks); + var position = editHandle ? editHandle.position : event.groundCoords; + // @ts-ignore + return _super.prototype.handleStopDragging.call(this, this.makeElevatedEvent(event, position)); + }; + ElevationHandler.prototype.getCursor = function (params) { + var cursor = _super.prototype.getCursor.call(this, params); + if (cursor === 'cell') { + cursor = 'ns-resize'; + } + return cursor; + }; + ElevationHandler.calculateElevationChangeWithViewport = function (viewport, _a) { + var pointerDownScreenCoords = _a.pointerDownScreenCoords, screenCoords = _a.screenCoords; + // Source: https://gis.stackexchange.com/a/127949/111804 + var metersPerPixel = (156543.03392 * Math.cos((viewport.latitude * Math.PI) / 180)) / Math.pow(2, viewport.zoom); + return (metersPerPixel * (pointerDownScreenCoords[1] - screenCoords[1])) / 2; + }; + return ElevationHandler; +}(ModifyHandler)); +export { ElevationHandler }; +//# sourceMappingURL=elevation-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/elevation-handler.js.map b/lib/modules/layers/src/mode-handlers/elevation-handler.js.map new file mode 100644 index 000000000..a80863c75 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/elevation-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"elevation-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/elevation-handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAc,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,SAAS,+BAA+B,CAAC,EAMxC;QALC,oDAAuB,EACvB,8BAAY;IAKZ,OAAO,EAAE,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,mEAAmE;AACnE;IAAsC,oCAAa;IAAnD;;IAuEA,CAAC;IA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ACzC,IAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpD,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QACvE,aAAa;QACb,OAAO,iBAAM,kBAAkB,YAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,oCAAS,GAAT,UAAU,MAA+B;QACvC,IAAI,MAAM,GAAG,iBAAM,SAAS,YAAC,MAAM,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,GAAG,WAAW,CAAC;SACtB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,qDAAoC,GAA3C,UACE,QAAa,EACb,EAMC;YALC,oDAAuB,EACvB,8BAAY;QAMd,wDAAwD;QACxD,IAAM,cAAc,GAClB,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE9F,OAAO,CAAC,cAAc,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/E,CAAC;IACH,uBAAC;AAAD,CAAC,AAvED,CAAsC,aAAa,GAuElD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts b/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts new file mode 100644 index 000000000..2699c6f71 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts @@ -0,0 +1,19 @@ +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditAction } from './mode-handler'; +import { ModifyHandler } from './modify-handler'; +export declare class ExtrudeHandler extends ModifyHandler { + isPointAdded: boolean; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + coordinatesSize(positionIndexes: number[], featureIndex: number): number; + getBearing(p1: any, p2: any): number; + isOrthogonal(positionIndexes: number[], featureIndex: number, size: number): boolean; + nextPositionIndexes(positionIndexes: number[], size: number): number[]; + prevPositionIndexes(positionIndexes: number[], size: number): number[]; + getPointForPositionIndexes(positionIndexes: number[], featureIndex: number): any; +} +//# sourceMappingURL=extrude-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts.map new file mode 100644 index 000000000..00ca89eda --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/extrude-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"extrude-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/extrude-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,qBAAa,cAAe,SAAQ,aAAa;IAC/C,YAAY,UAAS;IACrB,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAiDvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAyD7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IA8C3E,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM;IAmB/D,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG;IAQ3B,YAAY,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAkB1E,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAQtE,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAQtE,0BAA0B,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM;CAkB3E"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/extrude-handler.js b/lib/modules/layers/src/mode-handlers/extrude-handler.js new file mode 100644 index 000000000..bc544a6cb --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/extrude-handler.js @@ -0,0 +1,185 @@ +import { __extends, __read, __spread } from "tslib"; +import bearing from '@turf/bearing'; +import { generatePointsParallelToLinePoints } from '../utils'; +import { getPickedEditHandle } from './mode-handler'; +import { ModifyHandler } from './modify-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var ExtrudeHandler = /** @class */ (function (_super) { + __extends(ExtrudeHandler, _super); + function ExtrudeHandler() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.isPointAdded = false; + return _this; + } + ExtrudeHandler.prototype.handlePointerMove = function (event) { + this._lastPointerMovePicks = event.picks; + var editAction = null; + var editHandle = getPickedEditHandle(event.pointerDownPicks); + if (event.isDragging && editHandle) { + var size = this.coordinatesSize(editHandle.positionIndexes, editHandle.featureIndex); + var positionIndexes = this.isPointAdded + ? this.nextPositionIndexes(editHandle.positionIndexes, size) + : editHandle.positionIndexes; + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), editHandle.featureIndex); + var p2 = this.getPointForPositionIndexes(positionIndexes, editHandle.featureIndex); + if (p1 && p2) { + // p3 and p4 are end points for moving (extruding) edge + var _a = __read(generatePointsParallelToLinePoints(p1, p2, event.groundCoords), 2), p3 = _a[0], p4 = _a[1]; + var updatedData = this.getImmutableFeatureCollection() + .replacePosition(editHandle.featureIndex, this.prevPositionIndexes(positionIndexes, size), p4) + .replacePosition(editHandle.featureIndex, positionIndexes, p3) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'extruding', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: this.nextPositionIndexes(editHandle.positionIndexes, size), + position: p3, + }, + }; + } + } + // Cancel map panning if pointer went down on an edit handle + var cancelMapPan = Boolean(editHandle); + return { editAction: editAction, cancelMapPan: cancelMapPan }; + }; + ExtrudeHandler.prototype.handleStartDragging = function (event) { + var editAction = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var editHandle = getPickedEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle && editHandle.type === 'intermediate') { + var size = this.coordinatesSize(editHandle.positionIndexes, editHandle.featureIndex); + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(editHandle.positionIndexes, size), editHandle.featureIndex); + var p2 = this.getPointForPositionIndexes(editHandle.positionIndexes, editHandle.featureIndex); + if (p1 && p2) { + var updatedData = this.getImmutableFeatureCollection(); + if (!this.isOrthogonal(editHandle.positionIndexes, editHandle.featureIndex, size)) { + updatedData = updatedData.addPosition(editHandle.featureIndex, editHandle.positionIndexes, p2); + } + if (!this.isOrthogonal(this.prevPositionIndexes(editHandle.positionIndexes, size), editHandle.featureIndex, size)) { + updatedData = updatedData.addPosition(editHandle.featureIndex, editHandle.positionIndexes, p1); + this.isPointAdded = true; + } + editAction = { + updatedData: updatedData.getObject(), + editType: 'startExtruding', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: editHandle.positionIndexes, + position: p1, + }, + }; + } + } + return editAction; + }; + ExtrudeHandler.prototype.handleStopDragging = function (event) { + var editAction = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var editHandle = getPickedEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle) { + var size = this.coordinatesSize(editHandle.positionIndexes, editHandle.featureIndex); + var positionIndexes = this.isPointAdded + ? this.nextPositionIndexes(editHandle.positionIndexes, size) + : editHandle.positionIndexes; + // p1 and p1 are end points for edge + var p1 = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), editHandle.featureIndex); + var p2 = this.getPointForPositionIndexes(positionIndexes, editHandle.featureIndex); + if (p1 && p2) { + // p3 and p4 are end points for new moved (extruded) edge + var _a = __read(generatePointsParallelToLinePoints(p1, p2, event.groundCoords), 2), p3 = _a[0], p4 = _a[1]; + var updatedData = this.getImmutableFeatureCollection() + .replacePosition(editHandle.featureIndex, this.prevPositionIndexes(positionIndexes, size), p4) + .replacePosition(editHandle.featureIndex, positionIndexes, p3) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'extruded', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: editHandle.positionIndexes, + position: p3, + }, + }; + } + } + this.isPointAdded = false; + return editAction; + }; + ExtrudeHandler.prototype.coordinatesSize = function (positionIndexes, featureIndex) { + var size = 0; + var feature = this.getImmutableFeatureCollection().getObject().features[featureIndex]; + var coordinates = feature.geometry.coordinates; + // for Multi polygons, length will be 3 + if (positionIndexes.length === 3) { + var _a = __read(positionIndexes, 2), a = _a[0], b = _a[1]; + if (coordinates.length && coordinates[a].length) { + size = coordinates[a][b].length; + } + } + else { + var _b = __read(positionIndexes, 1), b = _b[0]; + if (coordinates.length && coordinates[b].length) { + size = coordinates[b].length; + } + } + return size; + }; + ExtrudeHandler.prototype.getBearing = function (p1, p2) { + var angle = bearing(p1, p2); + if (angle < 0) { + return Math.floor(360 + angle); + } + return Math.floor(angle); + }; + ExtrudeHandler.prototype.isOrthogonal = function (positionIndexes, featureIndex, size) { + if (positionIndexes[positionIndexes.length - 1] === size - 1) { + positionIndexes[positionIndexes.length - 1] = 0; + } + var prevPoint = this.getPointForPositionIndexes(this.prevPositionIndexes(positionIndexes, size), featureIndex); + var nextPoint = this.getPointForPositionIndexes(this.nextPositionIndexes(positionIndexes, size), featureIndex); + var currentPoint = this.getPointForPositionIndexes(positionIndexes, featureIndex); + var prevAngle = this.getBearing(currentPoint, prevPoint); + var nextAngle = this.getBearing(currentPoint, nextPoint); + return [89, 90, 91, 269, 270, 271].includes(Math.abs(prevAngle - nextAngle)); + }; + ExtrudeHandler.prototype.nextPositionIndexes = function (positionIndexes, size) { + var next = __spread(positionIndexes); + if (next.length) { + next[next.length - 1] = next[next.length - 1] === size - 1 ? 0 : next[next.length - 1] + 1; + } + return next; + }; + ExtrudeHandler.prototype.prevPositionIndexes = function (positionIndexes, size) { + var prev = __spread(positionIndexes); + if (prev.length) { + prev[prev.length - 1] = prev[prev.length - 1] === 0 ? size - 2 : prev[prev.length - 1] - 1; + } + return prev; + }; + ExtrudeHandler.prototype.getPointForPositionIndexes = function (positionIndexes, featureIndex) { + var p1; + var feature = this.getImmutableFeatureCollection().getObject().features[featureIndex]; + var coordinates = feature.geometry.coordinates; + // for Multi polygons, length will be 3 + if (positionIndexes.length === 3) { + var _a = __read(positionIndexes, 3), a = _a[0], b = _a[1], c = _a[2]; + if (coordinates.length && coordinates[a].length) { + p1 = coordinates[a][b][c]; + } + } + else { + var _b = __read(positionIndexes, 2), b = _b[0], c = _b[1]; + if (coordinates.length && coordinates[b].length) { + p1 = coordinates[b][c]; + } + } + return p1; + }; + return ExtrudeHandler; +}(ModifyHandler)); +export { ExtrudeHandler }; +//# sourceMappingURL=extrude-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/extrude-handler.js.map b/lib/modules/layers/src/mode-handlers/extrude-handler.js.map new file mode 100644 index 000000000..7d5a84ec8 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/extrude-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extrude-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/extrude-handler.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAc,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,mEAAmE;AACnE;IAAoC,kCAAa;IAAjD;QAAA,qEA2OC;QA1OC,kBAAY,GAAG,KAAK,CAAC;;IA0OvB,CAAC;IAzOC,0CAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC,KAAK,CAAC;QAEzC,IAAI,UAAU,GAAkC,IAAI,CAAC;QAErD,IAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAE/D,IAAI,KAAK,CAAC,UAAU,IAAI,UAAU,EAAE;YAClC,IAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;YACvF,IAAM,eAAe,GAAG,IAAI,CAAC,YAAY;gBACvC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC;gBAC5D,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC;YAC/B,oCAAoC;YACpC,IAAM,EAAE,GAAG,IAAI,CAAC,0BAA0B,CACxC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,IAAI,CAAC,EAC/C,UAAU,CAAC,YAAY,CACxB,CAAC;YACF,IAAM,EAAE,GAAG,IAAI,CAAC,0BAA0B,CAAC,eAAe,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;YACrF,IAAI,EAAE,IA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/layers/src/mode-handlers/mode-handler.d.ts b/lib/modules/layers/src/mode-handlers/mode-handler.d.ts new file mode 100644 index 000000000..70f00ec94 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/mode-handler.d.ts @@ -0,0 +1,61 @@ +import { ImmutableFeatureCollection, FeatureCollection, Feature, Polygon, Geometry, Position } from '@nebula.gl/edit-modes'; +import { ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, DeckGLPick } from '../event-types'; +export declare type EditHandleType = 'existing' | 'intermediate' | 'snap'; +export declare type EditHandle = { + position: Position; + positionIndexes: number[]; + featureIndex: number; + type: EditHandleType; +}; +export declare type EditAction = { + updatedData: FeatureCollection; + editType: string; + featureIndexes: number[]; + editContext: any; +}; +export declare class ModeHandler { + featureCollection: ImmutableFeatureCollection; + _tentativeFeature: Feature | null | undefined; + _modeConfig: any; + _selectedFeatureIndexes: number[]; + _clickSequence: Position[]; + constructor(featureCollection?: FeatureCollection); + getFeatureCollection(): FeatureCollection; + getImmutableFeatureCollection(): ImmutableFeatureCollection; + getSelectedFeature(): Feature | null | undefined; + getSelectedGeometry(): Geometry | null | undefined; + getSelectedFeaturesAsFeatureCollection(): FeatureCollection; + setFeatureCollection(featureCollection: FeatureCollection): void; + getModeConfig(): any; + setModeConfig(modeConfig: any): void; + getSelectedFeatureIndexes(): number[]; + setSelectedFeatureIndexes(indexes: number[]): void; + getClickSequence(): Position[]; + resetClickSequence(): void; + getTentativeFeature(): Feature | null | undefined; + _setTentativeFeature(tentativeFeature: Feature | null | undefined): void; + /** + * Returns a flat array of positions for the given feature along with their indexes into the feature's geometry's coordinates. + * + * @param featureIndex The index of the feature to get edit handles + */ + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; + isSelectionPicked(picks: DeckGLPick[]): boolean; + getAddFeatureAction(geometry: Geometry): EditAction; + getAddManyFeaturesAction(featureCollection: FeatureCollection): EditAction; + getAddFeatureOrBooleanPolygonAction(geometry: Polygon): EditAction | null | undefined; + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; +} +export declare function getPickedEditHandle(picks: any[] | null | undefined): EditHandle | null | undefined; +export declare function getIntermediatePosition(position1: Position, position2: Position): Position; +export declare function getEditHandlesForGeometry(geometry: Geometry, featureIndex: number, editHandleType?: EditHandleType): EditHandle[]; +//# sourceMappingURL=mode-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/mode-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/mode-handler.d.ts.map new file mode 100644 index 000000000..a601b1134 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/mode-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mode-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/mode-handler.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAExB,oBAAY,cAAc,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,CAAC;AAElE,oBAAY,UAAU,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC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AC,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAsBnD,wBAAwB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,UAAU;IA0B1E,mCAAmC,CAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IA8DrF,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAM7D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAIvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAI7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;CAG5E;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,GAC9B,UAAU,GAAG,IAAI,GAAG,SAAS,CAM/B;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAO1F;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,cAA2B,gBA6D5C"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/mode-handler.js b/lib/modules/layers/src/mode-handlers/mode-handler.js new file mode 100644 index 000000000..a6aae2128 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/mode-handler.js @@ -0,0 +1,304 @@ +// TODO edit-modes: delete handlers once EditMode fully implemented +import { __read, __spread, __values } from "tslib"; +import turfUnion from '@turf/union'; +import turfDifference from '@turf/difference'; +import turfIntersect from '@turf/intersect'; +import { ImmutableFeatureCollection, } from '@nebula.gl/edit-modes'; +var ModeHandler = /** @class */ (function () { + function ModeHandler(featureCollection) { + this._modeConfig = null; + this._selectedFeatureIndexes = []; + this._clickSequence = []; + if (featureCollection) { + this.setFeatureCollection(featureCollection); + } + } + ModeHandler.prototype.getFeatureCollection = function () { + return this.featureCollection.getObject(); + }; + ModeHandler.prototype.getImmutableFeatureCollection = function () { + return this.featureCollection; + }; + ModeHandler.prototype.getSelectedFeature = function () { + if (this._selectedFeatureIndexes.length === 1) { + return this.featureCollection.getObject().features[this._selectedFeatureIndexes[0]]; + } + return null; + }; + ModeHandler.prototype.getSelectedGeometry = function () { + var feature = this.getSelectedFeature(); + if (feature) { + return feature.geometry; + } + return null; + }; + ModeHandler.prototype.getSelectedFeaturesAsFeatureCollection = function () { + var features = this.featureCollection.getObject().features; + var selectedFeatures = this.getSelectedFeatureIndexes().map(function (selectedIndex) { return features[selectedIndex]; }); + return { + type: 'FeatureCollection', + features: selectedFeatures, + }; + }; + ModeHandler.prototype.setFeatureCollection = function (featureCollection) { + this.featureCollection = new ImmutableFeatureCollection(featureCollection); + }; + ModeHandler.prototype.getModeConfig = function () { + return this._modeConfig; + }; + ModeHandler.prototype.setModeConfig = function (modeConfig) { + if (this._modeConfig === modeConfig) { + return; + } + this._modeConfig = modeConfig; + this._setTentativeFeature(null); + }; + ModeHandler.prototype.getSelectedFeatureIndexes = function () { + return this._selectedFeatureIndexes; + }; + ModeHandler.prototype.setSelectedFeatureIndexes = function (indexes) { + if (this._selectedFeatureIndexes === indexes) { + return; + } + this._selectedFeatureIndexes = indexes; + this._setTentativeFeature(null); + }; + ModeHandler.prototype.getClickSequence = function () { + return this._clickSequence; + }; + ModeHandler.prototype.resetClickSequence = function () { + this._clickSequence = []; + }; + ModeHandler.prototype.getTentativeFeature = function () { + return this._tentativeFeature; + }; + // TODO: remove the underscore + ModeHandler.prototype._setTentativeFeature = function (tentativeFeature) { + this._tentativeFeature = tentativeFeature; + if (!tentativeFeature) { + // Reset the click sequence + this._clickSequence = []; + } + }; + /** + * Returns a flat array of positions for the given feature along with their indexes into the feature's geometry's coordinates. + * + * @param featureIndex The index of the feature to get edit handles + */ + ModeHandler.prototype.getEditHandles = function (picks, groundCoords) { + return []; + }; + ModeHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + return 'cell'; + }; + ModeHandler.prototype.isSelectionPicked = function (picks) { + if (!picks.length) + return false; + var pickedIndexes = picks.map(function (_a) { + var index = _a.index; + return index; + }); + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + return selectedFeatureIndexes.some(function (index) { return pickedIndexes.includes(index); }); + }; + ModeHandler.prototype.getAddFeatureAction = function (geometry) { + // Unsure why flow can't deal with Geometry type, but there I fixed it + var geometryAsAny = geometry; + var updatedData = this.getImmutableFeatureCollection() + .addFeature({ + type: 'Feature', + properties: {}, + geometry: geometryAsAny, + }) + .getObject(); + return { + updatedData: updatedData, + editType: 'addFeature', + featureIndexes: [updatedData.features.length - 1], + editContext: { + featureIndexes: [updatedData.features.length - 1], + }, + }; + }; + ModeHandler.prototype.getAddManyFeaturesAction = function (featureCollection) { + var e_1, _a; + var features = featureCollection.features; + var updatedData = this.getImmutableFeatureCollection(); + var initialIndex = updatedData.getObject().features.length; + var updatedIndexes = []; + try { + for (var features_1 = __values(features), features_1_1 = features_1.next(); !features_1_1.done; features_1_1 = features_1.next()) { + var feature = features_1_1.value; + var properties = feature.properties, geometry = feature.geometry; + var geometryAsAny = geometry; + updatedData = updatedData.addFeature({ + type: 'Feature', + properties: properties, + geometry: geometryAsAny, + }); + updatedIndexes.push(initialIndex + updatedIndexes.length); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (features_1_1 && !features_1_1.done && (_a = features_1.return)) _a.call(features_1); + } + finally { if (e_1) throw e_1.error; } + } + return { + updatedData: updatedData.getObject(), + editType: 'addFeature', + featureIndexes: updatedIndexes, + editContext: { + featureIndexes: updatedIndexes, + }, + }; + }; + ModeHandler.prototype.getAddFeatureOrBooleanPolygonAction = function (geometry) { + var selectedFeature = this.getSelectedFeature(); + var modeConfig = this.getModeConfig(); + if (modeConfig && modeConfig.booleanOperation) { + if (!selectedFeature || + (selectedFeature.geometry.type !== 'Polygon' && + selectedFeature.geometry.type !== 'MultiPolygon')) { + // eslint-disable-next-line no-console,no-undef + console.warn('booleanOperation only supported for single Polygon or MultiPolygon selection'); + return null; + } + var feature = { + type: 'Feature', + geometry: geometry, + }; + var updatedGeometry = void 0; + if (modeConfig.booleanOperation === 'union') { + updatedGeometry = turfUnion(selectedFeature, feature); + } + else if (modeConfig.booleanOperation === 'difference') { + // @ts-ignore + updatedGeometry = turfDifference(selectedFeature, feature); + } + else if (modeConfig.booleanOperation === 'intersection') { + // @ts-ignore + updatedGeometry = turfIntersect(selectedFeature, feature); + } + else { + // eslint-disable-next-line no-console,no-undef + console.warn("Invalid booleanOperation " + modeConfig.booleanOperation); + return null; + } + if (!updatedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('Canceling edit. Boolean operation erased entire polygon.'); + return null; + } + var featureIndex = this.getSelectedFeatureIndexes()[0]; + var updatedData = this.getImmutableFeatureCollection() + .replaceGeometry(featureIndex, updatedGeometry.geometry) + .getObject(); + var editAction = { + updatedData: updatedData, + editType: 'unionGeometry', + featureIndexes: [featureIndex], + editContext: { + featureIndexes: [featureIndex], + }, + }; + return editAction; + } + return this.getAddFeatureAction(geometry); + }; + ModeHandler.prototype.handleClick = function (event) { + this._clickSequence.push(event.groundCoords); + return null; + }; + ModeHandler.prototype.handlePointerMove = function (event) { + return { editAction: null, cancelMapPan: false }; + }; + ModeHandler.prototype.handleStartDragging = function (event) { + return null; + }; + ModeHandler.prototype.handleStopDragging = function (event) { + return null; + }; + return ModeHandler; +}()); +export { ModeHandler }; +export function getPickedEditHandle(picks) { + var info = picks && picks.find(function (pick) { return pick.isEditingHandle; }); + if (info) { + return info.object; + } + return null; +} +export function getIntermediatePosition(position1, position2) { + var intermediatePosition = [ + (position1[0] + position2[0]) / 2.0, + (position1[1] + position2[1]) / 2.0, + ]; + // @ts-ignore + return intermediatePosition; +} +export function getEditHandlesForGeometry(geometry, featureIndex, editHandleType) { + if (editHandleType === void 0) { editHandleType = 'existing'; } + var handles = []; + switch (geometry.type) { + case 'Point': + // positions are not nested + handles = [ + { + position: geometry.coordinates, + positionIndexes: [], + featureIndex: featureIndex, + type: editHandleType, + }, + ]; + break; + case 'MultiPoint': + case 'LineString': + // positions are nested 1 level + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates, [], featureIndex, editHandleType)); + break; + case 'Polygon': + case 'MultiLineString': + // positions are nested 2 levels + for (var a = 0; a < geometry.coordinates.length; a++) { + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates[a], [a], featureIndex, editHandleType)); + if (geometry.type === 'Polygon') { + // Don't repeat the first/last handle for Polygons + handles = handles.slice(0, -1); + } + } + break; + case 'MultiPolygon': + // positions are nested 3 levels + for (var a = 0; a < geometry.coordinates.length; a++) { + for (var b = 0; b < geometry.coordinates[a].length; b++) { + handles = handles.concat(getEditHandlesForCoordinates(geometry.coordinates[a][b], [a, b], featureIndex, editHandleType)); + // Don't repeat the first/last handle for Polygons + handles = handles.slice(0, -1); + } + } + break; + default: + // @ts-ignore + throw Error("Unhandled geometry type: " + geometry.type); + } + return handles; +} +function getEditHandlesForCoordinates(coordinates, positionIndexPrefix, featureIndex, editHandleType) { + if (editHandleType === void 0) { editHandleType = 'existing'; } + var editHandles = []; + for (var i = 0; i < coordinates.length; i++) { + var position = coordinates[i]; + editHandles.push({ + position: position, + positionIndexes: __spread(positionIndexPrefix, [i]), + featureIndex: featureIndex, + type: editHandleType, + }); + } + return editHandles; +} +//# sourceMappingURL=mode-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/mode-handler.js.map b/lib/modules/layers/src/mode-handlers/mode-handler.js.map new file mode 100644 index 000000000..24ab4070e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/mode-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mode-handler.js","sourceRoot":"","sources":["../../../../../modules/lay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BAChC;aACF;YAED,MAAM;QACR;YACE,aAAa;YACb,MAAM,KAAK,CAAC,8BAA4B,QAAQ,CAAC,IAAM,CAAC,CAAC;KAC5D;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,4BAA4B,CACnC,WAAkB,EAClB,mBAA6B,EAC7B,YAAoB,EACpB,cAA2C;IAA3C,+BAAA,EAAA,2BAA2C;IAE3C,IAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC;YACf,QAAQ,UAAA;YACR,eAAe,WAAM,mBAAmB,GAAE,CAAC,EAAC;YAC5C,YAAY,cAAA;YACZ,IAAI,EAAE,cAAc;SACrB,CAAC,CAAC;KACJ;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/modify-handler.d.ts b/lib/modules/layers/src/mode-handlers/modify-handler.d.ts new file mode 100644 index 000000000..9ff0720be --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/modify-handler.d.ts @@ -0,0 +1,20 @@ +import { Position, FeatureOf, Point, LineString } from '@nebula.gl/edit-modes'; +import { NearestPointType } from '../utils'; +import { ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditAction, EditHandle, ModeHandler } from './mode-handler'; +export declare class ModifyHandler extends ModeHandler { + _lastPointerMovePicks: any; + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; + nearestPointOnLine(line: FeatureOf, inPoint: FeatureOf): NearestPointType; + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; +} +//# sourceMappingURL=modify-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/modify-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/modify-handler.d.ts.map new file mode 100644 index 000000000..c7077cb50 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/modify-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/modify-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAGL,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAGxB,qBAAa,aAAc,SAAQ,WAAW;IAC5C,qBAAqB,EAAE,GAAG,CAAC;IAE3B,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,EAAE;IA0EzF,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,gBAAgB;IAiB5F,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAoD7D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IA6BvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAyB7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAwB3E,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;CAY3D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/modify-handler.js b/lib/modules/layers/src/mode-handlers/modify-handler.js new file mode 100644 index 000000000..0e229813d --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/modify-handler.js @@ -0,0 +1,211 @@ +import { __extends, __read, __spread, __values } from "tslib"; +import nearestPointOnLine from '@turf/nearest-point-on-line'; +import { point, lineString as toLineString } from '@turf/helpers'; +import { recursivelyTraverseNestedArrays, nearestPointOnProjectedLine, } from '../utils'; +import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry, } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var ModifyHandler = /** @class */ (function (_super) { + __extends(ModifyHandler, _super); + function ModifyHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ModifyHandler.prototype.getEditHandles = function (picks, groundCoords) { + var e_1, _a; + var _this = this; + var handles = []; + var features = this.featureCollection.getObject().features; + try { + for (var _b = __values(this.getSelectedFeatureIndexes()), _c = _b.next(); !_c.done; _c = _b.next()) { + var index = _c.value; + if (index < features.length) { + var geometry = features[index].geometry; + handles.push.apply(handles, __spread(getEditHandlesForGeometry(geometry, index))); + } + else { + console.warn("selectedFeatureIndexes out of range " + index); // eslint-disable-line no-console,no-undef + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + // intermediate edit handle + if (picks && picks.length && groundCoords) { + var existingEditHandle = picks.find(function (pick) { return pick.isEditingHandle && pick.object && pick.object.type === 'existing'; }); + // don't show intermediate point when too close to an existing edit handle + var featureAsPick = !existingEditHandle && picks.find(function (pick) { return !pick.isEditingHandle; }); + // is the feature in the pick selected + if (featureAsPick && + !featureAsPick.object.geometry.type.includes('Point') && + this.getSelectedFeatureIndexes().includes(featureAsPick.index)) { + var intermediatePoint_1 = null; + var positionIndexPrefix_1 = []; + var referencePoint_1 = point(groundCoords); + // process all lines of the (single) feature + recursivelyTraverseNestedArrays(featureAsPick.object.geometry.coordinates, [], function (lineString, prefix) { + var lineStringFeature = toLineString(lineString); + var candidateIntermediatePoint = _this.nearestPointOnLine( + // @ts-ignore + lineStringFeature, referencePoint_1); + if (!intermediatePoint_1 || + candidateIntermediatePoint.properties.dist < intermediatePoint_1.properties.dist) { + intermediatePoint_1 = candidateIntermediatePoint; + positionIndexPrefix_1 = prefix; + } + }); + // tack on the lone intermediate point to the set of handles + if (intermediatePoint_1) { + var position = intermediatePoint_1.geometry.coordinates, index = intermediatePoint_1.properties.index; + handles = __spread(handles, [ + { + position: position, + positionIndexes: __spread(positionIndexPrefix_1, [index + 1]), + featureIndex: featureAsPick.index, + type: 'intermediate', + }, + ]); + } + } + } + return handles; + }; + // turf.js does not support elevation for nearestPointOnLine + ModifyHandler.prototype.nearestPointOnLine = function (line, inPoint) { + var coordinates = line.geometry.coordinates; + if (coordinates.some(function (coord) { return coord.length > 2; })) { + var modeConfig = this.getModeConfig(); + if (modeConfig && modeConfig.viewport) { + // This line has elevation, we need to use alternative algorithm + return nearestPointOnProjectedLine(line, inPoint, modeConfig.viewport); + } + // eslint-disable-next-line no-console,no-undef + console.log('Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'); + } + return nearestPointOnLine(line, inPoint); + }; + ModifyHandler.prototype.handleClick = function (event) { + var editAction = null; + var clickedEditHandle = getPickedEditHandle(event.picks); + if (clickedEditHandle && clickedEditHandle.featureIndex >= 0) { + if (clickedEditHandle.type === 'existing') { + var updatedData = void 0; + try { + updatedData = this.getImmutableFeatureCollection() + .removePosition(clickedEditHandle.featureIndex, clickedEditHandle.positionIndexes) + .getObject(); + } + catch (ignored) { + // This happens if user attempts to remove the last point + } + if (updatedData) { + editAction = { + updatedData: updatedData, + editType: 'removePosition', + featureIndexes: [clickedEditHandle.featureIndex], + editContext: { + positionIndexes: clickedEditHandle.positionIndexes, + position: clickedEditHandle.position, + }, + }; + } + } + else if (clickedEditHandle.type === 'intermediate') { + var updatedData = this.getImmutableFeatureCollection() + .addPosition(clickedEditHandle.featureIndex, clickedEditHandle.positionIndexes, clickedEditHandle.position) + .getObject(); + if (updatedData) { + editAction = { + updatedData: updatedData, + editType: 'addPosition', + featureIndexes: [clickedEditHandle.featureIndex], + editContext: { + positionIndexes: clickedEditHandle.positionIndexes, + position: clickedEditHandle.position, + }, + }; + } + } + } + return editAction; + }; + ModifyHandler.prototype.handlePointerMove = function (event) { + this._lastPointerMovePicks = event.picks; + var editAction = null; + var editHandle = getPickedEditHandle(event.pointerDownPicks); + if (event.isDragging && editHandle) { + var updatedData = this.getImmutableFeatureCollection() + .replacePosition(editHandle.featureIndex, editHandle.positionIndexes, event.groundCoords) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'movePosition', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: editHandle.positionIndexes, + position: event.groundCoords, + }, + }; + } + // Cancel map panning if pointer went down on an edit handle + var cancelMapPan = Boolean(editHandle); + return { editAction: editAction, cancelMapPan: cancelMapPan }; + }; + ModifyHandler.prototype.handleStartDragging = function (event) { + var editAction = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var editHandle = getPickedEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle && editHandle.type === 'intermediate') { + var updatedData = this.getImmutableFeatureCollection() + .addPosition(editHandle.featureIndex, editHandle.positionIndexes, event.groundCoords) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'addPosition', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: editHandle.positionIndexes, + position: event.groundCoords, + }, + }; + } + return editAction; + }; + ModifyHandler.prototype.handleStopDragging = function (event) { + var editAction = null; + var selectedFeatureIndexes = this.getSelectedFeatureIndexes(); + var editHandle = getPickedEditHandle(event.picks); + if (selectedFeatureIndexes.length && editHandle) { + var updatedData = this.getImmutableFeatureCollection() + .replacePosition(editHandle.featureIndex, editHandle.positionIndexes, event.groundCoords) + .getObject(); + editAction = { + updatedData: updatedData, + editType: 'finishMovePosition', + featureIndexes: [editHandle.featureIndex], + editContext: { + positionIndexes: editHandle.positionIndexes, + position: event.groundCoords, + }, + }; + } + return editAction; + }; + ModifyHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + var picks = this._lastPointerMovePicks; + if (picks && picks.length > 0) { + var handlePicked = picks.some(function (pick) { return pick.isEditingHandle; }); + if (handlePicked) { + return 'cell'; + } + } + return isDragging ? 'grabbing' : 'grab'; + }; + return ModifyHandler; +}(ModeHandler)); +export { ModifyHandler }; +//# sourceMappingURL=modify-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/modify-handler.js.map b/lib/modules/layers/src/mode-handlers/modify-handler.js.map new file mode 100644 index 000000000..d501ce657 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/modify-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"modify-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/modify-handler.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,GAE5B,MAAM,UAAU,CAAC;AAOlB,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,mEAAmE;AACnE;IAAmC,iCAAW;IAA9C;;IA8OA,CAAC;IA3OC,sCAAc,GAAd,UAAe,KAAkC,EAAE,YAAuB;;QAA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GAAG,IAAI,CAAC,qBAAqB,CAAC;QAEzC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,IAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,eAAe,EAApB,CAAoB,CAAC,CAAC;YAChE,IAAI,YAAY,EAAE;gBAChB,OAAO,MAAM,CAAC;aACf;SACF;QAED,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;IACH,oBAAC;AAAD,CAAC,AA9OD,CAAmC,WAAW,GA8O7C"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts b/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts new file mode 100644 index 000000000..4ad686ab6 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts @@ -0,0 +1,18 @@ +import { FeatureCollection, Position } from '@nebula.gl/edit-modes'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class RotateHandler extends ModeHandler { + _isRotatable: boolean; + _geometryBeingRotated: FeatureCollection | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; + getRotateAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction; +} +//# sourceMappingURL=rotate-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts.map new file mode 100644 index 000000000..f6b0c5684 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/rotate-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/rotate-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,YAAY,EAAE,OAAO,CAAC;IACtB,qBAAqB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAE5D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAsBvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAS7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAgB3E,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAQ1D,eAAe,CAAC,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU;CAuBhG"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/rotate-handler.js b/lib/modules/layers/src/mode-handlers/rotate-handler.js new file mode 100644 index 000000000..3b028af68 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/rotate-handler.js @@ -0,0 +1,77 @@ +import { __extends } from "tslib"; +import turfCentroid from '@turf/centroid'; +import turfBearing from '@turf/bearing'; +import turfTransformRotate from '@turf/transform-rotate'; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var RotateHandler = /** @class */ (function (_super) { + __extends(RotateHandler, _super); + function RotateHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + RotateHandler.prototype.handlePointerMove = function (event) { + var editAction = null; + this._isRotatable = Boolean(this._geometryBeingRotated) || this.isSelectionPicked(event.picks); + if (!this._isRotatable || !event.pointerDownGroundCoords) { + // Nothing to do + return { editAction: null, cancelMapPan: false }; + } + if (event.isDragging && this._geometryBeingRotated) { + // Rotate the geometry + editAction = this.getRotateAction(event.pointerDownGroundCoords, event.groundCoords, 'rotating'); + } + return { editAction: editAction, cancelMapPan: true }; + }; + RotateHandler.prototype.handleStartDragging = function (event) { + if (!this._isRotatable) { + return null; + } + this._geometryBeingRotated = this.getSelectedFeaturesAsFeatureCollection(); + return null; + }; + RotateHandler.prototype.handleStopDragging = function (event) { + var editAction = null; + if (this._geometryBeingRotated) { + // Rotate the geometry + editAction = this.getRotateAction(event.pointerDownGroundCoords, event.groundCoords, 'rotated'); + this._geometryBeingRotated = null; + } + return editAction; + }; + RotateHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + if (this._isRotatable) { + // TODO: look at doing SVG cursors to get a better "rotate" cursor + return 'move'; + } + return isDragging ? 'grabbing' : 'grab'; + }; + RotateHandler.prototype.getRotateAction = function (startDragPoint, currentPoint, editType) { + var startPosition = startDragPoint; + var centroid = turfCentroid(this._geometryBeingRotated); + var angle = getRotationAngle(centroid, startPosition, currentPoint); + // @ts-ignore + var rotatedFeatures = turfTransformRotate(this._geometryBeingRotated, angle); + var updatedData = this.getImmutableFeatureCollection(); + var selectedIndexes = this.getSelectedFeatureIndexes(); + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = rotatedFeatures.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return { + updatedData: updatedData.getObject(), + editType: editType, + featureIndexes: selectedIndexes, + editContext: null, + }; + }; + return RotateHandler; +}(ModeHandler)); +export { RotateHandler }; +function getRotationAngle(centroid, startDragPoint, currentPoint) { + var bearing1 = turfBearing(centroid, startDragPoint); + var bearing2 = turfBearing(centroid, currentPoint); + return bearing2 - bearing1; +} +//# sourceMappingURL=rotate-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/rotate-handler.js.map b/lib/modules/layers/src/mode-handlers/rotate-handler.js.map new file mode 100644 index 000000000..4b6d9f913 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/rotate-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"rotate-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/rotate-handler.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AAGzD,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAAmC,iCAAW;IAA9C;;IAoFA,CAAC;IAhFC,yCAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAI,UAAU,GAAkC,IAAI,CAAC;QAErD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE/F,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE;YACxD,gBAAgB;YAChB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;SAClD;QAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAClD,sBAAsB;YACtB,UAAU,GAAG,IAAI,CAAC,eAAe,CAC/B,KAAK,CAAC,uBAAuB,EAC7B,KAAK,CAAC,YAAY,EAClB,UAAU,CACX,CAAC;SACH;QAED,OAAO,EAAE,UAAU,YAAA,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EAAE,CAAC;QACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;YACzC,IAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjD,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;SACjF;QAED,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE;YACpC,QAAQ,UAAA;YACR,cAAc,EAAE,eAAe;YAC/B,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AApFD,CAAmC,WAAW,GAoF7C;;AAED,SAAS,gBAAgB,CAAC,QAAkB,EAAE,cAAwB,EAAE,YAAsB;IAC5F,IAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACvD,IAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACrD,OAAO,QAAQ,GAAG,QAAQ,CAAC;AAC7B,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/scale-handler.d.ts b/lib/modules/layers/src/mode-handlers/scale-handler.d.ts new file mode 100644 index 000000000..294e9048c --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/scale-handler.d.ts @@ -0,0 +1,18 @@ +import { FeatureCollection, Position } from '@nebula.gl/edit-modes'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class ScaleHandler extends ModeHandler { + _isScalable: boolean; + _geometryBeingScaled: FeatureCollection | null | undefined; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; + getScaleAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction; +} +//# sourceMappingURL=scale-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/scale-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/scale-handler.d.ts.map new file mode 100644 index 000000000..8e53af0e7 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/scale-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/scale-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,WAAW,EAAE,OAAO,CAAC;IACrB,oBAAoB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAE3D,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAsBvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAS7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAY3E,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAQ1D,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU;CAyB/F"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/scale-handler.js b/lib/modules/layers/src/mode-handlers/scale-handler.js new file mode 100644 index 000000000..21ea22f5b --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/scale-handler.js @@ -0,0 +1,79 @@ +import { __extends } from "tslib"; +import turfCentroid from '@turf/centroid'; +import turfDistance from '@turf/distance'; +import turfTransformScale from '@turf/transform-scale'; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var ScaleHandler = /** @class */ (function (_super) { + __extends(ScaleHandler, _super); + function ScaleHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ScaleHandler.prototype.handlePointerMove = function (event) { + var editAction = null; + this._isScalable = Boolean(this._geometryBeingScaled) || this.isSelectionPicked(event.picks); + if (!this._isScalable || !event.pointerDownGroundCoords) { + // Nothing to do + return { editAction: null, cancelMapPan: false }; + } + if (event.isDragging && this._geometryBeingScaled) { + // Scale the geometry + editAction = this.getScaleAction(event.pointerDownGroundCoords, event.groundCoords, 'scaling'); + } + return { editAction: editAction, cancelMapPan: true }; + }; + ScaleHandler.prototype.handleStartDragging = function (event) { + if (!this._isScalable) { + return null; + } + this._geometryBeingScaled = this.getSelectedFeaturesAsFeatureCollection(); + return null; + }; + ScaleHandler.prototype.handleStopDragging = function (event) { + var editAction = null; + if (this._geometryBeingScaled) { + // Scale the geometry + editAction = this.getScaleAction(event.pointerDownGroundCoords, event.groundCoords, 'scaled'); + this._geometryBeingScaled = null; + } + return editAction; + }; + ScaleHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + if (this._isScalable) { + // TODO: look at doing SVG cursors to get a better "scale" cursor + return 'move'; + } + return isDragging ? 'grabbing' : 'grab'; + }; + ScaleHandler.prototype.getScaleAction = function (startDragPoint, currentPoint, editType) { + var startPosition = startDragPoint; + var centroid = turfCentroid(this._geometryBeingScaled); + var factor = getScaleFactor(centroid, startPosition, currentPoint); + // @ts-ignore + var scaledFeatures = turfTransformScale(this._geometryBeingScaled, factor, { + origin: centroid, + }); + var updatedData = this.getImmutableFeatureCollection(); + var selectedIndexes = this.getSelectedFeatureIndexes(); + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = scaledFeatures.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return { + updatedData: updatedData.getObject(), + editType: editType, + featureIndexes: selectedIndexes, + editContext: null, + }; + }; + return ScaleHandler; +}(ModeHandler)); +export { ScaleHandler }; +function getScaleFactor(centroid, startDragPoint, currentPoint) { + var startDistance = turfDistance(centroid, startDragPoint); + var endDistance = turfDistance(centroid, currentPoint); + return endDistance / startDistance; +} +//# sourceMappingURL=scale-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/scale-handler.js.map b/lib/modules/layers/src/mode-handlers/scale-handler.js.map new file mode 100644 index 000000000..71c054af6 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/scale-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scale-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/scale-handler.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAAkC,gCAAW;IAA7C;;IAkFA,CAAC;IA9EC,wCAAiB,GAAjB,UACE,KAAuB;QAEvB,IAAI,UAAU,GAAkC,IAAI,CAAC;QAErD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE7F,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CA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ts new file mode 100644 index 000000000..d746daedc --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/snappable-handler.d.ts @@ -0,0 +1,34 @@ +import { Feature, FeatureCollection, Position } from '@nebula.gl/edit-modes'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditHandle, EditAction, ModeHandler } from './mode-handler'; +declare type HandlePicks = { + pickedHandle?: EditHandle; + potentialSnapHandle?: EditHandle; +}; +export declare class SnappableHandler extends ModeHandler { + _handler: ModeHandler; + _editHandlePicks: HandlePicks | null | undefined; + _startDragSnapHandlePosition: Position; + constructor(handler: ModeHandler); + setFeatureCollection(featureCollection: FeatureCollection): void; + setModeConfig(modeConfig: any): void; + setSelectedFeatureIndexes(indexes: number[]): void; + _getSnappedMouseEvent(event: Record, snapPoint: Position): PointerMoveEvent; + _getEditHandlePicks(event: PointerMoveEvent): HandlePicks; + _updatePickedHandlePosition(editAction: EditAction): void; + _getSnapTargets(): Feature[]; + _getNonPickedIntermediateHandles(): EditHandle[]; + getEditHandles(picks?: Array>, groundCoords?: Position): any[]; + _getSnapAwareEvent(event: Record): Record; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor(event: { + isDragging: boolean; + }): string; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; +} +export {}; +//# sourceMappingURL=snappable-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/snappable-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/snappable-handler.d.ts.map new file mode 100644 index 000000000..7c0b957db --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/snappable-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"snappable-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/snappable-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QA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IAAI,GAAG,SAAS;IAK7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAQ3E,SAAS,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAIjD,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;CAexE"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/snappable-handler.js b/lib/modules/layers/src/mode-handlers/snappable-handler.js new file mode 100644 index 000000000..71f87fc99 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/snappable-handler.js @@ -0,0 +1,144 @@ +import { __assign, __extends, __read, __spread, __values } from "tslib"; +import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry, } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var SnappableHandler = /** @class */ (function (_super) { + __extends(SnappableHandler, _super); + function SnappableHandler(handler) { + var _this = _super.call(this) || this; + _this._handler = handler; + return _this; + } + SnappableHandler.prototype.setFeatureCollection = function (featureCollection) { + this._handler.setFeatureCollection(featureCollection); + }; + SnappableHandler.prototype.setModeConfig = function (modeConfig) { + this._modeConfig = modeConfig; + this._handler.setModeConfig(modeConfig); + }; + SnappableHandler.prototype.setSelectedFeatureIndexes = function (indexes) { + this._handler.setSelectedFeatureIndexes(indexes); + }; + SnappableHandler.prototype._getSnappedMouseEvent = function (event, snapPoint) { + // @ts-ignore + return Object.assign({}, event, { + groundCoords: snapPoint, + pointerDownGroundCoords: this._startDragSnapHandlePosition, + }); + }; + SnappableHandler.prototype._getEditHandlePicks = function (event) { + var picks = event.picks; + var potentialSnapHandle = picks.find(function (pick) { return pick.object && pick.object.type === 'intermediate'; }); + var handles = { potentialSnapHandle: potentialSnapHandle && potentialSnapHandle.object }; + var pickedHandle = getPickedEditHandle(event.pointerDownPicks); + if (pickedHandle) { + return __assign(__assign({}, handles), { pickedHandle: pickedHandle }); + } + return handles; + }; + SnappableHandler.prototype._updatePickedHandlePosition = function (editAction) { + var pickedHandle = (this._editHandlePicks || {}).pickedHandle; + if (pickedHandle && editAction) { + var featureIndexes = editAction.featureIndexes, updatedData = editAction.updatedData; + for (var i = 0; i < featureIndexes.length; i++) { + var selectedIndex = featureIndexes[i]; + var updatedFeature = updatedData.features[selectedIndex]; + var positionIndexes = pickedHandle.positionIndexes, featureIndex = pickedHandle.featureIndex; + if (selectedIndex >= 0 && featureIndex === selectedIndex) { + var coordinates = updatedFeature.geometry.coordinates; + pickedHandle.position = positionIndexes.reduce(function (a, b) { return a[b]; }, coordinates); + } + } + } + }; + // If additionalSnapTargets is present in modeConfig and is populated, this + // method will return those features along with the features + // that live in the current layer. Otherwise, this method will simply return the + // features from the current layer + SnappableHandler.prototype._getSnapTargets = function () { + var additionalSnapTargets = (this.getModeConfig() || {}).additionalSnapTargets; + additionalSnapTargets = additionalSnapTargets || []; + var features = __spread(this._handler.featureCollection.getObject().features, additionalSnapTargets); + return features; + }; + SnappableHandler.prototype._getNonPickedIntermediateHandles = function () { + var handles = []; + var features = this._getSnapTargets(); + for (var i = 0; i < features.length; i++) { + // Filter out the currently selected feature(s) + var isCurrentIndexFeatureNotSelected = i < features.length && !this._handler.getSelectedFeatureIndexes().includes(i); + if (isCurrentIndexFeatureNotSelected) { + var geometry = features[i].geometry; + handles.push.apply(handles, __spread(getEditHandlesForGeometry(geometry, i, 'intermediate'))); + } + } + return handles; + }; + // If no snap handle has been picked, only display the edit handles of the + // selected feature. If a snap handle has been picked, display said snap handle + // along with all snappable points on all non-selected features. + SnappableHandler.prototype.getEditHandles = function (picks, groundCoords) { + var e_1, _a; + var enableSnapping = (this._modeConfig || {}).enableSnapping; + var handles = this._handler.getEditHandles(picks, groundCoords); + if (!enableSnapping) + return handles; + var pickedHandle = (this._editHandlePicks || {}).pickedHandle; + if (pickedHandle) { + handles.push.apply(handles, __spread(this._getNonPickedIntermediateHandles(), [pickedHandle])); + return handles; + } + var features = this._handler.featureCollection.getObject().features; + try { + for (var _b = __values(this._handler.getSelectedFeatureIndexes()), _c = _b.next(); !_c.done; _c = _b.next()) { + var index = _c.value; + if (index < features.length) { + var geometry = features[index].geometry; + handles.push.apply(handles, __spread(getEditHandlesForGeometry(geometry, index, 'snap'))); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + return handles.filter(Boolean); + }; + SnappableHandler.prototype._getSnapAwareEvent = function (event) { + var potentialSnapHandle = (this._editHandlePicks || {}).potentialSnapHandle; + return potentialSnapHandle && potentialSnapHandle.position + ? this._getSnappedMouseEvent(event, potentialSnapHandle.position) + : event; + }; + SnappableHandler.prototype.handleStartDragging = function (event) { + this._startDragSnapHandlePosition = (getPickedEditHandle(event.picks) || {}).position; + return this._handler.handleStartDragging(event); + }; + SnappableHandler.prototype.handleStopDragging = function (event) { + // @ts-ignore + var modeActionSummary = this._handler.handleStopDragging(this._getSnapAwareEvent(event)); + this._editHandlePicks = null; + return modeActionSummary; + }; + SnappableHandler.prototype.getCursor = function (event) { + return this._handler.getCursor(event); + }; + SnappableHandler.prototype.handlePointerMove = function (event) { + var enableSnapping = (this._handler.getModeConfig() || {}).enableSnapping; + if (enableSnapping) { + this._editHandlePicks = this._getEditHandlePicks(event); + } + // @ts-ignore + var modeActionSummary = this._handler.handlePointerMove(this._getSnapAwareEvent(event)); + var editAction = modeActionSummary.editAction; + if (editAction) { + this._updatePickedHandlePosition(editAction); + } + return modeActionSummary; + }; + return SnappableHandler; +}(ModeHandler)); +export { SnappableHandler }; +//# sourceMappingURL=snappable-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/snappable-handler.js.map b/lib/modules/layers/src/mode-handlers/snappable-handler.js.map new file mode 100644 index 000000000..f531db8f3 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/snappable-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"snappable-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/snappable-handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAIxB,mEAAmE;AACnE;IAAsC,oCAAW;IAK/C,0BAAY,OAAoB;QAAhC,YACE,iBAAO,SAER;QADC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;;IAC1B,CAAC;IAED,+CAAoB,GAApB,UAAqB,iBAAoC;QACvD,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACxD,CAAC;IAED,wCAAa,GAAb,UAAc,UAAe;QAC3B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,oDAAyB,GAAzB,UAA0B,OAAiB;QACzC,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,gDAAqB,GAArB,UAAsB,KAA0B,EAAE,SAAmB;QACnE,aAAa;QACb,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE;YAC9B,YAAY,EAAE,SAAS;YACvB,uBAAuB,EAAE,IAAI,CAAC,4BAA4B;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,8CAAmB,GAAnB,UAAoB,KAAuB;QACjC,IAAA,mBAAK,CAAW;QAExB,IAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CACpC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,EAAlD,CAAkD,CAC7D,CAAC;QACF,IAAM,OAAO,GAAG,EAAE,mBAAmB,EAAE,mBAAmB,I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CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,IAAA,yCAAU,CAAuB;QACzC,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;SAC9C;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACH,uBAAC;AAAD,CAAC,AAzKD,CAAsC,WAAW,GAyKhD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts b/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts new file mode 100644 index 000000000..53c430b4b --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts @@ -0,0 +1,12 @@ +import { ClickEvent, PointerMoveEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class SplitPolygonHandler extends ModeHandler { + calculateGroundCoords(clickSequence: any, groundCoords: any): any; + handleClick(event: ClickEvent): EditAction | null | undefined; + handlePointerMove({ groundCoords, }: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + splitPolygon(): EditAction; +} +//# sourceMappingURL=split-polygon-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts.map new file mode 100644 index 000000000..7de352f4c --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/split-polygon-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"split-polygon-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/split-polygon-handler.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,qBAAqB,CAAC,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG;IAgD3D,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAoC7D,iBAAiB,CAAC,EAChB,YAAY,GACb,EAAE,gBAAgB,GAAG;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAoB1F,YAAY;CAuDb"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/split-polygon-handler.js b/lib/modules/layers/src/mode-handlers/split-polygon-handler.js new file mode 100644 index 000000000..dffdc4d9c --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/split-polygon-handler.js @@ -0,0 +1,162 @@ +import { __assign, __extends, __read, __spread } from "tslib"; +import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; +import turfDifference from '@turf/difference'; +import turfBuffer from '@turf/buffer'; +import lineIntersect from '@turf/line-intersect'; +import { lineString } from '@turf/helpers'; +import turfBearing from '@turf/bearing'; +import turfDistance from '@turf/distance'; +import turfDestination from '@turf/destination'; +import turfPolygonToLine from '@turf/polygon-to-line'; +import nearestPointOnLine from '@turf/nearest-point-on-line'; +import { generatePointsParallelToLinePoints } from '../utils'; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var SplitPolygonHandler = /** @class */ (function (_super) { + __extends(SplitPolygonHandler, _super); + function SplitPolygonHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + SplitPolygonHandler.prototype.calculateGroundCoords = function (clickSequence, groundCoords) { + var modeConfig = this.getModeConfig(); + if (!modeConfig || !modeConfig.lock90Degree || !clickSequence.length) { + return groundCoords; + } + if (clickSequence.length === 1) { + // if first point is clicked, then find closest polygon point and build ~90deg vector + var firstPoint_1 = clickSequence[0]; + var selectedGeometry = this.getSelectedGeometry(); + // @ts-ignore + var feature = turfPolygonToLine(selectedGeometry); + var lines = feature.type === 'FeatureCollection' ? feature.features : [feature]; + var minDistance_1 = Number.MAX_SAFE_INTEGER; + var closestPoint_1 = null; + // If Multipolygon, then we should find nearest polygon line and stick split to it. + lines.forEach(function (line) { + var snapPoint = nearestPointOnLine(line, firstPoint_1); + var distanceFromOrigin = turfDistance(snapPoint, firstPoint_1); + if (minDistance_1 > distanceFromOrigin) { + minDistance_1 = distanceFromOrigin; + closestPoint_1 = snapPoint; + } + }); + if (closestPoint_1) { + // closest point is used as 90degree entry to the polygon + var lastBearing = turfBearing(firstPoint_1, closestPoint_1); + var currentDistance = turfDistance(firstPoint_1, groundCoords, { units: 'meters' }); + return turfDestination(firstPoint_1, currentDistance, lastBearing, { + units: 'meters', + }).geometry.coordinates; + } + return groundCoords; + } + // Allow only 90 degree turns + var lastPoint = clickSequence[clickSequence.length - 1]; + var _a = __read(generatePointsParallelToLinePoints(clickSequence[clickSequence.length - 2], lastPoint, groundCoords), 1), approximatePoint = _a[0]; + // align point with current ground + var nearestPt = nearestPointOnLine(lineString([lastPoint, approximatePoint]), groundCoords) + .geometry.coordinates; + return nearestPt; + }; + SplitPolygonHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, __assign(__assign({}, event), { groundCoords: this.calculateGroundCoords(this.getClickSequence(), event.groundCoords) })); + var editAction = null; + var tentativeFeature = this.getTentativeFeature(); + var selectedGeometry = this.getSelectedGeometry(); + var clickSequence = this.getClickSequence(); + if (!selectedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('A polygon must be selected for splitting'); + this._setTentativeFeature(null); + return editAction; + } + var pt = { + type: 'Point', + coordinates: clickSequence[clickSequence.length - 1], + }; + // @ts-ignore + var isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry); + if (clickSequence.length > 1 && tentativeFeature && !isPointInPolygon) { + this.resetClickSequence(); + // @ts-ignore + var isLineInterectingWithPolygon = lineIntersect(tentativeFeature, selectedGeometry); + if (isLineInterectingWithPolygon.features.length === 0) { + this._setTentativeFeature(null); + return editAction; + } + return this.splitPolygon(); + } + return editAction; + }; + SplitPolygonHandler.prototype.handlePointerMove = function (_a) { + var groundCoords = _a.groundCoords; + var clickSequence = this.getClickSequence(); + var result = { editAction: null, cancelMapPan: false }; + if (clickSequence.length === 0) { + // nothing to do yet + return result; + } + this._setTentativeFeature({ + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: __spread(clickSequence, [this.calculateGroundCoords(clickSequence, groundCoords)]), + }, + }); + return result; + }; + SplitPolygonHandler.prototype.splitPolygon = function () { + var selectedGeometry = this.getSelectedGeometry(); + var tentativeFeature = this.getTentativeFeature(); + var featureIndex = this.getSelectedFeatureIndexes()[0]; + var modeConfig = this.getModeConfig() || {}; + // Default gap in between the polygon + var _a = modeConfig.gap, gap = _a === void 0 ? 0.1 : _a, _b = modeConfig.units, units = _b === void 0 ? 'centimeters' : _b; + if (gap === 0) { + gap = 0.1; + units = 'centimeters'; + } + // @ts-ignore + var buffer = turfBuffer(tentativeFeature, gap, { units: units }); + // @ts-ignore + var updatedGeometry = turfDifference(selectedGeometry, buffer); + this._setTentativeFeature(null); + if (!updatedGeometry) { + // eslint-disable-next-line no-console,no-undef + console.warn('Canceling edit. Split Polygon erased'); + return null; + } + var _c = updatedGeometry.geometry, type = _c.type, coordinates = _c.coordinates; + var updatedCoordinates = []; + if (type === 'Polygon') { + // Update the coordinates as per Multipolygon + // @ts-ignore + updatedCoordinates = coordinates.map(function (c) { return [c]; }); + } + else { + // Handle Case when Multipolygon has holes + // @ts-ignore + updatedCoordinates = coordinates.reduce(function (agg, prev) { + prev.forEach(function (p) { + agg.push([p]); + }); + return agg; + }, []); + } + // Update the type to Mulitpolygon + var updatedData = this.getImmutableFeatureCollection().replaceGeometry(featureIndex, { + type: 'MultiPolygon', + coordinates: updatedCoordinates, + }); + var editAction = { + updatedData: updatedData.getObject(), + editType: 'split', + featureIndexes: [featureIndex], + editContext: null, + }; + return editAction; + }; + return SplitPolygonHandler; +}(ModeHandler)); +export { SplitPolygonHandler }; +//# sourceMappingURL=split-polygon-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/split-polygon-handler.js.map b/lib/modules/layers/src/mode-handlers/split-polygon-handler.js.map new file mode 100644 index 000000000..341de214f --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/split-polygon-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"split-polygon-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/split-polygon-handler.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,MAAM,gCAAgC,CAAC;AACnE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAAyC,uCAAW;IAApD;;IAkKA,CAAC;IAjKC,mDAAqB,GAArB,UAAsB,aAAkB,EAAE,YAAiB;QACzD,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YACpE,OAAO,YAAY,CAAC;SACrB;QACD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,qFAAqF;YACrF,IAAM,YAAU,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACpC,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpD,aAAa;YACb,I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layers/src/mode-handlers/three-click-polygon-handler.d.ts new file mode 100644 index 000000000..a25d40aed --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.d.ts @@ -0,0 +1,6 @@ +import { ClickEvent } from '../event-types'; +import { ModeHandler, EditAction } from './mode-handler'; +export declare class ThreeClickPolygonHandler extends ModeHandler { + handleClick(event: ClickEvent): EditAction | null | undefined; +} +//# sourceMappingURL=three-click-polygon-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.d.ts.map new file mode 100644 index 000000000..36c6cd3d5 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"three-click-polygon-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/three-click-polygon-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,wBAAyB,SAAQ,WAAW;IACvD,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;CAmB9D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js new file mode 100644 index 000000000..62eaf9ed1 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js @@ -0,0 +1,26 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var ThreeClickPolygonHandler = /** @class */ (function (_super) { + __extends(ThreeClickPolygonHandler, _super); + function ThreeClickPolygonHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ThreeClickPolygonHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, event); + var tentativeFeature = this.getTentativeFeature(); + var clickSequence = this.getClickSequence(); + if (clickSequence.length > 2 && + tentativeFeature && + tentativeFeature.geometry.type === 'Polygon') { + var editAction = this.getAddFeatureOrBooleanPolygonAction(tentativeFeature.geometry); + this.resetClickSequence(); + this._setTentativeFeature(null); + return editAction; + } + return null; + }; + return ThreeClickPolygonHandler; +}(ModeHandler)); +export { ThreeClickPolygonHandler }; +//# sourceMappingURL=three-click-polygon-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js.map b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js.map new file mode 100644 index 000000000..e5bb2d027 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/three-click-polygon-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"three-click-polygon-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/three-click-polygon-handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAA8C,4CAAW;IAAzD;;IAoBA,CAAC;IAnBC,8CAAW,GAAX,UAAY,KAAiB;QAC3B,iBAAM,WAAW,YAAC,KAAK,CAAC,CAAC;QAEzB,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IACE,aAAa,CAAC,MAAM,GAAG,CAAC;YACxB,gBAAgB;YAChB,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAC5C;YACA,IAAM,UAAU,GAAG,IAAI,CAAC,mCAAmC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACvF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,UAAU,CAAC;SACnB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IACH,+BAAC;AAAD,CAAC,AApBD,CAA8C,WAAW,GAoBxD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/translate-handler.d.ts b/lib/modules/layers/src/mode-handlers/translate-handler.d.ts new file mode 100644 index 000000000..3aebcc524 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/translate-handler.d.ts @@ -0,0 +1,18 @@ +import { FeatureCollection, Position } from '@nebula.gl/edit-modes'; +import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../event-types'; +import { EditAction, ModeHandler } from './mode-handler'; +export declare class TranslateHandler extends ModeHandler { + _geometryBeforeTranslate: FeatureCollection | null | undefined; + _isTranslatable: boolean; + handlePointerMove(event: PointerMoveEvent): { + editAction: EditAction | null | undefined; + cancelMapPan: boolean; + }; + handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined; + handleStopDragging(event: StopDraggingEvent): EditAction | null | undefined; + getCursor({ isDragging }: { + isDragging: boolean; + }): string; + getTranslateAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction | null | undefined; +} +//# sourceMappingURL=translate-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/translate-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/translate-handler.d.ts.map new file mode 100644 index 000000000..7593b4551 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/translate-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/translate-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,wBAAwB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/D,eAAe,EAAE,OAAO,CAAC;IAEzB,iBAAiB,CACf,KAAK,EAAE,gBAAgB,GACtB;QAAE,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAuBvE,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAS7E,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAgB3E,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAO1D,kBAAkB,CAChB,cAAc,EAAE,QAAQ,EACxB,YAAY,EAAE,QAAQ,EACtB,QAAQ,EAAE,MAAM,GACf,UAAU,GAAG,IAAI,GAAG,SAAS;CAiCjC"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/translate-handler.js b/lib/modules/layers/src/mode-handlers/translate-handler.js new file mode 100644 index 000000000..de8475d89 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/translate-handler.js @@ -0,0 +1,78 @@ +import { __extends } from "tslib"; +import turfBearing from '@turf/bearing'; +import turfDistance from '@turf/distance'; +import turfTransformTranslate from '@turf/transform-translate'; +import { point } from '@turf/helpers'; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var TranslateHandler = /** @class */ (function (_super) { + __extends(TranslateHandler, _super); + function TranslateHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + TranslateHandler.prototype.handlePointerMove = function (event) { + var editAction = null; + this._isTranslatable = + Boolean(this._geometryBeforeTranslate) || this.isSelectionPicked(event.picks); + if (!this._isTranslatable || !event.pointerDownGroundCoords) { + // Nothing to do + return { editAction: null, cancelMapPan: false }; + } + if (event.isDragging && this._geometryBeforeTranslate) { + // Translate the geometry + editAction = this.getTranslateAction(event.pointerDownGroundCoords, event.groundCoords, 'translating'); + } + return { editAction: editAction, cancelMapPan: true }; + }; + TranslateHandler.prototype.handleStartDragging = function (event) { + if (!this._isTranslatable) { + return null; + } + this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(); + return null; + }; + TranslateHandler.prototype.handleStopDragging = function (event) { + var editAction = null; + if (this._geometryBeforeTranslate) { + // Translate the geometry + editAction = this.getTranslateAction(event.pointerDownGroundCoords, event.groundCoords, 'translated'); + this._geometryBeforeTranslate = null; + } + return editAction; + }; + TranslateHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + if (this._isTranslatable) { + return 'move'; + } + return isDragging ? 'grabbing' : 'grab'; + }; + TranslateHandler.prototype.getTranslateAction = function (startDragPoint, currentPoint, editType) { + if (!this._geometryBeforeTranslate) { + return null; + } + var p1 = point(startDragPoint); + var p2 = point(currentPoint); + var distanceMoved = turfDistance(p1, p2); + var direction = turfBearing(p1, p2); + var movedFeatures = turfTransformTranslate( + // @ts-ignore + this._geometryBeforeTranslate, distanceMoved, direction); + var updatedData = this.getImmutableFeatureCollection(); + var selectedIndexes = this.getSelectedFeatureIndexes(); + for (var i = 0; i < selectedIndexes.length; i++) { + var selectedIndex = selectedIndexes[i]; + var movedFeature = movedFeatures.features[i]; + updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry); + } + return { + updatedData: updatedData.getObject(), + editType: editType, + featureIndexes: selectedIndexes, + editContext: null, + }; + }; + return TranslateHandler; +}(ModeHandler)); +export { TranslateHandler }; +//# sourceMappingURL=translate-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/translate-handler.js.map b/lib/modules/layers/src/mode-handlers/translate-handler.js.map new file mode 100644 index 000000000..b49f6bfd6 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/translate-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"translate-handler.js","sourceRoot":"","sources":["../../../../../modules/lay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AC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC/C,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;SACjF;QAED,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE;YACpC,QAAQ,UAAA;YACR,cAAc,EAAE,eAAe;YAC/B,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;IACH,uBAAC;AAAD,CAAC,AAlGD,CAAsC,WAAW,GAkGhD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts new file mode 100644 index 000000000..4e7d8a6fa --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts @@ -0,0 +1,6 @@ +import { ClickEvent } from '../event-types'; +import { ModeHandler, EditAction } from './mode-handler'; +export declare class TwoClickPolygonHandler extends ModeHandler { + handleClick(event: ClickEvent): EditAction | null | undefined; +} +//# sourceMappingURL=two-click-polygon-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts.map new file mode 100644 index 000000000..e69956861 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"two-click-polygon-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/two-click-polygon-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;CAmB9D"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js new file mode 100644 index 000000000..9df09ef88 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js @@ -0,0 +1,26 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var TwoClickPolygonHandler = /** @class */ (function (_super) { + __extends(TwoClickPolygonHandler, _super); + function TwoClickPolygonHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + TwoClickPolygonHandler.prototype.handleClick = function (event) { + _super.prototype.handleClick.call(this, event); + var tentativeFeature = this.getTentativeFeature(); + var clickSequence = this.getClickSequence(); + if (clickSequence.length > 1 && + tentativeFeature && + tentativeFeature.geometry.type === 'Polygon') { + var editAction = this.getAddFeatureOrBooleanPolygonAction(tentativeFeature.geometry); + this.resetClickSequence(); + this._setTentativeFeature(null); + return editAction; + } + return null; + }; + return TwoClickPolygonHandler; +}(ModeHandler)); +export { TwoClickPolygonHandler }; +//# sourceMappingURL=two-click-polygon-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js.map b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js.map new file mode 100644 index 000000000..89d8e87d6 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/two-click-polygon-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"two-click-polygon-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/two-click-polygon-handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAA4C,0CAAW;IAAvD;;IAoBA,CAAC;IAnBC,4CAAW,GAAX,UAAY,KAAiB;QAC3B,iBAAM,WAAW,YAAC,KAAK,CAAC,CAAC;QAEzB,IAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,IAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IACE,aAAa,CAAC,MAAM,GAAG,CAAC;YACxB,gBAAgB;YAChB,gBAAgB,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAC5C;YACA,IAAM,UAAU,GAAG,IAAI,CAAC,mCAAmC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACvF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,UAAU,CAAC;SACnB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IACH,6BAAC;AAAD,CAAC,AApBD,CAA4C,WAAW,GAoBtD"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/view-handler.d.ts b/lib/modules/layers/src/mode-handlers/view-handler.d.ts new file mode 100644 index 000000000..84ede80e9 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/view-handler.d.ts @@ -0,0 +1,9 @@ +import { Position } from '@nebula.gl/edit-modes'; +import { EditHandle, ModeHandler } from './mode-handler'; +export declare class ViewHandler extends ModeHandler { + getCursor({ isDragging }: { + isDragging: boolean; + }): string; + getEditHandles(picks?: Array>, groundCoords?: Position): EditHandle[]; +} +//# sourceMappingURL=view-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/view-handler.d.ts.map b/lib/modules/layers/src/mode-handlers/view-handler.d.ts.map new file mode 100644 index 000000000..fd09804ad --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/view-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"view-handler.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/view-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,WAAY,SAAQ,WAAW;IAC1C,SAAS,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAI1D,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,UAAU,EAAE;CAG1F"} \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/view-handler.js b/lib/modules/layers/src/mode-handlers/view-handler.js new file mode 100644 index 000000000..0b1bc1031 --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/view-handler.js @@ -0,0 +1,19 @@ +import { __extends } from "tslib"; +import { ModeHandler } from './mode-handler'; +// TODO edit-modes: delete handlers once EditMode fully implemented +var ViewHandler = /** @class */ (function (_super) { + __extends(ViewHandler, _super); + function ViewHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ViewHandler.prototype.getCursor = function (_a) { + var isDragging = _a.isDragging; + return isDragging ? 'grabbing' : 'grab'; + }; + ViewHandler.prototype.getEditHandles = function (picks, groundCoords) { + return []; + }; + return ViewHandler; +}(ModeHandler)); +export { ViewHandler }; +//# sourceMappingURL=view-handler.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/mode-handlers/view-handler.js.map b/lib/modules/layers/src/mode-handlers/view-handler.js.map new file mode 100644 index 000000000..fedb8434e --- /dev/null +++ b/lib/modules/layers/src/mode-handlers/view-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"view-handler.js","sourceRoot":"","sources":["../../../../../modules/layers/src/mode-handlers/view-handler.ts"],"names":[],"mappings":";AACA,OAAO,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzD,mEAAmE;AACnE;IAAiC,+BAAW;IAA5C;;IAQA,CAAC;IAPC,+BAAS,GAAT,UAAU,EAAuC;YAArC,0BAAU;QACpB,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;IAED,oCAAc,GAAd,UAAe,KAAkC,EAAE,YAAuB;QACxE,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,kBAAC;AAAD,CAAC,AARD,CAAiC,WAAW,GAQ3C"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/color/color.d.ts b/lib/modules/layers/src/shaderlib/color/color.d.ts new file mode 100644 index 000000000..45a3c5e09 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/color/color.d.ts @@ -0,0 +1,9 @@ +declare function getUniforms(opts?: Record): Record; +declare const _default: { + name: string; + vs: string; + fs: string; + getUniforms: typeof getUniforms; +}; +export default _default; +//# sourceMappingURL=color.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/color/color.d.ts.map b/lib/modules/layers/src/shaderlib/color/color.d.ts.map new file mode 100644 index 000000000..3a97e9f62 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/color/color.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/color/color.ts"],"names":[],"mappings":"AASA,iBAAS,WAAW,CAAC,IAAI,yBAAgB,0BAMxC;;;;;;;AAiCD,wBAKE"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/color/color.js b/lib/modules/layers/src/shaderlib/color/color.js new file mode 100644 index 000000000..bf0f9bf69 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/color/color.js @@ -0,0 +1,24 @@ +// TODO - this module is a WIP +/* eslint-disable camelcase */ +var INITIAL_STATE = { + color_uOpacity: 1.0, + color_uDesaturate: 0.0, + color_uBrightness: 1.0, +}; +function getUniforms(opts) { + if (opts === void 0) { opts = INITIAL_STATE; } + var uniforms = {}; + if (opts.opacity) { + uniforms.color_uOpacity = opts.opacity; + } + return uniforms; +} +var vs = "varying vec4 color_vColor;\n\ncolor_setColor(vec4 color) {\n color_vColor = color;\n}\n"; +var fs = "uniform float color_uOpacity;\nuniform float color_uDesaturate;\nuniform float color_uBrightness;\n\nvarying vec4 color_vColor;\n\nvec4 color_getColor() {\n return color_vColor;\n}\n\nvec4 color_filterColor(vec4 color) {\n // apply desaturation and brightness\n if (color_uDesaturate > 0.01) {\n float luminance = (color.r + color.g + color.b) * 0.333333333 + color_uBrightness;\n color = vec4(mix(color.rgb, vec3(luminance), color_uDesaturate), color.a);\n\n // Apply opacity\n color = vec4(color.rgb, color.a * color_uOpacity);\n return color;\n}\n"; +export default { + name: 'color', + vs: vs, + fs: fs, + getUniforms: getUniforms, +}; +//# sourceMappingURL=color.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/color/color.js.map b/lib/modules/layers/src/shaderlib/color/color.js.map new file mode 100644 index 000000000..81e670cc4 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/color/color.js.map @@ -0,0 +1 @@ +{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/color/color.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,8BAA8B;AAC9B,IAAM,aAAa,GAA2B;IAC5C,cAAc,EAAE,GAAG;IACnB,iBAAiB,EAAE,GAAG;IACtB,iBAAiB,EAAE,GAAG;CACvB,CAAC;AAEF,SAAS,WAAW,CAAC,IAAoB;IAApB,qBAAA,EAAA,oBAAoB;IACvC,IAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC;KACxC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,IAAM,EAAE,GAAG,0FAMV,CAAC;AAEF,IAAM,EAAE,GAAG,ojBAqBV,CAAC;AAEF,eAAe;IACb,IAAI,EAAE,OAAO;IACb,EAAE,IAAA;IACF,EAAE,IAAA;IACF,WAAW,aAAA;CACZ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/outline/outline.d.ts b/lib/modules/layers/src/shaderlib/outline/outline.d.ts new file mode 100644 index 000000000..8e421635b --- /dev/null +++ b/lib/modules/layers/src/shaderlib/outline/outline.d.ts @@ -0,0 +1,9 @@ +declare function getUniforms({ outlineEnabled, outlineRenderShadowmap, outlineShadowmap }?: Record): Record; +declare const _default: { + name: string; + vs: string; + fs: string; + getUniforms: typeof getUniforms; +}; +export default _default; +//# sourceMappingURL=outline.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/outline/outline.d.ts.map b/lib/modules/layers/src/shaderlib/outline/outline.d.ts.map new file mode 100644 index 000000000..bca37f97d --- /dev/null +++ b/lib/modules/layers/src/shaderlib/outline/outline.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/outline/outline.ts"],"names":[],"mappings":"AAOA,iBAAS,WAAW,CAAC,EAAE,cAAc,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,sBAAgB,uBAchG;;;;;;;AAuED,wBAKE"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/outline/outline.js b/lib/modules/layers/src/shaderlib/outline/outline.js new file mode 100644 index 000000000..f5d4d2189 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/outline/outline.js @@ -0,0 +1,31 @@ +/* eslint-disable camelcase */ +var INITIAL_STATE = { + outlineEnabled: false, + outlineRenderShadowmap: false, + outlineShadowmap: null, +}; +function getUniforms(_a) { + var _b = _a === void 0 ? INITIAL_STATE : _a, outlineEnabled = _b.outlineEnabled, outlineRenderShadowmap = _b.outlineRenderShadowmap, outlineShadowmap = _b.outlineShadowmap; + var uniforms = {}; + if (outlineEnabled !== undefined) { + // ? 1.0 : 0.0; + uniforms.outline_uEnabled = outlineEnabled; + } + if (outlineRenderShadowmap !== undefined) { + // ? 1.0 : 0.0; + uniforms.outline_uRenderOutlines = outlineRenderShadowmap; + } + if (outlineShadowmap !== undefined) { + uniforms.outline_uShadowmap = outlineShadowmap; + } + return uniforms; +} +var vs = "attribute float instanceZLevel;\nvarying float outline_vzLevel;\nvarying vec4 outline_vPosition;\n\n// Set the z level for the outline shadowmap rendering\nvoid outline_setZLevel(float zLevel) {\n outline_vzLevel = zLevel;\n}\n\n// Store an adjusted position for texture2DProj\nvoid outline_setUV(vec4 position) {\n // mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n"; +var fs = "uniform bool outline_uEnabled;\nuniform bool outline_uRenderOutlines;\nuniform sampler2D outline_uShadowmap;\n\nvarying float outline_vzLevel;\n// varying vec2 outline_vUV;\nvarying vec4 outline_vPosition;\n\nconst float OUTLINE_Z_LEVEL_ERROR = 0.01;\n\n// Return a darker color in shadowmap\nvec4 outline_filterShadowColor(vec4 color) {\n return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);\n}\n\n// Return a darker color if in shadowmap\nvec4 outline_filterDarkenColor(vec4 color) {\n if (outline_uEnabled) {\n float maxZLevel;\n if (outline_vPosition.q > 0.0) {\n maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;\n } else {\n discard;\n }\n if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {\n vec4(color.rgb * 0.5, color.a);\n } else {\n discard;\n }\n }\n return color;\n}\n\n// if enabled and rendering outlines - Render depth to shadowmap\n// if enabled and rendering colors - Return a darker color if in shadowmap\n// if disabled, just return color\nvec4 outline_filterColor(vec4 color) {\n if (outline_uEnabled) {\n return outline_uRenderOutlines ?\n outline_filterShadowColor(color) :\n outline_filterDarkenColor(color);\n }\n return color;\n}\n"; +export default { + name: 'outline', + vs: vs, + fs: fs, + getUniforms: getUniforms, +}; +//# sourceMappingURL=outline.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/outline/outline.js.map b/lib/modules/layers/src/shaderlib/outline/outline.js.map new file mode 100644 index 000000000..3c9cab497 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/outline/outline.js.map @@ -0,0 +1 @@ +{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/outline/outline.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,IAAM,aAAa,GAAwB;IACzC,cAAc,EAAE,KAAK;IACrB,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,SAAS,WAAW,CAAC,EAA4E;QAA5E,uCAA4E,EAA1E,kCAAc,EAAE,kDAAsB,EAAE,sCAAgB;IAC7E,IAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,eAAe;QACf,QAAQ,CAAC,gBAAgB,GAAG,cAAc,CAAC;KAC5C;IACD,IAAI,sBAAsB,KAAK,SAAS,EAAE;QACxC,eAAe;QACf,QAAQ,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;KAC3D;IACD,IAAI,gBAAgB,KAAK,SAAS,EAAE;QAClC,QAAQ,CAAC,kBAAkB,GAAG,gBAAgB,CAAC;KAChD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,IAAM,EAAE,GAAG,giBAoBV,CAAC;AAEF,IAAM,EAAE,GAAG,ywCA6CV,CAAC;AAEF,eAAe;IACb,IAAI,EAAE,SAAS;IACf,EAAE,IAAA;IACF,EAAE,IAAA;IACF,WAAW,aAAA;CACZ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/utils/utils.d.ts b/lib/modules/layers/src/shaderlib/utils/utils.d.ts new file mode 100644 index 000000000..9eafa84d4 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/utils/utils.d.ts @@ -0,0 +1,9 @@ +declare function getUniforms({}?: {}): void; +declare const _default: { + name: string; + vs: string; + fs: string; + getUniforms: typeof getUniforms; +}; +export default _default; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/utils/utils.d.ts.map b/lib/modules/layers/src/shaderlib/utils/utils.d.ts.map new file mode 100644 index 000000000..1bfd0c2a7 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/utils/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/utils/utils.ts"],"names":[],"mappings":"AAKA,iBAAS,WAAW,CAAC,EAAE,KAAgB,QAAI;;;;;;;AAsB3C,wBAKE"} \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/utils/utils.js b/lib/modules/layers/src/shaderlib/utils/utils.js new file mode 100644 index 000000000..f2ecfc715 --- /dev/null +++ b/lib/modules/layers/src/shaderlib/utils/utils.js @@ -0,0 +1,15 @@ +// TODO - this module is a WIP +/* eslint-disable camelcase */ +var INITIAL_STATE = {}; +function getUniforms(_a) { + _a = INITIAL_STATE; +} +var vs = "// Note - fairly generic, move to a UV or screen package, or even project?\nvec2 project_clipspace_to_uv(vec4 position) {\n vec2 p = vec2(position.x / position.w, position.y / position.w);\n return vec2((p.x + 1.0) / 2.0, (p.y + 1.0) / 2.0);\n}\n\nvec2 project_clipspace_to_projective_uv(vec4 position) {\n // outline_vPosition = mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n return vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n"; +var fs = vs; +export default { + name: 'outline', + vs: vs, + fs: fs, + getUniforms: getUniforms, +}; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/shaderlib/utils/utils.js.map b/lib/modules/layers/src/shaderlib/utils/utils.js.map new file mode 100644 index 000000000..2670d0b1c --- /dev/null +++ b/lib/modules/layers/src/shaderlib/utils/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/layers/src/shaderlib/utils/utils.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,8BAA8B;AAC9B,IAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,SAAS,WAAW,CAAC,EAAkB;SAAb,aAAa;AAAG,CAAC;AAE3C,IAAM,EAAE,GAAG,+hBAgBV,CAAC;AAEF,IAAM,EAAE,GAAG,EAAE,CAAC;AAEd,eAAe;IACb,IAAI,EAAE,SAAS;IACf,EAAE,IAAA;IACF,EAAE,IAAA;IACF,WAAW,aAAA;CACZ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/style.d.ts b/lib/modules/layers/src/style.d.ts new file mode 100644 index 000000000..8c33b8ce4 --- /dev/null +++ b/lib/modules/layers/src/style.d.ts @@ -0,0 +1,9 @@ +export declare const ArrowStyles: { + NONE: number; + FORWARD: number; + BACKWARD: number; + BOTH: number; +}; +export declare const DEFAULT_ARROWS = 1; +export declare const MAX_ARROWS = 3; +//# sourceMappingURL=style.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/style.d.ts.map b/lib/modules/layers/src/style.d.ts.map new file mode 100644 index 000000000..6f3689ea7 --- /dev/null +++ b/lib/modules/layers/src/style.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/style.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAEF,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,UAAU,IAAI,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/style.js b/lib/modules/layers/src/style.js new file mode 100644 index 000000000..b5eaa182f --- /dev/null +++ b/lib/modules/layers/src/style.js @@ -0,0 +1,10 @@ +// Describes the arrow style of polylines +export var ArrowStyles = { + NONE: 0, + FORWARD: 1, + BACKWARD: 2, + BOTH: 3, +}; +export var DEFAULT_ARROWS = 1; +export var MAX_ARROWS = 3; +//# sourceMappingURL=style.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/style.js.map b/lib/modules/layers/src/style.js.map new file mode 100644 index 000000000..bdd053ac4 --- /dev/null +++ b/lib/modules/layers/src/style.js.map @@ -0,0 +1 @@ +{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../../modules/layers/src/style.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,IAAM,UAAU,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/types.d.ts b/lib/modules/layers/src/types.d.ts new file mode 100644 index 000000000..def72b69f --- /dev/null +++ b/lib/modules/layers/src/types.d.ts @@ -0,0 +1,13 @@ +export declare type Color = [number, number, number, number]; +export declare type Viewport = { + width: number; + height: number; + longitude: number; + latitude: number; + zoom: number; + isDragging?: boolean; + isMoving?: boolean; + bearing?: number; + pitch?: number; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/types.d.ts.map b/lib/modules/layers/src/types.d.ts.map new file mode 100644 index 000000000..08d4467aa --- /dev/null +++ b/lib/modules/layers/src/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../modules/layers/src/types.ts"],"names":[],"mappings":"AACA,oBAAY,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,oBAAY,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/src/types.js b/lib/modules/layers/src/types.js new file mode 100644 index 000000000..5b2306a4c --- /dev/null +++ b/lib/modules/layers/src/types.js @@ -0,0 +1 @@ +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/types.js.map b/lib/modules/layers/src/types.js.map new file mode 100644 index 000000000..1abdd3d0b --- /dev/null +++ b/lib/modules/layers/src/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../modules/layers/src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/src/utils.d.ts b/lib/modules/layers/src/utils.d.ts new file mode 100644 index 000000000..3df076e68 --- /dev/null +++ b/lib/modules/layers/src/utils.d.ts @@ -0,0 +1,12 @@ +import { Position, Point, LineString, FeatureOf, FeatureWithProps, Viewport } from '@nebula.gl/edit-modes'; +export declare type NearestPointType = FeatureWithProps; +export declare function toDeckColor(color?: [number, number, number, number] | number, defaultColor?: [number, number, number, number]): [number, number, number, number]; +export declare function recursivelyTraverseNestedArrays(array: Array, prefix: Array, fn: Function): boolean; +export declare function generatePointsParallelToLinePoints(p1: Position, p2: Position, groundCoords: Position): Position[]; +export declare function distance2d(x1: number, y1: number, x2: number, y2: number): number; +export declare function mix(a: number, b: number, ratio: number): number; +export declare function nearestPointOnProjectedLine(line: FeatureOf, inPoint: FeatureOf, viewport: Viewport): NearestPointType; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/src/utils.d.ts.map b/lib/modules/layers/src/utils.d.ts.map new file mode 100644 index 000000000..b0a4fb0bb --- /dev/null +++ b/lib/modules/layers/src/utils.d.ts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GACjB,gBAAgB,CA+DlB"} \ No newline at end of file diff --git a/lib/modules/layers/src/utils.js b/lib/modules/layers/src/utils.js new file mode 100644 index 000000000..fce61e710 --- /dev/null +++ b/lib/modules/layers/src/utils.js @@ -0,0 +1,139 @@ +import { __read, __spread } from "tslib"; +import destination from '@turf/destination'; +import bearing from '@turf/bearing'; +import pointToLineDistance from '@turf/point-to-line-distance'; +import { point } from '@turf/helpers'; +import WebMercatorViewport from 'viewport-mercator-project'; +export function toDeckColor(color, defaultColor) { + if (defaultColor === void 0) { defaultColor = [255, 0, 0, 255]; } + if (!Array.isArray(color)) { + return defaultColor; + } + return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]; +} +// +// a GeoJSON helper function that calls the provided function with +// an argument that is the most deeply-nested array having elements +// that are arrays of primitives as an argument, e.g. +// +// { +// "type": "MultiPolygon", +// "coordinates": [ +// [ +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// ], +// [ +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// ] +// ] +// } +// +// the function would be called on: +// +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// +// and +// +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// +export function recursivelyTraverseNestedArrays(array, prefix, fn) { + if (!Array.isArray(array[0])) { + return true; + } + for (var i = 0; i < array.length; i++) { + if (recursivelyTraverseNestedArrays(array[i], __spread(prefix, [i]), fn)) { + fn(array, prefix); + break; + } + } + return false; +} +export function generatePointsParallelToLinePoints(p1, p2, groundCoords) { + var lineString = { + type: 'LineString', + coordinates: [p1, p2], + }; + var pt = point(groundCoords); + var ddistance = pointToLineDistance(pt, lineString); + var lineBearing = bearing(p1, p2); + // Check if current point is to the left or right of line + // Line from A=(x1,y1) to B=(x2,y2) a point P=(x,y) + // then (x−x1)(y2−y1)−(y−y1)(x2−x1) + var isPointToLeftOfLine = (groundCoords[0] - p1[0]) * (p2[1] - p1[1]) - (groundCoords[1] - p1[1]) * (p2[0] - p1[0]); + // Bearing to draw perpendicular to the line string + var orthogonalBearing = isPointToLeftOfLine < 0 ? lineBearing - 90 : lineBearing - 270; + // Get coordinates for the point p3 and p4 which are perpendicular to the lineString + // Add the distance as the current position moves away from the lineString + var p3 = destination(p2, ddistance, orthogonalBearing); + var p4 = destination(p1, ddistance, orthogonalBearing); + //@ts-ignore + return [p3.geometry.coordinates, p4.geometry.coordinates]; +} +export function distance2d(x1, y1, x2, y2) { + var dx = x1 - x2; + var dy = y1 - y2; + return Math.sqrt(dx * dx + dy * dy); +} +export function mix(a, b, ratio) { + return b * ratio + a * (1 - ratio); +} +export function nearestPointOnProjectedLine(line, inPoint, viewport) { + var wmViewport = new WebMercatorViewport(viewport); + // Project the line to viewport, then find the nearest point + var coordinates = line.geometry.coordinates; + var projectedCoords = coordinates.map(function (_a) { + var _b = __read(_a, 3), x = _b[0], y = _b[1], _c = _b[2], z = _c === void 0 ? 0 : _c; + return wmViewport.project([x, y, z]); + }); + //@ts-ignore + var _a = __read(wmViewport.project(inPoint.geometry.coordinates), 2), x = _a[0], y = _a[1]; + // console.log('projectedCoords', JSON.stringify(projectedCoords)); + var minDistance = Infinity; + var minPointInfo = {}; + projectedCoords.forEach(function (_a, index) { + var _b = __read(_a, 2), x2 = _b[0], y2 = _b[1]; + if (index === 0) { + return; + } + var _c = __read(projectedCoords[index - 1], 2), x1 = _c[0], y1 = _c[1]; + // line from projectedCoords[index - 1] to projectedCoords[index] + // convert to Ax + By + C = 0 + var A = y1 - y2; + var B = x2 - x1; + var C = x1 * y2 - x2 * y1; + // https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line + var div = A * A + B * B; + var distance = Math.abs(A * x + B * y + C) / Math.sqrt(div); + // TODO: Check if inside bounds + if (distance < minDistance) { + minDistance = distance; + minPointInfo = { + index: index, + x0: (B * (B * x - A * y) - A * C) / div, + y0: (A * (-B * x + A * y) - B * C) / div, + }; + } + }); + //@ts-ignore + var index = minPointInfo.index, x0 = minPointInfo.x0, y0 = minPointInfo.y0; + var _b = __read(projectedCoords[index - 1], 3), x1 = _b[0], y1 = _b[1], _c = _b[2], z1 = _c === void 0 ? 0 : _c; + var _d = __read(projectedCoords[index], 3), x2 = _d[0], y2 = _d[1], _e = _d[2], z2 = _e === void 0 ? 0 : _e; + // calculate what ratio of the line we are on to find the proper z + var lineLength = distance2d(x1, y1, x2, y2); + var startToPointLength = distance2d(x1, y1, x0, y0); + var ratio = startToPointLength / lineLength; + var z0 = mix(z1, z2, ratio); + return { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: wmViewport.unproject([x0, y0, z0]), + }, + properties: { + // TODO: calculate the distance in proper units + dist: minDistance, + index: index - 1, + }, + }; +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/lib/modules/layers/src/utils.js.map b/lib/modules/layers/src/utils.js.map new file mode 100644 index 000000000..18745bcba --- /dev/null +++ b/lib/modules/layers/src/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../modules/layers/src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,mBAAmB,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAStC,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAM5D,MAAM,UAAU,WAAW,CACzB,KAAiD,EACjD,YAAiE;IAAjE,6BAAA,EAAA,gBAAkD,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;IAEjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,YAAY,CAAC;KACrB;IACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAA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;SACjB;KACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/dependencies.test.d.ts b/lib/modules/layers/test/dependencies.test.d.ts new file mode 100644 index 000000000..5990646f0 --- /dev/null +++ b/lib/modules/layers/test/dependencies.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=dependencies.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/dependencies.test.d.ts.map b/lib/modules/layers/test/dependencies.test.d.ts.map new file mode 100644 index 000000000..2b0523115 --- /dev/null +++ b/lib/modules/layers/test/dependencies.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dependencies.test.d.ts","sourceRoot":"","sources":["../../../../modules/layers/test/dependencies.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/test/dependencies.test.js b/lib/modules/layers/test/dependencies.test.js new file mode 100644 index 000000000..e923f83ee --- /dev/null +++ b/lib/modules/layers/test/dependencies.test.js @@ -0,0 +1,20 @@ +import { __read, __spread } from "tslib"; +import { readFileSync, readdirSync, existsSync } from 'fs'; +var RESOLVED_REGEX = /^resolved/gi; +var NOT_ALLOWED_REPO = 'unpm.u'; +var EXAMPLES_DIR = __dirname + "/../../../examples"; +it("Ensure yarn.lock doesn't contain " + NOT_ALLOWED_REPO, function () { + var rootLockFile = __dirname + "/../../../yarn.lock"; + var exampleLockFiles = readdirSync("" + EXAMPLES_DIR) + .map(function (example) { return EXAMPLES_DIR + "/" + example + "/yarn.lock"; }) + .filter(existsSync); + __spread([rootLockFile], exampleLockFiles).forEach(function (lockfile) { + var contents = readFileSync(lockfile, 'utf8').split('\n'); + contents.forEach(function (line) { + if (line.trim().match(RESOLVED_REGEX)) { + expect(line).not.toEqual(expect.stringContaining(NOT_ALLOWED_REPO)); + } + }); + }); +}); +//# sourceMappingURL=dependencies.test.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/dependencies.test.js.map b/lib/modules/layers/test/dependencies.test.js.map new file mode 100644 index 000000000..604d04f36 --- /dev/null +++ b/lib/modules/layers/test/dependencies.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"dependencies.test.js","sourceRoot":"","sources":["../../../../modules/layers/test/dependencies.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAE3D,IAAM,cAAc,GAAG,aAAa,CAAC;AACrC,IAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,IAAM,YAAY,GAAM,SAAS,uBAAoB,CAAC;AAEtD,EAAE,CAAC,sCAAoC,gBAAkB,EAAE;IACzD,IAAM,YAAY,GAAM,SAAS,wBAAqB,CAAC;IACvD,IAAM,gBAAgB,GAAG,WAAW,CAAC,KAAG,YAAc,CAAC;SACpD,GAAG,CAAC,UAAC,OAAO,IAAK,OAAG,YAAY,SAAI,OAAO,eAAY,EAAtC,CAAsC,CAAC;SACxD,MAAM,CAAC,UAAU,CAAC,CAAC;IAEtB,UAAC,YAAY,GAAK,gBAAgB,EAAE,OAAO,CAAC,UAAC,QAAQ;QACnD,IAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE5D,QAAQ,CAAC,OAAO,CAAC,UAAC,IAAI;YACpB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;gBACrC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC;aACrE;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/curve-utils.test.d.ts b/lib/modules/layers/test/lib/curve-utils.test.d.ts new file mode 100644 index 000000000..d88ef8f9d --- /dev/null +++ b/lib/modules/layers/test/lib/curve-utils.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=curve-utils.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/curve-utils.test.d.ts.map b/lib/modules/layers/test/lib/curve-utils.test.d.ts.map new file mode 100644 index 000000000..4de9bbcf1 --- /dev/null +++ b/lib/modules/layers/test/lib/curve-utils.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"curve-utils.test.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/curve-utils.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/curve-utils.test.js b/lib/modules/layers/test/lib/curve-utils.test.js new file mode 100644 index 000000000..06741606a --- /dev/null +++ b/lib/modules/layers/test/lib/curve-utils.test.js @@ -0,0 +1,20 @@ +import { generateCurveFromControlPoints } from '../../src/curve-utils'; +var POLYLINE = { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [-122.41988182067871, 37.8014343052295], + [-122.41904497146605, 37.802790657411244], + [-122.41724252700804, 37.801603850614384], + [-122.41612672805786, 37.80314669573162], + ], + }, +}; +it('test generateCurveFromControlPoints', function () { + // @ts-ignore + var result = generateCurveFromControlPoints(POLYLINE); + expect(result).toMatchSnapshot(); +}); +//# sourceMappingURL=curve-utils.test.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/curve-utils.test.js.map b/lib/modules/layers/test/lib/curve-utils.test.js.map new file mode 100644 index 000000000..82e3a33db --- /dev/null +++ b/lib/modules/layers/test/lib/curve-utils.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"curve-utils.test.js","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/curve-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAGvE,IAAM,QAAQ,GAAY;IACxB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE;QACR,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE;YACX,CAAC,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;YACvC,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;YACzC,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;YACzC,CAAC,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;SACzC;KACF;CACF,CAAC;AAEF,EAAE,CAAC,qCAAqC,EAAE;IACxC,aAAa;IACb,IAAM,MAAM,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts new file mode 100644 index 000000000..639f482eb --- /dev/null +++ b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=elevated-edit-handle-layer.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts.map b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts.map new file mode 100644 index 000000000..04dba99d8 --- /dev/null +++ b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"elevated-edit-handle-layer.test.d.ts","sourceRoot":"","sources":["../../../../../../modules/layers/test/lib/layers/elevated-edit-handle-layer.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js new file mode 100644 index 000000000..7ed2b8f93 --- /dev/null +++ b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js @@ -0,0 +1,12 @@ +/* eslint-env jest */ +import ElevatedEditHandleLayer from '../../../src/layers/elevated-edit-handle-layer'; +describe('ElevatedEditHandleLayer tests', function () { + test('renderLayers()', function () { + // @ts-ignore + var layer = new ElevatedEditHandleLayer(); + var render = layer.renderLayers(); + expect(Array.isArray(render)).toBeTruthy(); + expect(render.length).toBe(2); + }); +}); +//# sourceMappingURL=elevated-edit-handle-layer.test.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js.map b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js.map new file mode 100644 index 000000000..6e93ada91 --- /dev/null +++ b/lib/modules/layers/test/lib/layers/elevated-edit-handle-layer.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"elevated-edit-handle-layer.test.js","sourceRoot":"","sources":["../../../../../../modules/layers/test/lib/layers/elevated-edit-handle-layer.test.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,uBAAuB,MAAM,gDAAgD,CAAC;AAErF,QAAQ,CAAC,+BAA+B,EAAE;IACxC,IAAI,CAAC,gBAAgB,EAAE;QACrB,aAAa;QACb,IAAM,KAAK,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC5C,IAAM,MAAM,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/math.test.d.ts b/lib/modules/layers/test/lib/math.test.d.ts new file mode 100644 index 000000000..7078ca5c3 --- /dev/null +++ b/lib/modules/layers/test/lib/math.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=math.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/math.test.d.ts.map b/lib/modules/layers/test/lib/math.test.d.ts.map new file mode 100644 index 000000000..4778b6628 --- /dev/null +++ b/lib/modules/layers/test/lib/math.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"math.test.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/math.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/math.test.js b/lib/modules/layers/test/lib/math.test.js new file mode 100644 index 000000000..d47640bdd --- /dev/null +++ b/lib/modules/layers/test/lib/math.test.js @@ -0,0 +1,19 @@ +import { convertE7Array, toDegree, toRadian } from '../../src/math'; +it('test toDegree()', function () { + expect(toDegree(Math.PI / 4)).toBe(45); + expect(toDegree(Math.PI / 2)).toBe(90); + expect(toDegree((Math.PI * 3) / 2)).toBe(270); +}); +it('test toRadian()', function () { + expect(toRadian(45)).toBe(Math.PI / 4); + expect(toRadian(90)).toBe(Math.PI / 2); + expect(toRadian(270)).toBe((Math.PI * 3) / 2); +}); +it('test convertE7Array()', function () { + var points = [378034847, -1224078182, 378039091, -1224079046]; + expect(convertE7Array(points)).toEqual([ + [-122.4078182, 37.8034847], + [-122.4079046, 37.8039091], + ]); +}); +//# sourceMappingURL=math.test.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/math.test.js.map b/lib/modules/layers/test/lib/math.test.js.map new file mode 100644 index 000000000..75075b6da --- /dev/null +++ b/lib/modules/layers/test/lib/math.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"math.test.js","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/math.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEpE,EAAE,CAAC,iBAAiB,EAAE;IACpB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,iBAAiB,EAAE;IACpB,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uBAAuB,EAAE;IAC1B,IAAM,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QACrC,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC;QAC1B,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/test-utils.d.ts b/lib/modules/layers/test/lib/test-utils.d.ts new file mode 100644 index 000000000..0dfca5099 --- /dev/null +++ b/lib/modules/layers/test/lib/test-utils.d.ts @@ -0,0 +1,59 @@ +import { Position, FeatureCollection } from '@nebula.gl/edit-modes'; +import { ClickEvent, PointerMoveEvent, StopDraggingEvent } from '../../src/event-types'; +export declare const FeatureType: { + POINT: string; + LINE_STRING: string; + POLYGON: string; + MULTI_POINT: string; + MULTI_LINE_STRING: string; + MULTI_POLYGON: string; +}; +export declare const featuresForSnappingTests: FeatureCollection; +export declare const mockPickedHandle: { + featureIndex: number; + position: number[]; + positionIndexes: number[]; + type: string; +}; +export declare const mockNonPickedHandle: { + featureIndex: number; + position: number[]; + positionIndexes: number[]; + type: string; +}; +export declare const mockedGeoJsonProperties: { + testString: string; + testNumber: number; +}; +export declare function createPointFeature(options?: { + [K: string]: any; +}): any; +export declare function createLineStringFeature(options?: { + [K: string]: any; +}): any; +export declare function createPolygonFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiPointFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiLineStringFeature(options?: { + [K: string]: any; +}): any; +export declare function createMultiPolygonFeature(options?: { + [K: string]: any; +}): any; +export declare function getFeatureCollectionFeatures(options?: { + [K: string]: any; +}): any[]; +export declare function createFeatureCollection(options?: { + [K: string]: any; +}): { + type: string; + features: any[]; +}; +export declare function getMockFeatureDetails(featureType: string): any; +export declare function createClickEvent(groundCoords: Position, picks?: any[]): ClickEvent; +export declare function createPointerDragEvent(groundCoords: Position, pointerDownGroundCoords: Position, picks?: any[]): StopDraggingEvent; +export declare function createPointerMoveEvent(groundCoords: Position, picks?: any[]): PointerMoveEvent; +//# sourceMappingURL=test-utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/test-utils.d.ts.map b/lib/modules/layers/test/lib/test-utils.d.ts.map new file mode 100644 index 000000000..938a75bac --- /dev/null +++ b/lib/modules/layers/test/lib/test-utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAExF,eAAO,MAAM,WAAW;;;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,YAAY,EAAE,QAAQ,EACtB,uBAAuB,EAAE,QAAQ,EACjC,KAAK,GAAE,GAAG,EAAO,GAChB,iBAAiB,CAYnB;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,QAAQ,EACtB,KAAK,GAAE,GAAG,EAAO,GAChB,gBAAgB,CAWlB"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/test-utils.js b/lib/modules/layers/test/lib/test-utils.js new file mode 100644 index 000000000..d8ed53e01 --- /dev/null +++ b/lib/modules/layers/test/lib/test-utils.js @@ -0,0 +1,313 @@ +/* eslint-env jest */ +export var FeatureType = { + POINT: 'Point', + LINE_STRING: 'LineString', + POLYGON: 'Polygon', + MULTI_POINT: 'MultiPoint', + MULTI_LINE_STRING: 'MultiLineString', + MULTI_POLYGON: 'MultiPolygon', +}; +var mockFeatures = { + Point: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { type: 'Point', coordinates: [1, 2] }, + }, + clickCoords: [1, 2], + }, + LineString: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [1, 2], + [2, 3], + [3, 4], + ], + }, + }, + clickCoords: [1, 2], + }, + Polygon: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + // exterior ring + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + }, + }, + clickCoords: [-0.5, -0.5], + }, + MultiPoint: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPoint', + coordinates: [ + [1, 2], + [3, 4], + ], + }, + }, + clickCoords: [3, 4], + }, + MultiLineString: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiLineString', + coordinates: [ + [ + [1, 2], + [2, 3], + [3, 4], + ], + [ + [5, 6], + [6, 7], + [7, 8], + ], + ], + }, + }, + clickCoords: [6, 7], + }, + MultiPolygon: { + geoJson: { + type: 'Feature', + properties: {}, + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + // exterior ring polygon 1 + [ + [-1, -1], + [1, -1], + [1, 1], + [-1, 1], + [-1, -1], + ], + // hole polygon 1 + [ + [-0.5, -0.5], + [-0.5, 0.5], + [0.5, 0.5], + [0.5, -0.5], + [-0.5, -0.5], + ], + ], + [ + // exterior ring polygon 2 + [ + [2, -1], + [4, -1], + [4, 1], + [2, 1], + [2, -1], + ], + ], + ], + }, + }, + clickCoords: [1, 1], + }, +}; +export var featuresForSnappingTests = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.49485401280788, 37.987923255302974], + [-122.44252582524939, 37.987923255302974], + [-122.44252847887157, 37.93873205786406], + [-122.49485666643005, 37.93873205786406], + [-122.49485401280788, 37.987923255302974], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40814940182412, 37.97528325161274], + [-122.37737022011595, 37.97528325161274], + [-122.37737142575622, 37.952934704562644], + [-122.40815060746439, 37.952934704562644], + [-122.40814940182412, 37.97528325161274], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Point', + coordinates: [-122.28103267622373, 37.98843664327903], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40908525092362, 37.85902221692065], + [-122.34432261530361, 37.85902221692065], + [-122.3442469760231, 37.8157115979288], + [-122.40900961164311, 37.8157115979288], + [-122.40908525092362, 37.85902221692065], + ], + ], + }, + }, + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-122.40682264287454, 38.13330760982133], + [-122.34143228624993, 38.13330760982133], + [-122.34144710122638, 38.08906337516829], + [-122.40683745785105, 38.08906337516829], + [-122.40682264287454, 38.13330760982133], + ], + ], + }, + }, + ], +}; +export var mockPickedHandle = { + featureIndex: 0, + position: [-122.49485401280788, 37.987923255302974], + positionIndexes: [0, 0], + type: 'snap', +}; +export var mockNonPickedHandle = { + featureIndex: 1, + position: [-122.37737022011595, 37.97528325161274], + positionIndexes: [0, 1], + type: 'intermediate', +}; +export var mockedGeoJsonProperties = { testString: 'hi', testNumber: 10 }; +function createFeature(featureType, options) { + var feature = mockFeatures[featureType].geoJson; + var mockGeoJsonProperties = (options || {}).mockGeoJsonProperties; + if (mockGeoJsonProperties) { + feature.properties = mockedGeoJsonProperties; + } + return feature; +} +export function createPointFeature(options) { + return createFeature(FeatureType.POINT, options); +} +export function createLineStringFeature(options) { + return createFeature(FeatureType.LINE_STRING, options); +} +export function createPolygonFeature(options) { + return createFeature(FeatureType.POLYGON, options); +} +export function createMultiPointFeature(options) { + return createFeature(FeatureType.MULTI_POINT, options); +} +export function createMultiLineStringFeature(options) { + return createFeature(FeatureType.MULTI_LINE_STRING, options); +} +export function createMultiPolygonFeature(options) { + return createFeature(FeatureType.MULTI_POLYGON, options); +} +export function getFeatureCollectionFeatures(options) { + return [ + createPointFeature(options), + createLineStringFeature(options), + createPolygonFeature(options), + createMultiPointFeature(options), + createMultiLineStringFeature(options), + createMultiPolygonFeature(options), + ]; +} +export function createFeatureCollection(options) { + return { + type: 'FeatureCollection', + features: getFeatureCollectionFeatures(options), + }; +} +export function getMockFeatureDetails(featureType) { + var featureCollectionIndex = getFeatureCollectionFeatures().findIndex(function (feature) { return feature.geometry.type === featureType; }); + var featureDetails = mockFeatures[featureType]; + featureDetails.index = featureCollectionIndex; + return featureDetails; +} +export function createClickEvent(groundCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + groundCoords: groundCoords, + picks: picks, + sourceEvent: null, + }; +} +export function createPointerDragEvent(groundCoords, pointerDownGroundCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + groundCoords: groundCoords, + picks: picks, + // @ts-ignore + isDragging: true, + pointerDownPicks: null, + pointerDownScreenCoords: [-1, -1], + pointerDownGroundCoords: pointerDownGroundCoords, + sourceEvent: null, + }; +} +export function createPointerMoveEvent(groundCoords, picks) { + if (picks === void 0) { picks = []; } + return { + screenCoords: [-1, -1], + groundCoords: groundCoords, + picks: picks, + isDragging: false, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownGroundCoords: null, + sourceEvent: null, + }; +} +//# sourceMappingURL=test-utils.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/test-utils.js.map b/lib/modules/layers/test/lib/test-utils.js.map new file mode 100644 index 000000000..fed9fd532 --- /dev/null +++ b/lib/modules/layers/test/lib/test-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/test-utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAKrB,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,YAAY;IACzB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,YAAY;IACzB,iBAAiB,EAAE,iBAAiB;IACpC,aAAa,EAAE,cAAc;CAC9B,CAAC;AAEF,IAAM,YAAY,GAAG;IACnB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;SACjD;QACD,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KACpB;IACD,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE;gBACR,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE;oBACX,CAAC,CAAC,EAAE,CAAC,CAAC;oBACN,CAAC,CAAC,EAAE,CAAC,CAAC;oBACN,CAAC,CAAC,EAAE,CAA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;QAC7B,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/utils.test.d.ts b/lib/modules/layers/test/lib/utils.test.d.ts new file mode 100644 index 000000000..c727c85cb --- /dev/null +++ b/lib/modules/layers/test/lib/utils.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=utils.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/utils.test.d.ts.map b/lib/modules/layers/test/lib/utils.test.d.ts.map new file mode 100644 index 000000000..e181a27d4 --- /dev/null +++ b/lib/modules/layers/test/lib/utils.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/utils.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/layers/test/lib/utils.test.js b/lib/modules/layers/test/lib/utils.test.js new file mode 100644 index 000000000..47a91994e --- /dev/null +++ b/lib/modules/layers/test/lib/utils.test.js @@ -0,0 +1,194 @@ +import { __read } from "tslib"; +import { toDeckColor, recursivelyTraverseNestedArrays, generatePointsParallelToLinePoints, distance2d, mix, nearestPointOnProjectedLine, } from '../../src/utils'; +var Point = { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [102.0, 0.5], + }, +}; +var LineString = { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [ + [102.0, 0.0], + [103.0, 1.0], + [104.0, 0.0], + [105.0, 1.0], + ], + }, +}; +var Polygon = { + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [35, 10], + [45, 45], + [15, 40], + [10, 20], + [35, 10], + ], + [ + [20, 30], + [35, 35], + [30, 20], + [20, 30], + ], + ], + }, +}; +var MultiPolygon = { + type: 'Feature', + geometry: { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [40, 40], + [20, 45], + [45, 30], + [40, 40], + ], + ], + [ + [ + [20, 35], + [10, 30], + [10, 10], + [30, 5], + [45, 20], + [20, 35], + ], + [ + [30, 20], + [20, 15], + [20, 25], + [30, 20], + ], + ], + ], + }, +}; +describe('toDeckColor()', function () { + it('toDeckColor() - positive case', function () { + var deckColor = toDeckColor([100, 90, 255, 1]); + var expectedResult = [25500, 22950, 65025, 255]; + expect(deckColor).toEqual(expectedResult); + }); + it('toDeckColor() - invalid color', function () { + var deckColor = toDeckColor(123123); + var expectedDefaultDeckColor = [255, 0, 0, 255]; + expect(deckColor).toEqual(expectedDefaultDeckColor); + }); +}); +describe('recursivelyTraverseNestedArrays()', function () { + it('should not call function for point', function () { + var callCount = 0; + var callback = function (array, prefix) { return callCount++; }; + recursivelyTraverseNestedArrays(Point.geometry.coordinates, [], callback); + expect(callCount).toBe(0); + }); + it('should work for LineString', function () { + var results = []; + recursivelyTraverseNestedArrays(LineString.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(1); + expect(JSON.stringify(results[0].array)).toBe('[[102,0],[103,1],[104,0],[105,1]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[]'); + }); + it('should work for Polygon', function () { + var results = []; + recursivelyTraverseNestedArrays(Polygon.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(2); + expect(JSON.stringify(results[0].array)).toBe('[[35,10],[45,45],[15,40],[10,20],[35,10]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[0]'); + expect(JSON.stringify(results[1].array)).toBe('[[20,30],[35,35],[30,20],[20,30]]'); + expect(JSON.stringify(results[1].prefix)).toBe('[1]'); + }); + it('should work for MultiPolygon', function () { + var results = []; + recursivelyTraverseNestedArrays(MultiPolygon.geometry.coordinates, [], function (array, prefix) { + results.push({ + array: array, + prefix: prefix, + }); + }); + expect(results.length).toBe(3); + expect(JSON.stringify(results[0].array)).toBe('[[40,40],[20,45],[45,30],[40,40]]'); + expect(JSON.stringify(results[0].prefix)).toBe('[0,0]'); + expect(JSON.stringify(results[1].array)).toBe('[[20,35],[10,30],[10,10],[30,5],[45,20],[20,35]]'); + expect(JSON.stringify(results[1].prefix)).toBe('[1,0]'); + expect(JSON.stringify(results[2].array)).toBe('[[30,20],[20,15],[20,25],[30,20]]'); + expect(JSON.stringify(results[2].prefix)).toBe('[1,1]'); + }); +}); +describe('generatePointsParallelToLinePoints()', function () { + it('generate Points Parallel to Line Points -- empty points', function () { + var p1 = [0, 0]; + var p2 = [0, 0]; + var _a = __read(generatePointsParallelToLinePoints(p1, p2, [0, 0]), 2), p3 = _a[0], p4 = _a[1]; + expect(p3).toEqual([0, 0]); + expect(p4).toEqual([0, 0]); + }); + it('generate Points Parallel to Line Points -- valid points', function () { + var p1 = [-122.32, 37.81800998554937]; + var p2 = [-122.37, 37.83386913944292]; + var _a = __read(generatePointsParallelToLinePoints(p1, p2, [-124.5, 37.9]), 2), p3 = _a[0], p4 = _a[1]; + expect(p3).toEqual([-123.14819346449626, 36.26988514860277]); + expect(p4).toEqual([-123.09803547871964, 36.254027457172775]); + }); +}); +describe('nearestPointOnProjectedLine() and related functions', function () { + it('distance2d()', function () { + expect(distance2d(0, 0, 0, 0)).toEqual(0); + expect(distance2d(0, 1, 0, 0)).toEqual(1); + }); + it('mix()', function () { + expect(mix(1, 2, 0)).toEqual(1); + expect(mix(1, 2, 1)).toEqual(2); + }); + it('nearestPointOnProjectedLine()', function () { + var line = { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [ + [0, 0, 0], + [1, 1, 1], + ], + }, + }; + var inPoint = { + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [0.5, 0.5], + }, + }; + var viewport = { + // @ts-ignore + project: function (x) { return x; }, + unproject: function (x) { return x; }, + }; + var result = nearestPointOnProjectedLine(line, inPoint, viewport); + expect(result.geometry.type).toEqual('Point'); + expect(result.geometry.coordinates.length).toEqual(3); + expect(result.geometry.coordinates[0]).toBeCloseTo(0.5, 3); + expect(result.geometry.coordinates[1]).toBeCloseTo(0.5, 3); + expect(result.geometry.coordinates[2]).toBeCloseTo(0.5, 3); + expect(result.properties.index).toEqual(0); + }); +}); +//# sourceMappingURL=utils.test.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/lib/utils.test.js.map b/lib/modules/layers/test/lib/utils.test.js.map new file mode 100644 index 000000000..3912ab2d7 --- /dev/null +++ b/lib/modules/layers/test/lib/utils.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../modules/layers/test/lib/utils.test.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,kCAAkC,EAClC,UAAU,EACV,GAAG,EACH,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AASzB,IAAM,KAAK,GAAG;IACZ,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC;KAC1B;CACF,CAAC;AAEF,IAAM,UAAU,GAAG;IACjB,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE;YACX,CAAC,KAAK,EAAE,GAAG,CAAC;YACZ,CAAC,KAAK,EAAE,GAAG,CAAC;YACZ,CAAC,KAAK,EAAE,GAAG,CAAC;YACZ,CAAC,KAAK,EAAE,GAAG,CAAC;SACb;KACF;CACF,CAAC;AAEF,IAAM,OAAO,GAAG;IACd,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACX;gBACE,CAAC,EAAE,EAAE,EAAE,CAAC;gBACR,CAAC,EAAE,EAAE,EAAE,CAAC;gBACR,CAAC,EAAE,EAAE,EAAE,CAAC;gBACR,CAAC,EAAE,EAAE,EAAE,CAAC;gBACR,CAAC,EAAE,EAAE,EAAE,CAAC;aACT;YACD;gBACE,CAAC,EAAE,EAAE,EAAE,CAAC;gBACR,CAAC,EAAE,EAAE,EAAE,CAAC;gB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d.ts b/lib/modules/layers/test/mocks/index.d.ts new file mode 100644 index 000000000..463864999 --- /dev/null +++ b/lib/modules/layers/test/mocks/index.d.ts @@ -0,0 +1,11 @@ +export declare const center: number[]; +export declare const viewport: { + bearing: number; + height: number; + latitude: number; + longitude: number; + pitch: number; + width: number; + zoom: number; +}; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/layers/test/mocks/index.d.ts.map b/lib/modules/layers/test/mocks/index.d.ts.map new file mode 100644 index 000000000..eba00cb0b --- /dev/null +++ b/lib/modules/layers/test/mocks/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../modules/layers/test/mocks/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,UAAa,CAAC;AAEjC,eAAO,MAAM,QAAQ;;;;;;;;CAQpB,CAAC"} \ No newline at end of file diff --git a/lib/modules/layers/test/mocks/index.js b/lib/modules/layers/test/mocks/index.js new file mode 100644 index 000000000..fa7519b7a --- /dev/null +++ b/lib/modules/layers/test/mocks/index.js @@ -0,0 +1,11 @@ +export var center = [-122, 37]; +export var viewport = { + bearing: 0, + height: 600, + latitude: center[1], + longitude: center[0], + pitch: 0, + width: 800, + zoom: 12, +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/layers/test/mocks/index.js.map b/lib/modules/layers/test/mocks/index.js.map new file mode 100644 index 000000000..6af45821d --- /dev/null +++ b/lib/modules/layers/test/mocks/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/layers/test/mocks/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAEjC,MAAM,CAAC,IAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IACpB,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,EAAE;CACT,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/index.d.ts b/lib/modules/main/src/index.d.ts new file mode 100644 index 000000000..6429932c5 --- /dev/null +++ b/lib/modules/main/src/index.d.ts @@ -0,0 +1,47 @@ +export { ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS } from './lib/style'; +export { SELECTION_TYPE } from './lib/deck-renderer/deck-drawer'; +export { default as Feature } from './lib/feature'; +export { default as LayerMouseEvent } from './lib/layer-mouse-event'; +export { default as NebulaLayer } from './lib/nebula-layer'; +export { default as JunctionsLayer } from './lib/layers/junctions-layer'; +export { default as TextsLayer } from './lib/layers/texts-layer'; +export { default as SegmentsLayer } from './lib/layers/segments-layer'; +export { default as NebulaCore } from './lib/nebula'; +export { toDeckColor } from './lib/utils'; +export type { Color, Style } from './types'; +export { EditableGeoJsonLayer } from '@nebula.gl/layers'; +export { SelectionLayer } from '@nebula.gl/layers'; +export { ElevatedEditHandleLayer } from '@nebula.gl/layers'; +export { PathOutlineLayer } from '@nebula.gl/layers'; +export { PathMarkerLayer } from '@nebula.gl/layers'; +export type { EditMode } from '@nebula.gl/edit-modes'; +export { GeoJsonEditMode } from '@nebula.gl/edit-modes'; +export { ModifyMode } from '@nebula.gl/edit-modes'; +export { TranslateMode } from '@nebula.gl/edit-modes'; +export { ScaleMode } from '@nebula.gl/edit-modes'; +export { RotateMode } from '@nebula.gl/edit-modes'; +export { DuplicateMode } from '@nebula.gl/edit-modes'; +export { ExtendLineStringMode } from '@nebula.gl/edit-modes'; +export { SplitPolygonMode } from '@nebula.gl/edit-modes'; +export { ExtrudeMode } from '@nebula.gl/edit-modes'; +export { ElevationMode } from '@nebula.gl/edit-modes'; +export { TransformMode } from '@nebula.gl/edit-modes'; +export { DrawPointMode } from '@nebula.gl/edit-modes'; +export { DrawLineStringMode } from '@nebula.gl/edit-modes'; +export { DrawPolygonMode } from '@nebula.gl/edit-modes'; +export { DrawRectangleMode } from '@nebula.gl/edit-modes'; +export { DrawCircleByDiameterMode } from '@nebula.gl/edit-modes'; +export { DrawCircleFromCenterMode } from '@nebula.gl/edit-modes'; +export { DrawEllipseByBoundingBoxMode } from '@nebula.gl/edit-modes'; +export { DrawEllipseUsingThreePointsMode } from '@nebula.gl/edit-modes'; +export { DrawRectangleUsingThreePointsMode } from '@nebula.gl/edit-modes'; +export { Draw90DegreePolygonMode } from '@nebula.gl/edit-modes'; +export { DrawPolygonByDraggingMode } from '@nebula.gl/edit-modes'; +export { ImmutableFeatureCollection } from '@nebula.gl/edit-modes'; +export { ViewMode } from '@nebula.gl/edit-modes'; +export { MeasureDistanceMode } from '@nebula.gl/edit-modes'; +export { MeasureAreaMode } from '@nebula.gl/edit-modes'; +export { MeasureAngleMode } from '@nebula.gl/edit-modes'; +export { CompositeMode } from '@nebula.gl/edit-modes'; +export { SnappableMode } from '@nebula.gl/edit-modes'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/index.d.ts.map b/lib/modules/main/src/index.d.ts.map new file mode 100644 index 000000000..99695fe21 --- /dev/null +++ b/lib/modules/main/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/main/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,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uB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/index.js b/lib/modules/main/src/index.js new file mode 100644 index 000000000..46bebf29f --- /dev/null +++ b/lib/modules/main/src/index.js @@ -0,0 +1,50 @@ +export { ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS } from './lib/style'; +export { SELECTION_TYPE } from './lib/deck-renderer/deck-drawer'; +export { default as Feature } from './lib/feature'; +export { default as LayerMouseEvent } from './lib/layer-mouse-event'; +export { default as NebulaLayer } from './lib/nebula-layer'; +export { default as JunctionsLayer } from './lib/layers/junctions-layer'; +export { default as TextsLayer } from './lib/layers/texts-layer'; +export { default as SegmentsLayer } from './lib/layers/segments-layer'; +export { default as NebulaCore } from './lib/nebula'; +// Utils +export { toDeckColor } from './lib/utils'; +// Moved to @nebula.gl/layers +export { EditableGeoJsonLayer } from '@nebula.gl/layers'; +export { SelectionLayer } from '@nebula.gl/layers'; +export { ElevatedEditHandleLayer } from '@nebula.gl/layers'; +export { PathOutlineLayer } from '@nebula.gl/layers'; +export { PathMarkerLayer } from '@nebula.gl/layers'; +export { GeoJsonEditMode } from '@nebula.gl/edit-modes'; +// Alter modes +export { ModifyMode } from '@nebula.gl/edit-modes'; +export { TranslateMode } from '@nebula.gl/edit-modes'; +export { ScaleMode } from '@nebula.gl/edit-modes'; +export { RotateMode } from '@nebula.gl/edit-modes'; +export { DuplicateMode } from '@nebula.gl/edit-modes'; +export { ExtendLineStringMode } from '@nebula.gl/edit-modes'; +export { SplitPolygonMode } from '@nebula.gl/edit-modes'; +export { ExtrudeMode } from '@nebula.gl/edit-modes'; +export { ElevationMode } from '@nebula.gl/edit-modes'; +export { TransformMode } from '@nebula.gl/edit-modes'; +// Draw modes +export { DrawPointMode } from '@nebula.gl/edit-modes'; +export { DrawLineStringMode } from '@nebula.gl/edit-modes'; +export { DrawPolygonMode } from '@nebula.gl/edit-modes'; +export { DrawRectangleMode } from '@nebula.gl/edit-modes'; +export { DrawCircleByDiameterMode } from '@nebula.gl/edit-modes'; +export { DrawCircleFromCenterMode } from '@nebula.gl/edit-modes'; +export { DrawEllipseByBoundingBoxMode } from '@nebula.gl/edit-modes'; +export { DrawEllipseUsingThreePointsMode } from '@nebula.gl/edit-modes'; +export { DrawRectangleUsingThreePointsMode } from '@nebula.gl/edit-modes'; +export { Draw90DegreePolygonMode } from '@nebula.gl/edit-modes'; +export { DrawPolygonByDraggingMode } from '@nebula.gl/edit-modes'; +export { ImmutableFeatureCollection } from '@nebula.gl/edit-modes'; +// Other modes +export { ViewMode } from '@nebula.gl/edit-modes'; +export { MeasureDistanceMode } from '@nebula.gl/edit-modes'; +export { MeasureAreaMode } from '@nebula.gl/edit-modes'; +export { MeasureAngleMode } from '@nebula.gl/edit-modes'; +export { CompositeMode } from '@nebula.gl/edit-modes'; +export { SnappableMode } from '@nebula.gl/edit-modes'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/main/src/index.js.map b/lib/modules/main/src/index.js.map new file mode 100644 index 000000000..558220e3b --- /dev/null +++ b/lib/modules/main/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/main/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,QAAQ;AACR,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,6BAA6B;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBA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E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,cAAc;AACd,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts b/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts new file mode 100644 index 000000000..9d890249c --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts @@ -0,0 +1,15 @@ +export default class DeckCache { + objects: TCONV[]; + originals: TORIG[]; + updateTrigger: number; + _idToPosition: Map; + _getData: () => TORIG[]; + _convert: (arg0: TORIG) => TCONV; + constructor(getData: () => TORIG[], convert: (arg0: TORIG) => TCONV); + updateAllDeckObjects(): void; + updateDeckObjectsByIds(ids: string[]): void; + triggerUpdate(): void; + getDeckObjectById(id: string): TCONV | null | undefined; + getOriginalById(id: string): TORIG | null | undefined; +} +//# sourceMappingURL=deck-cache.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts.map b/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts.map new file mode 100644 index 000000000..d32f8e9e2 --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-cache.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"deck-cache.d.ts","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/deck-renderer/deck-cache.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,SAAS,CAAC,KAAK,EAAE,KAAK;IACzC,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,SAAS,EAAE,KAAK,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK,CAAC;gBAErB,OAAO,EAAE,MAAM,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK;IAUnE,oBAAoB;IAgBpB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE;IAapC,aAAa;IAIb,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;IAKvD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;CAItD"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-cache.js b/lib/modules/main/src/lib/deck-renderer/deck-cache.js new file mode 100644 index 000000000..a05796c60 --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-cache.js @@ -0,0 +1,50 @@ +var DeckCache = /** @class */ (function () { + function DeckCache(getData, convert) { + this.objects = []; + this.originals = []; + this.updateTrigger = 0; + this._idToPosition = new Map(); + this._getData = getData; + this._convert = convert; + } + DeckCache.prototype.updateAllDeckObjects = function () { + var _this = this; + if (!this._getData || !this._convert) + return; + this.originals.length = 0; + this.objects.length = 0; + this._idToPosition.clear(); + this._getData().forEach(function (d) { + _this._idToPosition.set(d.id, _this.objects.length); + _this.originals.push(d); + _this.objects.push(_this._convert(d)); + }); + this.triggerUpdate(); + }; + DeckCache.prototype.updateDeckObjectsByIds = function (ids) { + var _this = this; + if (!this._getData || !this._convert) + return; + ids.forEach(function (id) { + var p = _this._idToPosition.get(id); + if (p !== undefined) { + _this.objects[p] = _this._convert(_this.originals[p]); + } + }); + this.triggerUpdate(); + }; + DeckCache.prototype.triggerUpdate = function () { + this.updateTrigger++; + }; + DeckCache.prototype.getDeckObjectById = function (id) { + var p = this._idToPosition.get(id); + return p !== undefined ? this.objects[p] : null; + }; + DeckCache.prototype.getOriginalById = function (id) { + var p = this._idToPosition.get(id); + return p !== undefined ? this.originals[p] : null; + }; + return DeckCache; +}()); +export default DeckCache; +//# sourceMappingURL=deck-cache.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-cache.js.map b/lib/modules/main/src/lib/deck-renderer/deck-cache.js.map new file mode 100644 index 000000000..34c4ad1db --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-cache.js.map @@ -0,0 +1 @@ +{"version":3,"file":"deck-cache.js","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/deck-renderer/deck-cache.ts"],"names":[],"mappings":"AAAA;IAQE,mBAAY,OAAsB,EAAE,OAA+B;QACjE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QAEvB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,wCAAoB,GAApB;QAAA,iBAcC;QAbC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE7C,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAE3B,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAC,CAAC;YACxB,KAAI,CAAC,aAAa,CAAC,GAAG,CAAE,CAAS,CAAC,EAAE,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AAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,CAAC;IACH,gBAAC;AAAD,CAAC,AA5DD,IA4DC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts b/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts new file mode 100644 index 000000000..ed79c503d --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts @@ -0,0 +1,27 @@ +export declare const SELECTION_TYPE: { + NONE: any; + RECTANGLE: string; + POLYGON: string; +}; +export default class DeckDrawer { + nebula: Record; + usePolygon: boolean; + validPolygon: boolean; + landPoints: [number, number][]; + mousePoints: [number, number][]; + constructor(nebula: Record); + _getLayerIds(): any; + _selectFromPickingInfos(pickingInfos: Record[]): void; + _getBoundingBox(): Record; + _selectRectangleObjects(): void; + _selectPolygonObjects(): void; + _getMousePosFromEvent(event: Record): [number, number]; + handleEvent(event: Record, lngLat: [number, number], selectionType: number): { + redraw: boolean; + deactivate: boolean; + }; + reset(): void; + _makeStartPointHighlight(center: [number, number]): number[]; + render(): any[]; +} +//# sourceMappingURL=deck-drawer.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts.map b/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts.map new file mode 100644 index 000000000..49f4e3b5f --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-drawer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"deck-drawer.d.ts","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/deck-renderer/deck-drawer.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,cAAc;;;;CAI1B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;gBAEpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOvC,YAAY;IAOZ,uBAAuB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAQ3D,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAYtC,uBAAuB;IAgBvB,qBAAqB;IASrB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAKnE,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,aAAa,EAAE,MAAM,GACpB;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE;IAuD3C,KAAK;IAKL,wBAAwB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE;IAM5D,MAAM;CAoGP"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-drawer.js b/lib/modules/main/src/lib/deck-renderer/deck-drawer.js new file mode 100644 index 000000000..5096259e9 --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-drawer.js @@ -0,0 +1,237 @@ +import { __assign, __read, __spread } from "tslib"; +import { PolygonLayer } from '@deck.gl/layers'; +import { point, polygon } from '@turf/helpers'; +import turfBbox from '@turf/bbox'; +import turfBboxPolygon from '@turf/bbox-polygon'; +import turfBuffer from '@turf/buffer'; +import turfDifference from '@turf/difference'; +import turfDistance from '@turf/distance'; +var POLYGON_LINE_COLOR = [0, 255, 0, 255]; +var POLYGON_FILL_COLOR = [255, 255, 255, 90]; +var POLYGON_LINE_WIDTH = 2; +var POLYGON_DASHES = [20, 20]; +var POLYGON_THRESHOLD = 0.01; +var EXPANSION_KM = 10; +var LAYER_ID_VIEW = 'DeckDrawerView'; +var LAYER_ID_PICK = 'DeckDrawerPick'; +export var SELECTION_TYPE = { + NONE: null, + RECTANGLE: 'rectangle', + POLYGON: 'polygon', +}; +var DeckDrawer = /** @class */ (function () { + function DeckDrawer(nebula) { + this.nebula = nebula; + this.usePolygon = false; + this.landPoints = []; + this.mousePoints = []; + } + DeckDrawer.prototype._getLayerIds = function () { + // TODO: sort by mouse priority + return this.nebula.deckgl.props.layers + .filter(function (l) { return l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enableSelection; }) + .map(function (l) { return l.id; }); + }; + DeckDrawer.prototype._selectFromPickingInfos = function (pickingInfos) { + var objects = pickingInfos.map(function (_a) { + var layer = _a.layer, index = _a.index, object = _a.object; + return object.original || layer.props.nebulaLayer.deckCache.originals[index]; + }); + this.nebula.props.onSelection(objects); + }; + DeckDrawer.prototype._getBoundingBox = function () { + var mousePoints = this.mousePoints; + var allX = mousePoints.map(function (mousePoint) { return mousePoint[0]; }); + var allY = mousePoints.map(function (mousePoint) { return mousePoint[1]; }); + var x = Math.min.apply(Math, __spread(allX)); + var y = Math.min.apply(Math, __spread(allY)); + var maxX = Math.max.apply(Math, __spread(allX)); + var maxY = Math.max.apply(Math, __spread(allY)); + return { x: x, y: y, width: maxX - x, height: maxY - y }; + }; + DeckDrawer.prototype._selectRectangleObjects = function () { + if (this.landPoints.length !== 2) + return; + var _a = __read(this.mousePoints[0], 2), x1 = _a[0], y1 = _a[1]; + var _b = __read(this.mousePoints[1], 2), x2 = _b[0], y2 = _b[1]; + var pickingInfos = this.nebula.deckgl.pickObjects({ + x: Math.min(x1, x2), + y: Math.min(y1, y2), + width: Math.abs(x2 - x1), + height: Math.abs(y2 - y1), + layerIds: this._getLayerIds(), + }); + this._selectFromPickingInfos(pickingInfos); + }; + DeckDrawer.prototype._selectPolygonObjects = function () { + var pickingInfos = this.nebula.deckgl.pickObjects(__assign(__assign({}, this._getBoundingBox()), { layerIds: __spread([LAYER_ID_PICK], this._getLayerIds()) })); + this._selectFromPickingInfos(pickingInfos.filter(function (item) { return item.layer.id !== LAYER_ID_PICK; })); + }; + DeckDrawer.prototype._getMousePosFromEvent = function (event) { + var offsetX = event.offsetX, offsetY = event.offsetY; + return [offsetX, offsetY]; + }; + DeckDrawer.prototype.handleEvent = function (event, lngLat, selectionType) { + // capture all events (mouse-up is needed to prevent us stuck in moving map) + if (event.type !== 'mouseup') + event.stopPropagation(); + // @ts-ignore + this.usePolygon = selectionType === SELECTION_TYPE.POLYGON; + var redraw = false; + var deactivate = false; + var _a = this, usePolygon = _a.usePolygon, landPoints = _a.landPoints, mousePoints = _a.mousePoints; + if (event.type === 'mousedown') { + if (usePolygon && landPoints.length) { + // if landPoints.length is zero we want to insert two points (so we let it run the else) + // also don't insert if polygon is invalid + if (this.landPoints.length < 3 || this.validPolygon) { + landPoints.push(lngLat); + mousePoints.push(this._getMousePosFromEvent(event)); + } + } + else { + this.landPoints = [lngLat, lngLat]; + var m = this._getMousePosFromEvent(event); + this.mousePoints = [m, m]; + } + redraw = true; + } + else if (event.type === 'mousemove' && landPoints.length) { + // update last point + landPoints[landPoints.length - 1] = lngLat; + mousePoints[mousePoints.length - 1] = this._getMousePosFromEvent(event); + redraw = true; + } + else if (event.type === 'mouseup') { + if (usePolygon) { + // check to see if completed + // TODO: Maybe double-click to finish? + if (landPoints.length > 4 && + turfDistance(landPoints[0], landPoints[landPoints.length - 1]) < POLYGON_THRESHOLD && + this.validPolygon) { + this._selectPolygonObjects(); + this.reset(); + redraw = true; + deactivate = true; + } + } + else { + this._selectRectangleObjects(); + this.reset(); + redraw = true; + deactivate = true; + } + } + return { redraw: redraw, deactivate: deactivate }; + }; + DeckDrawer.prototype.reset = function () { + this.landPoints = []; + this.mousePoints = []; + }; + DeckDrawer.prototype._makeStartPointHighlight = function (center) { + var buffer = turfBuffer(point(center), POLYGON_THRESHOLD / 4.0); + // @ts-ignore + return turfBboxPolygon(turfBbox(buffer)).geometry.coordinates; + }; + DeckDrawer.prototype.render = function () { + var _this = this; + var data = []; + var dataPick = []; + if (!this.usePolygon && this.landPoints.length === 2) { + // Use mouse points instead of land points so we get the right shape + // no matter what bearing is. + var _a = __read(this.mousePoints, 2), _b = __read(_a[0], 2), x1 = _b[0], y1 = _b[1], _c = __read(_a[1], 2), x2 = _c[0], y2 = _c[1]; + var selPolygon = [ + [x1, y1], + [x1, y2], + [x2, y2], + [x2, y1], + [x1, y1], + ].map(function (mousePos) { return _this.nebula.unprojectMousePosition(mousePos); }); + data.push({ + polygon: selPolygon, + lineColor: POLYGON_LINE_COLOR, + fillColor: POLYGON_FILL_COLOR, + }); + } + else if (this.usePolygon && this.landPoints.length) { + data.push({ + polygon: this.landPoints, + lineColor: POLYGON_LINE_COLOR, + fillColor: POLYGON_FILL_COLOR, + }); + // Hack: use a polygon to hide the outside, because pickObjects() + // does not support polygons + if (this.landPoints.length >= 3) { + var landPointsPoly = polygon([__spread(this.landPoints, [this.landPoints[0]])]); + var bigBuffer = turfBuffer(point(this.landPoints[0]), EXPANSION_KM); + var bigPolygon = void 0; + try { + // turfDifference throws an exception if the polygon + // intersects with itself + bigPolygon = turfDifference(bigBuffer, landPointsPoly); + dataPick.push({ + polygon: bigPolygon.geometry.coordinates, + fillColor: [0, 0, 0, 1], + }); + this.validPolygon = true; + } + catch (e) { + // invalid selection polygon + this.validPolygon = false; + } + } + } + if (this.landPoints.length) { + // highlight start point + data.push({ + polygon: this._makeStartPointHighlight(this.landPoints[0]), + lineColor: [0, 0, 0, 0], + fillColor: POLYGON_LINE_COLOR, + }); + } + // Hack to make the PolygonLayer() stay active, + // otherwise it takes 3 seconds (!) to init! + // TODO: fix this + data.push({ polygon: [[0, 0]] }); + dataPick.push({ polygon: [[0, 0]] }); + return [ + new PolygonLayer({ + id: LAYER_ID_VIEW, + data: data, + // @ts-ignore + fp64: false, + opacity: 1.0, + pickable: false, + lineWidthMinPixels: POLYGON_LINE_WIDTH, + lineWidthMaxPixels: POLYGON_LINE_WIDTH, + lineDashJustified: true, + getLineDashArray: function (x) { return POLYGON_DASHES; }, + // @ts-ignore + getLineColor: function (obj) { return obj.lineColor || [0, 0, 0, 255]; }, + // @ts-ignore + getFillColor: function (obj) { return obj.fillColor || [0, 0, 0, 255]; }, + // @ts-ignore + getPolygon: function (o) { return o.polygon; }, + }), + new PolygonLayer({ + id: LAYER_ID_PICK, + data: dataPick, + // @ts-ignore + getLineColor: function (obj) { return obj.lineColor || [0, 0, 0, 255]; }, + // @ts-ignore + getFillColor: function (obj) { return obj.fillColor || [0, 0, 0, 255]; }, + // @ts-ignore + fp64: false, + opacity: 1.0, + stroked: false, + pickable: true, + // @ts-ignore + getPolygon: function (o) { return o.polygon; }, + }), + ]; + }; + return DeckDrawer; +}()); +export default DeckDrawer; +//# sourceMappingURL=deck-drawer.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/deck-renderer/deck-drawer.js.map b/lib/modules/main/src/lib/deck-renderer/deck-drawer.js.map new file mode 100644 index 000000000..36b47b122 --- /dev/null +++ b/lib/modules/main/src/lib/deck-renderer/deck-drawer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"deck-drawer.js","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/deck-renderer/deck-drawer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,IAAM,kBAAkB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAA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D,aAAa;gBACb,UAAU,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS;aAC7B,CAAC;YACF,IAAI,YAAY,CAAC;gBACf,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,QAAQ;gBACd,aAAa;gBACb,YAAY,EAAE,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAA/B,CAA+B;gBACtD,aAAa;gBACb,YAAY,EAAE,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAA/B,CAA+B;gBACtD,aAAa;gBACb,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,GAAG;gBACZ,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,IAAI;gBACd,aAAa;gBACb,UAAU,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS;aAC7B,CAAC;SACH,CAAC;IACJ,CAAC;IACH,iBAAC;AAAD,CAAC,AAjPD,IAiPC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/feature.d.ts b/lib/modules/main/src/lib/feature.d.ts new file mode 100644 index 000000000..3f3d7f506 --- /dev/null +++ b/lib/modules/main/src/lib/feature.d.ts @@ -0,0 +1,11 @@ +import { Feature as GeoJson, Geometry } from 'geojson'; +import { Style } from '../types'; +export default class Feature { + geoJson: GeoJson; + style: Style; + original: any | null | undefined; + metadata: Record; + constructor(geoJson: GeoJson, style: Style, original?: any | null | undefined, metadata?: Record); + getCoords(): any; +} +//# sourceMappingURL=feature.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/feature.d.ts.map b/lib/modules/main/src/lib/feature.d.ts.map new file mode 100644 index 000000000..5102db131 --- /dev/null +++ b/lib/modules/main/src/lib/feature.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,OAAO,OAAO,OAAO;IAE1B,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAG5B,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,KAAK,EAAE,KAAK,EACZ,QAAQ,GAAE,GAAG,GAAG,IAAI,GAAG,SAAgB,EACvC,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAQpC,SAAS,IAAI,GAAG;CAIjB"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/feature.js b/lib/modules/main/src/lib/feature.js new file mode 100644 index 000000000..97bb76985 --- /dev/null +++ b/lib/modules/main/src/lib/feature.js @@ -0,0 +1,17 @@ +var Feature = /** @class */ (function () { + function Feature(geoJson, style, original, metadata) { + if (original === void 0) { original = null; } + if (metadata === void 0) { metadata = {}; } + this.geoJson = geoJson; + this.style = style; + this.original = original; + this.metadata = metadata; + } + Feature.prototype.getCoords = function () { + // @ts-ignore + return this.geoJson.geometry.coordinates; + }; + return Feature; +}()); +export default Feature; +//# sourceMappingURL=feature.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/feature.js.map b/lib/modules/main/src/lib/feature.js.map new file mode 100644 index 000000000..9e0e5145d --- /dev/null +++ b/lib/modules/main/src/lib/feature.js.map @@ -0,0 +1 @@ +{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/feature.ts"],"names":[],"mappings":"AAIA;IAOE,iBACE,OAA0B,EAC1B,KAAY,EACZ,QAAuC,EACvC,QAAkC;QADlC,yBAAA,EAAA,eAAuC;QACvC,yBAAA,EAAA,aAAkC;QAElC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,2BAAS,GAAT;QACE,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC3C,CAAC;IACH,cAAC;AAAD,CAAC,AAvBD,IAuBC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layer-mouse-event.d.ts b/lib/modules/main/src/lib/layer-mouse-event.d.ts new file mode 100644 index 000000000..38b6c5eba --- /dev/null +++ b/lib/modules/main/src/lib/layer-mouse-event.d.ts @@ -0,0 +1,12 @@ +import { Position } from 'geojson'; +export default class LayerMouseEvent { + canceled: boolean; + data: Record; + metadata: Record; + groundPoint: Position; + nativeEvent: MouseEvent; + nebula: Record; + constructor(nativeEvent: MouseEvent, { data, groundPoint, nebula, metadata }: Record); + stopPropagation(): void; +} +//# sourceMappingURL=layer-mouse-event.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layer-mouse-event.d.ts.map b/lib/modules/main/src/lib/layer-mouse-event.d.ts.map new file mode 100644 index 000000000..7c52468f7 --- /dev/null +++ b/lib/modules/main/src/lib/layer-mouse-event.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"layer-mouse-event.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/layer-mouse-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,QAAQ,EAAE,OAAO,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE9B,WAAW,EAAE,QAAQ,CAAC;IAEtB,WAAW,EAAE,UAAU,CAAC;IAExB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAG1B,WAAW,EAAE,UAAU,EACvB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAU9D,eAAe;CAIhB"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layer-mouse-event.js b/lib/modules/main/src/lib/layer-mouse-event.js new file mode 100644 index 000000000..e0cbc7999 --- /dev/null +++ b/lib/modules/main/src/lib/layer-mouse-event.js @@ -0,0 +1,17 @@ +var LayerMouseEvent = /** @class */ (function () { + function LayerMouseEvent(nativeEvent, _a) { + var data = _a.data, groundPoint = _a.groundPoint, nebula = _a.nebula, metadata = _a.metadata; + this.nativeEvent = nativeEvent; + this.data = data; + this.groundPoint = groundPoint; + this.nebula = nebula; + this.metadata = metadata; + } + LayerMouseEvent.prototype.stopPropagation = function () { + this.nativeEvent.stopPropagation(); + this.canceled = true; + }; + return LayerMouseEvent; +}()); +export default LayerMouseEvent; +//# sourceMappingURL=layer-mouse-event.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layer-mouse-event.js.map b/lib/modules/main/src/lib/layer-mouse-event.js.map new file mode 100644 index 000000000..e786e8260 --- /dev/null +++ b/lib/modules/main/src/lib/layer-mouse-event.js.map @@ -0,0 +1 @@ +{"version":3,"file":"layer-mouse-event.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/layer-mouse-event.ts"],"names":[],"mappings":"AAEA;IAaE,yBACE,WAAuB,EACvB,EAA4D;YAA1D,cAAI,EAAE,4BAAW,EAAE,kBAAM,EAAE,sBAAQ;QAErC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,yCAAe,GAAf;QACE,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IACH,sBAAC;AAAD,CAAC,AA7BD,IA6BC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/junctions-layer.d.ts b/lib/modules/main/src/lib/layers/junctions-layer.d.ts new file mode 100644 index 000000000..c70f8ae57 --- /dev/null +++ b/lib/modules/main/src/lib/layers/junctions-layer.d.ts @@ -0,0 +1,8 @@ +import NebulaLayer from '../nebula-layer'; +import DeckCache from '../deck-renderer/deck-cache'; +export default class JunctionsLayer extends NebulaLayer { + deckCache: DeckCache; + constructor(config: Record); + render({ nebula }: Record): any; +} +//# sourceMappingURL=junctions-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/junctions-layer.d.ts.map b/lib/modules/main/src/lib/layers/junctions-layer.d.ts.map new file mode 100644 index 000000000..5215b0fd9 --- /dev/null +++ b/lib/modules/main/src/lib/layers/junctions-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"junctions-layer.d.ts","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/junctions-layer.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,WAAW;IACrD,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMvC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CA2BvC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/junctions-layer.js b/lib/modules/main/src/lib/layers/junctions-layer.js new file mode 100644 index 000000000..c47c9b40d --- /dev/null +++ b/lib/modules/main/src/lib/layers/junctions-layer.js @@ -0,0 +1,43 @@ +import { __extends } from "tslib"; +import { JunctionScatterplotLayer } from '@nebula.gl/layers'; +import NebulaLayer from '../nebula-layer'; +import { toDeckColor } from '../utils'; +import DeckCache from '../deck-renderer/deck-cache'; +var JunctionsLayer = /** @class */ (function (_super) { + __extends(JunctionsLayer, _super); + function JunctionsLayer(config) { + var _this = _super.call(this, config) || this; + _this.deckCache = new DeckCache(config.getData, function (data) { return config.toNebulaFeature(data); }); + _this.enablePicking = true; + return _this; + } + JunctionsLayer.prototype.render = function (_a) { + var nebula = _a.nebula; + var defaultColor = [0x0, 0x0, 0x0, 0xff]; + var _b = this.deckCache, objects = _b.objects, updateTrigger = _b.updateTrigger; + return new JunctionScatterplotLayer({ + id: "junctions-" + this.id, + data: objects, + opacity: 1, + // @ts-ignore + fp64: false, + pickable: true, + getPosition: function (nf) { return nf.geoJson.geometry.coordinates; }, + getFillColor: function (nf) { return toDeckColor(nf.style.fillColor) || defaultColor; }, + getStrokeColor: function (nf) { + return toDeckColor(nf.style.outlineColor) || toDeckColor(nf.style.fillColor) || defaultColor; + }, + getRadius: function (nf) { return nf.style.pointRadiusMeters + nf.style.outlineRadiusMeters || 1; }, + getInnerRadius: function (nf) { return nf.style.pointRadiusMeters || 0.5; }, + parameters: { + depthTest: false, + blend: false, + }, + updateTriggers: { all: updateTrigger }, + nebulaLayer: this, + }); + }; + return JunctionsLayer; +}(NebulaLayer)); +export default JunctionsLayer; +//# sourceMappingURL=junctions-layer.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/junctions-layer.js.map b/lib/modules/main/src/lib/layers/junctions-layer.js.map new file mode 100644 index 000000000..5202eabd0 --- /dev/null +++ b/lib/modules/main/src/lib/layers/junctions-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"junctions-layer.js","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/junctions-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD;IAA4C,kCAAW;IAGrD,wBAAY,MAA2B;QAAvC,YACE,kBAAM,MAAM,CAAC,SAGd;QAFC,KAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,UAAC,IAAI,IAAK,OAAA,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAA5B,CAA4B,CAAC,CAAC;QACvF,KAAI,CAAC,aAAa,GAAG,IAAI,CAAC;;IAC5B,CAAC;IAED,+BAAM,GAAN,UAAO,EAA+B;YAA7B,kBAAM;QACb,IAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACrC,IAAA,mBAA2C,EAAzC,oBAAO,EAAE,gCAAgC,CAAC;QAElD,OAAO,IAAI,wBAAwB,CAAC;YAClC,EAAE,EAAE,eAAa,IAAI,CAAC,EAAI;YAC1B,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,CAAC;YACV,aAAa;YACb,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAA/B,CAA+B;YACpD,YAAY,EAAE,UAAC,EAAE,IAAK,OAAA,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,YAAY,EAA/C,CAA+C;YACrE,cAAc,EAAE,UAAC,EAAE;gBACjB,OAAA,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,YAAY;YAArF,CAAqF;YACvF,SAAS,EAAE,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,KAAK,CAAC,iBAAiB,GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,EAA9D,CAA8D;YACjF,cAAc,EAAE,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,KAAK,CAAC,iBAAiB,IAAI,GAAG,EAAjC,CAAiC;YACzD,UAAU,EAAE;gBACV,SAAS,EAAE,KAAK;gBAChB,KAAK,EAAE,KAAK;aACb;YAED,cAAc,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;YAEtC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IACH,qBAAC;AAAD,CAAC,AApCD,CAA4C,WAAW,GAoCtD"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/segments-layer.d.ts b/lib/modules/main/src/lib/layers/segments-layer.d.ts new file mode 100644 index 000000000..6df5a757f --- /dev/null +++ b/lib/modules/main/src/lib/layers/segments-layer.d.ts @@ -0,0 +1,17 @@ +import NebulaLayer from '../nebula-layer'; +import DeckCache from '../deck-renderer/deck-cache'; +export default class SegmentsLayer extends NebulaLayer { + deckCache: DeckCache; + noBlend: boolean; + highlightColor: [number, number, number, number]; + arrowSize: number; + rounded: boolean; + dashed: boolean; + markerLayerProps: Record | null | undefined; + constructor(config: Record); + getMouseOverSegment(): any; + _calcMarkerPercentages(nf: Record): number[]; + _getHighlightedObjectIndex({ nebula }: Record): number; + render({ nebula }: Record): any; +} +//# sourceMappingURL=segments-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/segments-layer.d.ts.map b/lib/modules/main/src/lib/layers/segments-layer.d.ts.map new file mode 100644 index 000000000..f93cc4922 --- /dev/null +++ b/lib/modules/main/src/lib/layers/segments-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"segments-layer.d.ts","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/segments-layer.ts"],"names":[],"mappings":"AAIA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AASpD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;gBAE7C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAcvC,mBAAmB,IAAI,GAAG;IAK1B,sBAAsB,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE;IAazD,0BAA0B,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAanE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAyCvC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/segments-layer.js b/lib/modules/main/src/lib/layers/segments-layer.js new file mode 100644 index 000000000..8ca96dd53 --- /dev/null +++ b/lib/modules/main/src/lib/layers/segments-layer.js @@ -0,0 +1,92 @@ +var _a; +import { __extends } from "tslib"; +import { PathMarkerLayer } from '@nebula.gl/layers'; +import { MAX } from '@luma.gl/constants'; +import { ArrowStyles, DEFAULT_STYLE, MAX_ARROWS } from '../style'; +import NebulaLayer from '../nebula-layer'; +import { toDeckColor } from '../utils'; +import DeckCache from '../deck-renderer/deck-cache'; +var NEBULA_TO_DECK_DIRECTIONS = (_a = {}, + _a[ArrowStyles.NONE] = { forward: false, backward: false }, + _a[ArrowStyles.FORWARD] = { forward: true, backward: false }, + _a[ArrowStyles.BACKWARD] = { forward: false, backward: true }, + _a[ArrowStyles.BOTH] = { forward: true, backward: true }, + _a); +var SegmentsLayer = /** @class */ (function (_super) { + __extends(SegmentsLayer, _super); + function SegmentsLayer(config) { + var _this = _super.call(this, config) || this; + _this.deckCache = new DeckCache(config.getData, function (data) { return config.toNebulaFeature(data); }); + _this.enableSelection = true; + var _a = config.enablePicking, enablePicking = _a === void 0 ? true : _a, _b = config.noBlend, noBlend = _b === void 0 ? false : _b, _c = config.rounded, rounded = _c === void 0 ? true : _c, _d = config.dashed, dashed = _d === void 0 ? false : _d, _e = config.markerLayerProps, markerLayerProps = _e === void 0 ? null : _e; + Object.assign(_this, { enablePicking: enablePicking, noBlend: noBlend, rounded: rounded, dashed: dashed, markerLayerProps: markerLayerProps }); + return _this; + } + SegmentsLayer.prototype.getMouseOverSegment = function () { + // TODO: remove references + return null; + }; + SegmentsLayer.prototype._calcMarkerPercentages = function (nf) { + var arrowPercentages = nf.style.arrowPercentages; + if (arrowPercentages) { + return arrowPercentages; + } + var arrowStyle = nf.style.arrowStyle || DEFAULT_STYLE.arrowStyle; + if (arrowStyle === ArrowStyles.NONE) + return []; + var arrowCount = Math.min(nf.style.arrowCount || DEFAULT_STYLE.arrowCount, MAX_ARROWS); + return [[0.5], [0.33, 0.66], [0.25, 0.5, 0.75]][arrowCount - 1]; + }; + SegmentsLayer.prototype._getHighlightedObjectIndex = function (_a) { + var nebula = _a.nebula; + var deckglMouseOverInfo = nebula.deckglMouseOverInfo; + if (deckglMouseOverInfo) { + var originalLayer = deckglMouseOverInfo.originalLayer, index = deckglMouseOverInfo.index; + if (originalLayer === this) { + return index; + } + } + // no object + return -1; + }; + SegmentsLayer.prototype.render = function (_a) { + var nebula = _a.nebula; + var defaultColor = [0x0, 0x0, 0x0, 0xff]; + var _b = this.deckCache, objects = _b.objects, updateTrigger = _b.updateTrigger; + return new PathMarkerLayer({ + id: "segments-" + this.id, + data: objects, + opacity: 1, + // @ts-ignore + fp64: false, + rounded: this.rounded, + pickable: true, + sizeScale: this.arrowSize || 6, + parameters: { + depthTest: false, + blend: !this.noBlend, + blendEquation: MAX, + }, + getPath: function (nf) { return nf.geoJson.geometry.coordinates; }, + // @ts-ignore + getColor: function (nf) { return toDeckColor(nf.style.lineColor, defaultColor); }, + getWidth: function (nf) { return nf.style.lineWidthMeters || 1; }, + getZLevel: function (nf) { return nf.style.zLevel * 255; }, + getDirection: function (nf) { return NEBULA_TO_DECK_DIRECTIONS[nf.style.arrowStyle]; }, + // @ts-ignore + getMarkerColor: function (nf) { return toDeckColor(nf.style.arrowColor, defaultColor); }, + getMarkerPercentages: this._calcMarkerPercentages, + updateTriggers: { all: updateTrigger }, + highlightedObjectIndex: this._getHighlightedObjectIndex({ nebula: nebula }), + highlightColor: toDeckColor(this.highlightColor), + dashJustified: this.dashed, + getDashArray: this.dashed ? function (nf) { return nf.style.dashArray; } : null, + markerLayerProps: this.markerLayerProps || + PathMarkerLayer.defaultProps.markerLayerProps, + nebulaLayer: this, + }); + }; + return SegmentsLayer; +}(NebulaLayer)); +export default SegmentsLayer; +//# sourceMappingURL=segments-layer.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/segments-layer.js.map b/lib/modules/main/src/lib/layers/segments-layer.js.map new file mode 100644 index 000000000..e987a9078 --- /dev/null +++ b/lib/modules/main/src/lib/layers/segments-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"segments-layer.js","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/segments-layer.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,E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AAA,EAAE,CAAC,KAAK,CAAC,SAAS,EAAlB,CAAkB,CAAC,CAAC,CAAC,IAAI;YAC7D,gBAAgB,EACd,IAAI,CAAC,gBAAgB;gBACpB,eAAuC,CAAC,YAAY,CAAC,gBAAgB;YAExE,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IACH,oBAAC;AAAD,CAAC,AA/FD,CAA2C,WAAW,GA+FrD"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/texts-layer.d.ts b/lib/modules/main/src/lib/layers/texts-layer.d.ts new file mode 100644 index 000000000..7d4398490 --- /dev/null +++ b/lib/modules/main/src/lib/layers/texts-layer.d.ts @@ -0,0 +1,8 @@ +import NebulaLayer from '../nebula-layer'; +import DeckCache from '../deck-renderer/deck-cache'; +export default class TextsLayer extends NebulaLayer { + deckCache: DeckCache; + constructor(config: Record); + render({ nebula }: Record): any; +} +//# sourceMappingURL=texts-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/texts-layer.d.ts.map b/lib/modules/main/src/lib/layers/texts-layer.d.ts.map new file mode 100644 index 000000000..4b4705995 --- /dev/null +++ b/lib/modules/main/src/lib/layers/texts-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"texts-layer.d.ts","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/texts-layer.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBAEnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKvC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CA0BvC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/texts-layer.js b/lib/modules/main/src/lib/layers/texts-layer.js new file mode 100644 index 000000000..f65e9f562 --- /dev/null +++ b/lib/modules/main/src/lib/layers/texts-layer.js @@ -0,0 +1,37 @@ +import { __extends } from "tslib"; +import { TextLayer } from '@deck.gl/layers'; +import NebulaLayer from '../nebula-layer'; +import { toDeckColor } from '../utils'; +import DeckCache from '../deck-renderer/deck-cache'; +var TextsLayer = /** @class */ (function (_super) { + __extends(TextsLayer, _super); + function TextsLayer(config) { + var _this = _super.call(this, config) || this; + _this.deckCache = new DeckCache(config.getData, function (data) { return config.toNebulaFeature(data); }); + return _this; + } + TextsLayer.prototype.render = function (_a) { + var nebula = _a.nebula; + var defaultColor = [0x0, 0x0, 0x0, 0xff]; + var _b = this.deckCache, objects = _b.objects, updateTrigger = _b.updateTrigger; + var zoom = nebula.props.viewport.zoom; + return new TextLayer({ + id: "texts-" + this.id, + data: objects, + opacity: 1, + fp64: false, + pickable: false, + getText: function (nf) { return nf.style.text; }, + getPosition: function (nf) { return nf.geoJson.geometry.coordinates; }, + // @ts-ignore + getColor: function (nf) { return toDeckColor(nf.style.fillColor) || defaultColor; }, + // TODO: layer should offer option to scale with zoom + sizeScale: 1 / Math.pow(2, 20 - zoom), + updateTriggers: { all: updateTrigger }, + nebulaLayer: this, + }); + }; + return TextsLayer; +}(NebulaLayer)); +export default TextsLayer; +//# sourceMappingURL=texts-layer.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/layers/texts-layer.js.map b/lib/modules/main/src/lib/layers/texts-layer.js.map new file mode 100644 index 000000000..63ffcdfb9 --- /dev/null +++ b/lib/modules/main/src/lib/layers/texts-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"texts-layer.js","sourceRoot":"","sources":["../../../../../../modules/main/src/lib/layers/texts-layer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,E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CAAC,AAlCD,CAAwC,WAAW,GAkClD"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/math.d.ts b/lib/modules/main/src/lib/math.d.ts new file mode 100644 index 000000000..83a573812 --- /dev/null +++ b/lib/modules/main/src/lib/math.d.ts @@ -0,0 +1,12 @@ +import { Position } from 'geojson'; +export declare function toDegree(radian: number): number; +export declare function toRadian(angle: number): number; +/** + * Converts an array of latitudes, longitudes in E7 format to a list of points in degrees. + * + * @param {[]} array: An E7 array [lat_e7, lng_e7, lat_e7, lng_e7, ...] + * @return {[]} An array of points in degrees + * [ [lng_degrees, lat_degrees], [lng_degrees, lat_degrees], ...] + */ +export declare function convertE7Array(array: number[]): Position[]; +//# sourceMappingURL=math.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/math.d.ts.map b/lib/modules/main/src/lib/math.d.ts.map new file mode 100644 index 000000000..eef1db0f5 --- /dev/null +++ b/lib/modules/main/src/lib/math.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAQ1D"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/math.js b/lib/modules/main/src/lib/math.js new file mode 100644 index 000000000..06c796510 --- /dev/null +++ b/lib/modules/main/src/lib/math.js @@ -0,0 +1,23 @@ +export function toDegree(radian) { + return (radian * 180) / Math.PI; +} +export function toRadian(angle) { + return (angle * Math.PI) / 180; +} +/** + * Converts an array of latitudes, longitudes in E7 format to a list of points in degrees. + * + * @param {[]} array: An E7 array [lat_e7, lng_e7, lat_e7, lng_e7, ...] + * @return {[]} An array of points in degrees + * [ [lng_degrees, lat_degrees], [lng_degrees, lat_degrees], ...] + */ +export function convertE7Array(array) { + var points = []; + for (var i = 0; i < array.length; i += 2) { + var lat = array[i] * 1e-7; + var lng = array[i + 1] * 1e-7; + points.push([lng, lat]); + } + return points; +} +//# sourceMappingURL=math.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/math.js.map b/lib/modules/main/src/lib/math.js.map new file mode 100644 index 000000000..f33eb2b43 --- /dev/null +++ b/lib/modules/main/src/lib/math.js.map @@ -0,0 +1 @@ +{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/math.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,IAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACxC,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC5B,IAAM,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;KACzB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula-layer.d.ts b/lib/modules/main/src/lib/nebula-layer.d.ts new file mode 100644 index 000000000..26ccbb42c --- /dev/null +++ b/lib/modules/main/src/lib/nebula-layer.d.ts @@ -0,0 +1,15 @@ +/// +import Event from 'events'; +import Feature from './feature'; +export default class NebulaLayer extends Event.EventEmitter { + getData: () => Record[]; + toNebulaFeature: (data: Record) => Feature; + id: string; + helperLayers: Record[]; + usesMapEvents: boolean; + enablePicking: boolean; + enableSelection: boolean; + constructor({ getData, on, toNebulaFeature }: Record); + render(config: Record): unknown; +} +//# sourceMappingURL=nebula-layer.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula-layer.d.ts.map b/lib/modules/main/src/lib/nebula-layer.d.ts.map new file mode 100644 index 000000000..c554a6d83 --- /dev/null +++ b/lib/modules/main/src/lib/nebula-layer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nebula-layer.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/nebula-layer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,QAAQ,CAAC;AAG3B,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK,CAAC,YAAY;IACzD,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IACrC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAGpC,aAAa,UAAS;IACtB,aAAa,UAAS;IACtB,eAAe,UAAS;gBAGZ,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAajE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;CAG7C"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula-layer.js b/lib/modules/main/src/lib/nebula-layer.js new file mode 100644 index 000000000..1c8c123c9 --- /dev/null +++ b/lib/modules/main/src/lib/nebula-layer.js @@ -0,0 +1,30 @@ +import { __extends } from "tslib"; +import Event from 'events'; +import uuid from 'uuid'; +var NebulaLayer = /** @class */ (function (_super) { + __extends(NebulaLayer, _super); + // + function NebulaLayer(_a) { + var getData = _a.getData, on = _a.on, toNebulaFeature = _a.toNebulaFeature; + var _this = _super.call(this) || this; + // flags + _this.usesMapEvents = false; + _this.enablePicking = false; + _this.enableSelection = false; + _this.id = uuid.v4(); + _this.getData = getData; + _this.toNebulaFeature = toNebulaFeature; + _this.helperLayers = []; + if (on) { + // @ts-ignore + Object.keys(on).forEach(function (key) { return _this.on(key, on[key]); }); + } + return _this; + } + NebulaLayer.prototype.render = function (config) { + return null; + }; + return NebulaLayer; +}(Event.EventEmitter)); +export default NebulaLayer; +//# sourceMappingURL=nebula-layer.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula-layer.js.map b/lib/modules/main/src/lib/nebula-layer.js.map new file mode 100644 index 000000000..bcc31c3d6 --- /dev/null +++ b/lib/modules/main/src/lib/nebula-layer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nebula-layer.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/nebula-layer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB;IAAyC,+BAAkB;IAUzD,EAAE;IAEF,qBAAY,EAAqD;YAAnD,oBAAO,EAAE,UAAE,EAAE,oCAAe;QAA1C,YACE,iBAAO,SAUR;QAjBD,QAAQ;QACR,mBAAa,GAAG,KAAK,CAAC;QACtB,mBAAa,GAAG,KAAK,CAAC;QACtB,qBAAe,GAAG,KAAK,CAAC;QAKtB,KAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACpB,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,KAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QAEvB,IAAI,EAAE,EAAE;YACN,aAAa;YACb,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG,IAAK,OAAA,KAAI,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAArB,CAAqB,CAAC,CAAC;SACzD;;IACH,CAAC;IAED,4BAAM,GAAN,UAAO,MAA2B;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IACH,kBAAC;AAAD,CAAC,AA5BD,CAAyC,KAAK,CAAC,YAAY,GA4B1D"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula.d.ts b/lib/modules/main/src/lib/nebula.d.ts new file mode 100644 index 000000000..536a4cf79 --- /dev/null +++ b/lib/modules/main/src/lib/nebula.d.ts @@ -0,0 +1,37 @@ +/// +/// +import { EventEmitter } from 'events'; +import { WebMercatorViewport } from '@deck.gl/core'; +import DeckDrawer from './deck-renderer/deck-drawer'; +export default class Nebula { + init(props: Record): void; + detach(): void; + updateProps(newProps: Record): void; + props: Record; + deckgl: Record | null; + mainContainer: Record | null; + deckglMouseOverInfo: Record | null | undefined; + _deckDrawer: DeckDrawer; + _mouseWasDown: boolean; + wmViewport: WebMercatorViewport; + queryObjectEvents: EventEmitter; + forceUpdate: Function; + inited: boolean; + log(message: string): void; + updateAllDeckObjects(): void; + updateDeckObjectsByIds(ids: string[]): void; + rerenderLayers(): void; + _isNebulaEvent({ buttons, target, type }: Record): boolean; + _onMouseEvent: (event: any) => void; + getMouseGroundPosition(event: Record): any[]; + unprojectMousePosition(mousePosition: [number, number]): [number, number]; + _handleDeckGLEvent(event: Record): void; + getExtraDeckLayers(): Record[]; + renderDeckLayers(): any[]; + getAllLayers(): any[]; + getRenderedLayers(): any[]; + updateAndGetRenderedLayers(layers: Record[], viewport: WebMercatorViewport, container: Record): any[]; + setDeck(deckgl: Record | null): void; + setMainContainer(mainContainer: Record | null): void; +} +//# sourceMappingURL=nebula.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula.d.ts.map b/lib/modules/main/src/lib/nebula.d.ts.map new file mode 100644 index 000000000..bd0eb919f --- /dev/null +++ b/lib/modules/main/src/lib/nebula.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nebula.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/nebula.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAMrD,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAU/B,MAAM;IAON,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5D,WAAW,EAAE,UAAU,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,mBAAmB,CAAC;IAChC,iBAAiB,EAAE,YAAY,CAAsB;IACrD,WAAW,EAAE,QAAQ,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAEhB,GAAG,CAAC,OAAO,EAAE,MAAM;IAOnB,oBAAoB;IASpB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE;IASpC,cAAc;IAId,cAAc,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA8B7D,aAAa,uBAwCX;IAEF,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIjD,sBAAsB,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAKzE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA2G7C,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAQ3C,gBAAgB;IAMhB,YAAY;IAcZ,iBAAiB;IAIjB,0BAA0B,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC7B,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAehC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAM1C,gBAAgB,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;CAK3D"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula.js b/lib/modules/main/src/lib/nebula.js new file mode 100644 index 000000000..5435b6cb9 --- /dev/null +++ b/lib/modules/main/src/lib/nebula.js @@ -0,0 +1,264 @@ +import { __read, __spread } from "tslib"; +import { EventEmitter } from 'events'; +import document from 'global/document'; +import { WebMercatorViewport } from '@deck.gl/core'; +import DeckDrawer from './deck-renderer/deck-drawer'; +import LayerMouseEvent from './layer-mouse-event'; +import NebulaLayer from './nebula-layer'; +var LOGGER_PREFIX = 'Nebula: '; +var Nebula = /** @class */ (function () { + function Nebula() { + var _this = this; + this.queryObjectEvents = new EventEmitter(); + this._onMouseEvent = function (event) { + if (!_this._isNebulaEvent(event)) { + return; + } + if (event.type === 'mousedown') { + _this._mouseWasDown = true; + } + // offsetX/Y of the MouseEvent provides the offset in the X/Y coordinate + // of the mouse pointer between that event and the padding edge of the target node. + // We set our listener to document so we need to adjust offsetX/Y + // in case the target is not be our WebGL canvas. + var _a = _this.mainContainer + ? _this.mainContainer.getBoundingClientRect() + : {}, _b = _a.top, top = _b === void 0 ? 0 : _b, _c = _a.left, left = _c === void 0 ? 0 : _c; + var proxyEvent = new Proxy(event, { + get: function (original, propertyName) { + if (propertyName === 'offsetX') { + return original.pageX - left; + } + if (propertyName === 'offsetY') { + return original.pageY - top; + } + // TODO: Properly use pointer events + if (propertyName === 'type') { + return original.type.replace('pointer', 'mouse'); + } + var result = original[propertyName]; + if (typeof result === 'function') { + return result.bind(original); + } + return result; + }, + }); + _this._handleDeckGLEvent(proxyEvent); + }; + } + Nebula.prototype.init = function (props) { + var _this = this; + this.props = props; + this.wmViewport = new WebMercatorViewport(this.props.viewport); + // TODO: Properly use pointer events: ['click', 'dblclick', 'pointermove', 'pointerup', 'pointerdown'] + ['click', 'dblclick', 'mousemove', 'mouseup', 'mousedown'].forEach(function (name) { + return document.addEventListener(name, _this._onMouseEvent, true); + }); + }; + Nebula.prototype.detach = function () { + var _this = this; + // TODO: Properly use pointer events: ['click', 'dblclick', 'pointermove', 'pointerup', 'pointerdown'] + ['click', 'dblclick', 'mousemove', 'mouseup', 'mousedown'].forEach(function (name) { + return document.removeEventListener(name, _this._onMouseEvent, true); + }); + }; + Nebula.prototype.updateProps = function (newProps) { + this.props = newProps; + var viewport = this.props.viewport; + this.wmViewport = new WebMercatorViewport(viewport); + }; + Nebula.prototype.log = function (message) { + var logger = this.props.logger; + if (logger && logger.info) { + logger.info(LOGGER_PREFIX + message); + } + }; + Nebula.prototype.updateAllDeckObjects = function () { + this.getAllLayers().forEach(function (layer) { + if (layer && layer.deckCache) { + layer.deckCache.updateAllDeckObjects(); + } + }); + this.forceUpdate(); + }; + Nebula.prototype.updateDeckObjectsByIds = function (ids) { + this.getAllLayers().forEach(function (layer) { + if (layer && layer.deckCache) { + layer.deckCache.updateDeckObjectsByIds(ids); + } + }); + this.forceUpdate(); + }; + Nebula.prototype.rerenderLayers = function () { + this.updateAllDeckObjects(); + }; + Nebula.prototype._isNebulaEvent = function (_a) { + var buttons = _a.buttons, target = _a.target, type = _a.type; + var viewport = this.props.viewport; + // allow mouseup event aggressively to cancel drag properly + // TODO: use pointer capture setPointerCapture() to capture mouseup properly after deckgl + if (this._mouseWasDown && type === 'mouseup') { + this._mouseWasDown = false; + return true; + } + // allow mousemove event while dragging + if (type === 'mousemove' && buttons > 0) { + return true; + } + if (!target.getBoundingClientRect) { + return false; + } + var rect = target.getBoundingClientRect(); + // Only listen to events coming from the basemap + // identified by the canvas of the same size as viewport. + // Need to round the rect dimension as some monitors + // have some sub-pixel difference with viewport. + return (Math.round(rect.width) === Math.round(viewport.width) && + Math.round(rect.height) === Math.round(viewport.height)); + }; + Nebula.prototype.getMouseGroundPosition = function (event) { + return this.wmViewport.unproject([event.offsetX, event.offsetY]); + }; + Nebula.prototype.unprojectMousePosition = function (mousePosition) { + // @ts-ignore + return this.wmViewport.unproject(mousePosition); + }; + Nebula.prototype._handleDeckGLEvent = function (event) { + var _a = this, deckgl = _a.deckgl, _b = _a.props, onMapMouseEvent = _b.onMapMouseEvent, selectionType = _b.selectionType, eventFilter = _b.eventFilter; + var sendMapEvent = true; + var cursor = 'auto'; + if (event && deckgl && selectionType) { + if (!this._deckDrawer) + this._deckDrawer = new DeckDrawer(this); + var lngLat = this.getMouseGroundPosition(event); + if (eventFilter && !eventFilter(lngLat, event)) + return; + // @ts-ignore + var drawerResult = this._deckDrawer.handleEvent(event, lngLat, selectionType); + if (drawerResult.redraw) + this.forceUpdate(); + return; + } + if (event && deckgl && (!event.buttons || event.type !== 'mousemove')) { + // TODO: sort by mouse priority + var layerIds = deckgl.props.layers + .filter(function (l) { return l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enablePicking; }) + .map(function (l) { return l.id; }); + var pickingInfo = deckgl.pickObject({ + x: event.offsetX, + y: event.offsetY, + radius: 5, + layerIds: layerIds, + }); + this.queryObjectEvents.emit('pick', { event: event, pickingInfo: pickingInfo }); + if (pickingInfo) { + sendMapEvent = false; + var index = pickingInfo.index, lngLat = pickingInfo.lngLat; + if (eventFilter && !eventFilter(lngLat, event)) + return; + var deckLayer = pickingInfo.layer, object = pickingInfo.object; + if (deckLayer && + deckLayer.props && + deckLayer.props.nebulaLayer && + deckLayer.props.nebulaLayer.eventHandler) { + deckLayer.props.nebulaLayer.eventHandler(event, pickingInfo); + } + var original = object.original || + (deckLayer.props.nebulaLayer && + deckLayer.props.nebulaLayer.deckCache && + deckLayer.props.nebulaLayer.deckCache.originals[index]); + if (original) { + this.deckglMouseOverInfo = { originalLayer: deckLayer.props.nebulaLayer, index: index }; + // @ts-ignore + var nebulaMouseEvent = new LayerMouseEvent(event, { + data: original, + metadata: object.metadata, + groundPoint: lngLat, + nebula: this, + }); + deckLayer.props.nebulaLayer.emit(event.type, nebulaMouseEvent); + this.forceUpdate(); + } + cursor = 'pointer'; + } + } + if (document.documentElement) { + document.documentElement.style.cursor = cursor; + } + if (sendMapEvent) { + this.deckglMouseOverInfo = null; + var lngLat = this.getMouseGroundPosition(event); + if (eventFilter && !eventFilter(lngLat, event)) + return; + // send to layers first + // @ts-ignore + var nebulaMouseEvent_1 = new LayerMouseEvent(event, { + groundPoint: lngLat, + nebula: this, + }); + this.getAllLayers() + .filter(function (layer) { return layer && layer.usesMapEvents; }) + .forEach(function (layer) { return layer.emit('mapMouseEvent', nebulaMouseEvent_1); }); + this.getAllLayers() + .filter(function (layer) { + return layer && layer.props && layer.props.nebulaLayer && layer.props.nebulaLayer.mapMouseEvent; + }) + .forEach(function (layer) { return layer.props.nebulaLayer.mapMouseEvent(nebulaMouseEvent_1, layer); }); + if (onMapMouseEvent) { + onMapMouseEvent(event, lngLat); + } + } + }; + Nebula.prototype.getExtraDeckLayers = function () { + var result = []; + if (this._deckDrawer) + result.push.apply(result, __spread(this._deckDrawer.render())); + return result; + }; + Nebula.prototype.renderDeckLayers = function () { + var _this = this; + return this.getAllLayers() + .map(function (layer) { return (layer instanceof NebulaLayer ? layer.render({ nebula: _this }) : layer); }) + .filter(Boolean); + }; + Nebula.prototype.getAllLayers = function () { + var result = []; + this.props.layers.filter(Boolean).forEach(function (layer) { + result.push(layer); + // Only NebulaLayers have helpers, Deck GL layers don't. + if (layer instanceof NebulaLayer) { + result.push.apply(result, __spread(layer.helperLayers)); + } + }); + return result.filter(Boolean); + }; + Nebula.prototype.getRenderedLayers = function () { + return __spread(this.renderDeckLayers(), this.getExtraDeckLayers()); + }; + Nebula.prototype.updateAndGetRenderedLayers = function (layers, viewport, container) { + if (this.inited) { + this.updateProps({ layers: layers, viewport: viewport }); + this.forceUpdate = function () { return container.forceUpdate(); }; + } + else { + this.inited = true; + this.init({ layers: layers, viewport: viewport }); + this.forceUpdate = function () { return container.forceUpdate(); }; + this.updateAllDeckObjects(); + } + return this.getRenderedLayers(); + }; + Nebula.prototype.setDeck = function (deckgl) { + if (deckgl) { + this.deckgl = deckgl; + } + }; + Nebula.prototype.setMainContainer = function (mainContainer) { + if (mainContainer) { + this.mainContainer = mainContainer; + } + }; + return Nebula; +}()); +export default Nebula; +//# sourceMappingURL=nebula.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/nebula.js.map b/lib/modules/main/src/lib/nebula.js.map new file mode 100644 index 000000000..ff55fcc1f --- /dev/null +++ b/lib/modules/main/src/lib/nebula.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nebula.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/nebula.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,UA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d.ts new file mode 100644 index 000000000..b959cfb1f --- /dev/null +++ b/lib/modules/main/src/lib/style.d.ts @@ -0,0 +1,20 @@ +export declare const ArrowStyles: { + NONE: number; + FORWARD: number; + BACKWARD: number; + BOTH: number; +}; +export declare const DEFAULT_ARROWS = 1; +export declare const MAX_ARROWS = 3; +export declare const DEFAULT_STYLE: { + arrowColor: number[]; + arrowCount: number; + arrowStyle: number; + fillColor: number[]; + lineColor: number[]; + lineWidthMeters: number; + outlineRadiusMeters: number; + opacity: number; + zLevel: number; +}; +//# sourceMappingURL=style.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/style.d.ts.map b/lib/modules/main/src/lib/style.d.ts.map new file mode 100644 index 000000000..fdcca7a47 --- /dev/null +++ b/lib/modules/main/src/lib/style.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/style.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAEF,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B,eAAO,MAAM,aAAa;;;;;;;;;;CAUzB,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/style.js b/lib/modules/main/src/lib/style.js new file mode 100644 index 000000000..0ab10d5e8 --- /dev/null +++ b/lib/modules/main/src/lib/style.js @@ -0,0 +1,21 @@ +// Describes the arrow style of polylines +export var ArrowStyles = { + NONE: 0, + FORWARD: 1, + BACKWARD: 2, + BOTH: 3, +}; +export var DEFAULT_ARROWS = 1; +export var MAX_ARROWS = 3; +export var DEFAULT_STYLE = { + arrowColor: [0, 0, 0, 1], + arrowCount: DEFAULT_ARROWS, + arrowStyle: ArrowStyles.NONE, + fillColor: [0, 0, 0, 1], + lineColor: [0, 0, 0, 1], + lineWidthMeters: 5, + outlineRadiusMeters: 0, + opacity: 1, + zLevel: 0, +}; +//# sourceMappingURL=style.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/style.js.map b/lib/modules/main/src/lib/style.js.map new file mode 100644 index 000000000..ae2c3915e --- /dev/null +++ b/lib/modules/main/src/lib/style.js.map @@ -0,0 +1 @@ +{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/style.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,IAAM,UAAU,GAAG,CAAC,CAAC;AAE5B,MAAM,CAAC,IAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxB,UAAU,EAAE,cAAc;IAC1B,UAAU,EAAE,WAAW,CAAC,IAAI;IAC5B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACvB,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACvB,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,CAAC;IACtB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;CACV,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/utils.d.ts b/lib/modules/main/src/lib/utils.d.ts new file mode 100644 index 000000000..444533781 --- /dev/null +++ b/lib/modules/main/src/lib/utils.d.ts @@ -0,0 +1,3 @@ +export declare function toDeckColor(color?: [number, number, number, number] | null | undefined, defaultColor?: [number, number, number, number]): [number, number, number, number]; +export declare function recursivelyTraverseNestedArrays(array: Array, prefix: Array, fn: Function): boolean; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/utils.d.ts.map b/lib/modules/main/src/lib/utils.d.ts.map new file mode 100644 index 000000000..255022cb0 --- /dev/null +++ b/lib/modules/main/src/lib/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../modules/main/src/lib/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CACzB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3D,YAAY,GAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAoB,GAChE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAKlC;AA2BD,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,EAAE,EAAE,QAAQ,WAYb"} \ No newline at end of file diff --git a/lib/modules/main/src/lib/utils.js b/lib/modules/main/src/lib/utils.js new file mode 100644 index 000000000..3fba46f61 --- /dev/null +++ b/lib/modules/main/src/lib/utils.js @@ -0,0 +1,46 @@ +import { __read, __spread } from "tslib"; +export function toDeckColor(color, defaultColor) { + if (defaultColor === void 0) { defaultColor = [255, 0, 0, 255]; } + if (!Array.isArray(color)) { + return defaultColor; + } + return [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]; +} +// +// a GeoJSON helper function that calls the provided function with +// an argument that is the most deeply-nested array having elements +// that are arrays of primitives as an argument, e.g. +// +// { +// "type": "MultiPolygon", +// "coordinates": [ +// [ +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// ], +// [ +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// ] +// ] +// } +// +// the function would be called on: +// +// [[30, 20], [45, 40], [10, 40], [30, 20]] +// +// and +// +// [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] +// +export function recursivelyTraverseNestedArrays(array, prefix, fn) { + if (!Array.isArray(array[0])) { + return true; + } + for (var i = 0; i < array.length; i++) { + if (recursivelyTraverseNestedArrays(array[i], __spread(prefix, [i]), fn)) { + fn(array, prefix); + break; + } + } + return false; +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/lib/modules/main/src/lib/utils.js.map b/lib/modules/main/src/lib/utils.js.map new file mode 100644 index 000000000..3a3d1ece5 --- /dev/null +++ b/lib/modules/main/src/lib/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../modules/main/src/lib/utils.ts"],"names":[],"mappings":";AAAA,MAAM,UAAU,WAAW,CACzB,KAA2D,EAC3D,YAAiE;IAAjE,6BAAA,EAAA,gBAAkD,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;IAEjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,YAAY,CAAC;KACrB;IACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,qDAAqD;AACrD,EAAE;AACF,IAAI;AACJ,4BAA4B;AAC5B,qBAAqB;AACrB,UAAU;AACV,qDAAqD;AACrD,WAAW;AACX,UAAU;AACV,4DAA4D;AAC5D,UAAU;AACV,MAAM;AACN,IAAI;AACJ,EAAE;AACF,mCAAmC;AACnC,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,MAAM;AACN,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,MAAM,UAAU,+BAA+B,CAC7C,KAAiB,EACjB,MAAqB,EACrB,EAAY;IAEZ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,+BAA+B,CAAC,KAAK,CAAC,CAAC,CAAC,WAAM,MAAM,GAAE,CAAC,IAAG,EAAE,CAAC,EAAE;YACjE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAClB,MAAM;SACP;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/types.d.ts b/lib/modules/main/src/types.d.ts new file mode 100644 index 000000000..55148e26f --- /dev/null +++ b/lib/modules/main/src/types.d.ts @@ -0,0 +1,36 @@ +export declare type LayerMouseEventResult = { + eventConsumed?: boolean; + eventSoftConsumed?: boolean; + mousePointer?: string | null | undefined; + shouldRedraw?: boolean | string[]; +}; +export declare type Color = [number, number, number, number]; +export declare type Style = { + dashArray?: number[]; + fillColor?: Color; + lineColor?: Color; + lineWidthMeters?: number; + pointRadiusMeters?: number; + outlineRadiusMeters?: number; + outlineColor?: Color; + mousePriority?: number; + arrowColor?: Color; + arrowStyle?: number; + arrowCount?: number; + iconNumber?: number; + text?: string; + tooltip?: string; + zLevel?: number; +}; +export declare type Viewport = { + width: number; + height: number; + longitude: number; + latitude: number; + zoom: number; + isDragging?: boolean; + isMoving?: boolean; + bearing?: number; + pitch?: number; +}; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/lib/modules/main/src/types.d.ts.map b/lib/modules/main/src/types.d.ts.map new file mode 100644 index 000000000..8c887d6bf --- /dev/null +++ b/lib/modules/main/src/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../modules/main/src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,qBAAqB,GAAG;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;CACnC,CAAC;AAGF,oBAAY,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,oBAAY,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"} \ No newline at end of file diff --git a/lib/modules/main/src/types.js b/lib/modules/main/src/types.js new file mode 100644 index 000000000..5b2306a4c --- /dev/null +++ b/lib/modules/main/src/types.js @@ -0,0 +1 @@ +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/modules/main/src/types.js.map b/lib/modules/main/src/types.js.map new file mode 100644 index 000000000..a6896ca77 --- /dev/null +++ b/lib/modules/main/src/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../modules/main/src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-cluster-overlay.d.ts b/lib/modules/overlays/src/html-cluster-overlay.d.ts new file mode 100644 index 000000000..a1a061757 --- /dev/null +++ b/lib/modules/overlays/src/html-cluster-overlay.d.ts @@ -0,0 +1,13 @@ +import HtmlOverlay from './html-overlay'; +export default class HtmlClusterOverlay extends HtmlOverlay { + _superCluster: Record; + _lastObjects: ObjType[] | null | undefined; + getItems(): Record[]; + getClusterObjects(clusterId: number): ObjType[]; + getAllObjects(): ObjType[]; + getObjectCoordinates(obj: ObjType): [number, number]; + getClusterOptions(): Record | null | undefined; + renderObject(coordinates: number[], obj: ObjType): Record | null | undefined; + renderCluster(coordinates: number[], clusterId: number, pointCount: number): Record | null | undefined; +} +//# sourceMappingURL=html-cluster-overlay.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-cluster-overlay.d.ts.map b/lib/modules/overlays/src/html-cluster-overlay.d.ts.map new file mode 100644 index 000000000..f7a4b90e4 --- /dev/null +++ b/lib/modules/overlays/src/html-cluster-overlay.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"html-cluster-overlay.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/src/html-cluster-overlay.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,kBAAkB,CAAC,OAAO,CAAE,SAAQ,WAAW;IAClE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAQ;IAElD,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAgCjC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE;IAS/C,aAAa,IAAI,OAAO,EAAE;IAK1B,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAKpD,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS;IAO3D,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS;IAMzF,aAAa,CACX,WAAW,EAAE,MAAM,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS;CAG1C"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-cluster-overlay.js b/lib/modules/overlays/src/html-cluster-overlay.js new file mode 100644 index 000000000..835bb22ff --- /dev/null +++ b/lib/modules/overlays/src/html-cluster-overlay.js @@ -0,0 +1,65 @@ +import { __extends } from "tslib"; +import { point } from '@turf/helpers'; +import Supercluster from 'supercluster'; +import HtmlOverlay from './html-overlay'; +var HtmlClusterOverlay = /** @class */ (function (_super) { + __extends(HtmlClusterOverlay, _super); + function HtmlClusterOverlay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._lastObjects = null; + return _this; + } + HtmlClusterOverlay.prototype.getItems = function () { + // supercluster().load() is expensive and we want to run it only + // when necessary and not for every frame. + var _this = this; + // TODO: Warn if this is running many times / sec + var newObjects = this.getAllObjects(); + if (newObjects !== this._lastObjects) { + this._superCluster = new Supercluster(this.getClusterOptions()); + this._superCluster.load(newObjects.map(function (object) { return point(_this.getObjectCoordinates(object), { object: object }); })); + this._lastObjects = newObjects; + // console.log('new Supercluster() run'); + } + var clusters = this._superCluster.getClusters([-180, -90, 180, 90], Math.round(this.getZoom())); + return clusters.map(function (_a) { + var coordinates = _a.geometry.coordinates, _b = _a.properties, cluster = _b.cluster, pointCount = _b.point_count, clusterId = _b.cluster_id, object = _b.object; + return cluster + ? _this.renderCluster(coordinates, clusterId, pointCount) + : _this.renderObject(coordinates, object); + }); + }; + HtmlClusterOverlay.prototype.getClusterObjects = function (clusterId) { + return this._superCluster + .getLeaves(clusterId, Infinity) + .map(function (object) { return object.properties.object; }); + }; + // Override to provide items that need clustering. + // If the items have not changed please provide the same array to avoid + // regeneration of the cluster which causes performance issues. + HtmlClusterOverlay.prototype.getAllObjects = function () { + return []; + }; + // override to provide coordinates for each object of getAllObjects() + HtmlClusterOverlay.prototype.getObjectCoordinates = function (obj) { + return [0, 0]; + }; + // Get options object used when instantiating supercluster + HtmlClusterOverlay.prototype.getClusterOptions = function () { + return { + maxZoom: 20, + }; + }; + // override to return an HtmlOverlayItem + HtmlClusterOverlay.prototype.renderObject = function (coordinates, obj) { + return null; + }; + // override to return an HtmlOverlayItem + // use getClusterObjects() to get cluster contents + HtmlClusterOverlay.prototype.renderCluster = function (coordinates, clusterId, pointCount) { + return null; + }; + return HtmlClusterOverlay; +}(HtmlOverlay)); +export default HtmlClusterOverlay; +//# sourceMappingURL=html-cluster-overlay.js.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-cluster-overlay.js.map b/lib/modules/overlays/src/html-cluster-overlay.js.map new file mode 100644 index 000000000..c53654cae --- /dev/null +++ b/lib/modules/overlays/src/html-cluster-overlay.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html-cluster-overlay.js","sourceRoot":"","sources":["../../../../modules/overlays/src/html-cluster-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,WAAW,MAA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OAAO,IAAI,CAAC,aAAa;aACtB,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC;aAC9B,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,UAAU,CAAC,MAAM,EAAxB,CAAwB,CAAC,CAAC;IAC/C,CAAC;IAED,kDAAkD;IAClD,uEAAuE;IACvE,+DAA+D;IAC/D,0CAAa,GAAb;QACE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,qEAAqE;IACrE,iDAAoB,GAApB,UAAqB,GAAY;QAC/B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,0DAA0D;IAC1D,8CAAiB,GAAjB;QACE,OAAO;YACL,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;IAED,wCAAwC;IACxC,yCAAY,GAAZ,UAAa,WAAqB,EAAE,GAAY;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,wCAAwC;IACxC,kDAAkD;IAClD,0CAAa,GAAb,UACE,WAAqB,EACrB,SAAiB,EACjB,UAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;IACH,yBAAC;AAAD,CAAC,AA3ED,CAAyD,WAAW,GA2EnE"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay-item.d.ts b/lib/modules/overlays/src/html-overlay-item.d.ts new file mode 100644 index 000000000..bb673cac0 --- /dev/null +++ b/lib/modules/overlays/src/html-overlay-item.d.ts @@ -0,0 +1,13 @@ +import * as React from 'react'; +declare type Props = { + x?: number; + y?: number; + coordinates: number[]; + children: any; + style?: Record; +}; +export default class HtmlOverlayItem extends React.Component { + render(): JSX.Element; +} +export {}; +//# sourceMappingURL=html-overlay-item.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay-item.d.ts.map b/lib/modules/overlays/src/html-overlay-item.d.ts.map new file mode 100644 index 000000000..81460067d --- /dev/null +++ b/lib/modules/overlays/src/html-overlay-item.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"html-overlay-item.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/src/html-overlay-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,aAAK,KAAK,GAAG;IAEX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IAGX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;IACjE,MAAM;CAUP"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay-item.js b/lib/modules/overlays/src/html-overlay-item.js new file mode 100644 index 000000000..2c94b34b3 --- /dev/null +++ b/lib/modules/overlays/src/html-overlay-item.js @@ -0,0 +1,23 @@ +import { __assign, __extends, __rest } from "tslib"; +import * as React from 'react'; +var styles = { + item: { + position: 'absolute', + userSelect: 'none', + }, +}; +var HtmlOverlayItem = /** @class */ (function (_super) { + __extends(HtmlOverlayItem, _super); + function HtmlOverlayItem() { + return _super !== null && _super.apply(this, arguments) || this; + } + HtmlOverlayItem.prototype.render = function () { + var _a = this.props, x = _a.x, y = _a.y, children = _a.children, style = _a.style, props = __rest(_a, ["x", "y", "children", "style"]); + return ( + //@ts-ignore + React.createElement("div", __assign({ style: __assign(__assign(__assign({}, styles.item), style), { left: x, top: y }) }, props), children)); + }; + return HtmlOverlayItem; +}(React.Component)); +export default HtmlOverlayItem; +//# sourceMappingURL=html-overlay-item.js.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay-item.js.map b/lib/modules/overlays/src/html-overlay-item.js.map new file mode 100644 index 000000000..ef5caa13f --- /dev/null +++ b/lib/modules/overlays/src/html-overlay-item.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html-overlay-item.js","sourceRoot":"","sources":["../../../../modules/overlays/src/html-overlay-item.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,IAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,QAAQ,EAAE,UAAU;QACpB,UAAU,EAAE,MAAM;KACnB;CACF,CAAC;AAaF;IAA6C,mCAAsB;IAAnE;;IAWA,CAAC;IAVC,gCAAM,GAAN;QACE,IAAM,eAAgD,EAA9C,QAAC,EAAE,QAAC,EAAE,sBAAQ,EAAE,gBAAK,EAAE,mDAAuB,CAAC;QAEvD,OAAO;QACL,YAAY;QACZ,sCAAK,KAAK,iCAAO,MAAM,CAAC,IAAI,GAAK,KAAK,KAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,OAAQ,KAAK,GACjE,QAAQ,CACL,CACP,CAAC;IACJ,CAAC;IACH,sBAAC;AAAD,CAAC,AAXD,CAA6C,KAAK,CAAC,SAAS,GAW3D"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay.js b/lib/modules/overlays/src/html-overlay.js new file mode 100644 index 000000000..71cfec4da --- /dev/null +++ b/lib/modules/overlays/src/html-overlay.js @@ -0,0 +1,71 @@ +import { __extends, __read } from "tslib"; +import * as React from 'react'; +var styles = { + mainContainer: { + width: '100%', + height: '100%', + position: 'absolute', + pointerEvents: 'none', + }, +}; +var HtmlOverlay = /** @class */ (function (_super) { + __extends(HtmlOverlay, _super); + function HtmlOverlay() { + return _super !== null && _super.apply(this, arguments) || this; + } + // Override this to provide your items + HtmlOverlay.prototype.getItems = function () { + var children = this.props.children; + if (children) { + return Array.isArray(children) ? children : [children]; + } + return []; + }; + HtmlOverlay.prototype.getCoords = function (coordinates) { + var pos = this.props.viewport.project(coordinates); + if (!pos) + return [-1, -1]; + return pos; + }; + HtmlOverlay.prototype.inView = function (_a) { + var _b = __read(_a, 2), x = _b[0], y = _b[1]; + var _c = this.props.viewport, width = _c.width, height = _c.height; + return !(x < 0 || y < 0 || x > width || y > height); + }; + HtmlOverlay.prototype.scaleWithZoom = function (n) { + var zoom = this.props.viewport.zoom; + return n / Math.pow(2, 20 - zoom); + }; + HtmlOverlay.prototype.breakpointWithZoom = function (threshold, a, b) { + var zoom = this.props.viewport.zoom; + return zoom > threshold ? a : b; + }; + HtmlOverlay.prototype.getViewport = function () { + return this.props.viewport; + }; + HtmlOverlay.prototype.getZoom = function () { + return this.props.viewport.zoom; + }; + HtmlOverlay.prototype.render = function () { + var _this = this; + var _a = this.props.zIndex, zIndex = _a === void 0 ? 1 : _a; + var style = Object.assign({ zIndex: zIndex }, styles.mainContainer); + var renderItems = []; + this.getItems() + .filter(Boolean) + .forEach(function (item, index) { + var _a = __read(_this.getCoords(item.props.coordinates), 2), x = _a[0], y = _a[1]; + if (_this.inView([x, y])) { + var key = item.key === null || item.key === undefined ? index : item.key; + renderItems.push(React.cloneElement(item, { x: x, y: y, key: key })); + } + }); + return React.createElement("div", { style: style }, renderItems); + }; + return HtmlOverlay; +}(Component)); +export default HtmlOverlay; +// This is needed for Deck.gl 8.0+ +//@ts-ignore +HtmlOverlay.deckGLViewProps = true; +//# sourceMappingURL=html-overlay.js.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-overlay.js.map b/lib/modules/overlays/src/html-overlay.js.map new file mode 100644 index 000000000..6c6ab1bee --- /dev/null +++ b/lib/modules/overlays/src/html-overlay.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html-overlay.js","sourceRoot":"","sources":["../../../../modules/overlays/src/html-overlay.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,IAAM,MAAM,GAAG;IACb,aAAa,EAAE;QACb,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,MAAM;KACtB;CACF,CAAC;AAGF;IAAyC,+BAOxC;IAPD;;IA+DA,CAAC;IAvDC,sCAAs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I,CAAC;IAClC,CAAC;IAED,4BAAM,GAAN;QAAA,iBAgBC;QAfS,IAAA,sBAAU,EAAV,+BAAU,CAAgB;QAClC,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,QAAA,EAAS,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QAErE,IAAM,WAAW,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,EAAE;aACZ,MAAM,CAAC,OAAO,CAAC;aACf,OAAO,CAAC,UAAC,IAAI,EAAE,KAAK;YACb,IAAA,uDAA+C,EAA9C,SAAC,EAAE,SAA2C,CAAC;YACtD,IAAI,KAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;gBACvB,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC3E,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,GAAG,KAAA,EAAE,CAAC,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;QAEL,OAAO,6BAAK,KAAK,EAAE,KAAK,IAAG,WAAW,CAAO,CAAC;IAChD,CAAC;IACH,kBAAC;AAAD,CAAC,AA/DD,CAAyC,SAAS,GA+DjD;;AAED,kCAAkC;AAClC,YAAY;AACZ,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-tooltip-overlay.d.ts b/lib/modules/overlays/src/html-tooltip-overlay.d.ts new file mode 100644 index 000000000..e39a11a2e --- /dev/null +++ b/lib/modules/overlays/src/html-tooltip-overlay.d.ts @@ -0,0 +1,16 @@ +import HtmlOverlay from './html-overlay'; +declare type State = { + visible: boolean; + pickingInfo: Record | null | undefined; +}; +export default class HtmlTooltipOverlay extends HtmlOverlay { + constructor(props: any); + componentWillMount(): void; + timeoutID: number | null | undefined; + state: State; + _getTooltip(pickingInfo: Record): string; + _makeOverlay(): JSX.Element; + getItems(): Array | null | undefined>; +} +export {}; +//# sourceMappingURL=html-tooltip-overlay.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-tooltip-overlay.d.ts.map b/lib/modules/overlays/src/html-tooltip-overlay.d.ts.map new file mode 100644 index 000000000..fc6021671 --- /dev/null +++ b/lib/modules/overlays/src/html-tooltip-overlay.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"html-tooltip-overlay.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/src/html-tooltip-overlay.tsx"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAGzC,aAAK,KAAK,GAAG;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CACrD,CAAC;AAcF,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,WAAW;gBAC7C,KAAK,EAAE,GAAG;IAKtB,kBAAkB;IAiBlB,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAQ;IAC5C,KAAK,EAAE,KAAK,CAAC;IAEb,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAIrD,YAAY;IAcZ,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAO1D"} \ No newline at end of file diff --git a/lib/modules/overlays/src/html-tooltip-overlay.js b/lib/modules/overlays/src/html-tooltip-overlay.js new file mode 100644 index 000000000..e0ecf497a --- /dev/null +++ b/lib/modules/overlays/src/html-tooltip-overlay.js @@ -0,0 +1,60 @@ +import { __extends } from "tslib"; +import * as React from 'react'; +import HtmlOverlay from './html-overlay'; +import HtmlOverlayItem from './html-overlay-item'; +var styles = { + tooltip: { + transform: 'translate(-50%,-100%)', + backgroundColor: 'rgba(0, 0, 0, 0.3)', + padding: '4px 8px', + borderRadius: 8, + color: 'white', + }, +}; +var SHOW_TOOLTIP_TIMEOUT = 250; +var HtmlTooltipOverlay = /** @class */ (function (_super) { + __extends(HtmlTooltipOverlay, _super); + function HtmlTooltipOverlay(props) { + var _this = _super.call(this, props) || this; + _this.timeoutID = null; + _this.state = { visible: false, pickingInfo: null }; + return _this; + } + HtmlTooltipOverlay.prototype.componentWillMount = function () { + var _this = this; + this.context.nebula.queryObjectEvents.on('pick', function (_a) { + var event = _a.event, pickingInfo = _a.pickingInfo; + if (_this.timeoutID !== null) { + window.clearTimeout(_this.timeoutID); + } + _this.timeoutID = null; + if (pickingInfo && _this._getTooltip(pickingInfo)) { + _this.timeoutID = window.setTimeout(function () { + _this.setState({ visible: true, pickingInfo: pickingInfo }); + }, SHOW_TOOLTIP_TIMEOUT); + } + else { + _this.setState({ visible: false }); + } + }); + }; + HtmlTooltipOverlay.prototype._getTooltip = function (pickingInfo) { + return pickingInfo.object.style.tooltip; + }; + HtmlTooltipOverlay.prototype._makeOverlay = function () { + var pickingInfo = this.state.pickingInfo; + if (pickingInfo) { + return (React.createElement(HtmlOverlayItem, { key: 0, coordinates: pickingInfo.lngLat, style: styles.tooltip }, this._getTooltip(pickingInfo))); + } + return null; + }; + HtmlTooltipOverlay.prototype.getItems = function () { + if (this.state.visible) { + return [this._makeOverlay()]; + } + return []; + }; + return HtmlTooltipOverlay; +}(HtmlOverlay)); +export default HtmlTooltipOverlay; +//# sourceMappingURL=html-tooltip-overlay.js.map \ No newline at end of file diff --git a/lib/modules/overlays/src/html-tooltip-overlay.js.map b/lib/modules/overlays/src/html-tooltip-overlay.js.map new file mode 100644 index 000000000..ee1fa2a12 --- /dev/null +++ b/lib/modules/overlays/src/html-tooltip-overlay.js.map @@ -0,0 +1 @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gBACL,KAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;aACnC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAKD,wCAAW,GAAX,UAAY,WAAgC;QAC1C,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,yCAAY,GAAZ;QACU,IAAA,oCAAW,CAAgB;QAEnC,IAAI,WAAW,EAAE;YACf,OAAO,CACL,oBAAC,eAAe,IAAC,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,IAC5E,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CACd,CACnB,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qCAAQ,GAAR;QACE,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;SAC9B;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,yBAAC;AAAD,CAAC,AAnDD,CAAgD,WAAW,GAmD1D"} \ No newline at end of file diff --git a/lib/modules/overlays/src/index.d.ts b/lib/modules/overlays/src/index.d.ts new file mode 100644 index 000000000..510e55efe --- /dev/null +++ b/lib/modules/overlays/src/index.d.ts @@ -0,0 +1,5 @@ +export { default as HtmlOverlay } from './html-overlay'; +export { default as HtmlOverlayItem } from './html-overlay-item'; +export { default as HtmlClusterOverlay } from './html-cluster-overlay'; +export { default as HtmlTooltipOverlay } from './html-tooltip-overlay'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/src/index.d.ts.map b/lib/modules/overlays/src/index.d.ts.map new file mode 100644 index 000000000..042169bff --- /dev/null +++ b/lib/modules/overlays/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"} \ No newline at end of file diff --git a/lib/modules/overlays/src/index.js b/lib/modules/overlays/src/index.js new file mode 100644 index 000000000..27088def1 --- /dev/null +++ b/lib/modules/overlays/src/index.js @@ -0,0 +1,7 @@ +// Core +export { default as HtmlOverlay } from './html-overlay'; +export { default as HtmlOverlayItem } from './html-overlay-item'; +export { default as HtmlClusterOverlay } from './html-cluster-overlay'; +// Helper +export { default as HtmlTooltipOverlay } from './html-tooltip-overlay'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/overlays/src/index.js.map b/lib/modules/overlays/src/index.js.map new file mode 100644 index 000000000..b080f75e8 --- /dev/null +++ b/lib/modules/overlays/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/overlays/src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,SAAS;AACT,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"} \ No newline at end of file diff --git a/lib/modules/overlays/test/html-overlay.test.d.ts b/lib/modules/overlays/test/html-overlay.test.d.ts new file mode 100644 index 000000000..10d9381ed --- /dev/null +++ b/lib/modules/overlays/test/html-overlay.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=html-overlay.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/test/html-overlay.test.d.ts.map b/lib/modules/overlays/test/html-overlay.test.d.ts.map new file mode 100644 index 000000000..1c96f1ebb --- /dev/null +++ b/lib/modules/overlays/test/html-overlay.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"html-overlay.test.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/test/html-overlay.test.tsx"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/overlays/test/html-overlay.test.js b/lib/modules/overlays/test/html-overlay.test.js new file mode 100644 index 000000000..8f0c82729 --- /dev/null +++ b/lib/modules/overlays/test/html-overlay.test.js @@ -0,0 +1,45 @@ +import React from 'react'; +import Renderer from 'react-test-renderer'; +import DeckGL from '@deck.gl/react'; +import HtmlOverlay from '../src/html-overlay'; +import HtmlOverlayItem from '../src/html-overlay-item'; +var initialViewState = { + longitude: 0, + latitude: 0, + zoom: 10, + pitch: 0, + bearing: 0, +}; +it('test HtmlOverlay map center', function () { + var Component = ( + // @ts-ignore + React.createElement(DeckGL, { initialViewState: initialViewState }, + React.createElement(HtmlOverlay, null, + React.createElement(HtmlOverlayItem, { coordinates: [0, 0, 0] }, "Map Center Zero Elevation"), + React.createElement(HtmlOverlayItem, { coordinates: [0, 0, 50000] }, "Map Center 50km Elevation")))); + var renderer = Renderer.create(Component); + expect(renderer.toJSON()).toMatchSnapshot(); +}); +it('HtmlOverlay is able to handle a single null child', function () { + var layer = new HtmlOverlay({ + viewport: { project: function (coords) { return coords; } }, + }); + expect(layer.render()).toMatchSnapshot(); +}); +it('HtmlOverlay is able to handle a null child with other valid children', function () { + var children = [ + React.createElement(HtmlOverlayItem, { key: 1, coordinates: [0, 0, 0] }, "Map Center Zero Elevation"), + React.createElement(HtmlOverlayItem, { key: 2, coordinates: [0, 0, 50000] }, "Map Center 50km Elevation"), + null, + ]; + var layer = new HtmlOverlay({ + children: children, + viewport: { project: function (coords) { return coords; } }, + }); + expect(layer.render()).toMatchSnapshot(); +}); +it('HtmlOverlay is able to handle no children', function () { + var layer = new HtmlOverlay({ viewport: { project: function (coords) { return coords; } } }); + expect(layer.render()).toMatchSnapshot(); +}); +//# sourceMappingURL=html-overlay.test.js.map \ No newline at end of file diff --git a/lib/modules/overlays/test/html-overlay.test.js.map b/lib/modules/overlays/test/html-overlay.test.js.map new file mode 100644 index 000000000..01c2cf179 --- /dev/null +++ b/lib/modules/overlays/test/html-overlay.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html-overlay.test.js","sourceRoot":"","sources":["../../../../modules/overlays/test/html-overlay.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,eAAe,MAAM,0BAA0B,CAAC;AAEvD,IAAM,gBAAgB,GAAG;IACvB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,EAAE,CAAC,6BAA6B,EAAE;IAChC,IAAM,SAAS,GAAG;IAChB,aAAa;IACb,oBAAC,MAAM,IAAC,gBAAgB,EAAE,gBAAgB;QACxC,oBAAC,WAAW;YACV,oBAAC,eAAe,IAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,gCAA6C;YACpF,oBAAC,eAAe,IAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,gCAA6C,CAC5E,CACP,CACV,CAAC;IACF,IAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;AAC9C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new file mode 100644 index 000000000..2cef0e624 --- /dev/null +++ b/lib/modules/overlays/test/html-tooltip-overlay.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=html-tooltip-overlay.test.d.ts.map \ No newline at end of file diff --git a/lib/modules/overlays/test/html-tooltip-overlay.test.d.ts.map b/lib/modules/overlays/test/html-tooltip-overlay.test.d.ts.map new file mode 100644 index 000000000..bcb52028a --- /dev/null +++ b/lib/modules/overlays/test/html-tooltip-overlay.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"html-tooltip-overlay.test.d.ts","sourceRoot":"","sources":["../../../../modules/overlays/test/html-tooltip-overlay.test.tsx"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/overlays/test/html-tooltip-overlay.test.js b/lib/modules/overlays/test/html-tooltip-overlay.test.js new file mode 100644 index 000000000..86b63710b --- /dev/null +++ b/lib/modules/overlays/test/html-tooltip-overlay.test.js @@ -0,0 +1,13 @@ +import React from 'react'; +import Renderer from 'react-test-renderer'; +import DeckGL from '@deck.gl/react'; +import HtmlTooltipOverlay from '../src/html-tooltip-overlay'; +it('test HtmlTooltipOverlay no items shown', function () { + var Component = ( + // @ts-ignore + React.createElement(DeckGL, null, + React.createElement(HtmlTooltipOverlay, null))); + var renderer = Renderer.create(Component); + expect(renderer.toJSON()).toMatchSnapshot(); +}); +//# sourceMappingURL=html-tooltip-overlay.test.js.map \ No newline at end of file diff --git a/lib/modules/overlays/test/html-tooltip-overlay.test.js.map b/lib/modules/overlays/test/html-tooltip-overlay.test.js.map new file mode 100644 index 000000000..2da9eb93b --- /dev/null +++ b/lib/modules/overlays/test/html-tooltip-overlay.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"html-tooltip-overlay.test.js","sourceRoot":"","sources":["../../../../modules/overlays/test/html-tooltip-overlay.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAE7D,EAAE,CAAC,wCAAwC,EAAE;IAC3C,IAAM,SAAS,GAAG;IAChB,aAAa;IACb,oBAAC,MAAM;QACL,oBAAC,kBAAkB,OAAG,CACf,CACV,CAAC;IACF,IAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;AAC9C,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/constants.d.ts b/lib/modules/react-map-gl-draw/src/constants.d.ts new file mode 100644 index 000000000..2c673153d --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/constants.d.ts @@ -0,0 +1,44 @@ +export declare enum GEOJSON_TYPE { + POINT = "Point", + LINE_STRING = "LineString", + POLYGON = "Polygon" +} +export declare enum SHAPE { + POINT = "Point", + LINE_STRING = "LineString", + POLYGON = "Polygon", + RECTANGLE = "Rectangle", + CIRCLE = "Circle" +} +export declare enum RENDER_TYPE { + POINT = "Point", + LINE_STRING = "LineString", + POLYGON = "Polygon", + RECTANGLE = "Rectangle" +} +export declare enum RENDER_STATE { + INACTIVE = "INACTIVE", + UNCOMMITTED = "UNCOMMITTED", + SELECTED = "SELECTED", + HOVERED = "HOVERED", + CLOSING = "CLOSING" +} +export declare enum GUIDE_TYPE { + TENTATIVE = "tentative", + EDIT_HANDLE = "editHandle", + CURSOR_EDIT_HANDLE = "cursorEditHandle" +} +export declare enum ELEMENT_TYPE { + FEATURE = "feature", + FILL = "fill", + SEGMENT = "segment", + EDIT_HANDLE = "editHandle" +} +export declare enum EDIT_TYPE { + ADD_FEATURE = "addFeature", + ADD_POSITION = "addPosition", + REMOVE_POSITION = "removePosition", + MOVE_POSITION = "movePosition", + FINISH_MOVE_POSITION = "finishMovePosition" +} +//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/constants.d.ts.map b/lib/modules/react-map-gl-draw/src/constants.d.ts.map new file mode 100644 index 000000000..012cbc2fc --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,WAAW,eAAe;IAC1B,OAAO,YAAY;CACpB;AAED,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,WAAW,eAAe;IAC1B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,WAAW,eAAe;IAC1B,OAAO,YAAY;IACnB,SAAS,cAAc;CACxB;AAED,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,WAAW,eAAe;IAC1B,kBAAkB,qBAAqB;CACxC;AAED,oBAAY,YAAY;IACtB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,WAAW,eAAe;CAC3B;AAED,oBAAY,SAAS;IACnB,WAAW,eAAe;IAC1B,YAAY,gBAAgB;IAC5B,eAAe,mBAAmB;IAClC,aAAa,iBAAiB;IAC9B,oBAAoB,uBAAuB;CAC5C"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/constants.js b/lib/modules/react-map-gl-draw/src/constants.js new file mode 100644 index 000000000..bdf12f499 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/constants.js @@ -0,0 +1,51 @@ +export var GEOJSON_TYPE; +(function (GEOJSON_TYPE) { + GEOJSON_TYPE["POINT"] = "Point"; + GEOJSON_TYPE["LINE_STRING"] = "LineString"; + GEOJSON_TYPE["POLYGON"] = "Polygon"; +})(GEOJSON_TYPE || (GEOJSON_TYPE = {})); +export var SHAPE; +(function (SHAPE) { + SHAPE["POINT"] = "Point"; + SHAPE["LINE_STRING"] = "LineString"; + SHAPE["POLYGON"] = "Polygon"; + SHAPE["RECTANGLE"] = "Rectangle"; + SHAPE["CIRCLE"] = "Circle"; +})(SHAPE || (SHAPE = {})); +export var RENDER_TYPE; +(function (RENDER_TYPE) { + RENDER_TYPE["POINT"] = "Point"; + RENDER_TYPE["LINE_STRING"] = "LineString"; + RENDER_TYPE["POLYGON"] = "Polygon"; + RENDER_TYPE["RECTANGLE"] = "Rectangle"; +})(RENDER_TYPE || (RENDER_TYPE = {})); +export var RENDER_STATE; +(function (RENDER_STATE) { + RENDER_STATE["INACTIVE"] = "INACTIVE"; + RENDER_STATE["UNCOMMITTED"] = "UNCOMMITTED"; + RENDER_STATE["SELECTED"] = "SELECTED"; + RENDER_STATE["HOVERED"] = "HOVERED"; + RENDER_STATE["CLOSING"] = "CLOSING"; +})(RENDER_STATE || (RENDER_STATE = {})); +export var GUIDE_TYPE; +(function (GUIDE_TYPE) { + GUIDE_TYPE["TENTATIVE"] = "tentative"; + GUIDE_TYPE["EDIT_HANDLE"] = "editHandle"; + GUIDE_TYPE["CURSOR_EDIT_HANDLE"] = "cursorEditHandle"; +})(GUIDE_TYPE || (GUIDE_TYPE = {})); +export var ELEMENT_TYPE; +(function (ELEMENT_TYPE) { + ELEMENT_TYPE["FEATURE"] = "feature"; + ELEMENT_TYPE["FILL"] = "fill"; + ELEMENT_TYPE["SEGMENT"] = "segment"; + ELEMENT_TYPE["EDIT_HANDLE"] = "editHandle"; +})(ELEMENT_TYPE || (ELEMENT_TYPE = {})); +export var EDIT_TYPE; +(function (EDIT_TYPE) { + EDIT_TYPE["ADD_FEATURE"] = "addFeature"; + EDIT_TYPE["ADD_POSITION"] = "addPosition"; + EDIT_TYPE["REMOVE_POSITION"] = "removePosition"; + EDIT_TYPE["MOVE_POSITION"] = "movePosition"; + EDIT_TYPE["FINISH_MOVE_POSITION"] = "finishMovePosition"; +})(EDIT_TYPE || (EDIT_TYPE = {})); +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/constants.js.map b/lib/modules/react-map-gl-draw/src/constants.js.map new file mode 100644 index 000000000..c923d4bb3 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,0CAA0B,CAAA;IAC1B,mCAAmB,CAAA;AACrB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,MAAM,CAAN,IAAY,KAMX;AAND,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,mCAA0B,CAAA;IAC1B,4BAAmB,CAAA;IACnB,gCAAuB,CAAA;IACvB,0BAAiB,CAAA;AACnB,CAAC,EANW,KAAK,KAAL,KAAK,QAMhB;AAED,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,yCAA0B,CAAA;IAC1B,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;AACzB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,2CAA2B,CAAA;IAC3B,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACrB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAED,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,wCAA0B,CAAA;IAC1B,qDAAuC,CAAA;AACzC,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAED,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,0CAA0B,CAAA;AAC5B,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,uCAA0B,CAAA;IAC1B,yCAA4B,CAAA;IAC5B,+CAAkC,CAAA;IAClC,2CAA8B,CAAA;IAC9B,wDAA2C,CAAA;AAC7C,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts new file mode 100644 index 000000000..a1c1474a6 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts @@ -0,0 +1,22 @@ +import { EditMode, GuideFeatureCollection, Feature, ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent, FeatureCollection, Tooltip, DraggingEvent } from '@nebula.gl/edit-modes'; +import { ModeProps } from '../types'; +export default class BaseMode implements EditMode { + _tentativeFeature: Feature | null | undefined; + _editHandles: Feature[] | null | undefined; + constructor(); + handlePan(event: ClickEvent, props: ModeProps): void; + handleClick(event: ClickEvent, props: ModeProps): void; + handleDblClick(event: ClickEvent, props: ModeProps): void; + handlePointerMove(event: PointerMoveEvent, props: ModeProps): void; + handleStartDragging(event: StartDraggingEvent, props: ModeProps): void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + getGuides(props: ModeProps): GuideFeatureCollection | null | undefined; + getTooltips(props: ModeProps): Tooltip[]; + handleDragging(event: DraggingEvent, props: ModeProps): void; + getTentativeFeature: () => Feature; + getEditHandles: () => Feature[]; + setTentativeFeature: (feature: Feature) => void; + getEditHandlesFromFeature(feature: Feature, featureIndex: number | null | undefined): any; + getSelectedFeature: (props: ModeProps, featureIndex: number) => Feature; +} +//# sourceMappingURL=base-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts.map b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts.map new file mode 100644 index 000000000..3306fb60e --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"base-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/base-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,aAAa,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAC1F,iBAAiB,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;;IAO3C,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAEhE,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAElE,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAErE,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAE9E,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAElF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAEhF,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,sBAAsB,GAAG,IAAI,GAAG,SAAS;IAGzF,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO,EAAE;IAG3D,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAE/E,mBAAmB,gBAEjB;IAEF,cAAc,kBAEZ;IAEF,mBAAmB,6BAEjB;IAEF,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAyBnF,kBAAkB,yEAahB;CACH"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js new file mode 100644 index 000000000..531c36a06 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js @@ -0,0 +1,67 @@ +import { GEOJSON_TYPE, GUIDE_TYPE } from '../constants'; +import { getFeatureCoordinates, isNumeric } from './utils'; +var BaseMode = /** @class */ (function () { + function BaseMode() { + var _this = this; + this.getTentativeFeature = function () { + return _this._tentativeFeature; + }; + this.getEditHandles = function () { + return _this._editHandles; + }; + this.setTentativeFeature = function (feature) { + _this._tentativeFeature = feature; + }; + this.getSelectedFeature = function (props, featureIndex) { + var data = props.data, selectedIndexes = props.selectedIndexes; + // @ts-ignore + var features = data && data.features; + var selectedIndex = isNumeric(featureIndex) + ? Number(featureIndex) + : selectedIndexes && selectedIndexes[0]; + return features && features[selectedIndex]; + }; + this._tentativeFeature = null; + this._editHandles = null; + } + BaseMode.prototype.handlePan = function (event, props) { }; + BaseMode.prototype.handleClick = function (event, props) { }; + BaseMode.prototype.handleDblClick = function (event, props) { }; + BaseMode.prototype.handlePointerMove = function (event, props) { }; + BaseMode.prototype.handleStartDragging = function (event, props) { }; + BaseMode.prototype.handleStopDragging = function (event, props) { }; + BaseMode.prototype.getGuides = function (props) { + return null; + }; + BaseMode.prototype.getTooltips = function (props) { + return []; + }; + BaseMode.prototype.handleDragging = function (event, props) { }; + BaseMode.prototype.getEditHandlesFromFeature = function (feature, featureIndex) { + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return null; + } + // @ts-ignore + return coordinates.map(function (coord, i) { + return { + type: 'Feature', + properties: { + // TODO deprecate renderType + renderType: feature.properties.renderType, + guideType: GUIDE_TYPE.EDIT_HANDLE, + editHandleType: 'existing', + featureIndex: featureIndex, + positionIndexes: [i], + }, + geometry: { + type: GEOJSON_TYPE.POINT, + coordinates: coord, + }, + }; + }); + }; + return BaseMode; +}()); +export default BaseMode; +//# sourceMappingURL=base-mode.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js.map b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js.map new file mode 100644 index 000000000..df24f00f4 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/base-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base-mode.js","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/base-mode.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3D;IAIE;QAAA,iBAGC;QAsBD,wBAAmB,GAAG;YACpB,OAAO,KAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC,CAAC;QAEF,mBAAc,GAAG;YACf,OAAO,KAAI,CAAC,YAAY,CAAC;QAC3B,CAAC,CAAC;QAEF,wBAAmB,GAAG,UAAC,OAAgB;YACrC,KAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;QACnC,CAAC,CAAC;QA2BF,uBAAkB,GAAG,UACnB,KAAmC,EACnC,YAAuC;YAE/B,IAAA,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OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,4BAA4B;oBAC5B,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU;oBACzC,SAAS,EAAE,UAAU,CAAC,WAAW;oBACjC,cAAc,EAAE,UAAU;oBAC1B,YAAY,cAAA;oBACZ,eAAe,EAAE,CAAC,CAAC,CAAC;iBACrB;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY,CAAC,KAAK;oBACxB,WAAW,EAAE,KAAK;iBACnB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAgBH,eAAC;AAAD,CAAC,AAhFD,IAgFC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts new file mode 100644 index 000000000..3eb1d29de --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts @@ -0,0 +1,30 @@ +import type { Feature, FeatureCollection, StopDraggingEvent, PointerMoveEvent, Position } from '@nebula.gl/edit-modes'; +import { ModeProps } from '../types'; +import { GEOJSON_TYPE, GUIDE_TYPE } from '../constants'; +import BaseMode from './base-mode'; +export default class EditingMode extends BaseMode { + handleClick: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent, props: ModeProps) => void; + handleStopDragging(event: StopDraggingEvent, props: ModeProps): void; + _handleDragging: (event: PointerMoveEvent | StopDraggingEvent, props: ModeProps) => void; + handlePointerMove: (event: PointerMoveEvent, props: ModeProps) => void; + _updateFeature: (props: ModeProps, type: string, options?: any) => FeatureCollection; + _getPointOnSegment(feature: Feature, picked: any, pickedMapCoords: Position): number[]; + _getCursorEditHandle: (event: PointerMoveEvent, feature: Feature) => { + type: string; + properties: { + guideType: GUIDE_TYPE; + shape: any; + positionIndexes: number[]; + editHandleType: string; + }; + geometry: { + type: GEOJSON_TYPE; + coordinates: number[]; + }; + }; + getGuides: (props: ModeProps) => { + type: string; + features: any; + }; +} +//# sourceMappingURL=editing-mode.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts.map b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts.map new file mode 100644 index 000000000..a9b8a05f4 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"editing-mode.d.ts","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/editing-mode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EAEjB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAkC,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,QAAQ,MAAM,aAAa,CAAC;AAQnC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,QAAQ;IAC/C,WAAW,0HA+CT;IAEF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAqBhF,eAAe,6FA6Db;IAEF,iBAAiB,yEAaf;IAGF,cAAc,0FA2EZ;IAEF,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ;IAe3E,oBAAoB;;;;;;;;;;;;MAsClB;IAEF,SAAS;;;MAyBP;CACH"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js new file mode 100644 index 000000000..2367df4ed --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js @@ -0,0 +1,265 @@ +import { __extends, __read, __spread } from "tslib"; +import { ImmutableFeatureCollection } from '@nebula.gl/edit-modes'; +import { SHAPE, EDIT_TYPE, ELEMENT_TYPE, GEOJSON_TYPE, GUIDE_TYPE } from '../constants'; +import BaseMode from './base-mode'; +import { findClosestPointOnLineSegment, getFeatureCoordinates, isNumeric, updateRectanglePosition, } from './utils'; +var EditingMode = /** @class */ (function (_super) { + __extends(EditingMode, _super); + function EditingMode() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.handleClick = function (event, props) { + var picked = event.picks && event.picks[0]; + var selectedFeatureIndex = props.selectedIndexes && props.selectedIndexes[0]; + // @ts-ignore + if (!picked || !picked.object || picked.featureIndex !== selectedFeatureIndex) { + return; + } + // @ts-ignore + var objectType = picked.type, featureIndex = picked.featureIndex, index = picked.index; + var feature = _this.getSelectedFeature(props, featureIndex); + if (feature && + (feature.geometry.type === GEOJSON_TYPE.POLYGON || + feature.geometry.type === GEOJSON_TYPE.LINE_STRING) && + objectType === ELEMENT_TYPE.SEGMENT) { + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return; + } + // @ts-ignore + var insertIndex = (index + 1) % coordinates.length; + var positionIndexes = feature.geometry.type === SHAPE.POLYGON ? [0, insertIndex] : [insertIndex]; + var insertMapCoords = _this._getPointOnSegment(feature, picked, event.mapCoords); + var updatedData = new ImmutableFeatureCollection(props.data) + // @ts-ignore + .addPosition(featureIndex, positionIndexes, insertMapCoords) + .getObject(); + props.onEdit({ + editType: EDIT_TYPE.ADD_POSITION, + updatedData: updatedData, + editContext: [ + { + featureIndex: featureIndex, + editHandleIndex: insertIndex, + // @ts-ignore + screenCoords: props.viewport && props.viewport.project(insertMapCoords), + mapCoords: insertMapCoords, + }, + ], + }); + } + }; + _this._handleDragging = function (event, props) { + var onEdit = props.onEdit; + // @ts-ignore + var selectedFeature = _this.getSelectedFeature(props); + // nothing clicked + // @ts-ignore + var isDragging = event.isDragging, pointerDownPicks = event.pointerDownPicks, screenCoords = event.screenCoords; + var lastPointerMoveEvent = props.lastPointerMoveEvent; + var clicked = pointerDownPicks && pointerDownPicks[0]; + // @ts-ignore + if (!clicked.object || !isNumeric(clicked.featureIndex)) { + return; + } + // @ts-ignore + var objectType = clicked.type, editHandleIndex = clicked.index; + // not dragging + var updatedData = null; + var editType = isDragging ? EDIT_TYPE.MOVE_POSITION : EDIT_TYPE.FINISH_MOVE_POSITION; + switch (objectType) { + case ELEMENT_TYPE.FEATURE: + case ELEMENT_TYPE.FILL: + case ELEMENT_TYPE.SEGMENT: + if (!props.featuresDraggable) { + break; + } // dragging feature + var dx = screenCoords[0] - lastPointerMoveEvent.screenCoords[0]; + var dy = screenCoords[1] - lastPointerMoveEvent.screenCoords[1]; + updatedData = _this._updateFeature(props, 'feature', { dx: dx, dy: dy }); + onEdit({ + editType: editType, + updatedData: updatedData, + editContext: null, + }); + break; + case ELEMENT_TYPE.EDIT_HANDLE: + // dragging editHandle + // dragging rectangle or other shapes + var updateType = selectedFeature.properties.shape === SHAPE.RECTANGLE ? 'rectangle' : 'editHandle'; + updatedData = _this._updateFeature(props, updateType, { + editHandleIndex: editHandleIndex, + mapCoords: event.mapCoords, + }); + onEdit({ + editType: editType, + updatedData: updatedData, + editContext: null, + }); + break; + default: + } + }; + _this.handlePointerMove = function (event, props) { + // no selected feature + // @ts-ignore + var selectedFeature = _this.getSelectedFeature(props); + if (!selectedFeature) { + return; + } + // @ts-ignore + if (!event.isDragging) { + return; + } + _this._handleDragging(event, props); + }; + // TODO - refactor + _this._updateFeature = function (props, type, options) { + if (options === void 0) { options = {}; } + var data = props.data, selectedIndexes = props.selectedIndexes, viewport = props.viewport; + var featureIndex = selectedIndexes && selectedIndexes[0]; + var feature = _this.getSelectedFeature(props, featureIndex); + var geometry = null; + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return null; + } + var newCoordinates = __spread(coordinates); + switch (type) { + case 'editHandle': + var positionIndexes = feature.geometry.type === GEOJSON_TYPE.POLYGON + ? [0, options.editHandleIndex] + : [options.editHandleIndex]; + return new ImmutableFeatureCollection(data) + .replacePosition(featureIndex, positionIndexes, options.mapCoords) + .getObject(); + case 'feature': + var dx_1 = options.dx, dy_1 = options.dy; + // @ts-ignore + newCoordinates = newCoordinates + .map(function (mapCoords) { + // @ts-ignore + var pixels = viewport && viewport.project(mapCoords); + if (pixels) { + pixels[0] += dx_1; + pixels[1] += dy_1; + return viewport && viewport.unproject(pixels); + } + return null; + }) + .filter(Boolean); + geometry = { + type: feature.geometry.type, + coordinates: feature.geometry.type === GEOJSON_TYPE.POLYGON + ? [newCoordinates] + : feature.geometry.type === GEOJSON_TYPE.POINT + ? newCoordinates[0] + : newCoordinates, + }; + return new ImmutableFeatureCollection(data) + .replaceGeometry(featureIndex, geometry) + .getObject(); + case 'rectangle': + // moved editHandleIndex and destination mapCoords + newCoordinates = updateRectanglePosition( + // @ts-ignore + feature, options.editHandleIndex, options.mapCoords); + geometry = { + type: GEOJSON_TYPE.POLYGON, + coordinates: newCoordinates, + }; + return new ImmutableFeatureCollection(data) + .replaceGeometry(featureIndex, geometry) + .getObject(); + default: + return data && new ImmutableFeatureCollection(data).getObject(); + } + }; + _this._getCursorEditHandle = function (event, feature) { + // @ts-ignore + var isDragging = event.isDragging, picks = event.picks; + // if not pick segment + var picked = picks && picks[0]; + // @ts-ignore + if (!picked || !isNumeric(picked.featureIndex) || picked.type !== ELEMENT_TYPE.SEGMENT) { + return null; + } + // if dragging or feature is neither polygon nor line string + if (isDragging || + (feature.geometry.type !== GEOJSON_TYPE.POLYGON && + feature.geometry.type !== GEOJSON_TYPE.LINE_STRING)) { + return null; + } + var insertMapCoords = _this._getPointOnSegment(feature, picked, event.mapCoords); + if (!insertMapCoords) { + return null; + } + return { + type: 'Feature', + properties: { + guideType: GUIDE_TYPE.CURSOR_EDIT_HANDLE, + shape: feature.properties.shape, + positionIndexes: [-1], + editHandleType: 'intermediate', + }, + geometry: { + type: GEOJSON_TYPE.POINT, + coordinates: insertMapCoords, + }, + }; + }; + // @ts-ignore + _this.getGuides = function (props) { + // @ts-ignore + var selectedFeature = _this.getSelectedFeature(props); + var selectedFeatureIndex = props.selectedIndexes && props.selectedIndexes[0]; + if (!selectedFeature || selectedFeature.geometry.type === GEOJSON_TYPE.POINT) { + return null; + } + var event = props.lastPointerMoveEvent; + // feature editHandles + var editHandles = _this.getEditHandlesFromFeature(selectedFeature, selectedFeatureIndex) || []; + // cursor editHandle + var cursorEditHandle = _this._getCursorEditHandle(event, selectedFeature); + if (cursorEditHandle) { + // @ts-ignore + editHandles.push(cursorEditHandle); + } + return { + type: 'FeatureCollection', + features: editHandles.length ? editHandles : null, + }; + }; + return _this; + } + EditingMode.prototype.handleStopDragging = function (event, props) { + // replace point + var picked = event.picks && event.picks[0]; + // @ts-ignore + if (!picked || !picked.Object || !isNumeric(picked.featureIndex)) { + return; + } + var pickedObject = picked.object; + switch (pickedObject.type) { + case ELEMENT_TYPE.FEATURE: + case ELEMENT_TYPE.FILL: + case ELEMENT_TYPE.EDIT_HANDLE: + this._handleDragging(event, props); + break; + default: + } + }; + EditingMode.prototype._getPointOnSegment = function (feature, picked, pickedMapCoords) { + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return null; + } + var srcVertexIndex = picked.index; + var targetVertexIndex = picked.index + 1; + return findClosestPointOnLineSegment( + // @ts-ignore + coordinates[srcVertexIndex], coordinates[targetVertexIndex], pickedMapCoords); + }; + return EditingMode; +}(BaseMode)); +export default EditingMode; +//# sourceMappingURL=editing-mode.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js.map b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js.map new file mode 100644 index 000000000..6878e3907 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/editing-mode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editing-mode.js","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/editing-mode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAWnE,OAAO,EAAE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,MAAM,CAAC;QACnC,QAAQ,YAAY,CAAC,IAAI,EAAE;YACzB,KAAK,YAAY,CAAC,OAAO,CAAC;YAC1B,KAAK,YAAY,CAAC,IAAI,CAAC;YACvB,KAAK,YAAY,CAAC,WAAW;gBAC3B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAEnC,MAAM;YACR,QAAQ;SACT;IACH,CAAC;IA8JD,wCAAkB,GAAlB,UAAmB,OAAgB,EAAE,MAAW,EAAE,eAAyB;QACzE,IAAM,WAAW,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,IAAI,CAAC;SACb;QACD,IAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;QACpC,IAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QAC3C,OAAO,6BAA6B;QAClC,aAAa;QACb,WAAW,CAAC,cAAc,CAAC,EAC3B,WAAW,CAAC,iBAAiB,CAAC,EAC9B,eAAe,CAChB,CAAC;IACJ,CAAC;IAoEH,kBAAC;AAAD,CAAC,AApTD,CAAyC,QAAQ,GAoThD"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts b/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts new file mode 100644 index 000000000..068bf38c0 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts @@ -0,0 +1,2 @@ +export { default as EditingMode } from './editing-mode'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts.map b/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts.map new file mode 100644 index 000000000..edef89301 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/index.js b/lib/modules/react-map-gl-draw/src/edit-modes/index.js new file mode 100644 index 000000000..f61e1b251 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/index.js @@ -0,0 +1,2 @@ +export { default as EditingMode } from './editing-mode'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/index.js.map b/lib/modules/react-map-gl-draw/src/edit-modes/index.js.map new file mode 100644 index 000000000..dbb569a45 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts b/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts new file mode 100644 index 000000000..9b45c075a --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts @@ -0,0 +1,15 @@ +import { MjolnirEvent } from 'mjolnir.js'; +import type { FeatureOf, Feature, Polygon, Position } from '@nebula.gl/edit-modes'; +export declare function isNumeric(val: any): boolean; +export declare function parseEventElement(evt: MjolnirEvent, features: Feature[], guides: Feature[]): { + object: any; + isGuide: boolean; + type: any; + index: any; + featureIndex: any; +}; +export declare function getScreenCoords(evt: MjolnirEvent): number[]; +export declare function findClosestPointOnLineSegment(p1: Position, p2: Position, p: Position): number[]; +export declare function getFeatureCoordinates(feature: Feature): number | [number, number] | [number, number, number] | ([number, number] | [number, number, number] | import("@nebula.gl/edit-modes").PolygonCoordinates | import("@nebula.gl/edit-modes").LineStringCoordinates | import("@nebula.gl/edit-modes").MultiPointCoordinates | import("@nebula.gl/edit-modes").MultiLineStringCoordinates | import("@nebula.gl/edit-modes").MultiPolygonCoordinates)[]; +export declare function updateRectanglePosition(feature: FeatureOf, editHandleIndex: number, mapCoords: Position): any; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts.map b/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts.map new file mode 100644 index 000000000..3996ab0b7 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAInF,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,WAEjC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;;;;;;EA4C1F;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,YAAY,YAKhD;AAED,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,YAqBpF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,sYASrD;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,EAC3B,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,QAAQ,OAsBpB"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/utils.js b/lib/modules/react-map-gl-draw/src/edit-modes/utils.js new file mode 100644 index 000000000..0edf1c38d --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/utils.js @@ -0,0 +1,105 @@ +import { __read, __spread } from "tslib"; +import { GEOJSON_TYPE, ELEMENT_TYPE, GUIDE_TYPE } from '../constants'; +export function isNumeric(val) { + return !Array.isArray(val) && !isNaN(parseFloat(val)) && isFinite(val); +} +export function parseEventElement(evt, features, guides) { + var elem = evt.target; + if (!elem || !elem.dataset || !elem.dataset.type) { + return null; + } + var featureIndex = elem.dataset.featureIndex; + featureIndex = isNumeric(featureIndex) ? Number(featureIndex) : -1; + var index = elem.dataset.index; + index = isNumeric(index) ? Number(index) : undefined; + var type = elem.dataset.type; + var tentativeFeature = guides && guides.find(function (g) { return g.properties.guideType === GUIDE_TYPE.TENTATIVE; }); + var object = null; + var isGuide = false; + switch (type) { + case ELEMENT_TYPE.EDIT_HANDLE: + object = guides.find(function (g) { + var indexes = g.properties.positionIndexes; + if (indexes) { + return indexes[indexes.length - 1] === index; + } + return false; + }); + isGuide = true; + break; + case ELEMENT_TYPE.SEGMENT: + case ELEMENT_TYPE.FEATURE: + case ELEMENT_TYPE.FILL: + object = features[featureIndex] || tentativeFeature; + break; + default: + } + return { + object: object, + isGuide: isGuide, + type: type, + index: index, + featureIndex: featureIndex, + }; +} +export function getScreenCoords(evt) { + var _a = evt.offsetCenter, x = _a.x, y = _a.y; + return [Number(x), Number(y)]; +} +export function findClosestPointOnLineSegment(p1, p2, p) { + // line + var k = (p2[1] - p1[1]) / (p2[0] - p1[0]); + var b = p1[1] - k * p1[0]; + // vertical line + if (!isFinite(k)) { + var q = [p1[0], p[1]]; + // @ts-ignore + return inBounds(p1, p2, q) ? q : null; + } + // p is on line [p1, p2] + if (p[0] * k + b - p[1] === 0) { + return inBounds(p1, p2, p) ? p : null; + } + var qx = (k * p[1] + p[0] - k * b) / (k * k + 1); + var qy = k * qx + b; + return inBounds(p1, p2, [qx, qy]) ? [qx, qy] : null; +} +export function getFeatureCoordinates(feature) { + var coordinates = feature && feature.geometry && feature.geometry.coordinates; + if (!coordinates) { + return null; + } + var isPolygonal = feature.geometry.type === GEOJSON_TYPE.POLYGON; + var isSinglePoint = feature.geometry.type === GEOJSON_TYPE.POINT; + return isPolygonal ? coordinates[0] : isSinglePoint ? [coordinates] : coordinates; +} +export function updateRectanglePosition(feature, editHandleIndex, mapCoords) { + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return null; + } + // @ts-ignore + var points = coordinates.slice(0, 4); + points[editHandleIndex % 4] = mapCoords; + /* + * p0.x, p0.y (p0) ------ p2.x, p0.y (p1) + * | | + * | | + * p0.x, p2.y (p3) ----- p2.x, p2.y (p2) + */ + var p0 = points[(editHandleIndex + 2) % 4]; + var p2 = points[editHandleIndex % 4]; + points[(editHandleIndex + 1) % 4] = [p2[0], p0[1]]; + points[(editHandleIndex + 3) % 4] = [p0[0], p2[1]]; + return feature.geometry.type === GEOJSON_TYPE.POLYGON ? [__spread(points, [points[0]])] : points; +} +function inBounds(p1, p2, p) { + var bounds = [ + Math.min(p1[0], p2[0]), + Math.max(p1[0], p2[0]), + Math.min(p1[1], p2[1]), + Math.max(p1[1], p2[1]), + ]; + return p[0] >= bounds[0] && p[0] <= bounds[1] && p[1] >= bounds[2] && p[1] <= bounds[3]; +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/edit-modes/utils.js.map b/lib/modules/react-map-gl-draw/src/edit-modes/utils.js.map new file mode 100644 index 000000000..67537b154 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/edit-modes/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../modules/react-map-gl-draw/src/edit-modes/utils.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,UAAU,SAAS,CAAC,GAAQ;IAChC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IA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,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;KACvB,CAAC;IAEF,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/editor.d.ts b/lib/modules/react-map-gl-draw/src/editor.d.ts new file mode 100644 index 000000000..44df697a5 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/editor.d.ts @@ -0,0 +1,39 @@ +import * as React from 'react'; +import { Feature } from '@nebula.gl/edit-modes'; +import { GeoJsonType } from './types'; +import { RENDER_STATE } from './constants'; +import ModeHandler from './mode-handler'; +import { editHandleStyle as defaultEditHandleStyle, featureStyle as defaultFeatureStyle } from './style'; +export default class Editor extends ModeHandler { + static defaultProps: { + clickRadius: number; + featureShape: string; + editHandleShape: string; + editHandleStyle: typeof defaultEditHandleStyle; + featureStyle: typeof defaultFeatureStyle; + featuresDraggable: boolean; + selectable: boolean; + mode: any; + features: any; + onSelect: any; + onUpdate: any; + onUpdateCursor: () => void; + }; + _getPathInScreenCoords(coordinates: any, type: GeoJsonType): any; + _getEditHandleState: (editHandle: Feature, renderState: string) => string; + _getFeatureRenderState: (index: number, renderState: RENDER_STATE) => RENDER_STATE.INACTIVE | RENDER_STATE.INACTIVE | RENDER_STATE.UNCOMMITTED | RENDER_STATE; + _getStyleProp: (styleProp: any, params: any) => any; + _renderEditHandle: (editHandle: Feature, feature: Feature) => JSX.Element; + _renderSegment: (featureIndex: React.ReactText, index: number, coordinates: number[], style: Record) => JSX.Element; + _renderSegments: (featureIndex: React.ReactText, coordinates: number[], style: Record) => any[]; + _renderFill: (featureIndex: React.ReactText, coordinates: number[], style: Record) => JSX.Element; + _renderTentativeFeature: (feature: Feature, cursorEditHandle: Feature) => any[]; + _renderGuides: (guideFeatures: Feature[]) => JSX.Element; + _renderPoint: (feature: Feature, index: number, path: string) => JSX.Element; + _renderPath: (feature: Feature, index: number, path: string) => JSX.Element; + _renderPolygon: (feature: Feature, index: number, path: string) => JSX.Element; + _renderFeature: (feature: Feature, index: number) => JSX.Element; + _renderCanvas: () => JSX.Element; + _render: () => JSX.Element; +} +//# sourceMappingURL=editor.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/editor.d.ts.map b/lib/modules/react-map-gl-draw/src/editor.d.ts.map new file mode 100644 index 000000000..e8e9c4446 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/editor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAiD,MAAM,aAAa,CAAC;AAC1F,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EACL,eAAe,IAAI,sBAAsB,EACzC,YAAY,IAAI,mBAAmB,EACpC,MAAM,SAAS,CAAC;AAYjB,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IAC7C,MAAM,CAAC,YAAY;;;;;;;;;;;;;MAAgB;IAGnC,sBAAsB,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW;IAyB1D,mBAAmB,uDAiCjB;IAEF,sBAAsB,wIAgBpB;IAEF,aAAa,uCAEX;IAKF,iBAAiB,yDAkGf;IAEF,cAAc,mHAmCZ;IAEF,eAAe,8FAQb;IAEF,WAAW,oGAWT;IAEF,uBAAuB,yDA4FrB;IAEF,aAAa,4CA+BX;IAEF,YAAY,iEAyDV;IAEF,WAAW,iEAuCT;IAEF,cAAc,iEAmCZ;IAEF,cAAc,mDA+BZ;IAEF,aAAa,oBAaX;IAEF,OAAO,oBAoBL;CACH"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/editor.js b/lib/modules/react-map-gl-draw/src/editor.js new file mode 100644 index 000000000..1f5ae95fe --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/editor.js @@ -0,0 +1,342 @@ +import { __assign, __extends, __read, __rest, __spread } from "tslib"; +import * as React from 'react'; +import { RENDER_STATE, SHAPE, GEOJSON_TYPE, GUIDE_TYPE, ELEMENT_TYPE } from './constants'; +import ModeHandler from './mode-handler'; +import { getFeatureCoordinates } from './edit-modes/utils'; +import { editHandleStyle as defaultEditHandleStyle, featureStyle as defaultFeatureStyle, } from './style'; +var defaultProps = __assign(__assign({}, ModeHandler.defaultProps), { clickRadius: 0, featureShape: 'circle', editHandleShape: 'rect', editHandleStyle: defaultEditHandleStyle, featureStyle: defaultFeatureStyle, featuresDraggable: true }); +var Editor = /** @class */ (function (_super) { + __extends(Editor, _super); + function Editor() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._getEditHandleState = function (editHandle, renderState) { + var _a = _this.state, pointerDownPicks = _a.pointerDownPicks, hovered = _a.hovered; + if (renderState) { + return renderState; + } + var editHandleIndex = editHandle.properties.positionIndexes[0]; + var draggingEditHandleIndex = null; + var pickedObject = pointerDownPicks && pointerDownPicks[0] && pointerDownPicks[0].object; + if (pickedObject && pickedObject.guideType === GUIDE_TYPE.EDIT_HANDLE) { + draggingEditHandleIndex = pickedObject.index; + } + if (editHandleIndex === draggingEditHandleIndex) { + return RENDER_STATE.SELECTED; + } + // @ts-ignore + if (hovered && hovered.type === ELEMENT_TYPE.EDIT_HANDLE) { + if (hovered.index === editHandleIndex) { + return RENDER_STATE.HOVERED; + } + // cursor hovered on first vertex when drawing polygon + if (hovered.index === 0 && + editHandle.properties.guideType === GUIDE_TYPE.CURSOR_EDIT_HANDLE) { + return RENDER_STATE.CLOSING; + } + } + return RENDER_STATE.INACTIVE; + }; + _this._getFeatureRenderState = function (index, renderState) { + var hovered = _this.state.hovered; + var selectedFeatureIndex = _this._getSelectedFeatureIndex(); + if (renderState) { + return renderState; + } + if (index === selectedFeatureIndex) { + return RENDER_STATE.SELECTED; + } + // @ts-ignore + if (hovered && hovered.type === ELEMENT_TYPE.FEATURE && hovered.featureIndex === index) { + return RENDER_STATE.HOVERED; + } + return RENDER_STATE.INACTIVE; + }; + _this._getStyleProp = function (styleProp, params) { + return typeof styleProp === 'function' ? styleProp(params) : styleProp; + }; + /* RENDER */ + /* eslint-disable max-params */ + _this._renderEditHandle = function (editHandle, feature) { + /* eslint-enable max-params */ + var coordinates = getFeatureCoordinates(editHandle); + var p = _this.project(coordinates && coordinates[0]); + if (!p) { + return null; + } + var _a = editHandle.properties, featureIndex = _a.featureIndex, positionIndexes = _a.positionIndexes, editHandleType = _a.editHandleType; + var _b = _this.props, clickRadius = _b.clickRadius, editHandleShape = _b.editHandleShape, editHandleStyle = _b.editHandleStyle; + var index = positionIndexes.length > 1 ? positionIndexes[1] : positionIndexes[0]; + var shape = _this._getStyleProp(editHandleShape, { + feature: feature || editHandle, + index: index, + featureIndex: featureIndex, + // @ts-ignore + state: _this._getEditHandleState(editHandle), + }); + var style = _this._getStyleProp(editHandleStyle, { + feature: feature || editHandle, + index: index, + featureIndex: featureIndex, + shape: shape, + // @ts-ignore + state: _this._getEditHandleState(editHandle), + }); + // disable events for cursor editHandle + if (editHandle.properties.guideType === GUIDE_TYPE.CURSOR_EDIT_HANDLE) { + style = __assign(__assign({}, style), { + // disable pointer events for cursor + pointerEvents: 'none' }); + } + var elemKey = ELEMENT_TYPE.EDIT_HANDLE + "." + featureIndex + "." + index + "." + editHandleType; + // first is to make path easily interacted with + switch (shape) { + case 'circle': + return (React.createElement("g", { key: elemKey, transform: "translate(" + p[0] + ", " + p[1] + ")" }, + React.createElement("circle", { "data-type": ELEMENT_TYPE.EDIT_HANDLE, "data-index": index, "data-feature-index": featureIndex, key: elemKey + ".hidden", style: __assign(__assign({}, style), { stroke: 'none', fill: '#000', fillOpacity: 0 }), cx: 0, cy: 0, r: clickRadius }), + React.createElement("circle", { "data-type": ELEMENT_TYPE.EDIT_HANDLE, "data-index": index, "data-feature-index": featureIndex, key: elemKey, style: style, cx: 0, cy: 0 }))); + case 'rect': + return (React.createElement("g", { key: elemKey, transform: "translate(" + p[0] + ", " + p[1] + ")" }, + React.createElement("rect", { "data-type": ELEMENT_TYPE.EDIT_HANDLE, "data-index": index, "data-feature-index": featureIndex, key: elemKey + ".hidden", style: __assign(__assign({}, style), { height: clickRadius, width: clickRadius, fill: '#000', fillOpacity: 0 }), r: clickRadius }), + React.createElement("rect", { "data-type": ELEMENT_TYPE.EDIT_HANDLE, "data-index": index, "data-feature-index": featureIndex, key: "" + elemKey, style: style }))); + default: + return null; + } + }; + _this._renderSegment = function (featureIndex, index, coordinates, style) { + var path = _this._getPathInScreenCoords(coordinates, GEOJSON_TYPE.LINE_STRING); + var radius = style.radius, others = __rest(style, ["radius"]); + var clickRadius = _this.props.clickRadius; + var elemKey = ELEMENT_TYPE.SEGMENT + "." + featureIndex + "." + index; + return (React.createElement("g", { key: elemKey }, + React.createElement("path", { key: elemKey + ".hidden", "data-type": ELEMENT_TYPE.SEGMENT, "data-index": index, "data-feature-index": featureIndex, style: __assign(__assign({}, others), { strokeWidth: clickRadius || radius, opacity: 0 }), d: path }), + React.createElement("path", { key: elemKey, "data-type": ELEMENT_TYPE.SEGMENT, "data-index": index, "data-feature-index": featureIndex, style: others, d: path }))); + }; + _this._renderSegments = function (featureIndex, coordinates, style) { + var segments = []; + for (var i = 0; i < coordinates.length - 1; i++) { + segments.push(_this._renderSegment(featureIndex, i, [coordinates[i], coordinates[i + 1]], style)); + } + return segments; + }; + _this._renderFill = function (featureIndex, coordinates, style) { + var path = _this._getPathInScreenCoords(coordinates, GEOJSON_TYPE.POLYGON); + return (React.createElement("path", { key: ELEMENT_TYPE.FILL + "." + featureIndex, "data-type": ELEMENT_TYPE.FILL, "data-feature-index": featureIndex, style: __assign(__assign({}, style), { stroke: 'none' }), d: path })); + }; + _this._renderTentativeFeature = function (feature, cursorEditHandle) { + var featureStyle = _this.props.featureStyle; + var geojsonType = feature.geometry.type, shape = feature.properties.shape; + var coordinates = getFeatureCoordinates(feature); + // @ts-ignore + if (!coordinates || coordinates.length < 2) { + return null; + } + // >= 2 coordinates + var firstCoords = coordinates[0]; + // @ts-ignore + var lastCoords = coordinates[coordinates.length - 1]; + var uncommittedStyle = _this._getStyleProp(featureStyle, { + feature: feature, + index: null, + state: RENDER_STATE.UNCOMMITTED, + }); + var committedPath; + var uncommittedPath; + var closingPath; + // @ts-ignore + var fill = _this._renderFill('tentative', coordinates, uncommittedStyle); + var type = shape || geojsonType; + switch (type) { + case SHAPE.LINE_STRING: + case SHAPE.POLYGON: + var committedStyle = _this._getStyleProp(featureStyle, { + feature: feature, + state: RENDER_STATE.SELECTED, + }); + if (cursorEditHandle) { + // @ts-ignore + var cursorCoords = coordinates[coordinates.length - 2]; + committedPath = _this._renderSegments('tentative', + // @ts-ignore + coordinates.slice(0, coordinates.length - 1), committedStyle); + uncommittedPath = _this._renderSegment('tentative-uncommitted', + // @ts-ignore + coordinates.length - 2, + // @ts-ignore + [cursorCoords, lastCoords], uncommittedStyle); + } + else { + // @ts-ignore + committedPath = _this._renderSegments('tentative', coordinates, committedStyle); + } + if (shape === SHAPE.POLYGON) { + var closingStyle = _this._getStyleProp(featureStyle, { + feature: feature, + index: null, + state: RENDER_STATE.CLOSING, + }); + closingPath = _this._renderSegment('tentative-closing', + // @ts-ignore + coordinates.length - 1, + // @ts-ignore + [lastCoords, firstCoords], closingStyle); + } + break; + case SHAPE.RECTANGLE: + uncommittedPath = _this._renderSegments('tentative', __spread(coordinates, [firstCoords]), uncommittedStyle); + break; + default: + } + return [fill, committedPath, uncommittedPath, closingPath].filter(Boolean); + }; + _this._renderGuides = function (guideFeatures) { + var features = _this.getFeatures(); + var cursorEditHandle = guideFeatures && + guideFeatures.find(function (f) { return f.properties.guideType === GUIDE_TYPE.CURSOR_EDIT_HANDLE; }); + var tentativeFeature = features.find(function (f) { return f.properties.guideType === GUIDE_TYPE.TENTATIVE; }); + return (React.createElement("g", { key: "feature-guides" }, guideFeatures.map(function (guide) { + var guideType = guide.properties.guideType; + switch (guideType) { + case GUIDE_TYPE.TENTATIVE: + return _this._renderTentativeFeature(guide, cursorEditHandle); + case GUIDE_TYPE.EDIT_HANDLE: + case GUIDE_TYPE.CURSOR_EDIT_HANDLE: + var shape = guide.properties.shape || guide.geometry.type; + // TODO this should be removed when fix editing mode + // don't render cursor for rectangle + if (shape === SHAPE.RECTANGLE && guide.properties.editHandleType === 'intermediate') { + return null; + } + var feature = (features && features[guide.properties.featureIndex]) || tentativeFeature; + return _this._renderEditHandle(guide, feature); + default: + return null; + } + }))); + }; + _this._renderPoint = function (feature, index, path) { + // @ts-ignore + var renderState = _this._getFeatureRenderState(index); + var _a = _this.props, featureStyle = _a.featureStyle, featureShape = _a.featureShape, clickRadius = _a.clickRadius; + var shape = _this._getStyleProp(featureShape, { feature: feature, index: index, state: renderState }); + var style = _this._getStyleProp(featureStyle, { feature: feature, index: index, state: renderState }); + var elemKey = "feature." + index; + if (shape === 'rect') { + return (React.createElement("g", { key: elemKey, transform: "translate(" + path[0][0] + ", " + path[0][1] + ")" }, + React.createElement("rect", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey + ".hidden", style: __assign(__assign({}, style), { width: clickRadius, height: clickRadius, fill: '#000', fillOpacity: 0 }) }), + React.createElement("rect", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey, style: style }))); + } + return (React.createElement("g", { key: "feature." + index, transform: "translate(" + path[0][0] + ", " + path[0][1] + ")" }, + React.createElement("circle", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey + ".hidden", style: __assign(__assign({}, style), { opacity: 0 }), cx: 0, cy: 0, r: clickRadius }), + React.createElement("circle", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey, style: style, cx: 0, cy: 0 }))); + }; + _this._renderPath = function (feature, index, path) { + var _a = _this.props, featureStyle = _a.featureStyle, clickRadius = _a.clickRadius; + var selectedFeatureIndex = _this._getSelectedFeatureIndex(); + var selected = index === selectedFeatureIndex; + // @ts-ignore + var renderState = _this._getFeatureRenderState(index); + var style = _this._getStyleProp(featureStyle, { feature: feature, index: index, state: renderState }); + var elemKey = "feature." + index; + if (selected) { + return ( + // @ts-ignore + React.createElement("g", { key: elemKey }, _this._renderSegments(index, feature.geometry.coordinates, style))); + } + // first is to make path easily interacted with + return (React.createElement("g", { key: elemKey }, + React.createElement("path", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey + ".hidden", style: __assign(__assign({}, style), { strokeWidth: clickRadius, opacity: 0 }), d: path }), + React.createElement("path", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey, style: style, d: path }))); + }; + _this._renderPolygon = function (feature, index, path) { + var featureStyle = _this.props.featureStyle; + var selectedFeatureIndex = _this._getSelectedFeatureIndex(); + var selected = index === selectedFeatureIndex; + // @ts-ignore + var renderState = _this._getFeatureRenderState(index); + var style = _this._getStyleProp(featureStyle, { feature: feature, index: index, state: renderState }); + var elemKey = "feature." + index; + if (selected) { + var coordinates = getFeatureCoordinates(feature); + if (!coordinates) { + return null; + } + return (React.createElement("g", { key: elemKey }, + //@ts-ignore + _this._renderFill(index, coordinates, style), + // @ts-ignore + _this._renderSegments(index, coordinates, style))); + } + return (React.createElement("path", { "data-type": ELEMENT_TYPE.FEATURE, "data-feature-index": index, key: elemKey, style: style, d: path })); + }; + _this._renderFeature = function (feature, index) { + var coordinates = getFeatureCoordinates(feature); + // @ts-ignore + if (!coordinates || !coordinates.length) { + return null; + } + var shape = feature.properties.shape, geojsonType = feature.geometry.type; + // @ts-ignore + var path = _this._getPathInScreenCoords(coordinates, geojsonType); + if (!path) { + return null; + } + var type = shape || geojsonType; + switch (type) { + case SHAPE.POINT: + return _this._renderPoint(feature, index, path); + case SHAPE.LINE_STRING: + return _this._renderPath(feature, index, path); + case SHAPE.CIRCLE: + case SHAPE.POLYGON: + case SHAPE.RECTANGLE: + return _this._renderPolygon(feature, index, path); + default: + return null; + } + }; + _this._renderCanvas = function () { + var features = _this.getFeatures(); + var guides = _this._modeHandler && _this._modeHandler.getGuides(_this.getModeProps()); + var guideFeatures = guides && guides.features; + return (React.createElement("svg", { key: "draw-canvas", width: "100%", height: "100%" }, + features && features.length > 0 && (React.createElement("g", { key: "feature-group" }, features.map(_this._renderFeature))), + guideFeatures && guideFeatures.length > 0 && React.createElement("g", { key: "feature-guides" }, _this._renderGuides(guideFeatures)))); + }; + _this._render = function () { + var viewport = (_this._context && _this._context.viewport) || {}; + var style = _this.props.style; + // @ts-ignore + var width = viewport.width, height = viewport.height; + return (React.createElement("div", { id: "editor", style: __assign({ width: width, + height: height }, style), ref: function (_) { + _this._containerRef = _; + } }, _this._renderCanvas())); + }; + return _this; + } + /* HELPERS */ + Editor.prototype._getPathInScreenCoords = function (coordinates, type) { + var _this = this; + if (coordinates.length === 0) { + return ''; + } + var screenCoords = coordinates.map(function (p) { return _this.project(p); }); + var pathString = ''; + switch (type) { + case GEOJSON_TYPE.POINT: + return screenCoords; + case GEOJSON_TYPE.LINE_STRING: + pathString = screenCoords.map(function (p) { return p[0] + "," + p[1]; }).join('L'); + return "M " + pathString; + case GEOJSON_TYPE.POLYGON: + pathString = screenCoords.map(function (p) { return p[0] + "," + p[1]; }).join('L'); + return "M " + pathString + " z"; + default: + return null; + } + }; + Editor.defaultProps = defaultProps; + return Editor; +}(ModeHandler)); +export default Editor; +//# sourceMappingURL=editor.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/editor.js.map b/lib/modules/react-map-gl-draw/src/editor.js.map new file mode 100644 index 000000000..a64db7331 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/editor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,eAAe,IAAI,sBAAsB,EACzC,YAAY,IAAI,mBAAmB,GACpC,MAAM,SAAS,CAAC;AAEjB,IAAM,YAAY,yBACb,WAAW,CAAC,YAAY,KAC3B,WAAW,EAAE,CAAC,EACd,YAAY,EAAE,QAAQ,EACtB,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,sBAAsB,EACvC,YAAY,EAAE,mBAAmB,EACjC,iBAAiB,EAAE,IAAI,GACxB,CAAC;AAEF;IAAoC,0BAAW;IAA/C;QAAA,qEAskBC;QAziBC,yBAAmB,GAAG,UAAC,UAAmB,EAAE,WAAsC;YAC1E,IAAA,gBAA0C,EAAxC,sCAAgB,EAAE,oBAAsB,CAAC;YAEjD,IAAI,WAAW,EAAE;gBACf,OAAO,WAAW,CAAC;aACpB;YAED,IAAM,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACjE,IAAI,uBAAuB,GAAG,IAAI,CAAC;YACnC,IAAM,YAAY,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC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M,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,KAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,CAAC;QAE7D,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,QAAQ,IAAI,EAAE;YACZ,KAAK,YAAY,CAAC,KAAK;gBACrB,OAAO,YAAY,CAAC;YAEtB,KAAK,YAAY,CAAC,WAAW;gBAC3B,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAG,CAAC,CAAC,CAAC,CAAC,SAAI,CAAC,CAAC,CAAC,CAAG,EAAjB,CAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClE,OAAO,OAAK,UAAY,CAAC;YAE3B,KAAK,YAAY,CAAC,OAAO;gBACvB,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAG,CAAC,CAAC,CAAC,CAAC,SAAI,CAAC,CAAC,CAAC,CAAG,EAAjB,CAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClE,OAAO,OAAK,UAAU,OAAI,CAAC;YAE7B;gBACE,OAAO,IAAI,CAAC;SACf;IACH,CAAC;IA1BM,mBAAY,GAAG,YAAY,CAAC;IAqkBrC,aAAC;CAAA,AAtkBD,CAAoC,WAAW,GAskB9C;eAtkBoB,MAAM"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/index.d.ts b/lib/modules/react-map-gl-draw/src/index.d.ts new file mode 100644 index 000000000..e93cb1b5a --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/index.d.ts @@ -0,0 +1,6 @@ +export { default as Editor } from './editor'; +export { GEOJSON_TYPE, SHAPE, RENDER_STATE, ELEMENT_TYPE, EDIT_TYPE } from './constants'; +export * from './edit-modes'; +export * from './types'; +export { DrawCircleFromCenterMode, DrawCircleByDiameterMode, DrawPointMode, DrawLineStringMode, DrawPolygonMode, DrawRectangleMode } from '@nebula.gl/edit-modes'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/index.d.ts.map b/lib/modules/react-map-gl-draw/src/index.d.ts.map new file mode 100644 index 000000000..3f1c318ad --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzF,cAAc,cAAc,CAAC;AAE7B,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EAClB,MAAM,uBAAuB,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/index.js b/lib/modules/react-map-gl-draw/src/index.js new file mode 100644 index 000000000..a9a393a22 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/index.js @@ -0,0 +1,6 @@ +export { default as Editor } from './editor'; +export { GEOJSON_TYPE, SHAPE, RENDER_STATE, ELEMENT_TYPE, EDIT_TYPE } from './constants'; +export * from './edit-modes'; +export * from './types'; +export { DrawCircleFromCenterMode, DrawCircleByDiameterMode, DrawPointMode, DrawLineStringMode, DrawPolygonMode, DrawRectangleMode } from '@nebula.gl/edit-modes'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/index.js.map b/lib/modules/react-map-gl-draw/src/index.js.map new file mode 100644 index 000000000..9f2d1b451 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzF,cAAc,cAAc,CAAC;AAE7B,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EAClB,MAAM,uBAAuB,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/mode-handler.d.ts b/lib/modules/react-map-gl-draw/src/mode-handler.d.ts new file mode 100644 index 000000000..ea5f30fcb --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/mode-handler.d.ts @@ -0,0 +1,77 @@ +import { MapContextProps } from 'react-map-gl'; +import React from 'react'; +import { Feature, Position, EditAction } from '@nebula.gl/edit-modes'; +import { MjolnirEvent } from 'mjolnir.js'; +import { EditorProps, EditorState, SelectAction } from './types'; +export default class ModeHandler extends React.PureComponent { + static displayName: string; + static defaultProps: { + selectable: boolean; + mode: any; + features: any; + onSelect: any; + onUpdate: any; + onUpdateCursor: () => void; + }; + constructor(props: EditorProps); + componentDidMount(): void; + componentDidUpdate(prevProps: EditorProps): void; + componentWillUnmount(): void; + _events: any; + _eventsRegistered: boolean; + _modeHandler: any; + _context: MapContextProps | null | undefined; + _containerRef: HTMLElement | null | undefined; + getFeatures: () => any; + addFeatures: (features: import("@nebula.gl/edit-modes").FeatureOf | import("@nebula.gl/edit-modes").FeatureOf | import("@nebula.gl/edit-modes").FeatureOf | import("@nebula.gl/edit-modes").FeatureOf | import("@nebula.gl/edit-modes").FeatureOf | import("@nebula.gl/edit-modes").FeatureOf | Feature[]) => void; + deleteFeatures: (featureIndexes: number | number[]) => void; + getModeProps(): { + data: any; + selectedIndexes: number[]; + lastPointerMoveEvent: import("@nebula.gl/edit-modes").PointerMoveEvent; + viewport: import("viewport-mercator-project").WebMercatorViewport; + featuresDraggable: boolean; + onEdit: (editAction: EditAction) => void; + onUpdateCursor: Function; + }; + _getMemorizedFeatureCollection: (args: any) => any; + _getFeatureCollection: () => any; + _setupModeHandler: () => void; + _clearEditingState: () => void; + _getSelectedFeatureIndex: () => number; + _onSelect: (selected: SelectAction) => void; + _onEdit: (editAction: EditAction) => void; + _degregisterEvents: () => void; + _registerEvents: () => void; + _onEvent: (handler: Function, evt: any, stopPropagation: boolean) => void; + _onClick: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => void; + _onDblclick: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => void; + _onPointerMove: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => void; + _onPointerDown: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => void; + _onPointerUp: (event: any) => void; + _onPan: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => void; + project: (pt: Position) => any; + unproject: (pt: Position) => any; + _getEvent(evt: MjolnirEvent): { + picks: { + object: any; + isGuide: boolean; + type: any; + index: any; + featureIndex: any; + }[]; + screenCoords: number[]; + mapCoords: any; + sourceEvent: any; + }; + _getHoverState: (event: import("@nebula.gl/edit-modes/dist-types/types").BasePointerEvent) => { + object: any; + index: number; + isGuide: boolean; + screenCoords: import("@nebula.gl/edit-modes").ScreenCoordinates; + mapCoords: Position; + }; + _render(): JSX.Element; + render(): JSX.Element; +} +//# sourceMappingURL=mode-handler.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/mode-handler.d.ts.map b/lib/modules/react-map-gl-draw/src/mode-handler.d.ts.map new file mode 100644 index 000000000..1af1c1c4e --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/mode-handler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mode-handler.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/mode-handler.tsx"],"names":[],"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AG,EAAE,YAAY;;;;;;;;;;;;IAgB3B,cAAc;;;;;;MAWZ;IAEF,OAAO;IAIP,MAAM;CAgBP"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/mode-handler.js b/lib/modules/react-map-gl-draw/src/mode-handler.js new file mode 100644 index 000000000..020de62bc --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/mode-handler.js @@ -0,0 +1,373 @@ +import { __assign, __extends } from "tslib"; +import { _MapContext as MapContext } from 'react-map-gl'; +import React from 'react'; +import { ImmutableFeatureCollection, _memoize as memoize, } from '@nebula.gl/edit-modes'; +import EditingMode from './edit-modes/editing-mode'; +import { getScreenCoords, parseEventElement, isNumeric } from './edit-modes/utils'; +import { EDIT_TYPE, ELEMENT_TYPE } from './constants'; +var defaultProps = { + selectable: true, + mode: null, + features: null, + onSelect: null, + onUpdate: null, + onUpdateCursor: function () { }, +}; +var defaultState = { + featureCollection: new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: [], + }), + selectedFeatureIndex: null, + // index, isGuide, mapCoords, screenCoords + hovered: null, + isDragging: false, + didDrag: false, + lastPointerMoveEvent: null, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownMapCoords: null, +}; +var ModeHandler = /** @class */ (function (_super) { + __extends(ModeHandler, _super); + function ModeHandler(props) { + var _this = _super.call(this, props) || this; + _this.getFeatures = function () { + var featureCollection = _this._getFeatureCollection(); + featureCollection = featureCollection && featureCollection.getObject(); + return featureCollection && featureCollection.features; + }; + _this.addFeatures = function (features) { + var featureCollection = _this._getFeatureCollection(); + if (featureCollection) { + if (!Array.isArray(features)) { + features = [features]; + } + featureCollection = featureCollection.addFeatures(features); + _this.setState({ featureCollection: featureCollection }); + } + }; + _this.deleteFeatures = function (featureIndexes) { + var featureCollection = _this._getFeatureCollection(); + var selectedFeatureIndex = _this._getSelectedFeatureIndex(); + if (featureCollection) { + if (!Array.isArray(featureIndexes)) { + featureIndexes = [featureIndexes]; + } + featureCollection = featureCollection.deleteFeatures(featureIndexes); + var newState = { featureCollection: featureCollection }; + if (featureIndexes.findIndex(function (index) { return selectedFeatureIndex === index; }) >= 0) { + newState.selectedFeatureIndex = null; + } + _this.setState(newState); + } + }; + /* MEMORIZERS */ + _this._getMemorizedFeatureCollection = memoize(function (_a) { + var propsFeatures = _a.propsFeatures, stateFeatures = _a.stateFeatures; + var features = propsFeatures || stateFeatures; + // Any changes in ImmutableFeatureCollection will create a new object + if (features instanceof ImmutableFeatureCollection) { + return features; + } + if (features && features.type === 'FeatureCollection') { + return new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: features.features, + }); + } + return new ImmutableFeatureCollection({ + type: 'FeatureCollection', + features: features || [], + }); + }); + _this._getFeatureCollection = function () { + return _this._getMemorizedFeatureCollection({ + propsFeatures: _this.props.features, + stateFeatures: _this.state.featureCollection, + }); + }; + _this._setupModeHandler = function () { + var mode = _this.props.mode; + _this._modeHandler = mode; + if (!mode) { + _this._degregisterEvents(); + return; + } + _this._registerEvents(); + }; + /* EDITING OPERATIONS */ + _this._clearEditingState = function () { + _this.setState({ + selectedFeatureIndex: null, + hovered: null, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownMapCoords: null, + isDragging: false, + didDrag: false, + }); + }; + _this._getSelectedFeatureIndex = function () { + if ('selectedFeatureIndex' in _this.props) { + return _this.props.selectedFeatureIndex; + } + return _this.state.selectedFeatureIndex; + }; + _this._onSelect = function (selected) { + _this.setState({ selectedFeatureIndex: selected && selected.selectedFeatureIndex }); + if (_this.props.onSelect) { + _this.props.onSelect(selected); + } + }; + _this._onEdit = function (editAction) { + var editType = editAction.editType, updatedData = editAction.updatedData, editContext = editAction.editContext; + _this.setState({ featureCollection: new ImmutableFeatureCollection(updatedData) }); + switch (editType) { + case EDIT_TYPE.ADD_FEATURE: + _this._onSelect({ + selectedFeature: null, + selectedFeatureIndex: null, + selectedEditHandleIndex: null, + screenCoords: editContext && editContext.screenCoords, + mapCoords: editContext && editContext.mapCoords, + }); + break; + default: + } + if (_this.props.onUpdate) { + _this.props.onUpdate({ + data: updatedData && updatedData.features, + editType: editType, + editContext: editContext, + }); + } + }; + /* EVENTS */ + _this._degregisterEvents = function () { + var eventManager = _this._context && _this._context.eventManager; + if (!_this._events || !eventManager) { + return; + } + if (_this._eventsRegistered) { + eventManager.off(_this._events); + _this._eventsRegistered = false; + } + }; + _this._registerEvents = function () { + var ref = _this._containerRef; + var eventManager = _this._context && _this._context.eventManager; + if (!_this._events || !ref || !eventManager) { + return; + } + if (_this._eventsRegistered) { + return; + } + eventManager.on(_this._events, ref); + _this._eventsRegistered = true; + }; + _this._onEvent = function (handler, evt, stopPropagation) { + var event = _this._getEvent(evt); + handler(event); + if (stopPropagation) { + evt.stopImmediatePropagation(); + } + }; + _this._onClick = function (event) { + var modeProps = _this.getModeProps(); + // TODO refactor EditingMode + // @ts-ignore + if (_this._modeHandler instanceof EditingMode || _this.props.selectable) { + var mapCoords = event.mapCoords, screenCoords = event.screenCoords; + var pickedObject = event.picks && event.picks[0]; + // @ts-ignore + if (pickedObject && isNumeric(pickedObject.featureIndex)) { + // @ts-ignore + var selectedFeatureIndex = pickedObject.featureIndex; + _this._onSelect({ + selectedFeature: pickedObject.object, + selectedFeatureIndex: selectedFeatureIndex, + selectedEditHandleIndex: + // @ts-ignore + pickedObject.type === ELEMENT_TYPE.EDIT_HANDLE ? pickedObject.index : null, + // @ts-ignore + mapCoords: mapCoords, + screenCoords: screenCoords, + }); + } + else { + _this._onSelect({ + selectedFeature: null, + selectedFeatureIndex: null, + selectedEditHandleIndex: null, + // @ts-ignore + mapCoords: mapCoords, + screenCoords: screenCoords, + }); + } + } + _this._modeHandler.handleClick(event, modeProps); + }; + _this._onDblclick = function (event) { + if (isNumeric(_this._getSelectedFeatureIndex())) { + event.sourceEvent.stopImmediatePropagation(); + } + }; + _this._onPointerMove = function (event) { + // hovering + var hovered = _this._getHoverState(event); + var _a = _this.state, isDragging = _a.isDragging, didDrag = _a.didDrag, pointerDownPicks = _a.pointerDownPicks, pointerDownScreenCoords = _a.pointerDownScreenCoords, pointerDownMapCoords = _a.pointerDownMapCoords; + if (isDragging && !didDrag && pointerDownScreenCoords) { + var dx = event.screenCoords[0] - pointerDownScreenCoords[0]; + var dy = event.screenCoords[1] - pointerDownScreenCoords[1]; + if (dx * dx + dy * dy > 5) { + _this.setState({ didDrag: true }); + } + } + var pointerMoveEvent = __assign(__assign({}, event), { isDragging: isDragging, + pointerDownPicks: pointerDownPicks, + pointerDownScreenCoords: pointerDownScreenCoords, + pointerDownMapCoords: pointerDownMapCoords }); + if (_this.state.didDrag) { + var modeProps = _this.getModeProps(); + _this._modeHandler.handlePointerMove(pointerMoveEvent, modeProps); + } + _this.setState({ + hovered: hovered, + // @ts-ignore + lastPointerMoveEvent: pointerMoveEvent, + }); + }; + _this._onPointerDown = function (event) { + var isDragging = event.picks && event.picks[0]; + var startDraggingEvent = __assign(__assign({}, event), { isDragging: isDragging, pointerDownScreenCoords: event.screenCoords, pointerDownMapCoords: event.mapCoords }); + var newState = { + isDragging: isDragging, + pointerDownPicks: event.picks, + pointerDownScreenCoords: event.screenCoords, + pointerDownMapCoords: event.mapCoords, + }; + // @ts-ignore + _this.setState(newState); + var modeProps = _this.getModeProps(); + _this._modeHandler.handleStartDragging(startDraggingEvent, modeProps); + }; + _this._onPointerUp = function (event) { + var _a = _this.state, didDrag = _a.didDrag, pointerDownPicks = _a.pointerDownPicks, pointerDownScreenCoords = _a.pointerDownScreenCoords, pointerDownMapCoords = _a.pointerDownMapCoords; + var stopDraggingEvent = __assign(__assign({}, event), { isDragging: false, pointerDownPicks: didDrag ? pointerDownPicks : null, pointerDownScreenCoords: didDrag ? pointerDownScreenCoords : null, pointerDownMapCoords: didDrag ? pointerDownMapCoords : null }); + var newState = { + isDragging: false, + didDrag: false, + pointerDownPicks: null, + pointerDownScreenCoords: null, + pointerDownMapCoords: null, + }; + _this.setState(newState); + var modeProps = _this.getModeProps(); + if (didDrag) { + _this._modeHandler.handleStopDragging(stopDraggingEvent, modeProps); + } + }; + _this._onPan = function (event) { + var isDragging = _this.state.isDragging; + if (isDragging) { + event.sourceEvent.stopImmediatePropagation(); + } + if (_this._modeHandler.handlePan) { + _this._modeHandler.handlePan(event, _this.getModeProps()); + } + }; + /* HELPERS */ + _this.project = function (pt) { + var viewport = _this._context && _this._context.viewport; + // @ts-ignore + return viewport && viewport.project(pt); + }; + _this.unproject = function (pt) { + var viewport = _this._context && _this._context.viewport; + // @ts-ignore + return viewport && viewport.unproject(pt); + }; + _this._getHoverState = function (event) { + var object = event.picks && event.picks[0]; + if (!object) { + return null; + } + return __assign({ screenCoords: event.screenCoords, mapCoords: event.mapCoords }, object); + }; + _this.state = defaultState; + _this._eventsRegistered = false; + _this._events = { + anyclick: function (evt) { return _this._onEvent(_this._onClick, evt, true); }, + dblclick: function (evt) { return _this._onEvent(_this._onDblclick, evt, false); }, + click: function (evt) { return evt.stopImmediatePropagation(); }, + pointermove: function (evt) { return _this._onEvent(_this._onPointerMove, evt, true); }, + pointerdown: function (evt) { return _this._onEvent(_this._onPointerDown, evt, true); }, + pointerup: function (evt) { return _this._onEvent(_this._onPointerUp, evt, true); }, + panmove: function (evt) { return _this._onEvent(_this._onPan, evt, false); }, + panstart: function (evt) { return _this._onEvent(_this._onPan, evt, false); }, + panend: function (evt) { return _this._onEvent(_this._onPan, evt, false); }, + }; + return _this; + } + ModeHandler.prototype.componentDidMount = function () { + this._setupModeHandler(); + }; + ModeHandler.prototype.componentDidUpdate = function (prevProps) { + if (prevProps.mode !== this.props.mode) { + this._clearEditingState(); + this._setupModeHandler(); + } + }; + ModeHandler.prototype.componentWillUnmount = function () { + this._degregisterEvents(); + }; + ModeHandler.prototype.getModeProps = function () { + var featureCollection = this._getFeatureCollection(); + var lastPointerMoveEvent = this.state.lastPointerMoveEvent; + var selectedFeatureIndex = this._getSelectedFeatureIndex(); + var viewport = this._context && this._context.viewport; + return { + data: featureCollection && featureCollection.featureCollection, + selectedIndexes: isNumeric(selectedFeatureIndex) ? [selectedFeatureIndex] : [], + lastPointerMoveEvent: lastPointerMoveEvent, + viewport: viewport, + featuresDraggable: this.props.featuresDraggable, + onEdit: this._onEdit, + onUpdateCursor: this.props.onUpdateCursor, + }; + }; + ModeHandler.prototype._getEvent = function (evt) { + var features = this.getFeatures(); + var guides = this._modeHandler.getGuides(this.getModeProps()); + var picked = parseEventElement(evt, features, guides && guides.features); + var screenCoords = getScreenCoords(evt); + // @ts-ignore + var mapCoords = this.unproject(screenCoords); + return { + picks: picked ? [picked] : null, + screenCoords: screenCoords, + mapCoords: mapCoords, + sourceEvent: evt, + }; + }; + ModeHandler.prototype._render = function () { + return React.createElement("div", null); + }; + ModeHandler.prototype.render = function () { + var _this = this; + return (React.createElement(MapContext.Consumer, null, function (context) { + _this._context = context; + var viewport = context && context.viewport; + if (!viewport || viewport.height <= 0 || viewport.width <= 0) { + return null; + } + return _this._render(); + })); + }; + ModeHandler.displayName = 'ModeHandler'; + ModeHandler.defaultProps = defaultProps; + return ModeHandler; +}(React.PureComponent)); +export default ModeHandler; +//# sourceMappingURL=mode-handler.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/mode-handler.js.map b/lib/modules/react-map-gl-draw/src/mode-handler.js.map new file mode 100644 index 000000000..0189871a5 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/mode-handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mode-handler.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/mode-handler.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,IAAI,UAAU,EAAmB,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,0BAA0B,EAI1B,QAAQ,IAAI,OAAO,GACpB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC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,CAAC,KAAK,IAAI,CAAC,EAAE;gBAC5D,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAI,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC,CACmB,CACvB,CAAC;IACJ,CAAC;IA3aM,uBAAW,GAAG,aAAa,CAAC;IAC5B,wBAAY,GAAG,YAAY,CAAC;IA2arC,kBAAC;CAAA,AA7aD,CAAyC,KAAK,CAAC,aAAa,GA6a3D;eA7aoB,WAAW"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/style.d.ts b/lib/modules/react-map-gl-draw/src/style.d.ts new file mode 100644 index 000000000..9668c67a9 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/style.d.ts @@ -0,0 +1,11 @@ +export declare function featureStyle({ feature, state }: { + feature: any; + state: any; +}): any; +export declare function editHandleStyle({ feature, shape, index, state }: { + feature: any; + shape: any; + index: any; + state: any; +}): {}; +//# sourceMappingURL=style.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/style.d.ts.map b/lib/modules/react-map-gl-draw/src/style.d.ts.map new file mode 100644 index 000000000..b131e378b --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/style.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/style.ts"],"names":[],"mappings":"AA2CA,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE;;;CAAA,OAiD9C;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;;;;;CAAA,MAoC/D"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/style.js b/lib/modules/react-map-gl-draw/src/style.js new file mode 100644 index 000000000..7e6ab3367 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/style.js @@ -0,0 +1,111 @@ +import { __assign } from "tslib"; +import { RENDER_STATE, SHAPE } from './constants'; +var RECT_STYLE = { + stroke: '#7ac943', + strokeWidth: 2, + x: -6, + y: -6, + height: 12, + width: 12, +}; +var CIRCLE_RADIUS = 8; +var SELECTED_STYLE = { + stroke: '#7ac943', + strokeWidth: 2, + fill: '#ffff00', + fillOpacity: 0.7, +}; +var HOVERED_STYLE = { + stroke: '#7ac943', + strokeWidth: 2, + fill: '#7ac943', + fillOpacity: 0.5, +}; +var UNCOMMITTED_STYLE = { + stroke: '#a7a7a7', + strokeWidth: 2, + fill: '#a9a9a9', + fillOpacity: 0.3, +}; +var INACTIVE_STYLE = UNCOMMITTED_STYLE; +var DEFAULT_STYLE = { + stroke: '#000000', + strokeWidth: 2, + fill: '#a9a9a9', + fillOpacity: 0.1, +}; +export function featureStyle(_a) { + var feature = _a.feature, state = _a.state; + var type = feature.properties.shape || feature.geometry.type; + var style = null; + switch (state) { + case RENDER_STATE.SELECTED: + style = __assign({}, SELECTED_STYLE); + break; + case RENDER_STATE.HOVERED: + style = __assign({}, HOVERED_STYLE); + break; + case RENDER_STATE.UNCOMMITTED: + case RENDER_STATE.CLOSING: + style = __assign({}, UNCOMMITTED_STYLE); + break; + case RENDER_STATE.INACTIVE: + style = __assign({}, INACTIVE_STYLE); + break; + default: + style = __assign({}, DEFAULT_STYLE); + } + switch (type) { + case SHAPE.POINT: + style.r = CIRCLE_RADIUS; + break; + case SHAPE.LINE_STRING: + style.fill = 'none'; + break; + case SHAPE.POLYGON: + if (state === RENDER_STATE.CLOSING) { + style.strokeDasharray = '4,2'; + } + break; + case SHAPE.RECTANGLE: + if (state === RENDER_STATE.UNCOMMITTED) { + style.strokeDasharray = '4,2'; + } + break; + default: + } + return style; +} +export function editHandleStyle(_a) { + var feature = _a.feature, shape = _a.shape, index = _a.index, state = _a.state; + var style = {}; + switch (state) { + case RENDER_STATE.SELECTED: + style = __assign({}, SELECTED_STYLE); + break; + case RENDER_STATE.HOVERED: + style = __assign({}, HOVERED_STYLE); + break; + case RENDER_STATE.UNCOMMITTED: + case RENDER_STATE.CLOSING: + style = __assign({}, UNCOMMITTED_STYLE); + break; + case RENDER_STATE.INACTIVE: + style = __assign({}, INACTIVE_STYLE); + break; + default: + style = __assign({}, DEFAULT_STYLE); + } + switch (shape) { + case 'circle': + //@ts-ignore + style.r = CIRCLE_RADIUS; + break; + case 'rect': + style = __assign(__assign({}, style), RECT_STYLE); + break; + default: + } + return style; +} +//# sourceMappingURL=style.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/style.js.map b/lib/modules/react-map-gl-draw/src/style.js.map new file mode 100644 index 000000000..8b63c6229 --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/style.js.map @@ -0,0 +1 @@ +{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/style.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAElD,IAAM,UAAU,GAAG;IACjB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,CAAC;IACd,CAAC,EAAE,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,CAAC;IACL,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,IAAM,aAAa,GAAG,CAAC,CAAC;AAExB,IAAM,cAAc,GAAG;IACrB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF,IAAM,aAAa,GAAG;IACpB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF,IAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF,IAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,IAAM,aAAa,GAAG;IACpB,MAAM,EAAE,SA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ACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAgC;QAA9B,oBAAO,EAAE,gBAAK,EAAE,gBAAK,EAAE,gBAAK;IAC5D,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,QAAQ,KAAK,EAAE;QACb,KAAK,YAAY,CAAC,QAAQ;YACxB,KAAK,gBAAQ,cAAc,CAAE,CAAC;YAC9B,MAAM;QAER,KAAK,YAAY,CAAC,OAAO;YACvB,KAAK,gBAAQ,aAAa,CAAE,CAAC;YAC7B,MAAM;QAER,KAAK,YAAY,CAAC,WAAW,CAAC;QAC9B,KAAK,YAAY,CAAC,OAAO;YACvB,KAAK,gBAAQ,iBAAiB,CAAE,CAAC;YACjC,MAAM;QAER,KAAK,YAAY,CAAC,QAAQ;YACxB,KAAK,gBAAQ,cAAc,CAAE,CAAC;YAC9B,MAAM;QAER;YACE,KAAK,gBAAQ,aAAa,CAAE,CAAC;KAChC;IAED,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,YAAY;YACZ,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC;YACxB,MAAM;QACR,KAAK,MAAM;YACT,KAAK,yBAAQ,KAAK,GAAK,UAAU,CAAE,CAAC;YACpC,MAAM;QACR,QAAQ;KACT;IAED,OAAO,KAAK,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/types.d.ts b/lib/modules/react-map-gl-draw/src/types.d.ts new file mode 100644 index 000000000..94639b4eb --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/types.d.ts @@ -0,0 +1,46 @@ +import { WebMercatorViewport } from 'viewport-mercator-project'; +import { ModeProps as BaseModeProps, Feature, ImmutableFeatureCollection, PointerMoveEvent, Pick, ClickEvent, ScreenCoordinates } from '@nebula.gl/edit-modes'; +import { RENDER_STATE, GEOJSON_TYPE, RENDER_TYPE } from './constants'; +export declare type Id = string | number; +export declare type RenderState = RENDER_STATE; +export declare type GeoJsonType = GEOJSON_TYPE; +export declare type RenderType = RENDER_TYPE; +export declare type SelectAction = { + selectedFeature: Feature | null | undefined; + selectedFeatureIndex?: number | null | undefined; + selectedEditHandleIndex?: number | null | undefined; + screenCoords: ScreenCoordinates | null | undefined; + mapCoords: Position | null | undefined; +}; +export declare type ModeProps = BaseModeProps & { + viewport: WebMercatorViewport | null | undefined; + featuresDraggable: boolean | null | undefined; +}; +export declare type EditorProps = { + mode: Record; + style: Record | null | undefined; + features: Feature[] | null | undefined; + selectedFeatureIndex: number | null | undefined; + clickRadius: number; + featureShape: Function | string; + editHandleShape: Function | string; + editHandleStyle: Function | any; + featureStyle: Function | any; + featuresDraggable: boolean | null | undefined; + onUpdate: Function; + onSelect: Function; + onUpdateCursor: Function; +}; +export declare type EditorState = { + featureCollection: ImmutableFeatureCollection | null | undefined; + selectedFeatureIndex: number | null | undefined; + hovered: Pick | null | undefined; + lastPointerMoveEvent: PointerMoveEvent; + isDragging: boolean; + didDrag: boolean; + pointerDownPicks: Pick[] | null | undefined; + pointerDownScreenCoords: ScreenCoordinates | null | undefined; + pointerDownMapCoords: Position | null | undefined; +}; +export declare type BaseEvent = ClickEvent; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/types.d.ts.map b/lib/modules/react-map-gl-draw/src/types.d.ts.map new file mode 100644 index 000000000..b5ffead3a --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,OAAO,EACP,0BAA0B,EAC1B,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,C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,SAAS,CAAC;IAC9C,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,iBAAiB,EAAE,0BAA0B,GAAG,IAAI,GAAG,SAAS,CAAC;IAEjE,oBAAoB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAEhD,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,oBAAoB,EAAE,gBAAgB,CAAC;IAEvC,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IAEjB,gBAAgB,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,uBAAuB,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9D,oBAAoB,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;CACnD,CAAC;AAEF,oBAAY,SAAS,GAAG,UAAU,CAAC"} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/types.js b/lib/modules/react-map-gl-draw/src/types.js new file mode 100644 index 000000000..5b2306a4c --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/types.js @@ -0,0 +1 @@ +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/src/types.js.map b/lib/modules/react-map-gl-draw/src/types.js.map new file mode 100644 index 000000000..08fefc57a --- /dev/null +++ b/lib/modules/react-map-gl-draw/src/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/test/utils.spec.d.ts b/lib/modules/react-map-gl-draw/test/utils.spec.d.ts new file mode 100644 index 000000000..defd4da05 --- /dev/null +++ b/lib/modules/react-map-gl-draw/test/utils.spec.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=utils.spec.d.ts.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/test/utils.spec.d.ts.map b/lib/modules/react-map-gl-draw/test/utils.spec.d.ts.map new file mode 100644 index 000000000..8f08e2749 --- /dev/null +++ b/lib/modules/react-map-gl-draw/test/utils.spec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/test/utils.spec.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/test/utils.spec.js b/lib/modules/react-map-gl-draw/test/utils.spec.js new file mode 100644 index 000000000..3c73ae535 --- /dev/null +++ b/lib/modules/react-map-gl-draw/test/utils.spec.js @@ -0,0 +1,48 @@ +/* eslint-env jest */ +import { findClosestPointOnLineSegment, isNumeric } from '../src/edit-modes/utils'; +describe('findClosestPointOnLineSegment', function () { + it('should return null when point on the line and out of bounds', function () { + var p1 = [1, 0]; + var p2 = [0, 0]; + var p = [2, 0]; + var point = findClosestPointOnLineSegment(p1, p2, p); + expect(point).toBe(null); + }); + it('should return null when line vertical and point out of bounds', function () { + var p1 = [0, 0]; + var p2 = [0, 1]; + var p = [0, 2]; + var point = findClosestPointOnLineSegment(p1, p2, p); + expect(point).toBe(null); + }); + it('should return expected when line vertical', function () { + var p1 = [0, 0]; + var p2 = [2, 0]; + var p = [1, 1]; + var point = findClosestPointOnLineSegment(p1, p2, p); + expect(point).toEqual([1, 0]); + }); + it('should return null when point out of bounds', function () { + var p1 = [1, 0]; + var p2 = [3, 5]; + var p = [4, 6]; + var point = findClosestPointOnLineSegment(p1, p2, p); + expect(point).toBe(null); + }); + it('should return expected', function () { + var p1 = [1, 0]; + var p2 = [3, 5]; + var p = [2, 3]; + var point = findClosestPointOnLineSegment(p1, p2, p); + expect(point).toEqual([2.1724137931034484, 2.931034482758621]); + }); +}); +describe('isNumeric', function () { + it('should match expect', function () { + var testCases = [null, undefined, '', 'a', [], [1], '1', '1.1', 1, 1.1]; + var expected = [false, false, false, false, false, false, true, true, true, true]; + var results = testCases.map(function (t) { return isNumeric(t); }); + expect(results).toEqual(expected); + }); +}); +//# sourceMappingURL=utils.spec.js.map \ No newline at end of file diff --git a/lib/modules/react-map-gl-draw/test/utils.spec.js.map b/lib/modules/react-map-gl-draw/test/utils.spec.js.map new file mode 100644 index 000000000..09e45baa2 --- /dev/null +++ b/lib/modules/react-map-gl-draw/test/utils.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../../modules/react-map-gl-draw/test/utils.spec.ts"],"names":[],"mappings":"AAAA,qBAAqB;AAErB,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGnF,QAAQ,CAAC,+BAA+B,EAAE;IACxC,EAAE,CAAC,6DAA6D,EAAE;QAChE,IAAM,EAAE,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,IAAM,EAAE,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,IAAM,CAAC,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3B,IAAM,KAAK,GAAG,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEvD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE;QAClE,IAAM,EAAE,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,IAAM,EAAE,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,IAAM,CAAC,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE3B,IAAM,KAAK,GAAG,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAEvD,MAAM,CAAC,KAAK,CAAC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E,iBAAiB,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,EAAE;IACpB,EAAE,CAAC,qBAAqB,EAAE;QACxB,IAAM,SAAS,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QAE1E,IAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACpF,IAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,SAAS,CAAC,CAAC,CAAC,EAAZ,CAAY,CAAC,CAAC;QAEnD,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/lib/website/src/pages/geojson-editor.d.ts b/lib/website/src/pages/geojson-editor.d.ts new file mode 100644 index 000000000..694c4b161 --- /dev/null +++ b/lib/website/src/pages/geojson-editor.d.ts @@ -0,0 +1,5 @@ +import * as React from 'react'; +export default class GeoJsonEditor extends React.Component { + render(): JSX.Element; +} +//# sourceMappingURL=geojson-editor.d.ts.map \ No newline at end of file diff --git a/lib/website/src/pages/geojson-editor.d.ts.map b/lib/website/src/pages/geojson-editor.d.ts.map new file mode 100644 index 000000000..0696f1116 --- /dev/null +++ b/lib/website/src/pages/geojson-editor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-editor.d.ts","sourceRoot":"","sources":["../../../../website/src/pages/geojson-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,KAAK,CAAC,SAAS;IACxD,MAAM;CAOP"} \ No newline at end of file diff --git a/lib/website/src/pages/geojson-editor.js b/lib/website/src/pages/geojson-editor.js new file mode 100644 index 000000000..190f7820c --- /dev/null +++ b/lib/website/src/pages/geojson-editor.js @@ -0,0 +1,19 @@ +import { __extends, __makeTemplateObject } from "tslib"; +import * as React from 'react'; +import styled from 'styled-components'; +import Example from '../../../examples/advanced/src/example'; +var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: calc(100vh - 4rem);\n margin-top: 4rem;\n"], ["\n width: 100%;\n height: calc(100vh - 4rem);\n margin-top: 4rem;\n"]))); +var GeoJsonEditor = /** @class */ (function (_super) { + __extends(GeoJsonEditor, _super); + function GeoJsonEditor() { + return _super !== null && _super.apply(this, arguments) || this; + } + GeoJsonEditor.prototype.render = function () { + return (React.createElement(Container, { id: "geoJsonEditorContainer" }, + React.createElement(Example, null))); + }; + return GeoJsonEditor; +}(React.Component)); +export default GeoJsonEditor; +var templateObject_1; +//# sourceMappingURL=geojson-editor.js.map \ No newline at end of file diff --git a/lib/website/src/pages/geojson-editor.js.map b/lib/website/src/pages/geojson-editor.js.map new file mode 100644 index 000000000..beed815f3 --- /dev/null +++ b/lib/website/src/pages/geojson-editor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"geojson-editor.js","sourceRoot":"","sources":["../../../../website/src/pages/geojson-editor.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,OAAO,MAAM,wCAAwC,CAAC;AAE7D,IAAM,SAAS,GAAG,MAAM,CAAC,GAAG,2IAAA,wEAI3B,IAAA,CAAC;AAEF;IAA2C,iCAAe;IAA1D;;IAQA,CAAC;IAPC,8BAAM,GAAN;QACE,OAAO,CACL,oBAAC,SAAS,IAAC,EAAE,EAAC,wBAAwB;YACpC,oBAAC,OAAO,OAAG,CACD,CACb,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AARD,CAA2C,KAAK,CAAC,SAAS,GAQzD"} \ No newline at end of file diff --git a/modules/editor/src/editor-modal.tsx b/modules/editor/src/editor-modal.tsx index 1a3bae740..198cb6c00 100644 --- a/modules/editor/src/editor-modal.tsx +++ b/modules/editor/src/editor-modal.tsx @@ -1,6 +1,6 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import Modal, { ModalProvider } from 'styled-react-modal'; import styled from 'styled-components'; diff --git a/modules/editor/src/export-component.tsx b/modules/editor/src/export-component.tsx index b52b32223..a58b1b9c4 100644 --- a/modules/editor/src/export-component.tsx +++ b/modules/editor/src/export-component.tsx @@ -1,6 +1,6 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import copy from 'clipboard-copy'; import downloadjs from 'downloadjs'; import styled from 'styled-components'; diff --git a/modules/editor/src/export-modal.tsx b/modules/editor/src/export-modal.tsx index 30a6d78d2..fd46716b5 100644 --- a/modules/editor/src/export-modal.tsx +++ b/modules/editor/src/export-modal.tsx @@ -1,5 +1,5 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import { AnyGeoJson } from '@nebula.gl/edit-modes'; import { EditorModal } from './editor-modal'; import { ExportComponent } from './export-component'; diff --git a/modules/editor/src/import-component.tsx b/modules/editor/src/import-component.tsx index d7b4bfe30..d813b219f 100644 --- a/modules/editor/src/import-component.tsx +++ b/modules/editor/src/import-component.tsx @@ -1,6 +1,6 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import Dropzone from 'react-dropzone'; import styled from 'styled-components'; import { Button } from './editor-modal'; diff --git a/modules/editor/src/import-modal.tsx b/modules/editor/src/import-modal.tsx index db575ac80..658348caa 100644 --- a/modules/editor/src/import-modal.tsx +++ b/modules/editor/src/import-modal.tsx @@ -1,6 +1,6 @@ /* eslint-env browser */ -import React from 'react'; +import * as React from 'react'; import { ImportComponent } from './import-component'; import { EditorModal } from './editor-modal'; diff --git a/modules/editor/src/toolbox.tsx b/modules/editor/src/toolbox.tsx index 4f0c93137..c84166f01 100644 --- a/modules/editor/src/toolbox.tsx +++ b/modules/editor/src/toolbox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { ViewMode, DrawPointMode, DrawPolygonMode } from '@nebula.gl/edit-modes'; import styled from 'styled-components'; import { ImportModal } from './import-modal'; diff --git a/modules/overlays/src/html-overlay-item.tsx b/modules/overlays/src/html-overlay-item.tsx index 5f318f096..04240af6a 100644 --- a/modules/overlays/src/html-overlay-item.tsx +++ b/modules/overlays/src/html-overlay-item.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import * as React from 'react'; const styles = { item: { @@ -18,7 +18,7 @@ type Props = { style?: Record; }; -export default class HtmlOverlayItem extends Component { +export default class HtmlOverlayItem extends React.Component { render() { const { x, y, children, style, ...props } = this.props; diff --git a/modules/overlays/src/html-overlay.tsx b/modules/overlays/src/html-overlay.tsx index 125ba52a3..ec2d6dbbc 100644 --- a/modules/overlays/src/html-overlay.tsx +++ b/modules/overlays/src/html-overlay.tsx @@ -1,4 +1,4 @@ -import React, { Component, cloneElement } from 'react'; +import * as React from 'react'; const styles = { mainContainer: { @@ -9,8 +9,8 @@ const styles = { }, }; -export default class HtmlOverlay extends Component< - { viewport?: Record; zIndex?: number; children?: React.ReactNode }, +export default class HtmlOverlay extends React.Component< + { viewport?: Record; zIndex?: number, children?: React.ReactNode }, any > { // Override this to provide your items @@ -62,7 +62,7 @@ export default class HtmlOverlay extends Component< const [x, y] = this.getCoords(item.props.coordinates); if (this.inView([x, y])) { const key = item.key === null || item.key === undefined ? index : item.key; - renderItems.push(cloneElement(item, { x, y, key })); + renderItems.push(React.cloneElement(item, { x, y, key })); } }); diff --git a/modules/overlays/src/html-tooltip-overlay.tsx b/modules/overlays/src/html-tooltip-overlay.tsx index ad25408a3..ba8753012 100644 --- a/modules/overlays/src/html-tooltip-overlay.tsx +++ b/modules/overlays/src/html-tooltip-overlay.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import HtmlOverlay from './html-overlay'; import HtmlOverlayItem from './html-overlay-item'; diff --git a/modules/react-map-gl-draw/README.md b/modules/react-map-gl-draw/README.md index 0c195f899..390f95953 100644 --- a/modules/react-map-gl-draw/README.md +++ b/modules/react-map-gl-draw/README.md @@ -168,7 +168,7 @@ class App extends Component { [codesandbox](https://codesandbox.io/s/react-map-gl-draw-example-5n97w?file=/src/app.js) ```js -import React, { Component } from 'react'; +import * as React from 'react'; import MapGL from 'react-map-gl'; import { Editor, @@ -191,15 +191,12 @@ const DEFAULT_VIEWPORT = { zoom: 14, }; -class App extends Component { - constructor(props) { - super(props); - this.state = { - viewport: DEFAULT_VIEWPORT, - modeId: null, - modeHandler: null, - }; - } +class App extends React.Component { + state = { + viewport: DEFAULT_VIEWPORT, + modeId: null, + modeHandler: null, + }; _switchMode = evt => { const modeId = evt.target.value === this.state.modeId ? null : evt.target.value; diff --git a/modules/react-map-gl-draw/src/editor.tsx b/modules/react-map-gl-draw/src/editor.tsx index 04b78ed34..bc0d0711b 100644 --- a/modules/react-map-gl-draw/src/editor.tsx +++ b/modules/react-map-gl-draw/src/editor.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { Feature } from '@nebula.gl/edit-modes'; import { GeoJsonType, RenderState, Id } from './types'; diff --git a/modules/react-map-gl-draw/src/mode-handler.tsx b/modules/react-map-gl-draw/src/mode-handler.tsx index 5efd1938f..3adfe08b2 100644 --- a/modules/react-map-gl-draw/src/mode-handler.tsx +++ b/modules/react-map-gl-draw/src/mode-handler.tsx @@ -1,5 +1,5 @@ import { _MapContext as MapContext, MapContextProps } from 'react-map-gl'; -import React, { PureComponent } from 'react'; +import * as React from 'react'; import { ImmutableFeatureCollection, Feature, @@ -45,7 +45,7 @@ const defaultState = { pointerDownMapCoords: null, }; -export default class ModeHandler extends PureComponent { +export default class ModeHandler extends React.PureComponent { static displayName = 'ModeHandler'; static defaultProps = defaultProps; diff --git a/website/src/pages/geojson-editor.tsx b/website/src/pages/geojson-editor.tsx index 8f6ec58f7..5547942f1 100644 --- a/website/src/pages/geojson-editor.tsx +++ b/website/src/pages/geojson-editor.tsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import * as React from 'react'; import styled from 'styled-components'; import Example from '../../../examples/advanced/src/example'; @@ -9,7 +9,7 @@ const Container = styled.div` margin-top: 4rem; `; -export default class GeoJsonEditor extends Component { +export default class GeoJsonEditor extends React.Component { render() { return (