forked from MapComplete/MapComplete
Merge branch 'master' into develop
This commit is contained in:
commit
1280ba2d14
4 changed files with 64 additions and 33 deletions
|
@ -523,6 +523,44 @@
|
||||||
],
|
],
|
||||||
"id": "Cuisine"
|
"id": "Cuisine"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "show-menu-image",
|
||||||
|
"render": {
|
||||||
|
"*": "{image_carousel(image:menu)}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "add-menu-image",
|
||||||
|
"render": {
|
||||||
|
"special": {
|
||||||
|
"type": "image_upload",
|
||||||
|
"image-key": "image:menu",
|
||||||
|
"label": {
|
||||||
|
"en": "Add an image from the menu",
|
||||||
|
"nl": "Voeg een foto van het menu toe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "menu-website",
|
||||||
|
"question": {
|
||||||
|
"en": "On what webpage is the menu published?"
|
||||||
|
},
|
||||||
|
"render": {
|
||||||
|
"special": {
|
||||||
|
"type": "link",
|
||||||
|
"href": "{website:menu}",
|
||||||
|
"text": {
|
||||||
|
"en": "Consult the menu"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"freeform": {
|
||||||
|
"key": "website:menu",
|
||||||
|
"type": "url"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "Reservation",
|
"id": "Reservation",
|
||||||
"condition": "takeaway!=only",
|
"condition": "takeaway!=only",
|
||||||
|
|
|
@ -24,7 +24,7 @@ export abstract class OsmObject {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.type = type
|
this.type = type
|
||||||
this.tags = {
|
this.tags = {
|
||||||
id: `${this.type}/${id}`,
|
id: `${this.type}/${id}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,24 +37,25 @@ export abstract class OsmObject {
|
||||||
const idN = element.id
|
const idN = element.id
|
||||||
let osmObject: OsmObject = null
|
let osmObject: OsmObject = null
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "node":
|
case "node": {
|
||||||
const node = new OsmNode(idN)
|
const node = new OsmNode(idN)
|
||||||
allNodes.set(idN, node)
|
allNodes.set(idN, node)
|
||||||
osmObject = node
|
osmObject = node
|
||||||
node.SaveExtraData(element)
|
node.SaveExtraData(element)
|
||||||
break
|
break
|
||||||
case "way":
|
}
|
||||||
|
case "way": {
|
||||||
osmObject = new OsmWay(idN)
|
osmObject = new OsmWay(idN)
|
||||||
const nodes = element.nodes.map((i) => allNodes.get(i))
|
const nodes = element.nodes.map((i) => allNodes.get(i))
|
||||||
osmObject.SaveExtraData(element, nodes)
|
osmObject.SaveExtraData(element, nodes)
|
||||||
break
|
break
|
||||||
case "relation":
|
}
|
||||||
|
case "relation": {
|
||||||
osmObject = new OsmRelation(idN)
|
osmObject = new OsmRelation(idN)
|
||||||
const allGeojsons = OsmToGeoJson(
|
const allGeojsons = OsmToGeoJson(
|
||||||
{ elements },
|
{ elements },
|
||||||
// @ts-ignore
|
|
||||||
{
|
{
|
||||||
flatProperties: true,
|
flatProperties: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const feature = allGeojsons.features.find(
|
const feature = allGeojsons.features.find(
|
||||||
|
@ -62,9 +63,10 @@ export abstract class OsmObject {
|
||||||
)
|
)
|
||||||
osmObject.SaveExtraData(element, feature)
|
osmObject.SaveExtraData(element, feature)
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osmObject !== undefined && OsmObject.backendURL !== OsmObject.defaultBackend) {
|
if (osmObject !== undefined) {
|
||||||
osmObject.tags["_backend"] = OsmObject.backendURL
|
osmObject.tags["_backend"] = OsmObject.backendURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +120,7 @@ export abstract class OsmObject {
|
||||||
const blacklist = polygonFeature.polygon === "blacklist"
|
const blacklist = polygonFeature.polygon === "blacklist"
|
||||||
result.set(key, {
|
result.set(key, {
|
||||||
values: new Set<string>(polygonFeature.values),
|
values: new Set<string>(polygonFeature.values),
|
||||||
blacklist: blacklist,
|
blacklist: blacklist
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,23 +151,20 @@ export abstract class OsmObject {
|
||||||
}
|
}
|
||||||
const v = this.tags[key]
|
const v = this.tags[key]
|
||||||
if (v !== "" && v !== undefined) {
|
if (v !== "" && v !== undefined) {
|
||||||
tags +=
|
tags += ` <tag k="${Utils.EncodeXmlValue(key)}" v="${Utils.EncodeXmlValue(this.tags[key])}"/>
|
||||||
' <tag k="' +
|
`
|
||||||
Utils.EncodeXmlValue(key) +
|
|
||||||
'" v="' +
|
|
||||||
Utils.EncodeXmlValue(this.tags[key]) +
|
|
||||||
'"/>\n'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract ChangesetXML(changesetId: string, header?: string): string
|
abstract ChangesetXML(changesetId: string, header?: string): string
|
||||||
|
|
||||||
protected VersionXML() {
|
protected VersionXML() {
|
||||||
if (this.version === undefined) {
|
if (this.version === undefined) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return 'version="' + this.version + '"'
|
return `version="${this.version}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LoadData(element: any): void {
|
protected LoadData(element: any): void {
|
||||||
|
@ -213,7 +212,7 @@ export class OsmNode extends OsmObject {
|
||||||
ChangesetXML(changesetId: string, header?: string): string {
|
ChangesetXML(changesetId: string, header?: string): string {
|
||||||
const tags = this.TagsXML()
|
const tags = this.TagsXML()
|
||||||
return ` <node id="${this.id}" ${header ?? ""} ${
|
return ` <node id="${this.id}" ${header ?? ""} ${
|
||||||
changesetId ? ' changeset="' + changesetId + '" ' : ""
|
changesetId ? " changeset=\"" + changesetId + "\" " : ""
|
||||||
}${this.VersionXML()} lat="${this.lat}" lon="${this.lon}">
|
}${this.VersionXML()} lat="${this.lat}" lon="${this.lon}">
|
||||||
${tags} </node>
|
${tags} </node>
|
||||||
`
|
`
|
||||||
|
@ -234,8 +233,8 @@ ${tags} </node>
|
||||||
properties: this.tags,
|
properties: this.tags,
|
||||||
geometry: {
|
geometry: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: [this.lon, this.lat],
|
coordinates: [this.lon, this.lat]
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,11 +264,11 @@ export class OsmWay extends OsmObject {
|
||||||
const tags = this.TagsXML()
|
const tags = this.TagsXML()
|
||||||
let nds = ""
|
let nds = ""
|
||||||
for (const node in this.nodes) {
|
for (const node in this.nodes) {
|
||||||
nds += ' <nd ref="' + this.nodes[node] + '"/>\n'
|
nds += " <nd ref=\"" + this.nodes[node] + "\"/>\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
return ` <way id="${this.id}" ${header ?? ""} ${
|
return ` <way id="${this.id}" ${header ?? ""} ${
|
||||||
changesetId ? 'changeset="' + changesetId + '" ' : ""
|
changesetId ? "changeset=\"" + changesetId + "\" " : ""
|
||||||
} ${this.VersionXML()}>
|
} ${this.VersionXML()}>
|
||||||
${nds}${tags} </way>
|
${nds}${tags} </way>
|
||||||
`
|
`
|
||||||
|
@ -314,18 +313,18 @@ ${nds}${tags} </way>
|
||||||
if (this.isPolygon()) {
|
if (this.isPolygon()) {
|
||||||
geometry = {
|
geometry = {
|
||||||
type: "Polygon",
|
type: "Polygon",
|
||||||
coordinates: [coordinates],
|
coordinates: [coordinates]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
geometry = {
|
geometry = {
|
||||||
type: "LineString",
|
type: "LineString",
|
||||||
coordinates: coordinates,
|
coordinates: coordinates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: <any>this.tags,
|
properties: <any>this.tags,
|
||||||
geometry,
|
geometry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,14 +361,8 @@ export class OsmRelation extends OsmObject {
|
||||||
ChangesetXML(changesetId: string, header?: string): string {
|
ChangesetXML(changesetId: string, header?: string): string {
|
||||||
let members = ""
|
let members = ""
|
||||||
for (const member of this.members) {
|
for (const member of this.members) {
|
||||||
members +=
|
members += ` <member type="${member.type}" ref="${member.ref}" role="${member.role}"/>
|
||||||
' <member type="' +
|
`
|
||||||
member.type +
|
|
||||||
'" ref="' +
|
|
||||||
member.ref +
|
|
||||||
'" role="' +
|
|
||||||
member.role +
|
|
||||||
'"/>\n'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tags = this.TagsXML()
|
const tags = this.TagsXML()
|
||||||
|
|
|
@ -239,7 +239,7 @@ export default class OsmObjectDownloader {
|
||||||
if (rawData["error"] !== undefined && rawData["statuscode"] === 410) {
|
if (rawData["error"] !== undefined && rawData["statuscode"] === 410) {
|
||||||
return "deleted"
|
return "deleted"
|
||||||
}
|
}
|
||||||
// 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)
|
// A full query might contain more than just the requested object (e.g. nodes that are part of a way, where we only want the way)
|
||||||
const parsed = OsmObject.ParseObjects(rawData["content"].elements)
|
const parsed = OsmObject.ParseObjects(rawData["content"].elements)
|
||||||
// Let us fetch the object we need
|
// Let us fetch the object we need
|
||||||
for (const osmObject of parsed) {
|
for (const osmObject of parsed) {
|
||||||
|
|
|
@ -243,7 +243,7 @@ class RewriteMetaInfoTags extends SimpleMetaTagger {
|
||||||
move("changeset", "_last_edit:changeset")
|
move("changeset", "_last_edit:changeset")
|
||||||
move("timestamp", "_last_edit:timestamp")
|
move("timestamp", "_last_edit:timestamp")
|
||||||
move("version", "_version_number")
|
move("version", "_version_number")
|
||||||
feature.properties._backend = feature.properties._backend ?? "https://api.openstreetmap.org"
|
feature.properties._backend ??= "https://www.openstreetmap.org"
|
||||||
return movedSomething
|
return movedSomething
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue