User:mmd

From OpenStreetMap Wiki
Jump to navigation Jump to search


OSM user page


A word of advice

Back in 2006...

OSM Wiki Warning 2006.png

Overpass API examples

All of the following examples are not supported on the official Overpass API instance at overpass-api.de!

Export highways in current bounding box in PBF format

try it yourself in overpass-turbo
[out:pbf];
way[highway]({{bbox}});
(._;>;);
out meta;


{{data:overpass,server=https://dev.overpass-api.de/api_mmd/}}

Export highways in current bounding box in OPL format

try it yourself in overpass-turbo
[out:opl];
way[highway]({{bbox}});
(._;>;);
out meta;


{{data:overpass,server=https://dev.overpass-api.de/api_mmd/}}

ICU regular expression support

Also see https://www.openstreetmap.org/user/mmd/diary/40197

Nodes with Chinese (Han) characters in current bounding box

try it yourself in overpass-turbo
// switch to ICU Regexp implemenation
// see http://userguide.icu-project.org/strings/regexp

[regexp:ICU];


node({{bbox}})["name"~"[\\p{script=Han}]"];

out meta center;


{{data:overpass,server=https://dev.overpass-api.de/api_mmd/}}


No-U-Turn Relations with from = to member

try it yourself in overpass-turbo
[timeout:30];

// No-u-turn restrictions mit from = to

rel[restriction=no_u_turn][type=restriction]({{bbox}})
   (if:count_by_role("via") == 1  &&
       count_by_role("from") == 1 &&
       count_by_role("to") == 1);

foreach -> .rel(
  
  way(r.rel:"from") -> .w_from;
  way(r.rel:"to")   -> .w_to;
 
  if ( w_from.min(id()) == w_to.min(id()) )
  (
     .rel out geom meta; 
  );
);

// Depends on 0.7.55+ features:
{{data:overpass,server=https://dev.overpass-api.de/api_mmd/}}


Ad hoc area creation

Find buildings without housenumber - both on way, as well as inside the way as node.

try it yourself in overpass-turbo
way[building][!"addr:housenumber"]({{bbox}});

foreach ->.pivot {
  ( 
    .pivot;
    node(w.pivot);
  );

  ( make_area [.pivot]; .result;)->.result;
}

foreach .result -> .area {

  node["addr:housenumber"](area.area);

  if(count(nodes) == 0) {
    way(pivot.area);
    out geom meta;
  }
}


{{data:overpass,server=//dev.overpass-api.de/api_mmd/}}

Overpass instance timestamp check

Quick and dirty script to extract current timestamp_osm_base and version number using a dummy query:

#!/bin/bash

declare -a arr=("https://dev.overpass-api.de/api_mmd/interpreter"
                "https://lz4.overpass-api.de/api/interpreter"
                "https://z.overpass-api.de/api/interpreter"
                "https://overpass.maptime.in/api/interpreter"
                "https://1.overpass.kumi.systems/api/interpreter"
                "https://2.overpass.kumi.systems/api/interpreter"
                "https://3.overpass.kumi.systems/api/interpreter"
                "https://4.overpass.kumi.systems/api/interpreter"

)

check() {

   RES_ALL=`curl -m 5 -s $1?data=%5Bout%3Ajson%5D%3Bout%3B`
   RES1=`echo $RES_ALL | jq -r ".osm3s .timestamp_osm_base"`
   RES2=`echo $RES_ALL | jq -r ".generator"`
   RES3=`date --utc +%FT%TZ`
   RES1S=`date -d "$RES1" '+%s'`
   RES3S=`date -d "$RES3" '+%s'`
   DELTA=$(( $RES3S - $RES1S ))
   DELTA_HOUR=`date -d@$DELTA -u +%H:%M:%S`
   printf "%-50s | %-20s | %10s | %-30s \n" "$i" "$RES1" "$DELTA_HOUR" "$RES2" 
}

for i in "${arr[@]}"
do
   check $i
done

Result:

Some instances may have a delay of more than 10 minutes, or even stopped updating completely. Watch out for outdated data.

https://dev.overpass-api.de/api_mmd/interpreter    | 2019-06-04T19:22:02Z |   00:02:32 | Overpass API 0.7.59_mmd        
https://lz4.overpass-api.de/api/interpreter        | 2019-06-04T19:24:02Z |   00:00:32 | Overpass API 0.7.55.7 8b86ff77 
https://z.overpass-api.de/api/interpreter          | 2019-06-04T19:22:02Z |   00:02:33 | Overpass API 0.7.55.7 8b86ff77 
https://overpass.maptime.in/api/interpreter        | 2019-06-04T19:23:02Z |   00:01:33 | Overpass API 0.7.55.6 486819c8 
https://1.overpass.kumi.systems/api/interpreter    | 2019-06-04T18:59:02Z |   00:25:33 | Overpass API 0.7.55.7 8b86ff77 
https://2.overpass.kumi.systems/api/interpreter    | 2019-05-31T02:11:02Z |   17:13:33 | Overpass API 0.7.55.7 8b86ff77 
https://3.overpass.kumi.systems/api/interpreter    | 2019-06-04T19:02:02Z |   00:22:34 | Overpass API 0.7.55.7 8b86ff77 
https://4.overpass.kumi.systems/api/interpreter    | 2019-06-04T19:12:03Z |   00:12:33 | Overpass API 0.7.55.7 8b86ff77