More GRB improvements

This commit is contained in:
Pieter Vander Vennet 2021-11-22 03:49:17 +01:00
parent 290cb6ce56
commit d6b61f6df6
6 changed files with 170 additions and 204 deletions

View file

@ -75,7 +75,7 @@ export default class FeaturePipeline {
.map(ch => ch.changes) .map(ch => ch.changes)
.filter(coor => coor["lat"] !== undefined && coor["lon"] !== undefined) .filter(coor => coor["lat"] !== undefined && coor["lon"] !== undefined)
.forEach(coor => { .forEach(coor => {
state.layoutToUse.layers.forEach(l => self.localStorageSavers.get(l.id).poison(coor["lon"], coor["lat"])) state.layoutToUse.layers.forEach(l => self.localStorageSavers.get(l.id)?.poison(coor["lon"], coor["lat"]))
}) })
}) })
@ -227,10 +227,9 @@ export default class FeaturePipeline {
if (layer.maxAgeOfCache > 0) { if (layer.maxAgeOfCache > 0) {
const saver = self.localStorageSavers.get(layer.id) const saver = self.localStorageSavers.get(layer.id)
if(saver === undefined){ if(saver === undefined){
console.warn("No local storage saver found for ", layer.id) console.error("No local storage saver found for ", layer.id)
}else{ }else{
saver.MarkVisited(tileId, new Date())
saver.MarkVisited(tileId, new Date())
} }
} }
self.freshnesses.get(layer.id).addTileLoad(tileId, new Date()) self.freshnesses.get(layer.id).addTileLoad(tileId, new Date())
@ -264,7 +263,7 @@ export default class FeaturePipeline {
maxZoomLevel: state.layoutToUse.clustering.maxZoom, maxZoomLevel: state.layoutToUse.clustering.maxZoom,
registerTile: (tile) => { registerTile: (tile) => {
// We save the tile data for the given layer to local storage - data sourced from overpass // We save the tile data for the given layer to local storage - data sourced from overpass
self.localStorageSavers.get(tile.layer.layerDef.id).addTile(tile) self.localStorageSavers.get(tile.layer.layerDef.id)?.addTile(tile)
perLayerHierarchy.get(source.layer.layerDef.id).registerTile(new RememberingSource(tile)) perLayerHierarchy.get(source.layer.layerDef.id).registerTile(new RememberingSource(tile))
tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile)) tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile))
@ -426,7 +425,7 @@ export default class FeaturePipeline {
const tileIndex = Tiles.tile_index(paddedToZoomLevel, x, y) const tileIndex = Tiles.tile_index(paddedToZoomLevel, x, y)
downloadedLayers.forEach(layer => { downloadedLayers.forEach(layer => {
self.freshnesses.get(layer.id).addTileLoad(tileIndex, date) self.freshnesses.get(layer.id).addTileLoad(tileIndex, date)
self.localStorageSavers.get(layer.id).MarkVisited(tileIndex, date) self.localStorageSavers.get(layer.id)?.MarkVisited(tileIndex, date)
}) })
}) })

View file

