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

0
1

I have OSM data using osm2pgsql (slim) with default style in PostgreSQL GIS DB. For my usage I'm trying to predict where the customer will go according to his current position on some way node.

In order to do so I want to get the all way (road) data by its current partial way.

I know how to do it by overpass using recursion up but can't find how to do it with SQL query (actually I done something but not so good by getting the way ref and then look for more ways with the same ref)

Tn'x for any help.

asked 30 May '18, 11:22

altopalo's gravatar image

altopalo
5381013
accept rate: 0%

edited 30 May '18, 19:04

The answer is probably something with the relations between the data objects in the DB. So is there a good explanations of the data schema & relations of the osm2postgress schema? (can't find a decent documentation on that)

(31 May '18, 10:42) altopalo

I found the solution, so is someone will search for it.

Need to use planet_osm_rels table

Sample:

select osm_id, ref, name, way 
FROM planet_osm_roads where ST_DWithin(ST_Transform(ST_SetSrid(ST_Point(-1.021076,51.714512), 4326), 3857), way,20000) 
and osm_id in( 
    SELECT distinct(unnest(parts)) as part 
    FROM planet_osm_rels 
    WHERE parts @> ARRAY[147856382]::bigint[] and tags @> ARRAY['M40']::text[]
)
permanent link

answered 13 Dec '18, 12:53

altopalo's gravatar image

altopalo
5381013
accept rate: 0%

edited 13 Dec '18, 12:55

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:

×223
×147
×37
×34

question asked: 30 May '18, 11:22

question was seen: 2,596 times

last updated: 13 Dec '18, 12:55

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