First steps for a delete button

This commit is contained in:
Pieter Vander Vennet 2021-06-28 18:06:54 +02:00
parent b7798a470c
commit 985e97d43b
10 changed files with 246 additions and 75 deletions

View file

@ -13,6 +13,7 @@ export default class UserDetails {
public loggedIn = false;
public name = "Not logged in";
public uid: number;
public csCount = 0;
public img: string;
public unreadMessages = 0;
@ -167,6 +168,7 @@ export class OsmConnection {
data.loggedIn = true;
console.log("Login completed, userinfo is ", userInfo);
data.name = userInfo.getAttribute('display_name');
data.uid= Number(userInfo.getAttribute("id"))
data.csCount = userInfo.getElementsByTagName("changesets")[0].getAttribute("count");
data.img = undefined;

View file

@ -43,11 +43,47 @@ export abstract class OsmObject {
}
}
public static DownloadHistory(id: string, continuation: (versions: OsmObject[]) => void): void {
/**
* Downloads the ways that are using this node.
* Beware: their geometry will be incomplete!
* @param id
* @param continuation
* @constructor
*/
public static DownloadReferencingWays(id: string, continuation: (referencingWays: OsmWay[]) => void){
Utils.downloadJson(`https://www.openStreetMap.org/api/0.6/${id}/ways`)
.then(data => {
const ways = data.elements.map(wayInfo => {
const way = new OsmWay(wayInfo.id)
way.LoadData(wayInfo)
return way
})
continuation(ways)
})
}
/**
* Downloads the relations that are using this feature.
* Beware: their geometry will be incomplete!
* @param id
* @param continuation
* @constructor
*/
public static DownloadReferencingRelations(id: string, continuation: (referencingRelations: OsmRelation[]) => void){
Utils.downloadJson(`https://www.openStreetMap.org/api/0.6/${id}/relations`)
.then(data => {
const rels = data.elements.map(wayInfo => {
const rel = new OsmRelation(wayInfo.id)
rel.LoadData(wayInfo)
return rel
})
continuation(rels)
})
}
public static DownloadHistory(id: string, continuation: (versions: OsmObject[]) => void): void{
const splitted = id.split("/");
const type = splitted[0];
const idN = splitted[1];
$.getJSON("https://openStreetMap.org/api/0.6/" + type + "/" + idN + "/history", data => {
$.getJSON("https://www.openStreetMap.org/api/0.6/" + type + "/" + idN + "/history", data => {
const elements: any[] = data.elements;
const osmObjects: OsmObject[] = []
for (const element of elements) {