[OSM-talk] Overpass API 0.7.4: the difference operator

Roland Olbricht roland.olbricht at gmx.de
Fri Aug 2 16:15:40 UTC 2013


Dear Co-mappers,

The new release 0.7.4 of Overpass API has just been deployed on
http://overpass-api.de/
The Rambler instance will continue to run version 0.7.3 for some days in case 
of unexpected flaws in the new version. A lot of minor bugs have been fixed. 
More important, the query for ways on small bounding boxes is now more 
efficient. This speeds up
http://overpass.apis.dev.openstreetmap.org/
the beta prototype for a popup overlay on the main page.

I've also made two extensions in the syntax: The use of Global Bounding Boxes 
will be subject of a later mail to talk@ when the newest version of the JOSM 
plugin mirrored_download has been deployed.

Now I talk about the difference operator: It simplifies the kind of searches 
"every object that has property (or is an) X, but hasn't property (or is an) 
Y". For example, all nodes that have a value for "maxheight" but aren't part 
of a street (a way with tag "highway"):

http://overpass-turbo.eu/s/Ib

// New in Overpass 0.7.4: the difference operator

[bbox:50.6,7.0,50.8,7.3];
(
  node[maxheight];     // All nodes witha value for "maxheight"
  -
  (way[highway];>;);   // that aren't part of any kind of street
);
out;

For the very common case "has tag X, but not tag Y" I suggest to carry on with 
"[...!~...]". This is more efficient than the difference operator:

http://overpass-turbo.eu/s/Ic

// New in Overpass 0.7.4: the difference operator
//
// If the negation only covers that a certain tag is absent, you may prefer
// the tag negation operator. This operator is faster than difference.

[bbox:50.7,7.0,50.75,7.1];
( way[highway=residential][name!~'.'];  // ways with tag "highway", but 
without tag "name"
  >;
);
out;

All details are given in the wiki:
http://wiki.openstreetmap.org/wiki/Overpass_API/versions

Cheers,

Roland




More information about the talk mailing list