Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add number of nodes information to measurement panel #4644

Merged
merged 1 commit into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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