NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Thinking about how to visualize the direction of a way in mapcontrib or umap instance using an Overpass query: it might be done by querying the second node of a way. If you overlay that node on the way itself, it can show you where it begins. Maybe again for the second-last. (Not the first and last nodes, because they would often overlap with the nodes of an adjacent way)

Say I want to show the direction of highways that don't have a oneway tag in this way, how would I go from this basic query?

[out:json][timeout:25];
(
  way["highway"][!"oneway"]({{bbox}});
);
out body;
>;
out skel qt;

If you have a better idea to approach the problem, do go ahead.

asked 10 Feb '17, 07:49

joost%20schouppe's gravatar image

joost schouppe
3.4k245087
accept rate: 12%


visualize the direction of a way

The optimal solution for this would be to make the displaying software (here: umap) render the direction of the lines for one.

[…] by querying the second node of a way.

The Overpass API doesn't (yet?) support nth-child queries for way-nodes (or relation members).

But you could do this in post-processing: After converting the Overpass result to GeoJSON, run something like the following (in nodejs):

var geojson = … geojson.features.forEach(f => { if (f.geometry.type !== "LineString") return; var newcoords = [0,0], coords = f.geometry.coordinates; newcoords[0] = coords[0][0]*0.75+coords[1][0]*0.25; newcoords[1] = coords[0][1]*0.75+coords[1][1]*0.25; geojson.features.push({type:'Feature', properties:{}, geometry:{type:'Point', coordinates:newcoords}}); });

After that, there are additional point features in the geojson which are placed near the start point of each LineString (1 quarter distance towards the second vertex).

permanent link

answered 23 Feb '17, 16:24

tyr_asd's gravatar image

tyr_asd
1.2k51927
accept rate: 64%

Thanks for the help!

(24 Feb '17, 07:48) joost schouppe

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×314
×167
×24
×1

question asked: 10 Feb '17, 07:49

question was seen: 3,469 times

last updated: 24 Feb '17, 07:48

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum