mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
be a bit more lenient when determining if a node is an address node
consider some additional tags as "not interesting"/non-POI-like: * check_date/fixme/note/note:*/survey:* — mapping related tags * layer/level/level:ref — can be considered attributes of the address * ref:* – often used to indicate a source ID on imported data
This commit is contained in:
@@ -75,11 +75,6 @@ export function svgLabels(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
function get(array, prop) {
|
||||
return function(d, i) { return array[i][prop]; };
|
||||
}
|
||||
|
||||
|
||||
function drawLinePaths(selection, labels, filter, classes) {
|
||||
var paths = selection.selectAll('path:not(.debug)')
|
||||
.filter(d => filter(d.entity))
|
||||
@@ -374,12 +369,6 @@ export function svgLabels(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
function isAddressPoint(tags) {
|
||||
const keys = Object.keys(tags);
|
||||
return keys.length > 0 && keys.every(key =>
|
||||
key.startsWith('addr:') || !osmIsInterestingTag(key));
|
||||
}
|
||||
|
||||
function getPointLabel(entity, width, height, style) {
|
||||
var y = (style.geometry === 'point' ? -12 : 0);
|
||||
var pointOffsets = {
|
||||
@@ -775,7 +764,7 @@ export function svgLabels(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
var _textWidthCache = {};
|
||||
const _textWidthCache = {};
|
||||
export function textWidth(text, size, container) {
|
||||
let c = _textWidthCache[size];
|
||||
if (!c) c = _textWidthCache[size] = {};
|
||||
@@ -791,3 +780,23 @@ export function textWidth(text, size, container) {
|
||||
elem.remove();
|
||||
return c[text];
|
||||
}
|
||||
|
||||
|
||||
const nonPrimaryKeys = new Set([
|
||||
'check_date',
|
||||
'fixme',
|
||||
'layer',
|
||||
'level',
|
||||
'level:ref',
|
||||
'note'
|
||||
]);
|
||||
const nonPrimaryKeysRegex = /^(ref|survey|note):/;
|
||||
export function isAddressPoint(tags) {
|
||||
const keys = Object.keys(tags);
|
||||
return keys.length > 0 && keys.every(key =>
|
||||
key.startsWith('addr:') ||
|
||||
!osmIsInterestingTag(key) ||
|
||||
nonPrimaryKeys.has(key) ||
|
||||
nonPrimaryKeysRegex.test(key)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,32 +2,26 @@ import deepEqual from 'fast-deep-equal';
|
||||
import { clamp } from 'lodash-es';
|
||||
|
||||
import { geoScaleToZoom } from '../geo';
|
||||
import { osmEntity, osmIsInterestingTag } from '../osm';
|
||||
import { osmEntity } from '../osm';
|
||||
import { svgPointTransform } from './helpers';
|
||||
import { svgTagClasses } from './tag_classes';
|
||||
import { presetManager } from '../presets';
|
||||
import { textWidth } from './labels';
|
||||
import { textWidth, isAddressPoint } from './labels';
|
||||
|
||||
export function svgPoints(projection, context) {
|
||||
|
||||
function markerPath(selection, klass) {
|
||||
const isHousenumber = d => {
|
||||
const tagKeys = Object.keys(d.tags);
|
||||
if (tagKeys.length === 0) return false;
|
||||
return Object.keys(d.tags).every(key =>
|
||||
key.startsWith('addr:') || !osmIsInterestingTag(key));
|
||||
};
|
||||
const addressShieldWidth = d => {
|
||||
const width = textWidth(d.tags['addr:housenumber'] || d.tags['addr:housename'] || '', 10, selection.node().parentElement);
|
||||
return clamp(width, 10, 34) + 8;
|
||||
};
|
||||
selection
|
||||
.attr('class', klass)
|
||||
.attr('transform', d => isHousenumber(d)
|
||||
.attr('transform', d => isAddressPoint(d.tags)
|
||||
? `translate(-${addressShieldWidth(d)/2}, -8)`
|
||||
: 'translate(-8, -23)')
|
||||
.attr('d', d => {
|
||||
if (!isHousenumber(d)) {
|
||||
if (!isAddressPoint(d.tags)) {
|
||||
return 'M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z';
|
||||
}
|
||||
const shieldWidth = addressShieldWidth(d);
|
||||
|
||||
Reference in New Issue
Block a user