drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
716 stars 90 forks source link

abs() function #569

Closed mmd-osm closed 2 years ago

mmd-osm commented 4 years ago

The examples in https://dev.overpass-api.de/blog/total_0_7_56.html#memberpos would probably benefit from having an abs() function to return the absolute value of a number.

This should be a bit easier to read:

way(60538085);
node(w)(if:lrs_in(id(),set(per_vertex(
    ! ( abs(angle()) > 88 && abs(angle()) < 92 ) &&
    ! ( abs(angle()) < 2)
    ? ref() : 0))));
out geom;

current version:

way(60538085);
node(w)(if:lrs_in(id(),set(per_vertex(
    (angle()<-92 || (angle() >-88 && angle() < -2)
    || (angle() > 2 && angle() < 88) || angle() > 92)
    ? ref() : 0))));
out geom;
mmd-osm commented 2 years ago

Implemented in https://github.com/drolbr/Overpass-API/commit/e83dce54d0b192b67761d2df66f61da4b741d62d

I’m closing this issue… Thanks!