diff --git a/assets/layers/conflation/conflation.json b/assets/layers/conflation/conflation.json index f21b5f715..4718cb475 100644 --- a/assets/layers/conflation/conflation.json +++ b/assets/layers/conflation/conflation.json @@ -22,7 +22,7 @@ ] }, "icon": { - "render": "addSmall:#000", + "render": "addSmall", "mappings": [ { "if": "detach=yes", diff --git a/package-lock.json b/package-lock.json index 87f10618a..4c11ea403 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mapcomplete", - "version": "0.36.9", + "version": "0.36.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mapcomplete", - "version": "0.36.9", + "version": "0.36.11", "license": "GPL-3.0-or-later", "dependencies": { "@rgossiaux/svelte-headlessui": "^1.0.2", @@ -15,6 +15,7 @@ "@turf/boolean-intersects": "^6.5.0", "@turf/buffer": "^6.5.0", "@turf/collect": "^6.5.0", + "@turf/difference": "^6.5.0", "@turf/distance": "^6.5.0", "@turf/length": "^6.5.0", "@turf/turf": "^6.5.0", diff --git a/package.json b/package.json index a244bbc6e..284e24768 100644 --- a/package.json +++ b/package.json @@ -103,6 +103,7 @@ "@turf/boolean-intersects": "^6.5.0", "@turf/buffer": "^6.5.0", "@turf/collect": "^6.5.0", + "@turf/difference": "^6.5.0", "@turf/distance": "^6.5.0", "@turf/length": "^6.5.0", "@turf/turf": "^6.5.0", diff --git a/src/Logic/ExtraFunctions.ts b/src/Logic/ExtraFunctions.ts index 27140ba32..497ecea46 100644 --- a/src/Logic/ExtraFunctions.ts +++ b/src/Logic/ExtraFunctions.ts @@ -264,7 +264,8 @@ class ClosestNObjectFunc implements ExtraFunction { const bbox = GeoOperations.bbox( GeoOperations.buffer(GeoOperations.bbox(feature), maxDistance) ) - allFeatures = params.getFeaturesWithin(name, new BBox(bbox.geometry.coordinates)) + const coors = <[number, number][]>bbox.geometry.coordinates + allFeatures = params.getFeaturesWithin(name, new BBox(coors)) } else { allFeatures = [features] } diff --git a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts index 350feaabc..951b688c5 100644 --- a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts +++ b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts @@ -39,8 +39,8 @@ export default class FeatureSourceMerger implements IndexedFeatureSource { }) } - protected addData(featuress: Feature[][]) { - featuress = Utils.NoNull(featuress) + protected addData(sources: Feature[][]) { + sources = Utils.NoNull(sources) let somethingChanged = false const all: Map = new Map() const unseen = new Set() @@ -51,7 +51,7 @@ export default class FeatureSourceMerger implements IndexedFeatureSource { unseen.add(oldValue.properties.id) } - for (const features of featuress) { + for (const features of sources) { for (const f of features) { const id = f.properties.id unseen.delete(id) diff --git a/src/Logic/FeatureSource/TiledFeatureSource/DynamicTileSource.ts b/src/Logic/FeatureSource/TiledFeatureSource/DynamicTileSource.ts index ea1155d00..e8e69ee2a 100644 --- a/src/Logic/FeatureSource/TiledFeatureSource/DynamicTileSource.ts +++ b/src/Logic/FeatureSource/TiledFeatureSource/DynamicTileSource.ts @@ -6,7 +6,7 @@ import FeatureSourceMerger from "../Sources/FeatureSourceMerger" /*** * A tiled source which dynamically loads the required tiles at a fixed zoom level. - * A single featureSource will be initiliased for every tile in view; which will alter be merged into this featureSource + * A single featureSource will be initialized for every tile in view; which will later be merged into this featureSource */ export default class DynamicTileSource extends FeatureSourceMerger { constructor( diff --git a/src/Logic/GeoOperations.ts b/src/Logic/GeoOperations.ts index d47eec5c7..c90869b83 100644 --- a/src/Logic/GeoOperations.ts +++ b/src/Logic/GeoOperations.ts @@ -153,7 +153,7 @@ export class GeoOperations { continue } - const intersection = GeoOperations.calculateInstersection( + const intersection = GeoOperations.calculateIntersection( feature, otherFeature, featureBBox @@ -184,7 +184,7 @@ export class GeoOperations { // Calculate the surface area of the intersection - const intersection = this.calculateInstersection(feature, otherFeature, featureBBox) + const intersection = this.calculateIntersection(feature, otherFeature, featureBBox) if (intersection === null) { continue } @@ -1029,7 +1029,7 @@ export class GeoOperations { * Returns 0 if both are linestrings * Returns null if the features are not intersecting */ - private static calculateInstersection( + private static calculateIntersection( feature, otherFeature, featureBBox: BBox, @@ -1099,7 +1099,7 @@ export class GeoOperations { return null } if (otherFeature.geometry.type === "LineString") { - return this.calculateInstersection( + return this.calculateIntersection( otherFeature, feature, otherFeatureBBox, @@ -1119,6 +1119,19 @@ export class GeoOperations { // See https://github.com/Turfjs/turf/pull/2238 return null } + if (e.message.indexOf("SweepLine tree") >= 0) { + console.log("Applying fallback intersection...") + const intersection = turf.intersect( + turf.truncate(feature), + turf.truncate(otherFeature) + ) + if (intersection == null) { + return null + } + return turf.area(intersection) // in m² + // Another workaround: https://github.com/Turfjs/turf/issues/2258 + } + throw e } } diff --git a/src/Logic/MetaTagging.ts b/src/Logic/MetaTagging.ts index 75cbcc712..6477bbac7 100644 --- a/src/Logic/MetaTagging.ts +++ b/src/Logic/MetaTagging.ts @@ -274,17 +274,20 @@ export default class MetaTagging { console.warn( "Could not calculate a " + (isStrict ? "strict " : "") + - " calculated tag for key " + - key + - " defined by " + - code + - " (in layer" + - layerId + + "calculated tag for key", + key, + "for feature", + feat.properties.id, + " defined by", + code, + "(in layer", + layerId + ") due to \n" + e + "\n. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e, - e.stack + e.stack, + { feat } ) MetaTagging.errorPrintCount++ if (MetaTagging.errorPrintCount == MetaTagging.stopErrorOutputAt) { diff --git a/src/Logic/Osm/Changes.ts b/src/Logic/Osm/Changes.ts index 91fb20852..935bb80b3 100644 --- a/src/Logic/Osm/Changes.ts +++ b/src/Logic/Osm/Changes.ts @@ -148,7 +148,6 @@ export class Changes { } public applyChanges(changes: ChangeDescription[]) { - console.log("Received changes:", changes) this.pendingChanges.data.push(...changes) this.pendingChanges.ping() this.allChanges.data.push(...changes) @@ -191,7 +190,6 @@ export class Changes { } // This is a new object that should be created states.set(id, "created") - console.log("Creating object for changeDescription", change) let osmObj: OsmObject = undefined switch (change.type) { case "node": @@ -255,7 +253,6 @@ export class Changes { const nlon = Utils.Round7(change.changes.lon) const n = obj if (n.lat !== nlat || n.lon !== nlon) { - console.log("Node moved:", n.lat, nlat, n.lon, nlon) n.lat = nlat n.lon = nlon changed = true @@ -443,7 +440,6 @@ export class Changes { objects.forEach((obj) => SimpleMetaTagger.removeBothTagging(obj.tags)) } - console.log("Got the fresh objects!", objects, "pending: ", pending) if (pending.length == 0) { console.log("No pending changes...") return true @@ -528,9 +524,7 @@ export class Changes { await this._changesetHandler.UploadChangeset( (csId, remappings) => { if (remappings.size > 0) { - console.log("Rewriting pending changes from", pending, "with", remappings) pending = pending.map((ch) => ChangeDescriptionTools.rewriteIds(ch, remappings)) - console.log("Result is", pending) } const changes: { diff --git a/src/UI/Map/Icon.svelte b/src/UI/Map/Icon.svelte index df1cc1d12..7bec894bc 100644 --- a/src/UI/Map/Icon.svelte +++ b/src/UI/Map/Icon.svelte @@ -30,6 +30,7 @@ import Direction_gradient from "../../assets/svg/Direction_gradient.svelte" import Mastodon from "../../assets/svg/Mastodon.svelte" import Party from "../../assets/svg/Party.svelte" + import AddSmall from "../../assets/svg/AddSmall.svelte" /** * Renders a single icon. @@ -111,6 +112,8 @@ {:else if icon === "party"} + {:else if icon === "addSmall"} + {:else} {/if} diff --git a/src/UI/Popup/AutoApplyButton.ts b/src/UI/Popup/AutoApplyButton.ts index 4f89f23c5..b711e71e5 100644 --- a/src/UI/Popup/AutoApplyButton.ts +++ b/src/UI/Popup/AutoApplyButton.ts @@ -159,7 +159,7 @@ class ApplyButton extends UIElement { private async Run() { try { console.log("Applying auto-action on " + this.target_feature_ids.length + " features") - + const appliedOn: string[] = [] for (let i = 0; i < this.target_feature_ids.length; i++) { const targetFeatureId = this.target_feature_ids[i] const feature = this.state.indexedFeatures.featuresById.data.get(targetFeatureId) @@ -190,6 +190,7 @@ class ApplyButton extends UIElement { specialRendering.args ) } + appliedOn.push(targetFeatureId) if (i % 50 === 0) { await this.state.changes.flushChanges("Auto button: intermediate save") } @@ -198,6 +199,12 @@ class ApplyButton extends UIElement { console.log("Flushing changes...") await this.state.changes.flushChanges("Auto button: done") this.buttonState.setData("done") + console.log( + "Applied changes onto", + appliedOn.length, + "items, unique IDs:", + new Set(appliedOn).size + ) } catch (e) { console.error("Error while running autoApply: ", e) this.buttonState.setData({ error: e })