add number of nodes information to measurement panel

This commit is contained in:
Wille Marcel
2018-01-02 10:45:44 -03:00
parent be5929d4dc
commit 9f1b928f89
3 changed files with 21 additions and 2 deletions
+1
View File
@@ -318,6 +318,7 @@ en:
location: Location
metric: Metric
imperial: Imperial
node_count: Number of nodes
geometry:
point: point
vertex: vertex
+2 -1
View File
@@ -397,7 +397,8 @@
"centroid": "Centroid",
"location": "Location",
"metric": "Metric",
"imperial": "Imperial"
"imperial": "Imperial",
"node_count": "Number of nodes"
}
},
"geometry": {
+18 -1
View File
@@ -42,6 +42,14 @@ export function uiPanelMeasurement(context) {
return result;
}
function nodeCount(feature) {
if (feature.type === 'LineString') return feature.coordinates.length;
if (feature.type === 'Polygon') {
return feature.coordinates[0].length - 1;
}
}
function displayLength(m) {
var d = m * (isImperial ? 3.28084 : 1),
@@ -170,6 +178,15 @@ export function uiPanelMeasurement(context) {
(closed ? t('info_panels.measurement.closed') + ' ' : '') + t('geometry.' + geometry)
);
if (entity.type !== 'relation') {
list
.append('li')
.text(t('info_panels.measurement.node_count') + ':')
.append('span')
.text(nodeCount(feature)
);
}
if (closed) {
var area = steradiansToSqmeters(entity.area(resolver));
list
@@ -179,6 +196,7 @@ export function uiPanelMeasurement(context) {
.text(displayArea(area));
}
list
.append('li')
.text(lengthLabel + ':')
@@ -193,7 +211,6 @@ export function uiPanelMeasurement(context) {
centroid[1].toFixed(OSM_PRECISION) + ', ' + centroid[0].toFixed(OSM_PRECISION)
);
var toggle = isImperial ? 'imperial' : 'metric';
selection