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

I'm writing IOS app that will warn users about exceeding speed limit while driving car. I'll get location from GPS.

How can I find the WAY where I'm currently driving? I've notice that WAY object contains NODEs and NODEs contains coordinates. The only way I came up with is to connect all nodes from WAY and check if I am on this connected patch. Hope there is easiest way...

I've try Overpass API

Pawel

asked 01 Jun '13, 23:04

psci's gravatar image

psci
11112
accept rate: 0%


Several options, all of which require that you set up your own server:

  • load OSM data into PostGIS database with osm2pgsql (ideally configured to load only roads), then make ST_DWITHIN query to find all roads in the vicinity of your point and order them by ST_DISTANCE. This will give correct results even if your query point is a long distance between road nodes.
  • set up an instance of the Nominatim geocoder (also requires server with PostGIS etc) and have it reverse-geocode the position you are looking for; since this will occasionally not return the road itself but also POIs or houses, toy with the "zoom" parameter or modify the software to only return roads

Options that do not require setting up your own server, but that will get you blocked on the respective servers very quickly if your app sends these queries every couple of seconds:

  • use existing Nominatim servers and reverse geocode your location (of course the "modify the software" option is not available then)
  • use Overpass to request all "highway" type ways in a rectangle around your point, with their nodes; then, as you describe, compute the line segments between consecutive points in these ways, and find out which of these line segments is nearest to your position.

Neither of these options will correctly find out whether you are on a bridge or under the same bridge - this is something that would require additional analysis on your part (I was there 10 seconds ago, now I am here, this means I cannot be traveling on that road, it must be this road...)

permanent link

answered 01 Jun '13, 23:37

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Do you mean such query? The location I assumed.

/al

permanent link

answered 04 Jun '13, 14:42

_al's gravatar image

_al
86021018
accept rate: 4%

Your answer
toggle preview

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
×97
×91

question asked: 01 Jun '13, 23:04

question was seen: 54,225 times

last updated: 04 Jun '13, 14:42

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