@ -302,11 +302,10 @@ export default class ImportButton extends Toggle {
let action: OsmChangeAction & { getPreview(): Promise<FeatureSource> } let action: OsmChangeAction & { getPreview(): Promise<FeatureSource> }
const theme = o.state.layoutToUse.id
const changes = o.state.changes const changes = o.state.changes
let confirm: () => Promise<string> let confirm: () => Promise<string>
if (o.conflationSettings !== undefined) { if (o.conflationSettings !== undefined) {
// Conflate the way
action = new ReplaceGeometryAction( action = new ReplaceGeometryAction(
o.state, o.state,
o.feature, o.feature,
@ -323,6 +322,7 @@ export default class ImportButton extends Toggle {
} }
} else { } else {
// Upload the way to OSM
const geom = o.feature.geometry const geom = o.feature.geometry
let coordinates: [number, number][] let coordinates: [number, number][]
if (geom.type === "LineString") { if (geom.type === "LineString") {
@ -331,7 +331,6 @@ export default class ImportButton extends Toggle {
coordinates = geom.coordinates[0] coordinates = geom.coordinates[0]
} }
action = new CreateWayWithPointReuseAction( action = new CreateWayWithPointReuseAction(
o.newTags.data, o.newTags.data,
coordinates, coordinates,
@ -341,7 +340,6 @@ export default class ImportButton extends Toggle {
withinRangeOfM: 1, withinRangeOfM: 1,
ifMatches: new Tag("_is_part_of_building", "true"), ifMatches: new Tag("_is_part_of_building", "true"),
mode: "move_osm_point" mode: "move_osm_point"
}] }]
) )
@ -364,7 +362,13 @@ export default class ImportButton extends Toggle {
}) })
}) })
const confirmButton = new SubtleButton(o.image(), o.message) const tagsExplanation = new VariableUiElement(o.newTags.map(tagsToApply => {
const tagsStr = tagsToApply.map(t => t.asHumanString(false, true)).join("&");
return Translations.t.general.add.importTags.Subs({tags: tagsStr});
}
)).SetClass("subtle")
const confirmButton = new SubtleButton(o.image(), new Combine([o.message, tagsExplanation]).SetClass("flex flex-col"))
confirmButton.onClick(async () => { confirmButton.onClick(async () => {
{ {
if (isImported.data) { if (isImported.data) {
@ -380,9 +384,7 @@ export default class ImportButton extends Toggle {
} }
}) })
const cancel = new SubtleButton(Svg.close_ui(), Translations.t.general.cancel).onClick(() => { const cancel = new SubtleButton(Svg.close_ui(), Translations.t.general.cancel).onClick(() => importClicked.setData(false))
importClicked.setData(false)
})
return new Combine([confirmationMap, confirmButton, cancel]).SetClass("flex flex-col") return new Combine([confirmationMap, confirmButton, cancel]).SetClass("flex flex-col")

View file

@ -31,44 +31,150 @@
"enableGeolocation": false, "enableGeolocation": false,
"layers": [ "layers": [
{ {
"id": "osm-fixmes", "builtin": "type_node",
"name": { "isShown": {
"nl": "Fixmes op gebouwen" "render": "no"
}, },
"passAllFeatures": true, "override": {
"calculatedTags": [
"_is_part_of_building=feat.get('parent_ways')?.some(p => p.building !== undefined && p.building !== '') ?? false",
"_is_part_of_building_passage=feat.get('parent_ways')?.some(p => p.tunnel === 'building_passage') ?? false",
"_is_part_of_highway=!feat.get('is_part_of_building_passage') && (feat.get('parent_ways')?.some(p => p.highway !== undefined && p.highway !== '') ?? false)",
"_is_part_of_landuse=feat.get('parent_ways')?.some(p => (p.landuse !== undefined && p.landuse !== '') || (p.natural !== undefined && p.natural !== '')) ?? false"
],
"mapRendering": [
{
"icon": "square:#00f",
"iconSize": "5,5,center",
"location": "point"
}
]
}
},
{
"id": "OSM-buildings",
"name": "All OSM-buildings",
"source": { "source": {
"maxCacheAge": 0, "osmTags": "building~*",
"osmTags": { "maxCacheAge": 0
"and": [
"fixme~*",
"building~*"
]
}
}, },
"calculatedTags": [ "calculatedTags": [
"_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]" "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]"
], ],
"title": { "mapRendering": [
"render": { {
"nl": "{addr:street} {addr:housenumber}" "width": {
}, "render": "2",
"mappings": [ "mappings": [
{ {
"if": { "if": "fixme~*",
"and": [ "then": "5"
"fixme~*" }
] ]
}, },
"then": { "color": {
"nl": "{fixme}" "render": "#00c",
} "mappings": [
{
"if": "fixme~*",
"then": "#ff00ff"
},
{
"if": "building=house",
"then": "#a00"
},
{
"if": "building=shed",
"then": "#563e02"
},
{
"if": {
"or": [
"building=garage",
"building=garages"
]
},
"then": "#f9bfbb"
},
{
"if": "building=yes",
"then": "#0774f2"
}
]
} }
] },
}, {
"description": { "location": [
"nl": "Dit gebouw heeft een foutmelding" "point",
}, "centroid"
],
"label": {
"mappings": [
{
"if": "addr:housenumber~*",
"then": "<div style='background-color: white; font: large; width: 1.5em; height: 1.5em; border-radius: 100%'>{addr:housenumber}</div>"
}
]
},
"iconSize": {
"render": "40,40,center"
}
}
],
"title": "OSM-gebouw",
"tagRenderings": [ "tagRenderings": [
{
"id": "building type",
"freeform": {
"key": "building"
},
"render": "The building type is <b>{building}</b>",
"question": {
"en": "What kind of building is this?"
},
"mappings": [
{
"if": "building=house",
"then": "A normal house"
},
{
"if": "building=detached",
"then": "A house detached from other building"
},
{
"if": "building=semidetached_house",
"then": "A house sharing only one wall with another house"
},
{
"if": "building=apartments",
"then": "An apartment building - highrise for living"
},
{
"if": "building=office",
"then": "An office building - highrise for work"
},
{
"if": "building=apartments",
"then": "An apartment building"
},
{
"if": "building=shed",
"then": "A small shed, e.g. in a garden"
},
{
"if": "building=garage",
"then": "A single garage to park a car"
},
{
"if": "building=garages",
"then": "A building containing only garages; typically they are all identical"
},
{
"if": "building=yes",
"then": "A building - no specification"
}
]
},
{ {
"id": "grb-housenumber", "id": "grb-housenumber",
"render": { "render": {
@ -185,153 +291,19 @@
"key": "building:min_level", "key": "building:min_level",
"type": "pnat" "type": "pnat"
} }
}
],
"mapRendering": [
{
"location": [
"point",
"centroid"
],
"label": {
"mappings": [
{
"if": "addr:housenumber~*",
"then": "<div style='background-color: white; font: large; width: 1.5em; height: 1.5em; border-radius: 100%'>{addr:housenumber}</div>"
}
]
},
"iconSize": {
"render": "40,40,center"
}
},
{
"dashArray": "2 2",
"color": {
"render": "#00f"
},
"width": {
"render": "2"
}
}
]
},
{
"builtin": "type_node",
"isShown": {
"render": "no"
},
"override": {
"calculatedTags": [
"_is_part_of_building=feat.get('parent_ways')?.some(p => p.building !== undefined && p.building !== '') ?? false",
"_is_part_of_building_passage=feat.get('parent_ways')?.some(p => p.tunnel === 'building_passage') ?? false",
"_is_part_of_highway=!feat.get('is_part_of_building_passage') && (feat.get('parent_ways')?.some(p => p.highway !== undefined && p.highway !== '') ?? false)",
"_is_part_of_landuse=feat.get('parent_ways')?.some(p => (p.landuse !== undefined && p.landuse !== '') || (p.natural !== undefined && p.natural !== '')) ?? false"
],
"mapRendering": [
{
"icon": "square:#00f",
"iconSize": "5,5,center",
"location": "point"
}
]
}
},
{
"id": "OSM-buildings",
"name": "All OSM-buildings",
"source": {
"osmTags": "building~*",
"maxCacheAge": 0
},
"mapRendering": [
{
"width": {
"render": "2"
},
"color": {
"render": "#00c",
"mappings": [
{
"if": "building=house",
"then": "#a00"
},
{
"if": "building=shed",
"then": "#563e02"
},
{
"if": {
"or": [
"building=garage",
"building=garages"
]
},
"then": "#f9bfbb"
},
{
"if": "building=yes",
"then": "#0774f2"
}
]
}
}
],
"title": "OSM-gebouw",
"tagRenderings": [
{
"id": "building type",
"freeform": {
"key": "building"
},
"render": "The building type is <b>{building}</b>",
"question": {
"en": "What kind of building is this?"
},
"mappings": [
{
"if": "building=house",
"then": "A normal house"
},
{
"if": "building=detached",
"then": "A house detached from other building"
},
{
"if": "building=semidetached_house",
"then": "A house sharing only one wall with another house"
},
{
"if": "building=apartments",
"then": "An apartment building - highrise for living"
},
{
"if": "building=office",
"then": "An office building - highrise for work"
},
{
"if": "building=apartments",
"then": "An apartment building"
},
{
"if": "building=shed",
"then": "A small shed, e.g. in a garden"
},
{
"if": "building=garage",
"then": "A single garage to park a car"
},
{
"if": "building=garages",
"then": "A building containing only garages; typically they are all identical"
},
{
"if": "building=yes",
"then": "A building - no specification"
}
]
}, },
"all_tags" "all_tags"
],
"filter": [
{
"id": "has-fixme",
"options": [
{
"osmTags": "fixme~*",
"question": "Heeft een FIXME"
}
]
}
] ]
}, },
{ {
@ -399,8 +371,10 @@
"point", "point",
"centroid" "centroid"
], ],
"icon": "circle:#bb3322", "iconSize": "15,15,center",
"iconSize": "15,15,center" "label": {
"render": "<div style='background:#faa' class='rounded-full'>{HNRLABEL}</div>"
}
} }
], ],
"calculatedTags": [ "calculatedTags": [
@ -507,7 +481,7 @@
}, },
{ {
"id": "Import-button", "id": "Import-button",
"render": "{import_button(OSM-buildings,building=$building; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref, Upload this building to OpenStreetMap)}", "render": "{import_button(OSM-buildings,building=$building; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber, Upload this building to OpenStreetMap)}",
"mappings": [ "mappings": [
{ {
"if": "_overlaps_with!=null", "if": "_overlaps_with!=null",

View file

@ -109,6 +109,7 @@
"openLayerControl": "Open the layer control box", "openLayerControl": "Open the layer control box",
"layerNotEnabled": "The layer {layer} is not enabled. Enable this layer to add a point", "layerNotEnabled": "The layer {layer} is not enabled. Enable this layer to add a point",
"hasBeenImported": "This point has already been imported", "hasBeenImported": "This point has already been imported",
"importTags": "The element will receive {tags}",
"zoomInMore": "Zoom in more to import this feature", "zoomInMore": "Zoom in more to import this feature",
"wrongType": "This element is not a point or a way and can not be imported" "wrongType": "This element is not a point or a way and can not be imported"
}, },

View file

@ -834,7 +834,7 @@
"grb": { "grb": {
"description": "This theme is an attempt to help automating the GRB import.<br/>Note that this is very hacky and 'steals' the GRB data from an external site; in order to do this, you need to install and activate <a href='https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/'>this firefox extension</a> for it to work.", "description": "This theme is an attempt to help automating the GRB import.<br/>Note that this is very hacky and 'steals' the GRB data from an external site; in order to do this, you need to install and activate <a href='https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/'>this firefox extension</a> for it to work.",
"layers": { "layers": {
"2": { "1": {
"tagRenderings": { "tagRenderings": {
"building type": { "building type": {
"question": "What kind of building is this?" "question": "What kind of building is this?"

View file

@ -753,9 +753,7 @@
"grb": { "grb": {
"description": "GRB Fixup", "description": "GRB Fixup",
"layers": { "layers": {
"0": { "1": {
"description": "Dit gebouw heeft een foutmelding",
"name": "Fixmes op gebouwen",
"tagRenderings": { "tagRenderings": {
"grb-fixme": { "grb-fixme": {
"mappings": { "mappings": {
@ -786,14 +784,6 @@
"grb-unit": { "grb-unit": {
"render": "De wooneenheid-aanduiding is <b>{addr:unit}</b> " "render": "De wooneenheid-aanduiding is <b>{addr:unit}</b> "
} }
},
"title": {
"mappings": {
"0": {
"then": "{fixme}"
}
},
"render": "{addr:street} {addr:housenumber}"
} }
} }
}, },