New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eox/drawtools

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eox/drawtools - npm Package Compare versions

Comparing version

to
0.13.0

src/helpers/features-to-geojson.js

4

package.json
{
"name": "@eox/drawtools",
"version": "0.12.0",
"version": "0.13.0",
"type": "module",

@@ -35,3 +35,3 @@ "devDependencies": {

"dependencies": {
"@eox/elements-utils": "^0.0.1",
"@eox/elements-utils": "^0.1.1",
"lit": "^3.2.0",

@@ -38,0 +38,0 @@ "ol": "^10.0.0"

// Import and export helper functions
export { default as copyTextToClipboard } from "./copy-text-to-clipboard"; // Copy a given text string to the clipboard
export { default as featuresToGeoJson } from "./features-to-geojson"; // Convert a feature to a GeoJSON representation
export { default as featuresToWKT } from "./features-to-wkt"; // Convert a feature to a Well-Known Text (WKT) representation

@@ -43,2 +43,3 @@ import { LitElement, html, nothing } from "lit";

noShadow: { type: Boolean },
format: { type: String },
type: { type: String },

@@ -151,2 +152,15 @@ unstyled: { type: Boolean },

/**
* @type {ReturnType<typeof import("./methods/draw/create-select-handler").default>}
*/
this.selectionEvents = null;
/**
* The format in which the drawn features should be emitted
*
* @default "feature"
* @type {"feature"| "geojson" | "wkt"}
*/
this.format = "feature";
/**
* Render the element without additional styles

@@ -162,6 +176,2 @@ */

this.noShadow = false;
/**
* @type {ReturnType<typeof import("./methods/draw/create-select-handler").default>}
*/
this.selectionEvents = null;
}

@@ -240,3 +250,6 @@

emitDrawnFeatures() {
const drawUpdateEvent = () => {
/**
* @param {import("./methods/draw/emit-drawn-features").EmitFormat} value
*/
const drawUpdateEvent = (value) => {
/**

@@ -247,5 +260,3 @@ * Fires whenever features are added, modified or discarded, where the event detail

*/
this.dispatchEvent(
new CustomEvent("drawupdate", { detail: this.drawnFeatures }),
);
this.dispatchEvent(new CustomEvent("drawupdate", { detail: value }));
};

@@ -252,0 +263,0 @@ emitDrawnFeaturesMethod(this, drawUpdateEvent);

@@ -0,1 +1,9 @@

import { featuresToGeoJson, featuresToWKT } from "../../helpers";
/***
* @typedef {import("ol").Feature[]
* | ReturnType<typeof featuresToGeoJson>
* | ReturnType<typeof featuresToWKT>} EmitFormat
*/
/**

@@ -5,3 +13,3 @@ * Emits drawn features after a timeout to allow updating drawn features.

* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
* @param {Function} drawUpdateEvent - event to be triggered after drawFeature is updated
* @param {(value:EmitFormat) => void} drawUpdateEvent - event to be triggered after drawFeature is updated
*/

@@ -27,2 +35,19 @@ const emitDrawnFeaturesMethod = (EoxDrawTool, drawUpdateEvent) => {

// Emit features based on the format provided
let value;
switch (EoxDrawTool.format) {
case "geojson":
value = featuresToGeoJson(EoxDrawTool.drawnFeatures);
break;
case "wkt":
value = featuresToWKT(EoxDrawTool.drawnFeatures);
break;
case "feature":
value = EoxDrawTool.drawnFeatures;
break;
default:
value = EoxDrawTool.drawnFeatures;
break;
}
EoxDrawTool.updateGeoJSON();

@@ -32,3 +57,3 @@ EoxDrawTool.requestUpdate();

// Triggering `drawupdate` event after drawFeature is updated
drawUpdateEvent();
drawUpdateEvent(value);
};

@@ -35,0 +60,0 @@

export { default as copyTextToClipboard } from "./copy-text-to-clipboard";
export { default as featuresToGeoJson } from "./features-to-geojson";
export { default as featuresToWKT } from "./features-to-wkt";
//# sourceMappingURL=index.d.ts.map

@@ -63,2 +63,5 @@ /**

};
format: {
type: StringConstructor;
};
type: {

@@ -139,2 +142,13 @@ type: StringConstructor;

/**
* @type {ReturnType<typeof import("./methods/draw/create-select-handler").default>}
*/
selectionEvents: ReturnType<typeof import("./methods/draw/create-select-handler").default>;
/**
* The format in which the drawn features should be emitted
*
* @default "feature"
* @type {"feature"| "geojson" | "wkt"}
*/
format: "feature" | "geojson" | "wkt";
/**
* Render the element without additional styles

@@ -150,6 +164,2 @@ */

/**
* @type {ReturnType<typeof import("./methods/draw/create-select-handler").default>}
*/
selectionEvents: ReturnType<typeof import("./methods/draw/create-select-handler").default>;
/**
* @onClick Event handler triggered to start drawing on the map.

@@ -156,0 +166,0 @@ */

export default emitDrawnFeaturesMethod;
/**
* *
*/
export type EmitFormat = import("ol").Feature[] | ReturnType<typeof featuresToGeoJson> | ReturnType<typeof featuresToWKT>;
/***
* @typedef {import("ol").Feature[]
* | ReturnType<typeof featuresToGeoJson>
* | ReturnType<typeof featuresToWKT>} EmitFormat
*/
/**
* Emits drawn features after a timeout to allow updating drawn features.
*
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
* @param {Function} drawUpdateEvent - event to be triggered after drawFeature is updated
* @param {(value:EmitFormat) => void} drawUpdateEvent - event to be triggered after drawFeature is updated
*/
declare function emitDrawnFeaturesMethod(EoxDrawTool: import("../../main").EOxDrawTools, drawUpdateEvent: Function): void;
declare function emitDrawnFeaturesMethod(EoxDrawTool: import("../../main").EOxDrawTools, drawUpdateEvent: (value: EmitFormat) => void): void;
import { featuresToGeoJson } from "../../helpers";
import { featuresToWKT } from "../../helpers";
//# sourceMappingURL=emit-drawn-features.d.ts.map

@@ -40,4 +40,13 @@ /**

selectStyleLayer: any;
/**
* Listener to handle selection events
* @param {import("ol/MapBrowserEvent").default<UIEvent>} event
* **/
listener: (event: import("ol/MapBrowserEvent").default<UIEvent>) => void;
changeSourceListener: () => void;
/**
* Adds a listener on pointermove
*/
pointerMoveListener: (e: any) => void;
/**
* Sets the active state of the interaction.

@@ -44,0 +53,0 @@ * @param {boolean} active - Whether the interaction should be active.

@@ -265,5 +265,5 @@ /**

*
* @param {string} id - The ID of the select interaction to remove.
* @param {string | number} id - The ID of the select interaction to remove.
*/
removeSelect(id: string): void;
removeSelect(id: string | number): void;
/**

@@ -270,0 +270,0 @@ * Removes a control from the map by its ID.

@@ -11,6 +11,6 @@ /**

*
* @param {string} id - The identifier for the select interaction to be removed.
* @param {string | number} id - The identifier for the select interaction to be removed.
* @param {import("../../main").EOxMap} EOxMap - The map object containing the select interactions list.
*/
export function removeSelectMethod(id: string, EOxMap: import("../../main").EOxMap): void;
export function removeSelectMethod(id: string | number, EOxMap: import("../../main").EOxMap): void;
/**

@@ -17,0 +17,0 @@ * Removes a control from the map and deletes it from the map controls list in EOxMap.

@@ -58,2 +58,4 @@ export type DrawOptions = Omit<import("ol/interaction/Draw").Options, "type"> & {

geometryFunction?: import("ol/interaction/Draw").GeometryFunction;
cursor?: "string";
atPixelOptions?: import("ol/Map").AtPixelOptions;
};

@@ -60,0 +62,0 @@ export type ControlOptions = import("ol/control/Control").Options;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet