<div dir="ltr"><div dir="auto" style="font-size:12.8px">>With osm xml format (overpass, josm), is there any technique to get the bounds of a given way ?</div><div dir="auto" style="font-size:12.8px"><span style="font-size:12.8px">>I want to get min lat/</span>lng<span style="font-size:12.8px"> and max lat/</span>lng<span style="font-size:12.8px"> without processing the whole document (which can be pretty big)</span><br></div><div>> ... <span style="font-size:12.8px">Thanks in advance for any hint</span><br><br>I am not sure if I understood your problem correctly, but there are some interesting <b>extended osm xml formats with geometries.</b></div><div><br></div><div><b>Overpass API</b> [1] has a different XML outputs:</div>* "out geom" : Add the full geometry to each object."<br>* "out bb" : Adds only the bounding box of each element to the element."<br>* "out center": This adds only the center of the above mentioned bounding box to ways and relations."<div>[1] <a href="https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Print_.28out.29" target="_blank">https://wiki.openstreetmap.<wbr>org/wiki/Overpass_API/<wbr>Overpass_QL#Print_.28out.29</a><br><br>so this query <a href="http://overpass-turbo.eu/s/oA4" target="_blank">http://overpass-turbo.<wbr>eu/s/oA4</a> <font color="#0000ff"> " way(24710885); out geom; "</font></div><div>calculate the bb + add geometries for the nodes; </div><div><br><div><font color="#0000ff" face="monospace, monospace"> <way id="24710885"></font></div><div><font color="#0000ff" face="monospace, monospace"> <b><bounds minlat="47.5082028" minlon="19.0240336" maxlat="47.5084101" maxlon="19.0268190"/></b></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="268581277" lat="47.5082713" lon="19.0268190"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="700251685" lat="47.5082049" lon="19.0265792"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="700251660" lat="47.5082028" lon="19.0265032"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="268583145" lat="47.5082056" lon="19.0264232"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="2859100026" lat="47.5082971" lon="19.0248566"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="3114752087" lat="47.5083150" lon="19.0245494"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="268583146" lat="47.5083293" lon="19.0243048"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="4451395635" lat="47.5084076" lon="19.0240419"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <nd ref="268583147" lat="47.5084101" lon="19.0240336"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <tag k="highway" v="residential"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <tag k="is_in" v="Budapest"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <tag k="name" v="Retek utca"/></font></div><div><font color="#0000ff" face="monospace, monospace"> <tag k="oneway" v="yes"/></font></div><div><font color="#0000ff" face="monospace, monospace"> </way></font></div><div><br></div></div><div><br></div><div>As I know <b>osmtogeojson</b> [ <a href="https://github.com/tyrasd/osmtogeojson" target="_blank">https://github.com/tyrasd/<wbr>osmtogeojson</a> ] supporting Overpass API's extended geometry output modes.</div><div><br></div><div>And <b>osmium-tool </b>has a similar special command: <b> <font color="#0000ff">"osmium add-locations-to-ways " </font></b><font color="#0000ff"> </font> to create a "Node Locations on Ways" , </div><div>so it is easy to calculate the bounding box.</div><div><pre style="font-family:consolas,"lucida console",monospace;font-size:14.4px;line-height:normal;border:1px dashed rgb(192,192,192);background-color:rgb(245,255,223);padding:1em;overflow:auto;color:rgb(32,32,32)"><way id="123"...>
<nd ref="12" lon="3.141" lat="5.926"/>
<nd ref="13" lon="2.111" lat="1.222"/>
</way> </pre>more info: </div><div>* <a href="https://blog.jochentopf.com/2016-04-20-node-locations-on-ways.html" target="_blank">https://blog.jochentopf.com/20<wbr>16-04-20-node-locations-on-way<wbr>s.html</a><br>* <a href="http://docs.osmcode.org/osmium/latest/osmium-add-locations-to-ways.html" target="_blank">http://docs.osmcode.org/osmium<wbr>/latest/osmium-add-locations-t<wbr>o-ways.html</a><br><br><br>If the preprocessing is ok, then maybe you can use <b><font color="#0000ff">"osmium-extract"</font> </b> to "create geographical extracts from an OSM file" and drop the unwanted nodes ... <br>* <a href="http://docs.osmcode.org/osmium/latest/osmium-extract.html" target="_blank">http://docs.osmcode.org/osmi<wbr>um/latest/osmium-extract.html</a><br>* <a href="https://blog.jochentopf.com/2017-02-06-expedicious-and-exact-extracts-with-osmium.html" target="_blank">https://blog.jochentopf.com/<wbr>2017-02-06-expedicious-and-exa<wbr>ct-extracts-with-osmium.html</a><br><br><br>best,</div><div> Imre</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-24 8:26 GMT+02:00 François Lacombe <span dir="ltr"><<a href="mailto:fl.infosreseaux@gmail.com" target="_blank">fl.infosreseaux@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hi all,<div dir="auto"><br></div><div dir="auto">With osm xml format (overpass, josm), is there any technique to get the bounds of a given way ?</div><div dir="auto"><br></div><div dir="auto">I want to get min lat/lng and max lat/lng without processing the whole document (which can be pretty big)</div><div dir="auto"><br></div><div dir="auto">This would be useful to list all nodes from my db contained into that bounds prior to process ways.</div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">The question can be extended to relations if possible</div><div dir="auto"><br></div><div dir="auto">Thanks in advance for any hint</div><div dir="auto"><br></div><div dir="auto">All the best</div><div dir="auto">Francois</div></div>
<br>______________________________<wbr>_________________<br>
dev mailing list<br>
<a href="mailto:dev@openstreetmap.org">dev@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/dev" rel="noreferrer" target="_blank">https://lists.openstreetmap.<wbr>org/listinfo/dev</a><br>
<br></blockquote></div><br></div>