Skip to content

Commit

Permalink
Merge branch 'openstreetmap:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sezerbozbiyik authored Nov 20, 2024
2 parents 7da059f + 3bda6c7 commit b9b7c1c
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 241 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ have `.area` and `.way` classes.
Elements also receive classes according to certain of the OSM key-value tags that are
assigned to them.

Tag classes are prefixed with `tag-` (see [`iD.svgTagClasses`](https://github.com/openstreetmap/iD/blob/develop/js/id/svg/tag_classes.js) for details).
Tag classes are prefixed with `tag-` (see [`iD.svgTagClasses`](https://github.com/openstreetmap/iD/blob/develop/modules/svg/tag_classes.js) for details).

#### Primary

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
#### :camera: Street-Level
#### :white_check_mark: Validation
#### :bug: Bugfixes
* Fix unsolvable validator error triggered by regional presets ([#10459])
#### :earth_asia: Localization
* Update Sinitic languages in the Multilingual Names field ([#10488], thanks [@winstonsung])
* Update the list of languages in the Wikipedia field ([#10489])
Expand All @@ -54,6 +55,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Migrate unit tests from karma to vitest ([#10452])

[#10452]: https://github.com/openstreetmap/iD/pull/10452
[#10459]: https://github.com/openstreetmap/iD/pull/10459
[#10488]: https://github.com/openstreetmap/iD/pull/10488
[#10489]: https://github.com/openstreetmap/iD/pull/10489
[@winstonsung]: https://github.com/winstonsung/
Expand Down
16 changes: 16 additions & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,22 @@ en:
network_ref_direction: "{network} {ref} {direction}"
network_ref_from_to: "{network} {ref} from {from} to {to}"
network_ref_from_to_via: "{network} {ref} from {from} to {to} via {via}"
name_direction: "{name} {direction}"
network_name: "{network} {name}"
name_from_to: "{name} from {from} to {to}"
name_from_to_via: "{name} from {from} to {to} via {via}"
network_name_direction: "{network} {name} {direction}"
network_name_from_to: "{network} {name} from {from} to {to}"
network_name_from_to_via: "{network} {name} from {from} to {to} via {via}"
name: "{name}"
ref_name: "{ref}: {name}"
ref_name_direction: "{ref}: {name} {direction}"
ref_name_from_to: "{ref}: {name} from {from} to {to}"
ref_name_from_to_via: "{ref}: {name} from {from} to {to} via {via}"
network_ref_name: "{network} {ref}: {name}"
network_ref_name_direction: "{network} {ref}: {name} {direction}"
network_ref_name_from_to: "{network} {ref}: {name} from {from} to {to}"
network_ref_name_from_to_via: "{network} {ref}: {name} from {from} to {to} via {via}"
speed_unit: "Speed unit"
roadheight:
# symbol for meters
Expand Down
5 changes: 3 additions & 2 deletions modules/presets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export function presetIndex() {
let _loadPromise;


_this.ensureLoaded = () => {
if (_loadPromise) return _loadPromise;
/** @param {boolean=} bypassCache - used by unit tests */
_this.ensureLoaded = (bypassCache) => {
if (_loadPromise && !bypassCache) return _loadPromise;

return _loadPromise = Promise.all([
fileFetcher.get('preset_categories'),
Expand Down
6 changes: 5 additions & 1 deletion modules/ui/sections/raw_membership_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ export function uiSectionRawMembershipEditor(context) {
.attr('class', 'member-entity-name')
.classed('has-colour', d => d.relation.tags.colour && isColourValid(d.relation.tags.colour))
.style('border-color', d => d.relation.tags.colour)
.text(function(d) { return utilDisplayName(d.relation); });
.html(function(d) {
const matched = presetManager.match(d.relation, context.graph());
// hide the network from the name if there is NSI match
return utilDisplayName(d.relation, matched.suggestion);
});

labelEnter
.append('button')
Expand Down
26 changes: 22 additions & 4 deletions modules/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,35 @@ export function utilGetAllNodes(ids, graph) {
}
}


export function utilDisplayName(entity) {
/**
* @param {boolean} hideNetwork If true, the `network` tag will not be used in the name to prevent
* it being shown twice (see PR #8707#discussion_r712658175)
*/
export function utilDisplayName(entity, hideNetwork) {
var localizedNameKey = 'name:' + localizer.languageCode().toLowerCase();
var name = entity.tags[localizedNameKey] || entity.tags.name || '';
if (name) return name;

var tags = {
direction: entity.tags.direction,
from: entity.tags.from,
network: entity.tags.cycle_network || entity.tags.network,
name,
network: hideNetwork ? undefined : (entity.tags.cycle_network || entity.tags.network),
ref: entity.tags.ref,
to: entity.tags.to,
via: entity.tags.via
};

// A right or left-right arrow likely indicates a formulaic “name” as specified by the Public Transport v2 schema.
// This name format already contains enough details to disambiguate the feature; avoid duplicating these details.
if (entity.tags.route && entity.tags.name && entity.tags.name.match(/[→⇒↔⇔]|[-=]>/)) {
return entity.tags.name;
}

// Non-routes tend to be labeled in many places besides the relation lists, such as the map, where brevity is important.
if (!entity.tags.route && name) {
return name;
}

var keyComponents = [];

if (tags.network) {
Expand All @@ -199,6 +214,9 @@ export function utilDisplayName(entity) {
if (tags.ref) {
keyComponents.push('ref');
}
if (tags.name) {
keyComponents.push('name');
}

// Routes may need more disambiguation based on direction or destination
if (entity.tags.route) {
Expand Down
6 changes: 5 additions & 1 deletion modules/validations/mismatched_geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ export function validationMismatchedGeometry() {
var asSource = presetManager.match(entity, graph);

var targetGeom = targetGeoms.find(nodeGeom => {
var asTarget = presetManager.matchTags(entity.tags, nodeGeom);
const asTarget = presetManager.matchTags(
entity.tags,
nodeGeom,
entity.extent(graph).center(),
);
if (!asSource || !asTarget ||
asSource === asTarget ||
// sometimes there are two presets with the same tags for different geometries
Expand Down
Loading

0 comments on commit b9b7c1c

Please sign in to comment.