forked from MapComplete/MapComplete
Import work
This commit is contained in:
parent
42a6b37ca6
commit
e0b58a0f55
3 changed files with 68 additions and 4 deletions
|
@ -37,6 +37,7 @@ import TagApplyButton from "./TagApplyButton";
|
||||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||||
import * as conflation_json from "../../assets/layers/conflation/conflation.json";
|
import * as conflation_json from "../../assets/layers/conflation/conflation.json";
|
||||||
import {GeoOperations} from "../../Logic/GeoOperations";
|
import {GeoOperations} from "../../Logic/GeoOperations";
|
||||||
|
import {Or} from "../../Logic/Tags/Or";
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractImportButton implements SpecialVisualizations {
|
abstract class AbstractImportButton implements SpecialVisualizations {
|
||||||
|
@ -56,7 +57,7 @@ It is only functional in official themes, but can be tested in unoffical themes.
|
||||||
|
|
||||||
#### Specifying which tags to copy or add
|
#### Specifying which tags to copy or add
|
||||||
|
|
||||||
The argument \`tags\` of the import button takes a \`;\`-seperated list of tags to add.
|
The argument \`tags\` of the import button takes a \`;\`-seperated list of tags to add (or the name of a property which contains a JSON-list of properties).
|
||||||
|
|
||||||
${Utils.Special_visualizations_tagsToApplyHelpText}
|
${Utils.Special_visualizations_tagsToApplyHelpText}
|
||||||
${Utils.special_visualizations_importRequirementDocs}
|
${Utils.special_visualizations_importRequirementDocs}
|
||||||
|
@ -68,7 +69,7 @@ ${Utils.special_visualizations_importRequirementDocs}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tags",
|
name: "tags",
|
||||||
doc: "The tags to add onto the new object - see specification above"
|
doc: "The tags to add onto the new object - see specification above. If this is a key (a single word occuring in the properties of the object), the corresponding value is taken and expanded instead"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "text",
|
name: "text",
|
||||||
|
@ -201,7 +202,15 @@ ${Utils.special_visualizations_importRequirementDocs}
|
||||||
private parseArgs(argsRaw: string[], originalFeatureTags: UIEventSource<any>): { minzoom: string, max_snap_distance: string, snap_onto_layers: string, icon: string, text: string, tags: string, targetLayer: string, newTags: UIEventSource<Tag[]> } {
|
private parseArgs(argsRaw: string[], originalFeatureTags: UIEventSource<any>): { minzoom: string, max_snap_distance: string, snap_onto_layers: string, icon: string, text: string, tags: string, targetLayer: string, newTags: UIEventSource<Tag[]> } {
|
||||||
const baseArgs = Utils.ParseVisArgs(this.args, argsRaw)
|
const baseArgs = Utils.ParseVisArgs(this.args, argsRaw)
|
||||||
if (originalFeatureTags !== undefined) {
|
if (originalFeatureTags !== undefined) {
|
||||||
baseArgs["newTags"] = TagApplyButton.generateTagsToApply(baseArgs.tags, originalFeatureTags)
|
|
||||||
|
const tags = baseArgs.tags
|
||||||
|
if(tags.indexOf(" ") < 0 && tags.indexOf(";") < 0){
|
||||||
|
// This might be a propertie to expand...
|
||||||
|
const items : string = originalFeatureTags.data[tags]
|
||||||
|
baseArgs["newTags"] = TagApplyButton.generateTagsToApply(items, originalFeatureTags)
|
||||||
|
}else{
|
||||||
|
baseArgs["newTags"] = TagApplyButton.generateTagsToApply(tags, originalFeatureTags)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return baseArgs
|
return baseArgs
|
||||||
}
|
}
|
||||||
|
|
54
assets/layers/note_import/note_import.json
Normal file
54
assets/layers/note_import/note_import.json
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"id": "note_import",
|
||||||
|
"description": "Te template for note note imports.",
|
||||||
|
"source": {
|
||||||
|
"osmTags": {
|
||||||
|
"and": ["id~*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"geoJson": "https://api.openstreetmap.org/api/0.6/notes.json?closed=7&bbox={x_min},{y_min},{x_max},{y_max}",
|
||||||
|
"geoJsonZoomLevel": 12,
|
||||||
|
"maxCacheAge": 0
|
||||||
|
},
|
||||||
|
"minzoom": 10,
|
||||||
|
"title": {
|
||||||
|
"render": {
|
||||||
|
"en": "Possible feature"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"calculatedTags": [
|
||||||
|
"_first_comment:=feat.get('comments')[0].text.toLowerCase()",
|
||||||
|
"_is_import_comment:=(() => {const parsed = feat.properties._first_comment.match('\\(.*\\)https:\\/\\/mapcomplete\\.osm\\.be\\/\\([a-zA-Z0-9_-]*\\)[^\\n]*}')()"
|
||||||
|
],
|
||||||
|
"titleIcons": [
|
||||||
|
{
|
||||||
|
"render": "<a href='https://openstreetmap.org/note/{id}' target='_blank'><img src='./assets/svg/osm-logo-us.svg'></a>"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tagRenderings": [
|
||||||
|
{
|
||||||
|
"id": "conversation",
|
||||||
|
"render": "{visualize_note_comments()}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "add_image",
|
||||||
|
"render": "{add_image_to_note()}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "comment",
|
||||||
|
"render": "{add_note_comment()}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mapRendering": [
|
||||||
|
{
|
||||||
|
"location": [
|
||||||
|
"point",
|
||||||
|
"centroid"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"render": "teardrop:#3333cc"
|
||||||
|
},
|
||||||
|
"iconSize": "40,40,bottom"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -43,6 +43,7 @@
|
||||||
"startZoom": 1,
|
"startZoom": 1,
|
||||||
"widenFactor": 1,
|
"widenFactor": 1,
|
||||||
"layers": [
|
"layers": [
|
||||||
"public_bookcase"
|
"public_bookcase",
|
||||||
|
"note_import"
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue