>With osm xml format (overpass, josm), is there any technique to get the
bounds of a given way ?
>I want to get min lat/lng and max lat/lng without processing the whole
document (which can be pretty big)
> ... Thanks in advance for any hint

I am not sure if I understood your problem correctly,  but there are some
interesting  *extended osm xml formats with geometries.*

*Overpass API* [1] has a different XML outputs:
* "out geom" : Add the full geometry to each object."
* "out bb"      : Adds only the bounding box of each element to the
element."
* "out center": This adds only the center of the above mentioned bounding
box to ways and relations."
[1] https://wiki.openstreetmap.org/wiki/Overpass_API/
Overpass_QL#Print_.28out.29

so this query http://overpass-turbo.eu/s/oA4    " way(24710885);   out
geom; "
calculate the bb + add geometries for the nodes;

  <way id="24710885">
    *<bounds minlat="47.5082028" minlon="19.0240336" maxlat="47.5084101"
maxlon="19.0268190"/>*
    <nd ref="268581277" lat="47.5082713" lon="19.0268190"/>
    <nd ref="700251685" lat="47.5082049" lon="19.0265792"/>
    <nd ref="700251660" lat="47.5082028" lon="19.0265032"/>
    <nd ref="268583145" lat="47.5082056" lon="19.0264232"/>
    <nd ref="2859100026" lat="47.5082971" lon="19.0248566"/>
    <nd ref="3114752087" lat="47.5083150" lon="19.0245494"/>
    <nd ref="268583146" lat="47.5083293" lon="19.0243048"/>
    <nd ref="4451395635" lat="47.5084076" lon="19.0240419"/>
    <nd ref="268583147" lat="47.5084101" lon="19.0240336"/>
    <tag k="highway" v="residential"/>
    <tag k="is_in" v="Budapest"/>
    <tag k="name" v="Retek utca"/>
    <tag k="oneway" v="yes"/>
  </way>


As I know *osmtogeojson*  [ https://github.com/tyrasd/osmtogeojson ]
supporting Overpass API's extended geometry output modes.

And  *osmium-tool   *has a similar special command: * "osmium
add-locations-to-ways " *  to create a "Node Locations on Ways" ,
so it is easy to calculate the bounding box.

<way id="123"...>
  <nd ref="12" lon="3.141" lat="5.926"/>
  <nd ref="13" lon="2.111" lat="1.222"/>
</way>

more info:
* https://blog.jochentopf.com/2016-04-20-node-locations-on-ways.html
* http://docs.osmcode.org/osmium/latest/osmium-add-locations-to-ways.html


If the preprocessing is ok, then maybe you can use *"osmium-extract" *   to
"create geographical extracts from an OSM file"    and drop the unwanted
nodes ...
* http://docs.osmcode.org/osmium/latest/osmium-extract.html
* https://blog.jochentopf.com/2017-02-06-expedicious-and-exa
ct-extracts-with-osmium.html


best,
 Imre


2017-04-24 8:26 GMT+02:00 François Lacombe <fl.infosrese...@gmail.com>:

> Hi all,
>
> With osm xml format (overpass, josm), is there any technique to get the
> bounds of a given way ?
>
> I want to get min lat/lng and max lat/lng without processing the whole
> document (which can be pretty big)
>
> This would be useful to list all nodes from my db contained into that
> bounds prior to process ways.
> I want to prevent numerous queries to check if each individual node exists
> or not while importing ways, assuming that some nodes already exist and
> some other don't.
>
> The question can be extended to relations if possible
>
> Thanks in advance for any hint
>
> All the best
> Francois
>
> _______________________________________________
> dev mailing list
> dev@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/dev
>
>
_______________________________________________
dev mailing list
dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/dev

Reply via email to