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)
.filter(coor => coor["lat"] !== undefined && coor["lon"] !== undefined)
.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) {
const saver = self.localStorageSavers.get(layer.id)
if(saver === undefined){
console.warn("No local storage saver found for ", layer.id)
console.error("No local storage saver found for ", layer.id)
}else{
saver.MarkVisited(tileId, new Date())
saver.MarkVisited(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,
registerTile: (tile) => {
// 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))
tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile))
@ -426,7 +425,7 @@ export default class FeaturePipeline {
const tileIndex = Tiles.tile_index(paddedToZoomLevel, x, y)
downloadedLayers.forEach(layer => {
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> }
const theme = o.state.layoutToUse.id
const changes = o.state.changes
let confirm: () => Promise<string>
if (o.conflationSettings !== undefined) {
// Conflate the way
action = new ReplaceGeometryAction(
o.state,
o.feature,
@ -323,6 +322,7 @@ export default class ImportButton extends Toggle {
}
} else {
// Upload the way to OSM
const geom = o.feature.geometry
let coordinates: [number, number][]
if (geom.type === "LineString") {
@ -331,7 +331,6 @@ export default class ImportButton extends Toggle {
coordinates = geom.coordinates[0]
}
action = new CreateWayWithPointReuseAction(
o.newTags.data,
coordinates,
@ -341,7 +340,6 @@ export default class ImportButton extends Toggle {
withinRangeOfM: 1,
ifMatches: new Tag("_is_part_of_building", "true"),
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 () => {
{
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(() => {
importClicked.setData(false)
})
const cancel = new SubtleButton(Svg.close_ui(), Translations.t.general.cancel).onClick(() => importClicked.setData(false))
return new Combine([confirmationMap, confirmButton, cancel]).SetClass("flex flex-col")

View file

@ -31,44 +31,150 @@
"enableGeolocation": false,
"layers": [
{
"id": "osm-fixmes",
"name": {
"nl": "Fixmes op gebouwen"
"builtin": "type_node",
"isShown": {
"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": {
"maxCacheAge": 0,
"osmTags": {
"and": [
"fixme~*",
"building~*"
]
}
"osmTags": "building~*",
"maxCacheAge": 0
},
"calculatedTags": [
"_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]"
],
"title": {
"render": {
"nl": "{addr:street} {addr:housenumber}"
},
"mappings": [
{
"if": {
"and": [
"fixme~*"
]
},
"then": {
"nl": "{fixme}"
}
"mapRendering": [
{
"width": {
"render": "2",
"mappings": [
{
"if": "fixme~*",
"then": "5"
}
]
},
"color": {
"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": {
"nl": "Dit gebouw heeft een foutmelding"
},
},
{
"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"
}
}
],
"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"
}
]
},
{
"id": "grb-housenumber",
"render": {
@ -185,153 +291,19 @@
"key": "building:min_level",
"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"
],
"filter": [
{
"id": "has-fixme",
"options": [
{
"osmTags": "fixme~*",
"question": "Heeft een FIXME"
}
]
}
]
},
{
@ -399,8 +371,10 @@
"point",
"centroid"
],
"icon": "circle:#bb3322",
"iconSize": "15,15,center"
"iconSize": "15,15,center",
"label": {
"render": "<div style='background:#faa' class='rounded-full'>{HNRLABEL}</div>"
}
}
],
"calculatedTags": [
@ -507,7 +481,7 @@
},
{
"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": [
{
"if": "_overlaps_with!=null",

View file

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

View file

@ -834,7 +834,7 @@
"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.",
"layers": {
"2": {
"1": {
"tagRenderings": {
"building type": {
"question": "What kind of building is this?"

View file

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