Add the possibility to snap onto another layer with imports, add location confirm on input, add metalayer exporting all nodes, various fixes

This commit is contained in:
Pieter Vander Vennet 2021-10-31 02:08:39 +01:00
parent f5d6441b70
commit 23ae9d39c8
24 changed files with 807 additions and 390 deletions

View file

@ -4,23 +4,40 @@ import {Changes} from "../Changes";
import {Tag} from "../../Tags/Tag";
import CreateNewNodeAction from "./CreateNewNodeAction";
import {And} from "../../Tags/And";
import {TagsFilter} from "../../Tags/TagsFilter";
export default class CreateNewWayAction extends OsmChangeAction {
public newElementId: string = undefined
private readonly coordinates: ({ nodeId?: number, lat: number, lon: number })[];
private readonly tags: Tag[];
private readonly _options: { theme: string };
private readonly _options: {
theme: string, existingPointHandling?: {
withinRangeOfM: number,
ifMatches?: TagsFilter,
mode: "reuse_osm_point" | "move_osm_point"
} []
};
/***
* Creates a new way to upload to OSM
* @param tags: the tags to apply to the wya
* @param coordinates: the coordinates. Might have a nodeId, in this case, this node will be used
* @param options
* @param options
*/
constructor(tags: Tag[], coordinates: ({ nodeId?: number, lat: number, lon: number })[], options: {
theme: string
}) {
constructor(tags: Tag[], coordinates: ({ nodeId?: number, lat: number, lon: number })[],
options: {
theme: string,
/**
* IF specified, an existing OSM-point within this range and satisfying the condition 'ifMatches' will be used instead of a new coordinate.
* If multiple points are possible, only the closest point is considered
*/
existingPointHandling?: {
withinRangeOfM: number,
ifMatches?: TagsFilter,
mode: "reuse_osm_point" | "move_osm_point"
} []
}) {
super()
this.coordinates = coordinates;
this.tags = tags;
@ -49,14 +66,14 @@ export default class CreateNewWayAction extends OsmChangeAction {
// We have all created (or reused) all the points!
// Time to create the actual way
const id = changes.getNewID()
const newWay = <ChangeDescription> {
const newWay = <ChangeDescription>{
id,
type: "way",
meta:{
meta: {
theme: this._options.theme,
changeType: "import"
},
@ -67,7 +84,7 @@ export default class CreateNewWayAction extends OsmChangeAction {
}
}
newElements.push(newWay)
this.newElementId = "way/"+id
this.newElementId = "way/" + id
return newElements
}

View file

@ -206,7 +206,7 @@ export abstract class OsmObject {
return result;
}
private static ParseObjects(elements: any[]): OsmObject[] {
public static ParseObjects(elements: any[]): OsmObject[] {
const objects: OsmObject[] = [];
const allNodes: Map<number, OsmNode> = new Map<number, OsmNode>()