forked from MapComplete/MapComplete
More work on the custom theme generator, add aed template, move bookcases to json template
This commit is contained in:
parent
146552e62c
commit
560c8e1567
34 changed files with 1048 additions and 590 deletions
|
@ -53,7 +53,7 @@ export class FilteredLayer {
|
|||
this._style = layerDef.style;
|
||||
if (this._style === undefined) {
|
||||
this._style = function () {
|
||||
return {icon: {iconUrl: "./assets/bug.svg"}, color: "#000000"};
|
||||
return {icon: {iconUrl: "./assets/bug.svg"}, color: "#000"};
|
||||
}
|
||||
}
|
||||
this.name = name;
|
||||
|
@ -94,9 +94,9 @@ export class FilteredLayer {
|
|||
var tags = TagUtils.proprtiesToKV(feature.properties);
|
||||
if (this.filters.matches(tags)) {
|
||||
const centerPoint = GeoOperations.centerpoint(feature);
|
||||
feature.properties["_surface"] = GeoOperations.surfaceAreaInSqMeters(feature);
|
||||
const lat = centerPoint.geometry.coordinates[1];
|
||||
const lon = centerPoint.geometry.coordinates[0]
|
||||
feature.properties["_surface"] = ""+GeoOperations.surfaceAreaInSqMeters(feature);
|
||||
const lat = ""+centerPoint.geometry.coordinates[1];
|
||||
const lon = ""+centerPoint.geometry.coordinates[0]
|
||||
feature.properties["_lon"] = lat;
|
||||
feature.properties["_lat"] = lon;
|
||||
FilteredLayer.grid.getCode(lat, lon, (error, code) => {
|
||||
|
@ -233,8 +233,6 @@ export class FilteredLayer {
|
|||
const style = self._style(featureX.properties);
|
||||
if (featureX === feature) {
|
||||
console.log("Selected element is", featureX.properties.id)
|
||||
// style.weight = style.weight * 2;
|
||||
// console.log(style)
|
||||
}
|
||||
return style;
|
||||
});
|
||||
|
|
|
@ -19,12 +19,9 @@ export class Changes {
|
|||
|
||||
public readonly pendingChangesES = new UIEventSource<number>(this._pendingChanges.length);
|
||||
public readonly isSaving = new UIEventSource(false);
|
||||
private readonly _changesetComment: string;
|
||||
|
||||
constructor(
|
||||
changesetComment: string,
|
||||
state: State) {
|
||||
this._changesetComment = changesetComment;
|
||||
|
||||
this.SetupAutoSave(state);
|
||||
this.LastEffortSave();
|
||||
|
@ -74,6 +71,9 @@ export class Changes {
|
|||
const eventSource = State.state.allElements.getElement(elementId);
|
||||
|
||||
eventSource.data[key] = value;
|
||||
if(value === undefined || value === ""){
|
||||
delete eventSource.data[key];
|
||||
}
|
||||
eventSource.ping();
|
||||
// We get the id from the event source, as that ID might be rewritten
|
||||
this._pendingChanges.push({elementId: eventSource.data.id, key: key, value: value});
|
||||
|
@ -223,7 +223,7 @@ export class Changes {
|
|||
|
||||
console.log("Beginning upload...");
|
||||
// At last, we build the changeset and upload
|
||||
State.state.osmConnection.UploadChangeset(self._changesetComment,
|
||||
State.state.osmConnection.UploadChangeset(
|
||||
function (csId) {
|
||||
|
||||
let modifications = "";
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import osmAuth from "osm-auth";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import {CustomLayersState} from "../CustomLayersState";
|
||||
import {State} from "../../State";
|
||||
|
||||
export class UserDetails {
|
||||
|
||||
|
@ -262,16 +263,16 @@ export class OsmConnection {
|
|||
const newId = parseInt(node.attributes.new_id.value);
|
||||
if (oldId !== undefined && newId !== undefined &&
|
||||
!isNaN(oldId) && !isNaN(newId)) {
|
||||
mapping["node/"+oldId] = "node/"+newId;
|
||||
mapping["node/" + oldId] = "node/" + newId;
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
public UploadChangeset(comment: string, generateChangeXML: ((csid: string) => string),
|
||||
handleMapping: ((idMapping: any) => void),
|
||||
continuation: (() => void)) {
|
||||
public UploadChangeset(generateChangeXML: (csid: string) => string,
|
||||
handleMapping: (idMapping: any) => void,
|
||||
continuation: () => void) {
|
||||
|
||||
if (this._dryRun) {
|
||||
console.log("NOT UPLOADING as dryrun is true");
|
||||
|
@ -282,7 +283,7 @@ export class OsmConnection {
|
|||
}
|
||||
|
||||
const self = this;
|
||||
this.OpenChangeset(comment,
|
||||
this.OpenChangeset(
|
||||
function (csId) {
|
||||
var changesetXML = generateChangeXML(csId);
|
||||
self.AddChange(csId, changesetXML,
|
||||
|
@ -300,17 +301,20 @@ export class OsmConnection {
|
|||
}
|
||||
|
||||
|
||||
private OpenChangeset(comment: string, continuation: ((changesetId: string) => void)) {
|
||||
private OpenChangeset(continuation: (changesetId: string) => void) {
|
||||
|
||||
const layout = State.state.layoutToUse.data;
|
||||
|
||||
this.auth.xhr({
|
||||
method: 'PUT',
|
||||
path: '/api/0.6/changeset/create',
|
||||
options: { header: { 'Content-Type': 'text/xml' } },
|
||||
content: '<osm><changeset>' +
|
||||
'<tag k="created_by" v="MapComplete 0.0.0" />' +
|
||||
'<tag k="comment" v="' + comment + '"/>' +
|
||||
'</changeset></osm>'
|
||||
options: {header: {'Content-Type': 'text/xml'}},
|
||||
content: [`<osm><changeset>`,
|
||||
`<tag k="created_by" v="MapComplete ${State.vNumber}" />`,
|
||||
`<tag k="comment" v="Adding data with #MapComplete"/>`,
|
||||
`<tag k="theme" v="${layout.name}">`,
|
||||
layout.maintainer !== undefined ? `<tag k="theme-creator" v="${layout.maintainer}">` : "",
|
||||
`</changeset></osm>`].join("")
|
||||
}, function (err, response) {
|
||||
if (response === undefined) {
|
||||
console.log("err", err);
|
||||
|
|
|
@ -83,6 +83,9 @@ export abstract class OsmObject {
|
|||
console.log("WARNING: overwriting ",oldV, " with ", v," for key ",k)
|
||||
}
|
||||
this.tags[k] = v;
|
||||
if(v === undefined || v === ""){
|
||||
delete this.tags[k];
|
||||
}
|
||||
this.changed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,9 +60,6 @@ export class Tag extends TagsFilter {
|
|||
public invertValue: boolean
|
||||
|
||||
constructor(key: string | RegExp, value: string | RegExp, invertValue = false) {
|
||||
if (value === "*" && invertValue) {
|
||||
throw new Error("Invalid combination: invertValue && value == *")
|
||||
}
|
||||
|
||||
if (value instanceof RegExp && invertValue) {
|
||||
throw new Error("Unsupported combination: RegExp value and inverted value (use regex to invert the match)")
|
||||
|
@ -88,12 +85,17 @@ export class Tag extends TagsFilter {
|
|||
matches(tags: { k: string; v: string }[]): boolean {
|
||||
for (const tag of tags) {
|
||||
if (Tag.regexOrStrMatches(this.key, tag.k)) {
|
||||
|
||||
if (tag.v === "") {
|
||||
// This tag has been removed
|
||||
return this.value === ""
|
||||
// This tag has been removed -> always matches false
|
||||
return false;
|
||||
}
|
||||
if (this.value === "*") {
|
||||
// Any is allowed
|
||||
// Any is allowed (as long as the tag is not empty)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(this.value === tag.v){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -288,4 +290,12 @@ export class TagUtils {
|
|||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
static KVtoProperties(tags: Tag[]): any {
|
||||
const properties = {};
|
||||
for (const tag of tags) {
|
||||
properties[tag.key] = tag.value
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue