Skip to content

Commit

Permalink
Merge pull request #4644 from willemarcel/node-number
Browse files Browse the repository at this point in the history
add number of nodes information to measurement panel
  • Loading branch information
bhousel authored Jan 2, 2018
2 parents bf1f429 + 9f1b928 commit 47b9c99
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ en:
location: Location
metric: Metric
imperial: Imperial
node_count: Number of nodes
geometry:
point: point
vertex: vertex
Expand Down
3 changes: 2 additions & 1 deletion dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@
"centroid": "Centroid",
"location": "Location",
"metric": "Metric",
"imperial": "Imperial"
"imperial": "Imperial",
"node_count": "Number of nodes"
}
},
"geometry": {
Expand Down
19 changes: 18 additions & 1 deletion modules/ui/panels/measurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -179,6 +196,7 @@ export function uiPanelMeasurement(context) {
.text(displayArea(area));
}


list
.append('li')
.text(lengthLabel + ':')
Expand All @@ -193,7 +211,6 @@ export function uiPanelMeasurement(context) {
centroid[1].toFixed(OSM_PRECISION) + ', ' + centroid[0].toFixed(OSM_PRECISION)
);


var toggle = isImperial ? 'imperial' : 'metric';

selection
Expand Down

0 comments on commit 47b9c99

Please sign in to comment.