forked from MapComplete/MapComplete
Work on automatically creating an import layer for every feature
This commit is contained in:
parent
f67d0701b0
commit
a65afbbb58
13 changed files with 165 additions and 8 deletions
|
@ -3,7 +3,7 @@ import RelationsTracker from "./RelationsTracker";
|
|||
import {Utils} from "../../Utils";
|
||||
import {UIEventSource} from "../UIEventSource";
|
||||
import {BBox} from "../BBox";
|
||||
import osmtogeojson from "osmtogeojson";
|
||||
import * as osmtogeojson from "osmtogeojson";
|
||||
|
||||
/**
|
||||
* Interfaces overpass to get all the latest data
|
||||
|
@ -52,7 +52,8 @@ export class Overpass {
|
|||
}
|
||||
|
||||
self._relationTracker.RegisterRelations(json)
|
||||
const geojson = osmtogeojson.toGeoJSON(json);
|
||||
console.warn("OSMTOGEOJSON:", osmtogeojson)
|
||||
const geojson = osmtogeojson.default(json);
|
||||
const osmTime = new Date(json.osm3s.timestamp_osm_base);
|
||||
return [geojson, osmTime];
|
||||
}
|
||||
|
|
|
@ -117,4 +117,10 @@ export class And extends TagsFilter {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return {
|
||||
and: this.and.map(a => a.AsJson())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,5 +38,9 @@ export default class ComparingTag implements TagsFilter {
|
|||
usedKeys(): string[] {
|
||||
return [this._key];
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return this.asHumanString(false, false, {})
|
||||
}
|
||||
|
||||
}
|
|
@ -65,6 +65,12 @@ export class Or extends TagsFilter {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return {
|
||||
or: this.or.map(o => o.AsJson())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,4 +109,8 @@ export class RegexTag extends TagsFilter {
|
|||
console.error("Cannot export regex tag to asChange; ", this.key, this.value)
|
||||
return []
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return this.asHumanString()
|
||||
}
|
||||
}
|
|
@ -12,7 +12,8 @@ import {TagsFilter} from "./TagsFilter";
|
|||
export default class SubstitutingTag implements TagsFilter {
|
||||
private readonly _key: string;
|
||||
private readonly _value: string;
|
||||
private readonly _invert: boolean
|
||||
private readonly _invert: boolean
|
||||
|
||||
constructor(key: string, value: string, invert = false) {
|
||||
this._key = key;
|
||||
this._value = value;
|
||||
|
@ -59,11 +60,17 @@ private readonly _invert: boolean
|
|||
}
|
||||
|
||||
asChange(properties: any): { k: string; v: string }[] {
|
||||
if(this._invert){throw "An inverted substituting tag can not be used to create a change"}
|
||||
if (this._invert) {
|
||||
throw "An inverted substituting tag can not be used to create a change"
|
||||
}
|
||||
const v = SubstitutingTag.substituteString(this._value, properties);
|
||||
if (v.match(/{.*}/) !== null) {
|
||||
throw "Could not calculate all the substitutions: still have " + v
|
||||
}
|
||||
return [{k: this._key, v: v}];
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return this._key + (this._invert ? '!' : '') + "=" + this._value
|
||||
}
|
||||
}
|
|
@ -83,4 +83,8 @@ export class Tag extends TagsFilter {
|
|||
asChange(properties: any): { k: string; v: string }[] {
|
||||
return [{k: this.key, v: this.value}];
|
||||
}
|
||||
|
||||
AsJson() {
|
||||
return this.asHumanString(false, false)
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ export abstract class TagsFilter {
|
|||
|
||||
abstract matchesProperties(properties: any): boolean;
|
||||
|
||||
abstract asHumanString(linkToWiki: boolean, shorten: boolean, properties: any) : string;
|
||||
abstract asHumanString(linkToWiki: boolean, shorten: boolean, properties: any): string;
|
||||
|
||||
abstract usedKeys(): string[];
|
||||
|
||||
|
@ -20,4 +20,5 @@ export abstract class TagsFilter {
|
|||
*/
|
||||
abstract asChange(properties: any): { k: string, v: string }[]
|
||||
|
||||
abstract AsJson() ;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue