Jun 30, 2017

Querying OSM for stops alongside motorways

While covering some distance on Autobahnen I reminisced on hitchhiking days. Asking yourself through rest areas and fuel stations proved to be a quicker way to get on instead of smiling into car windows along roadsides. Some understanding helped of when the last opportunity will come to depart the current highway to hitch a ride in the direction of your destination. Country overview maps by merchandisers servicing bigger fuelstations help with this. Currently, such a view can be obtained via search for highway number at maps.rast.de which also provides a list of all stations. I wondered if Openstreetmap can provide a similar view. Using overpass-turbo, the introspection tool ("?"-symbol) of openstreetmap itself and keeping an eye on query slot status got me going. Specifics on germanys motorways and multiple examples and utilities helped to form a rough query.

This is restricted to a bounding box the A4 runs through.

[out:json][timeout:120][bbox:50.797500,9.4400024,51.027820,13.263245];
(
  (
    relation[network=BAB][ref="A 4"](50.797500,9.4400024,51.027820,13.263245);
  )->.autobahn;
  (
    way(around.autobahn:300)[highway=services](50.797500,9.4400024,51.027820,13.263245)->.services;
  );
  (
    node(around.autobahn:300)[amenity=fuel](50.797500,9.4400024,51.027820,13.263245)->.fuelstations;
  );
  (
    node(around.autobahn:300)[amenity=parking_space](50.797500,9.4400024,51.027820,13.263245)->.parkinspace;
  );
  (
    way(around.autobahn:100)[highway=rest_area](50.797500,9.4400024,51.027820,13.263245)->.restareas;
  );
);
((.services; .restareas; .parkinspace; .fuelstations;);>;);
out meta;


{{style:

node[highway=rest_area],[amenity=parking_space]
{ color: blue; fill-color: blue; }

area[highway=services],node[highway=services]
{ color: purple; fill-color: purple; }

node[amenity=fuel]
{ color: red; fill-color: red; }
}}

© OpenStreetMap contributors - licensed under CC BY-SA and derived from ODbl - https://www.openstreetmap.org/copyright © OpenStreetMap contributors

Other useful queries until today were locating nearby cellphone towers

[out:json];
  (node["tower:type"="communication"]({{bbox}}));
(._;>;);
out;

or when moving to a new neighborhood a few pragmatic essentials: like post_box and recycling. Checkout the Key:amenity at OSM.

node
  [amenity=recycling]({{bbox}});
out;