angle() | Calculates angle between two segments in a way |
center(…) | Expects a function that returns a geometry and calculates center of the bounding box of its argument. |
changeset() | Returns the id of the changeset for last update to an object |
count(…) | Count the number of objects with a given type (nodes, ways etc.) |
count_by_role() | Count number of members with a specific role |
count_distinct_members() | Count number of distinct members |
count_distinct_by_role() | Count number of distinct members with a specific role |
count_members() | Count number of members for an object |
count_tags() | Count tags for an object |
date(…) | Turns its argument into a number representing a date, for comparison purposes only |
gcat(…) | Calculate combined geometry from its input set |
geom() | Returns geometry of an object |
hull(…) | Expects a function that returns a geometry and returns the convex hull of its argument. |
id() | Returns OSM id of an object |
is_closed() | Returns 1 if a way is closed (first and last node are the same), and 0 otherwise. |
is_date(…) | Tests whether its argument represents a date |
is_number(…) | Returns 1/0 depending on which its argument is a number |
is_tag("name") | Returns 1 if an object has a tag called name. Otherwise 0. Compare with t. |
keys() | Returns keys for a given object |
lat(), lon() | Latitude/longitude of an object (or its bounding box centroid) |
length() | Returns length of an object. Will be length of a way or all ways in a relation |
lrs_in(…,...) | Returns 1 if its first argument is contained in the set provided as a second argument |
lrs_isect(…,...) | Returns the intersection of its two arguments, treated as sets |
lrs_min(…) | Returns the minimum of the elements in its argument |
lrs_max(…) | Returns the maximum of the elements in its argument |
lrs_union(…,...) | Returns the union of its two arguments, treated as sets |
lstr(..,..) | Returns linestring constructed from its arguments |
min(…) | Returns minimum value in the set provided as a parameter |
max(…) | Returns maximum value in the set provided as a parameter |
number(…) | Convers argument to a number, or "NaN" |
per_member(…) | Executes its argument once per member of the element |
per_vertex(…) | Executes its argument once per vertex of the element |
poly(…, …) | Returns a polygon constructed from its arguments |
pos() | Position for a member within an element |
pt(lat, lng) | Returns a valid OSM node geometry for given location |
set(…) | Returns semicolon list of all distinct values in its input. Compare with u(…) |
suffix(…) | Returns any value following a number in its input |
sum(…) | Sums up values in the set provided as parameter. |
timestamp() | Returns the timestamp of an object. |
trace(…) | Expects a function that returns a geomatry and returns the trace (whatever this is?) of its argument. |
type() | Returns type of an object. E.g. node or way. |
t["name"] | Returns the value of the name tag. Compare with is_tag. |
u(…) | Returns the value of sets whose members contains unique values, compare with set(…). |
uid() | Returns the user id of the user who last edited an object. |
user() | Returns the user name of last editor of an object. |
version() | Returns version number of an object. |
lon/lat
[out:json];
area[name='Pfungen'];
node[amenity=restaurant](area);
foreach {
make x
::id = u(id()),
lat = u(lat()),
lon = u(lon()),
name = u(t['name']);
out geom;
}
[out:json];
area[name='Pfungen'];
node[amenity=restaurant](area);
foreach {
make x
::id = u(id ()),
::geom = pt( u(lon()), u(lat())),
name = u(t['name']);
out geom;
}
[out:json];
area[name='Pfungen'];
node[amenity=restaurant][name=Linde ](area) -> .linde;
node[amenity=restaurant][name=Schlosshof](area) -> .schlosshof;
make x
dLon = linde.u(lon()) - schlosshof.u(lon()),
dLat = linde.u(lat()) - schlosshof.u(lat());
out;
length
Determine the number of ways in Pfungen with tag highway and sum up their lengths:
[out:csv(cnt, len)];
{{geocodeArea: Pfungen }};
way [ highway ]( area );
make x
cnt = count(ways ),
len = sum (length());
out;
Determine the length of each way in Pfungen whose highway tag is either residential or primary.
Use set(id)) to print (semicolon separated) all segment (way) id's with the same name value.
[out: csv(name, length, tag, ways) ];
{{geocodeArea: Pfungen }} -> .pfungen;
way
(area.pfungen)
[highway ~ '^(residential|primary)$' ]
[name ] -> .highways;
for.highways (t['name']) {
make x
name = _.val,
length = sum(length()),
tag = min(t['highway']), // Assume all segments have same highway value…
ways = set(id());
out;
}
According to
OpenStreetMap, the length of the Swiss border is 1938 km (while per Wikipedia, it is 1899 km):
[out:csv(lenBorder; false)];
area ['name:en' = 'Switzerland'];
rel(pivot);
make x lenBorder = sum(length()/1000);
out;
pt
make node
::geom=pt(42, 17);
out geom;
Creates
<node id="1">
<point lat="42.0000000" lon="17.0000000"/>
</xyz>
It would, IMHO, be desirable if it created <node id="1" lat="41.0000000" lon="17.0000000"/>.
is_closed
Find closed ways in Winterthur.
Since most (all?) buildings are closed anyway, filter them out:
{{geocodeArea: Winterthur}};
way
[!building]
(area)
(if: is_closed() == 1);
out geom;
poly
{{N= 47.79 }}
{{S= 45.74 }}
{{E= 5.89 }}
{{W= 10.65 }}
[out:json];
make bb_ch
::geom=poly(lstr(
pt( {{S}}, {{E}}),
pt( {{N}}, {{E}}),
pt( {{N}}, {{W}}),
pt( {{S}}, {{W}}),
pt( {{S}}, {{E}})
));
out geom;