Skip to content

Commit

Permalink
Swap out mergeStrategy idea with simpler preserveTags array
Browse files Browse the repository at this point in the history
(closes #4906)
  • Loading branch information
bhousel committed Feb 24, 2021
1 parent de8e23c commit deb8799
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 58 deletions.
1 change: 1 addition & 0 deletions data/brands/amenity/bar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"properties": {
"path": "brands/amenity/bar",
"skipCollection": true,
"preserveTags": ["^name"],
"exclude": {
"generic": ["^(pool|snack)?\\s?bar$"],
"named": ["^уют$"]
Expand Down
1 change: 1 addition & 0 deletions data/brands/amenity/cinema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/amenity/cinema",
"preserveTags": ["^name"],
"exclude": {
"generic": ["^cine(ma)?$"],
"named": ["^октябрь$"]
Expand Down
1 change: 1 addition & 0 deletions data/brands/amenity/fuel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/amenity/fuel",
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^((drummed|independent|جایگاه) )?(cng|filling|fuel|gas|gpl|gnv|lpg|petrol)( (station|pump))?$",
Expand Down
3 changes: 1 addition & 2 deletions data/brands/amenity/pharmacy.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"exclude": {
"generic": [
"^(alte )?apotheke( am markt)?$",
"^(apotek(a|et)|apteka?)$",
"^(centro naturista|eczane|botica|gyógyszertár|lékárna|ljekarna|parafarmacia)$",
"^apotek(a|et)$",
"^aptek(a)?$",
"^droguer[ií]a$",
"^farm[aàá]ci[aàáe]?$",
"^pharmac(ie|y)$",
Expand Down
1 change: 1 addition & 0 deletions data/brands/amenity/pub.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/amenity/pub",
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^(bar|bistro|pub)$",
Expand Down
1 change: 1 addition & 0 deletions data/brands/amenity/social_centre.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/amenity/social_centre",
"preserveTags": ["^name"],
"exclude": {"generic": ["^social centre$"]}
},
"items": [
Expand Down
2 changes: 2 additions & 0 deletions data/brands/amenity/vending_machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"amazon ロッカー",
"アマゾン・ハブ・ロッカー"
],
"preserveTags": ["^name"],
"tags": {
"amenity": "vending_machine",
"brand": "Amazon Hub ロッカー",
Expand All @@ -62,6 +63,7 @@
"locationSet": {
"include": ["de", "gb", "us"]
},
"preserveTags": ["^name"],
"tags": {
"amenity": "vending_machine",
"brand": "Amazon Locker",
Expand Down
1 change: 1 addition & 0 deletions data/brands/landuse/residential.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/landuse/residential",
"preserveTags": ["^name"],
"exclude": {"generic": ["^residential$"]}
},
"items": [
Expand Down
1 change: 1 addition & 0 deletions data/brands/office/insurance.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/office/insurance",
"preserveTags": ["^name"],
"exclude": {"generic": ["^insurance$"]}
},
"items": [
Expand Down
1 change: 1 addition & 0 deletions data/brands/shop/car.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/shop/car",
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^(car|mécanique)$",
Expand Down
1 change: 1 addition & 0 deletions data/brands/shop/car_repair.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/shop/car_repair",
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^(auto serwis|car repair)$",
Expand Down
1 change: 1 addition & 0 deletions data/brands/shop/electronics.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"displayName": "Apple Store",
"id": "applestore-9377b7",
"locationSet": {"include": ["001"]},
"preserveTags": ["^name"],
"tags": {
"brand": "Apple Store",
"brand:wikidata": "Q421253",
Expand Down
1 change: 1 addition & 0 deletions data/brands/shop/motorcycle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "brands/shop/motorcycle",
"preserveTags": ["^name"],
"exclude": {
"generic": ["^motorcycle$"],
"named": ["^independent$"]
Expand Down
6 changes: 3 additions & 3 deletions data/brands/tourism/hotel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"^гостиница$"
],
"named": [
"^(h(o|ô)tel\\s)?((zur\\s)?post|de france|de la gare|строитель)$",
"^(h(o|ô)tel\\s)?(astoria|belvedere|central|city|colonial|continental|europa)\\s?(h(o|ô)tel)?$",
"^(h(o|ô)tel\\s)?(grand|imperial|krone|palace|panorama|park|plaza|royal|victoria)\\s?(h(o|ô)tel)?$",
"^(h[oô]tel )?((zur )?post|de france|de la gare|строитель)$",
"^(h[oô]tel )?(astoria|belvedere|central|city|colonial|continental|europa)\\s?(h[oô]tel)?$",
"^(h[oô]tel )?(grand|imperial|krone|palace|panorama|park|plaza|royal|victoria)\\s?(h[oô]tel)?$",
"^budget inn$"
]
}
Expand Down
1 change: 1 addition & 0 deletions data/flags/man_made/flagpole.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "flags/man_made/flagpole",
"preserveTags": ["^flag:name"],
"exclude": {"generic": ["^flagpole$"]}
},
"items": [
Expand Down
1 change: 1 addition & 0 deletions data/operators/amenity/hospital.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "operators/amenity/hospital",
"preserveTags": ["^emergency$", "^name"],
"exclude": {
"generic": [
"^(govern?ment( authorities)?|govt( hospital)?|municipal|private|public|private not for profit|village)$",
Expand Down
1 change: 1 addition & 0 deletions data/operators/amenity/parking.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"properties": {
"path": "operators/amenity/parking",
"skipCollection": true,
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^parking( lot)?$",
Expand Down
1 change: 1 addition & 0 deletions data/operators/amenity/post_depot.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "operators/amenity/post_depot",
"preserveTags": ["^name"],
"exclude": {"generic": ["^post depot$"]}
},
"items": [
Expand Down
1 change: 1 addition & 0 deletions data/operators/amenity/post_office.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"properties": {
"path": "operators/amenity/post_office",
"preserveTags": ["^name"],
"exclude": {
"generic": [
"^(agencja pocztowa|ufficio postale|urząd pocztowy)$",
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/trees.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
"^shop/supermarket\\|(famiglia cooperativa|семейный)$",
"^shop/tailor\\|couture\\s?(dame|homme|mixte)?$",
"^tourism/(h|m)otel\\|budget inn$",
"^tourism/hotel\\|(h(o|ô)tel\\s)?((zur\\s)?post|de france|de la gare|строитель)$",
"^tourism/hotel\\|(h(o|ô)tel\\s)?(astoria|belvedere|central|city|continental|europa)\\s?(h(o|ô)tel)?$",
"^tourism/hotel\\|(h(o|ô)tel\\s)?(grand|imperial|krone|palace|panorama|park|plaza|royal|victoria)\\s?(h(o|ô)tel)?$"
"^tourism/hotel\\|(h[oô]tel\\s)?((zur\\s)?post|de france|de la gare|строитель)$",
"^tourism/hotel\\|(h[oô]tel\\s)?(astoria|belvedere|central|city|continental|europa)\\s?(h[oô]tel)?$",
"^tourism/hotel\\|(h[oô]tel\\s)?(grand|imperial|krone|palace|panorama|park|plaza|royal|victoria)\\s?(h[oô]tel)?$"
]
},
"flags": {
Expand Down
14 changes: 7 additions & 7 deletions lib/file_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ exports.write = (cache) => {

// clean locationSet
let cleaned = {};
if (item.locationSet.include) {
if (Array.isArray(item.locationSet.include)) {
cleaned.include = item.locationSet.include.map(_cleanLower).sort(withLocale);
} else {
cleaned.include = ['001']; // default to world
}
if (item.locationSet.exclude) {
if (Array.isArray(item.locationSet.exclude)) {
cleaned.exclude = item.locationSet.exclude.map(_cleanLower).sort(withLocale);
}
item.locationSet = cleaned;
Expand Down Expand Up @@ -257,21 +257,21 @@ exports.write = (cache) => {
let cleanedProps = {};
cleanedProps.path = tkv;

if (properties.nameTag) {
cleanedProps.nameTag = properties.nameTag;
}
if (properties.skipCollection) {
cleanedProps.skipCollection = properties.skipCollection;
}
if (Array.isArray(properties.preserveTags)) {
cleanedProps.preserveTags = properties.preserveTags.map(_cleanLower).sort(withLocale)
}

cleanedProps.exclude = {};
if (properties.exclude.generic) {
if (Array.isArray(properties.exclude.generic)) {
cleanedProps.exclude.generic = properties.exclude.generic.map(_cleanLower).sort(withLocale);
} else {
const v2 = v.replace(/_/g, ' '); // add the value as a generic name exclude (e.g. 'restaurant')
cleanedProps.exclude.generic = [`^${v2}$`];
}
if (properties.exclude.named) {
if (Array.isArray(properties.exclude.named)) {
cleanedProps.exclude.named = properties.exclude.named.map(_cleanLower).sort(withLocale);
}

Expand Down
63 changes: 21 additions & 42 deletions schema/categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,9 @@
"pattern": "^\\S+/\\S+/\\S+$"
},

"mergeStrategy": {
"$comment": "Values here should be patterns that match OSM tag keys",
"description": "(optional) Strategy to take when merging tag values from name-suggestion-index into OpenStreetMap",
"type": "object",
"required": [],
"additionalProperties": false,

"properties": {
"add": {
"description": "(optional) Values in OSM can be added, but existing values should not be modified",
"examples": ["^building$", "^flag:name$", "^takeaway$"],
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"format": "regex"
}
},
"replace": {
"description": "(optional) Values in OSM are always replaced with values in NSI",
"default": [".*"],
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"format": "regex"
}
},
"ignore": {
"description": "(optional) Values in NSI are never used to update OSM",
"examples": ["^payment:"],
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"format": "regex"
}
}
}
"preserveTags": {
"description": "(optional) For tags matching these patterns, NSI should not replace an existing value in OSM",
"$ref": "#/definitions/preserveTags"
},

"skipCollection": {
Expand Down Expand Up @@ -169,6 +133,17 @@
"pattern": "^.*\\.geojson$"
},

"preserveTags": {
"description": "(optional) For tags matching these patterns, NSI should not replace an existing value in OSM",
"examples": ["^name"],
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^\\S+$"
}
},

"notTags": {
"description": "A list of properties that we never want as tags, this is to prevent common mistakes",
"type": "object",
Expand All @@ -178,10 +153,10 @@
"id": { "not" : {} },
"include": { "not" : {} },
"locationSet": { "not" : {} },
"mergeStrategy": { "not" : {} },
"matchNames": { "not" : {} },
"matchTags": { "not" : {} },
"path": { "not" : {} },
"preserveTags": { "not" : {} },
"note": { "not" : {} },
"skipCollection": { "not" : {} },
"tags": { "not" : {} },
Expand Down Expand Up @@ -232,6 +207,11 @@
}
},

"preserveTags": {
"description": "(optional) For tags matching these patterns, NSI should not replace an existing value in OSM",
"$ref": "#/definitions/preserveTags"
},

"note": {
"description": "(optional) An optional note - can contain anything about the item.",
"type": "string"
Expand Down Expand Up @@ -302,9 +282,8 @@
{ "$ref": "#/definitions/notTags" }
]
}

}
}
}

}
}

0 comments on commit deb8799

Please sign in to comment.