Add move option, enable move and delete option on most layers

This commit is contained in:
Pieter Vander Vennet 2021-10-14 03:46:09 +02:00
parent 0a3eb966c1
commit 7e2b73ac5d
33 changed files with 454 additions and 104 deletions

View file

@ -18,7 +18,6 @@ export default class ChangeLocationAction extends OsmChangeAction {
this._id = Number(id.substring("node/".length))
this._newLonLat = newLonLat;
this._meta = meta;
throw "TODO"
}
protected async CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]> {

View file

@ -59,14 +59,13 @@ export abstract class OsmObject {
static async DownloadPropertiesOf(id: string): Promise<any> {
const splitted = id.split("/");
const type = splitted[0];
const idN = Number(splitted[1]);
if (idN < 0) {
return undefined;
}
const url = `${OsmObject.backendURL}api/0.6/${id}`;
const rawData = await Utils.downloadJson(url)
const rawData = await Utils.downloadJsonCached(url, 1000)
return rawData.elements[0].tags
}
@ -80,7 +79,7 @@ export abstract class OsmObject {
const full = (id.startsWith("way")) ? "/full" : "";
const url = `${OsmObject.backendURL}api/0.6/${id}${full}`;
const rawData = await Utils.downloadJson(url)
const rawData = await Utils.downloadJsonCached(url, 1000)
// A full query might contain more then just the requested object (e.g. nodes that are part of a way, where we only want the way)
const parsed = OsmObject.ParseObjects(rawData.elements);
// Lets fetch the object we need
@ -105,7 +104,7 @@ export abstract class OsmObject {
* Beware: their geometry will be incomplete!
*/
public static DownloadReferencingWays(id: string): Promise<OsmWay[]> {
return Utils.downloadJson(`${OsmObject.backendURL}api/0.6/${id}/ways`).then(
return Utils.downloadJsonCached(`${OsmObject.backendURL}api/0.6/${id}/ways`, 60 * 1000).then(
data => {
return data.elements.map(wayInfo => {
const way = new OsmWay(wayInfo.id)
@ -121,7 +120,7 @@ export abstract class OsmObject {
* Beware: their geometry will be incomplete!
*/
public static async DownloadReferencingRelations(id: string): Promise<OsmRelation[]> {
const data = await Utils.downloadJson(`${OsmObject.backendURL}api/0.6/${id}/relations`)
const data = await Utils.downloadJsonCached(`${OsmObject.backendURL}api/0.6/${id}/relations`, 60 * 1000)
return data.elements.map(wayInfo => {
const rel = new OsmRelation(wayInfo.id)
rel.LoadData(wayInfo)
@ -139,7 +138,7 @@ export abstract class OsmObject {
const idN = Number(splitted[1]);
const src = new UIEventSource<OsmObject[]>([]);
OsmObject.historyCache.set(id, src);
Utils.downloadJson(`${OsmObject.backendURL}api/0.6/${type}/${idN}/history`).then(data => {
Utils.downloadJsonCached(`${OsmObject.backendURL}api/0.6/${type}/${idN}/history`, 10 * 60 * 1000).then(data => {
const elements: any[] = data.elements;
const osmObjects: OsmObject[] = []
for (const element of elements) {