Fix various bugs

This commit is contained in:
Pieter Vander Vennet 2022-02-22 14:13:41 +01:00
parent 30f4be183e
commit 5284f198d8
26 changed files with 339 additions and 119 deletions

View file

@ -373,7 +373,7 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
{
name: "max_snap_distance",
doc: "If the imported object is a LineString or (Multi)Polygon, already existing OSM-points will be reused to construct the geometry of the newly imported way",
defaultValue: "5"
defaultValue: "0.05"
},
{
name: "move_osm_point_if",
@ -381,7 +381,7 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
}, {
name: "max_move_distance",
doc: "If an OSM-point is moved, the maximum amount of meters it is moved. Capped on 20m",
defaultValue: "1"
defaultValue: "0.05"
}, {
name: "snap_onto_layers",
doc: "If no existing nearby point exists, but a line of a specified layer is closeby, snap to this layer instead",
@ -406,24 +406,12 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
AbstractImportButton.importedIds.add(originalFeatureTags.data.id)
const args = this.parseArgs(argument, originalFeatureTags)
const feature = state.allElements.ContainingFeatures.get(id)
console.log("Geometry to auto-import is:", feature)
const geom = feature.geometry
let coordinates: [number, number][]
if (geom.type === "LineString") {
coordinates = geom.coordinates
} else if (geom.type === "Polygon") {
coordinates = geom.coordinates[0]
}
const mergeConfigs = this.GetMergeConfig(args);
const action = this.CreateAction(
const action = ImportWayButton.CreateAction(
feature,
args,
<FeaturePipelineState>state,
mergeConfigs,
coordinates
mergeConfigs
)
await state.changes.applyAction(action)
}
@ -455,18 +443,8 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
// Upload the way to OSM
const geom = feature.geometry
let coordinates: [number, number][]
if (geom.type === "LineString") {
coordinates = geom.coordinates
} else if (geom.type === "Polygon") {
coordinates = geom.coordinates[0]
}
const mergeConfigs = this.GetMergeConfig(args);
let action = this.CreateAction(feature, args, state, mergeConfigs, coordinates);
let action = ImportWayButton.CreateAction(feature, args, state, mergeConfigs);
return this.createConfirmPanelForWay(
state,
args,
@ -508,14 +486,12 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
return mergeConfigs;
}
private CreateAction(feature,
private static CreateAction(feature,
args: { max_snap_distance: string; snap_onto_layers: string; icon: string; text: string; tags: string; newTags: UIEventSource<any>; targetLayer: string },
state: FeaturePipelineState,
mergeConfigs: any[],
coordinates: [number, number][]) {
mergeConfigs: any[]) {
const coors = feature.geometry.coordinates
if (feature.geometry.type === "Polygon" && coors.length > 1) {
if ((feature.geometry.type === "Polygon" ) && coors.length > 1) {
const outer = coors[0]
const inner = [...coors]
inner.splice(0, 1)
@ -531,7 +507,7 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
return new CreateWayWithPointReuseAction(
args.newTags.data,
coordinates,
coors,
state,
mergeConfigs
)

View file

@ -28,7 +28,6 @@ export class LoginToggle extends VariableUiElement {
const login = new LoginButton(text, state)
super(
state.osmConnection.loadingStatus.map(osmConnectionState => {
console.trace("Current osm state is ", osmConnectionState)
if(osmConnectionState === "loading"){
return loading
}

View file

@ -107,7 +107,7 @@ export default class SplitRoadWizard extends Toggle {
.filter(p => GeoOperations.distanceBetween(p[0].geometry.coordinates, coordinates) < 5)
.map(p => p[1])
.sort((a, b) => a - b)
.reverse()
.reverse(/*Copy/derived list, inplace reverse is fine*/)
if (points.length > 0) {
for (const point of points) {
splitPoints.data.splice(point, 1)