@eox/drawtools
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -7,3 +7,3 @@ var Et = Object.defineProperty; | ||
var b = (i, t, e) => Ht(i, typeof t != "symbol" ? t + "" : t, e), et = (i, t, e) => t.has(i) || tt("Cannot " + e); | ||
var y = (i, t, e) => (et(i, t, "read from private field"), e ? e.call(i) : t.get(i)), $ = (i, t, e) => t.has(i) ? tt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), g = (i, t, e, r) => (et(i, t, "write to private field"), r ? r.call(i, e) : t.set(i, e), e); | ||
var y = (i, t, e) => (et(i, t, "read from private field"), e ? e.call(i) : t.get(i)), $ = (i, t, e) => t.has(i) ? tt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), f = (i, t, e, r) => (et(i, t, "write to private field"), r ? r.call(i, e) : t.set(i, e), e); | ||
/** | ||
@@ -49,3 +49,3 @@ * @license | ||
*/ | ||
const { is: It, defineProperty: Lt, getOwnPropertyDescriptor: Ut, getOwnPropertyNames: Ot, getOwnPropertySymbols: Pt, getPrototypeOf: Nt } = Object, v = globalThis, st = v.trustedTypes, Vt = st ? st.emptyScript : "", G = v.reactiveElementPolyfillSupport, L = (i, t) => i, Q = { toAttribute(i, t) { | ||
const { is: It, defineProperty: Lt, getOwnPropertyDescriptor: Ut, getOwnPropertyNames: Ot, getOwnPropertySymbols: Pt, getPrototypeOf: Nt } = Object, v = globalThis, st = v.trustedTypes, Vt = st ? st.emptyScript : "", D = v.reactiveElementPolyfillSupport, L = (i, t) => i, Q = { toAttribute(i, t) { | ||
switch (t) { | ||
@@ -278,3 +278,3 @@ case Boolean: | ||
} | ||
C.elementStyles = [], C.shadowRootOptions = { mode: "open" }, C[L("elementProperties")] = /* @__PURE__ */ new Map(), C[L("finalized")] = /* @__PURE__ */ new Map(), G == null || G({ ReactiveElement: C }), (v.reactiveElementVersions ?? (v.reactiveElementVersions = [])).push("2.0.4"); | ||
C.elementStyles = [], C.shadowRootOptions = { mode: "open" }, C[L("elementProperties")] = /* @__PURE__ */ new Map(), C[L("finalized")] = /* @__PURE__ */ new Map(), D == null || D({ ReactiveElement: C }), (v.reactiveElementVersions ?? (v.reactiveElementVersions = [])).push("2.0.4"); | ||
/** | ||
@@ -299,4 +299,4 @@ * @license | ||
for (; u < a.length && (o.lastIndex = u, p = o.exec(a), p !== null); ) u = o.lastIndex, o === I ? p[1] === "!--" ? o = at : p[1] !== void 0 ? o = lt : p[2] !== void 0 ? (_t.test(p[2]) && (s = RegExp("</" + p[2], "g")), o = w) : p[3] !== void 0 && (o = w) : o === w ? p[0] === ">" ? (o = s ?? I, c = -1) : p[1] === void 0 ? c = -2 : (c = o.lastIndex - p[2].length, d = p[1], o = p[3] === void 0 ? w : p[3] === '"' ? dt : ct) : o === dt || o === ct ? o = w : o === at || o === lt ? o = I : (o = w, s = void 0); | ||
const f = o === w && i[l + 1].startsWith("/>") ? " " : ""; | ||
n += o === I ? a + Bt : c >= 0 ? (r.push(d), a.slice(0, c) + $t + a.slice(c) + m + f) : a + m + (c === -2 ? l : f); | ||
const g = o === w && i[l + 1].startsWith("/>") ? " " : ""; | ||
n += o === I ? a + Bt : c >= 0 ? (r.push(d), a.slice(0, c) + $t + a.slice(c) + m + g) : a + m + (c === -2 ? l : g); | ||
} | ||
@@ -318,4 +318,4 @@ return [xt(i, n + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r]; | ||
if (s.hasAttributes()) for (const c of s.getAttributeNames()) if (c.endsWith($t)) { | ||
const u = p[o++], f = s.getAttribute(c).split(m), j = /([.?@])?(.*)/.exec(u); | ||
a.push({ type: 1, index: n, name: j[2], strings: f, ctor: j[1] === "." ? qt : j[1] === "?" ? Dt : j[1] === "@" ? Gt : D }), s.removeAttribute(c); | ||
const u = p[o++], g = s.getAttribute(c).split(m), j = /([.?@])?(.*)/.exec(u); | ||
a.push({ type: 1, index: n, name: j[2], strings: g, ctor: j[1] === "." ? qt : j[1] === "?" ? Gt : j[1] === "@" ? Dt : G }), s.removeAttribute(c); | ||
} else c.startsWith(m) && (a.push({ type: 6, index: n }), s.removeAttribute(c)); | ||
@@ -326,3 +326,3 @@ if (_t.test(s.tagName)) { | ||
s.textContent = q ? q.emptyScript : ""; | ||
for (let f = 0; f < u; f++) s.append(c[f], O()), _.nextNode(), a.push({ type: 2, index: ++n }); | ||
for (let g = 0; g < u; g++) s.append(c[g], O()), _.nextNode(), a.push({ type: 2, index: ++n }); | ||
s.append(c[u], O()); | ||
@@ -442,3 +442,3 @@ } | ||
} | ||
class D { | ||
class G { | ||
get tagName() { | ||
@@ -468,3 +468,3 @@ return this.element.tagName; | ||
} | ||
class qt extends D { | ||
class qt extends G { | ||
constructor() { | ||
@@ -477,3 +477,3 @@ super(...arguments), this.type = 3; | ||
} | ||
class Dt extends D { | ||
class Gt extends G { | ||
constructor() { | ||
@@ -486,3 +486,3 @@ super(...arguments), this.type = 4; | ||
} | ||
class Gt extends D { | ||
class Dt extends G { | ||
constructor(t, e, r, s, n) { | ||
@@ -780,3 +780,3 @@ super(t, e, r, s, n), this.type = 5; | ||
const { drawDisabled: e, discardDisabled: r } = ne(this); | ||
g(this, V, e), g(this, B, r); | ||
f(this, V, e), f(this, B, r); | ||
} | ||
@@ -944,3 +944,3 @@ /** | ||
document.querySelector(i) : t = i, t; | ||
}, ft = (i, t) => { | ||
}, gt = (i, t) => { | ||
var n; | ||
@@ -1014,5 +1014,10 @@ const r = pe(i.for), s = r.map; | ||
setTimeout(() => { | ||
i.drawnFeatures = i.drawLayer.getSource().getFeatures(), i.updateGeoJSON(), i.requestUpdate(), t(); | ||
const r = i.drawLayer.getSource().getFeatures(), s = i.eoxMap.projection || "EPSG:3857", n = i.projection; | ||
i.drawnFeatures = n ? r.map((o) => { | ||
o = o.clone(); | ||
const l = o.getGeometry().transform(s, n); | ||
return o.setGeometry(l), o; | ||
}) : r, i.updateGeoJSON(), i.requestUpdate(), t(); | ||
}, 0); | ||
}, fe = (i) => { | ||
}, ge = (i) => { | ||
const t = (s) => { | ||
@@ -1075,10 +1080,10 @@ (s == null ? void 0 : s.detail.id) !== "SelectLayerClickInteraction" || !s.detail.feature || (i.drawLayer.getSource().addFeature(s.detail.feature), i.eoxMap.dispatchEvent( | ||
i.draw = t.selectInteractions.SelectLayerClickInteraction, o.setActive(!1), t.selectInteractions.SelectLayerClickInteraction.setActive(!1), t.selectInteractions.SelectLayerHoverInteraction.setActive(!1); | ||
}, ge = (i, t, e, r) => { | ||
}, fe = (i, t, e, r) => { | ||
if (t) { | ||
if (e) { | ||
r && e !== r && gt(i, t), X(i, t, e); | ||
r && e !== r && ft(i, t), X(i, t, e); | ||
return; | ||
} | ||
if (!e && r) { | ||
gt(i, t); | ||
ft(i, t); | ||
return; | ||
@@ -1088,3 +1093,3 @@ } | ||
}; | ||
function gt(i, t) { | ||
function ft(i, t) { | ||
t && (i.discardDrawing(), i.selectionEvents.removeSelectionEvent(), i.draw = /** @type {import("ol/interaction").Draw} */ | ||
@@ -1142,3 +1147,3 @@ t.interactions.drawInteraction, t.selectInteractions.SelectLayerClickInteraction.remove(), t.selectInteractions.SelectLayerHoverInteraction.remove()); | ||
$(this, k); | ||
this.allowModify = !1, this.for = "eox-map", this.currentlyDrawing = !1, this.draw = null, this.drawLayer = null, this.layerId = "", this.drawnFeatures = [], this.modify = null, this.multipleFeatures = !1, this.importFeatures = !1, this.showEditor = !1, this.showList = !1, this.type = "Polygon", this.unstyled = !1, this.noShadow = !1, this.selectionEvents = null; | ||
this.allowModify = !1, this.for = "eox-map", this.currentlyDrawing = !1, this.draw = null, this.drawLayer = null, this.layerId = "", this.drawnFeatures = [], this.modify = null, this.multipleFeatures = !1, this.importFeatures = !1, this.showEditor = !1, this.showList = !1, this.projection = "EPSG:4326", this.type = "Polygon", this.unstyled = !1, this.noShadow = !1, this.selectionEvents = null; | ||
} | ||
@@ -1160,2 +1165,3 @@ // Define properties with defaults and types | ||
showList: { attribute: "show-list", type: Boolean }, | ||
projection: { type: String }, | ||
noShadow: { type: Boolean }, | ||
@@ -1172,3 +1178,3 @@ type: { type: String }, | ||
set layerId(e) { | ||
ge(this, this.eoxMap, e, y(this, k)), g(this, k, e); | ||
fe(this, this.eoxMap, e, y(this, k)), f(this, k, e); | ||
} | ||
@@ -1219,3 +1225,3 @@ get layerId() { | ||
updateGeoJSON() { | ||
g(this, R, JSON.stringify( | ||
f(this, R, JSON.stringify( | ||
this.eoxMap.parseFeature(this.drawnFeatures) || ut, | ||
@@ -1248,9 +1254,9 @@ void 0, | ||
firstUpdated() { | ||
const { EoxMap: e, OlMap: r } = ft(this, this.multipleFeatures); | ||
this.eoxMap = e, g(this, H, r), this.selectionEvents = fe(this), this.importFeatures && ve(this, this.eoxMap), this.updateGeoJSON(), this.requestUpdate(); | ||
const { EoxMap: e, OlMap: r } = gt(this, this.multipleFeatures); | ||
this.eoxMap = e, f(this, H, r), this.selectionEvents = ge(this), this.importFeatures && ve(this, this.eoxMap), this.updateGeoJSON(), this.requestUpdate(); | ||
} | ||
updated(e) { | ||
if (e.has("for")) { | ||
const { EoxMap: r, OlMap: s } = ft(this, this.multipleFeatures); | ||
this.eoxMap = r, g(this, H, s); | ||
const { EoxMap: r, OlMap: s } = gt(this, this.multipleFeatures); | ||
this.eoxMap = r, f(this, H, s); | ||
} | ||
@@ -1263,3 +1269,3 @@ } | ||
const r = y(this, E); | ||
g(this, E, e), this.requestUpdate("eoxMap", r); | ||
f(this, E, e), this.requestUpdate("eoxMap", r); | ||
} | ||
@@ -1266,0 +1272,0 @@ // Render method for UI display |
{ | ||
"name": "@eox/drawtools", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"type": "module", | ||
"devDependencies": { | ||
"ol": "^10.0.0", | ||
"vite": "^5.0.2" | ||
@@ -14,2 +13,3 @@ }, | ||
"files": [ | ||
"types", | ||
"dist", | ||
@@ -19,3 +19,15 @@ "src" | ||
"main": "./src/main.js", | ||
"types": "./types/drawtools/src/main.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
".": [ | ||
"./types/drawtools/src/main.d.ts" | ||
], | ||
"src/*": [ | ||
"./types/drawtools/src/*" | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"prepack": "tsc -p tsconfig.build.json || true", | ||
"build": "vite build", | ||
@@ -26,4 +38,5 @@ "watch": "vite build --watch" | ||
"@eox/elements-utils": "^0.0.1", | ||
"lit": "^3.2.0" | ||
"lit": "^3.2.0", | ||
"ol": "^10.0.0" | ||
} | ||
} |
@@ -41,2 +41,3 @@ import { LitElement, html, nothing } from "lit"; | ||
showList: { attribute: "show-list", type: Boolean }, | ||
projection: { type: String }, | ||
noShadow: { type: Boolean }, | ||
@@ -138,2 +139,6 @@ type: { type: String }, | ||
this.showList = false; | ||
/** | ||
* Projection of the emitted drawn features | ||
*/ | ||
this.projection = "EPSG:4326"; | ||
@@ -140,0 +145,0 @@ /** |
@@ -11,3 +11,17 @@ /** | ||
// Update drawnFeatures with features from drawLayer's source | ||
EoxDrawTool.drawnFeatures = EoxDrawTool.drawLayer.getSource().getFeatures(); | ||
const drawnFeatures = EoxDrawTool.drawLayer.getSource().getFeatures(); | ||
// Transform drawn features to the desired projection | ||
const source = EoxDrawTool.eoxMap.projection || "EPSG:3857"; | ||
// has a default value of EPSG:4326 | ||
const destination = EoxDrawTool.projection; | ||
// Update drawnFeatures with transformed features if the destination is defined | ||
EoxDrawTool.drawnFeatures = destination | ||
? drawnFeatures.map((feat) => { | ||
feat = feat.clone(); | ||
const transformed = feat.getGeometry().transform(source, destination); | ||
feat.setGeometry(transformed); | ||
return feat; | ||
}) | ||
: drawnFeatures; | ||
EoxDrawTool.updateGeoJSON(); | ||
@@ -14,0 +28,0 @@ EoxDrawTool.requestUpdate(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
233469
1
149
4643
3
+ Addedol@^10.0.0
+ Added@petamoriken/float16@3.9.1(transitive)
+ Added@types/rbush@4.0.0(transitive)
+ Addedcolor-name@2.0.0(transitive)
+ Addedcolor-parse@2.0.2(transitive)
+ Addedcolor-rgba@3.0.0(transitive)
+ Addedcolor-space@2.0.1(transitive)
+ Addedearcut@3.0.1(transitive)
+ Addedgeotiff@2.1.3(transitive)
+ Addedlerc@3.0.0(transitive)
+ Addedol@10.3.1(transitive)
+ Addedpako@2.1.0(transitive)
+ Addedparse-headers@2.0.5(transitive)
+ Addedpbf@4.0.1(transitive)
+ Addedprotocol-buffers-schema@3.6.0(transitive)
+ Addedquick-lru@6.1.2(transitive)
+ Addedquickselect@3.0.0(transitive)
+ Addedrbush@4.0.1(transitive)
+ Addedresolve-protobuf-schema@2.1.0(transitive)
+ Addedweb-worker@1.3.0(transitive)
+ Addedxml-utils@1.10.1(transitive)
+ Addedzstddec@0.1.0(transitive)