public static final class ExpressionFactory.Functions extends java.lang.Object
Environment
(if needed). This is
automatically filled in by JOSM and the user only sees the remaining arguments.
When one of the user supplied arguments cannot be converted the
expected type or is null, the function is not called and it returns null
immediately. Add the annotation ExpressionFactory.NullableArguments
to allow null arguments.
Every method must be static.Modifier | Constructor and Description |
---|---|
private |
Functions() |
Modifier and Type | Method and Description |
---|---|
static float |
alpha(java.awt.Color c)
Get the value of the alpha channel in the rgba color model
|
static java.lang.Object |
any(java.lang.Object... args)
Returns the first non-null object.
|
static java.lang.Float |
areasize(Environment env)
Returns the area of a closed way or multipolygon in square meters or
null . |
static boolean |
at(Environment env,
double lat,
double lon)
Determines if the object centroid lies at given lat/lon coordinates.
|
static float |
blue(java.awt.Color c)
Get the value of the blue color channel in the rgb color model
|
static java.lang.Double |
cardinal_to_radians(java.lang.String cardinal)
Converts an angle diven in cardinal directions to radians.
|
static LatLon |
center(Environment env)
Returns the center of the environment OSM primitive.
|
static java.lang.String |
child_tag(Environment env,
java.lang.String key)
Gets the value of the key
key from the object's child. |
static java.lang.String |
color2html(java.awt.Color c)
Computes the HTML notation (
#rrggbb ) for a color value). |
static java.lang.String |
concat(java.lang.Object... args)
Assembles the strings to one.
|
static java.lang.Integer |
count(java.util.List<?> lst)
Returns the number of elements in a list.
|
static long |
CRC32_checksum(java.lang.String s)
Calculates the CRC32 checksum from a string (based on RFC 1952).
|
static double |
degree_to_radians(double degree)
Converts an angle in degrees to radians.
|
static java.lang.Float |
divided_by(float... args)
Function associated to the numeric "/" operator.
|
static boolean |
equal(java.lang.Object a,
java.lang.Object b)
Determines if the objects
a and b are equal. |
static java.lang.Object |
eval(java.lang.Object o)
Identity function for compatibility with MapCSS specification.
|
static java.lang.Object |
get(java.util.List<?> lst,
float n)
Get the
n th element of the list lst (counting starts at 0). |
static boolean |
greater_equal(float a,
float b)
Function associated to the logical ">=" operator.
|
static boolean |
greater(float a,
float b)
Function associated to the logical ">" operator.
|
static float |
green(java.awt.Color c)
Get the value of the green color channel in the rgb color model
|
static boolean |
has_tag_key(Environment env,
java.lang.String key)
Determines whether the object has a tag with the given key.
|
static java.awt.Color |
hsb_color(float h,
float s,
float b)
Create color from hsb color model.
|
static java.awt.Color |
html2color(java.lang.String html)
Creates a color value from an HTML notation, i.e.,
#rrggbb . |
static java.lang.Float |
index(Environment env)
Returns the index of node in parent way or member in parent relation.
|
static boolean |
inside(Environment env,
java.lang.String codes)
Determines if the object is inside territories matching given ISO3166 codes.
|
static boolean |
is_anticlockwise(Environment env)
Determines whether the way is
closed and oriented anticlockwise ,
or non-closed and the 1st, 2nd and last node are in anticlockwise order . |
static boolean |
is_clockwise(Environment env)
Determines whether the way is
closed and oriented clockwise ,
or non-closed and the 1st, 2nd and last node are in clockwise order . |
static java.lang.Boolean |
is_prop_set(Environment env,
java.lang.String key)
Determines whether property
key is set. |
static java.lang.Boolean |
is_prop_set(Environment env,
java.lang.String key,
java.lang.String layer)
Determines whether property
key is set on layer layer . |
static boolean |
is_right_hand_traffic(Environment env)
check if there is right-hand traffic at the current location
|
static java.lang.String |
join_list(java.lang.String separator,
java.util.List<java.lang.String> values)
Joins a list of
values into a single string with fields separated by separator . |
static java.lang.String |
join(java.lang.String... args)
Assembles the strings to one, where the first entry is used as separator.
|
static java.lang.String |
JOSM_pref(Environment env,
java.lang.String key,
java.lang.String def)
|
static java.lang.Boolean |
JOSM_search(Environment env,
java.lang.String searchStr)
Determines whether the JOSM search with
searchStr applies to the object. |
static boolean |
less_equal(float a,
float b)
Function associated to the logical "<=" operator.
|
static boolean |
less(float a,
float b)
Function associated to the logical "<" operator.
|
static java.util.List<java.lang.Object> |
list(java.lang.Object... args)
Creates a list of values, e.g., for the
dashes property. |
static java.lang.String |
lower(java.lang.String s)
Converts string
s to lowercase. |
static java.lang.Float |
minus(float... args)
Function associated to the numeric "-" operator.
|
static boolean |
not_equal(java.lang.Object a,
java.lang.Object b)
Determines if the objects
a and b are not equal. |
static boolean |
not(boolean b)
Function associated to the logical "!" operator.
|
static int |
number_of_tags(Environment env)
Get the number of tags for the current primitive.
|
static long |
osm_id(Environment env)
Returns the OSM id of the current object.
|
static boolean |
outside(Environment env,
java.lang.String codes)
Determines if the object is outside territories matching given ISO3166 codes.
|
static java.lang.Long |
parent_osm_id(Environment env)
Returns the OSM id of the object's parent.
|
static java.lang.String |
parent_tag(Environment env,
java.lang.String key)
Gets the first non-null value of the key
key from the object's parent(s). |
static java.util.List<java.lang.String> |
parent_tags(Environment env,
java.lang.String key)
Gets a list of all non-null values of the key
key from the object's parent(s). |
static float |
plus(float... args)
Function associated to the numeric "+" operator.
|
static java.lang.Object |
print(java.lang.Object o)
Prints the object to the command line (for debugging purpose).
|
static java.lang.Object |
println(java.lang.Object o)
Prints the object to the command line, with new line at the end
(for debugging purpose).
|
static java.lang.Object |
prop(Environment env,
java.lang.String key)
Returns the value of the property
key , e.g., prop("width") . |
static java.lang.Object |
prop(Environment env,
java.lang.String key,
java.lang.String layer)
Returns the value of the property
key from layer layer . |
static float |
red(java.awt.Color c)
Get the value of the red color channel in the rgb color model
|
static java.util.List<java.lang.String> |
regexp_match(java.lang.String pattern,
java.lang.String target)
Tries to match string against pattern regexp and returns a list of capture groups in case of success.
|
static java.util.List<java.lang.String> |
regexp_match(java.lang.String pattern,
java.lang.String target,
java.lang.String flags)
Tries to match string against pattern regexp and returns a list of capture groups in case of success.
|
static boolean |
regexp_test(java.lang.String pattern,
java.lang.String target)
Tests if string
target matches pattern pattern |
static boolean |
regexp_test(java.lang.String pattern,
java.lang.String target,
java.lang.String flags)
Tests if string
target matches pattern pattern |
static java.lang.String |
replace(java.lang.String s,
java.lang.String target,
java.lang.String replacement)
Replaces in
s every target} substring by replacement . |
static java.awt.Color |
rgb(float r,
float g,
float b)
Creates a color value with the specified amounts of
r ed, g reen, b lue (arguments from 0.0 to 1.0) |
static java.awt.Color |
rgba(float r,
float g,
float b,
float alpha)
Creates a color value with the specified amounts of
r ed, g reen, b lue, alpha
(arguments from 0.0 to 1.0) |
static java.lang.String |
role(Environment env)
Returns the role of current object in parent relation, or role of child if current object is a relation.
|
static java.lang.Object |
setting(Environment env,
java.lang.String key)
Get value of a setting.
|
static java.util.List<java.lang.String> |
split(java.lang.String sep,
java.lang.String toSplit)
Splits string
toSplit at occurrences of the separator string sep and returns a list of matches. |
static java.lang.String |
substring(java.lang.String s,
float begin)
Returns the substring of
s starting at index begin (inclusive, 0-indexed). |
static java.lang.String |
substring(java.lang.String s,
float begin,
float end)
Returns the substring of
s starting at index begin (inclusive)
and ending at index end , (exclusive, 0-indexed). |
static java.lang.String |
tag(Environment env,
java.lang.String key)
Gets the value of the key
key from the object in question. |
static float |
times(float... args)
Function associated to the numeric "*" operator.
|
static java.lang.String |
tr(java.lang.String... args)
Translates some text for the current locale.
|
static java.lang.String |
trim(java.lang.String s)
Trim whitespaces from the string
s . |
static java.lang.String |
upper(java.lang.String s)
Converts string
s to uppercase. |
static java.lang.String |
URL_decode(java.lang.String s)
Percent-decode a string.
|
static java.lang.String |
URL_encode(java.lang.String s)
Percent-encode a string.
|
static java.lang.Float |
waylength(Environment env)
Returns the length of the way in metres or
null . |
static java.lang.String |
XML_encode(java.lang.String s)
XML-encode a string.
|
private Functions()
public static java.lang.Object eval(java.lang.Object o)
o
- any objecto
unchangedpublic static float plus(float... args)
args
- argumentspublic static java.lang.Float minus(float... args)
args
- argumentspublic static float times(float... args)
args
- argumentspublic static java.lang.Float divided_by(float... args)
args
- argumentspublic static java.util.List<java.lang.Object> list(java.lang.Object... args)
dashes
property.args
- The values to put in a listArrays.asList(Object[])
public static java.lang.Integer count(java.util.List<?> lst)
lst
- the listpublic static java.lang.Object any(java.lang.Object... args)
args
- argumentsUtils.firstNonNull(Object[])
public static java.lang.Object get(java.util.List<?> lst, float n)
n
th element of the list lst
(counting starts at 0).lst
- listn
- indexn
th element of the list, or null
if index out of rangepublic static java.util.List<java.lang.String> split(java.lang.String sep, java.lang.String toSplit)
toSplit
at occurrences of the separator string sep
and returns a list of matches.sep
- separator stringtoSplit
- string to splitString.split(String)
public static java.awt.Color rgb(float r, float g, float b)
r
ed, g
reen, b
lue (arguments from 0.0 to 1.0)r
- the red componentg
- the green componentb
- the blue componentColor.Color(float, float, float)
public static java.awt.Color rgba(float r, float g, float b, float alpha)
r
ed, g
reen, b
lue, alpha
(arguments from 0.0 to 1.0)r
- the red componentg
- the green componentb
- the blue componentalpha
- the alpha componentColor.Color(float, float, float, float)
public static java.awt.Color hsb_color(float h, float s, float b)
h
- hues
- saturationb
- brightnesspublic static java.awt.Color html2color(java.lang.String html)
#rrggbb
.html
- HTML notationpublic static java.lang.String color2html(java.awt.Color c)
#rrggbb
) for a color value).c
- colorpublic static float red(java.awt.Color c)
c
- colorColor.getRed()
public static float green(java.awt.Color c)
c
- colorColor.getGreen()
public static float blue(java.awt.Color c)
c
- colorColor.getBlue()
public static float alpha(java.awt.Color c)
c
- colorColor.getAlpha()
public static java.lang.String concat(java.lang.Object... args)
args
- argumentsUtils.join(java.lang.String, java.util.Collection<?>)
public static java.lang.String join(java.lang.String... args)
args
- arguments. First one is used as separatorUtils.join(java.lang.String, java.util.Collection<?>)
public static java.lang.String join_list(java.lang.String separator, java.util.List<java.lang.String> values)
values
into a single string with fields separated by separator
.separator
- the separatorvalues
- collection of objectsUtils.join(java.lang.String, java.util.Collection<?>)
public static java.lang.Object prop(Environment env, java.lang.String key)
key
, e.g., prop("width")
.env
- the environmentkey
- the property keypublic static java.lang.Object prop(Environment env, java.lang.String key, java.lang.String layer)
key
from layer layer
.env
- the environmentkey
- the property keylayer
- layerpublic static java.lang.Boolean is_prop_set(Environment env, java.lang.String key)
key
is set.env
- the environmentkey
- the property keytrue
if the property is set, false
otherwisepublic static java.lang.Boolean is_prop_set(Environment env, java.lang.String key, java.lang.String layer)
key
is set on layer layer
.env
- the environmentkey
- the property keylayer
- layertrue
if the property is set, false
otherwisepublic static java.lang.String tag(Environment env, java.lang.String key)
key
from the object in question.env
- the environmentkey
- the OSM keypublic static java.lang.String parent_tag(Environment env, java.lang.String key)
key
from the object's parent(s).env
- the environmentkey
- the OSM keykey
from the object's parent(s)public static java.util.List<java.lang.String> parent_tags(Environment env, java.lang.String key)
key
from the object's parent(s).
The values are sorted according to AlphanumComparator
.env
- the environmentkey
- the OSM keykey
from the object's parent(s)public static java.lang.String child_tag(Environment env, java.lang.String key)
key
from the object's child.env
- the environmentkey
- the OSM keykey
from the object's child, or null
if there is no childpublic static java.lang.Long parent_osm_id(Environment env)
Parent must be matched by child selector.
env
- the environmentnull
AbstractPrimitive.getUniqueId()
public static boolean has_tag_key(Environment env, java.lang.String key)
env
- the environmentkey
- the OSM keytrue
if the object has a tag with the given key, false
otherwisepublic static java.lang.Float index(Environment env)
env
- the environmentpublic static java.lang.String role(Environment env)
env
- the environmentEnvironment.getRole()
public static java.lang.Float areasize(Environment env)
null
.env
- the environmentnull
Geometry.computeArea(IPrimitive)
public static java.lang.Float waylength(Environment env)
null
.env
- the environmentnull
.Way.getLength()
public static boolean not(boolean b)
b
- boolean valuetrue
if !b
public static boolean greater_equal(float a, float b)
a
- first valueb
- second valuetrue
if a >= b
public static boolean less_equal(float a, float b)
a
- first valueb
- second valuetrue
if a <= b
public static boolean greater(float a, float b)
a
- first valueb
- second valuetrue
if a > b
public static boolean less(float a, float b)
a
- first valueb
- second valuetrue
if a < b
public static double degree_to_radians(double degree)
degree
- the angle in degreesMath.toRadians(double)
public static java.lang.Double cardinal_to_radians(java.lang.String cardinal)
n
, north
, ne
, northeast
,
e
, east
, se
, southeast
, s
, south
,
sw
, southwest
, w
, west
, nw
, northwest
.cardinal
- the angle in cardinal directions.RotationAngle.parseCardinalRotation(String)
public static boolean equal(java.lang.Object a, java.lang.Object b)
a
and b
are equal.a
- First objectb
- Second objecttrue
if objects are equal, false
otherwiseObject.equals(Object)
public static boolean not_equal(java.lang.Object a, java.lang.Object b)
a
and b
are not equal.a
- First objectb
- Second objectfalse
if objects are equal, true
otherwiseObject.equals(Object)
public static java.lang.Boolean JOSM_search(Environment env, java.lang.String searchStr)
searchStr
applies to the object.env
- the environmentsearchStr
- the search stringtrue
if the JOSM search with searchStr
applies to the objectSearchCompiler
public static java.lang.String JOSM_pref(Environment env, java.lang.String key, java.lang.String def)
env
- the environmentkey
- Key in JOSM preferencedef
- Default valuepublic static boolean regexp_test(java.lang.String pattern, java.lang.String target)
target
matches pattern pattern
pattern
- The regex expressiontarget
- The character sequence to be matchedtrue
if, and only if, the entire region sequence matches the patternPattern.matches(String, CharSequence)
public static boolean regexp_test(java.lang.String pattern, java.lang.String target, java.lang.String flags)
target
matches pattern pattern
pattern
- The regex expressiontarget
- The character sequence to be matchedflags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")true
if, and only if, the entire region sequence matches the patternPattern.CASE_INSENSITIVE
,
Pattern.DOTALL
,
Pattern.MULTILINE
public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target, java.lang.String flags)
pattern
- The regex expressiontarget
- The character sequence to be matchedflags
- a string that may contain "i" (case insensitive), "m" (multiline) and "s" ("dot all")Matcher.matches()
, or null
.Pattern.CASE_INSENSITIVE
,
Pattern.DOTALL
,
Pattern.MULTILINE
public static java.util.List<java.lang.String> regexp_match(java.lang.String pattern, java.lang.String target)
pattern
- The regex expressiontarget
- The character sequence to be matchedMatcher.matches()
, or null
.public static long osm_id(Environment env)
env
- the environmentAbstractPrimitive.getUniqueId()
public static java.lang.String tr(java.lang.String... args)
{0}
, {1}
, …args
- argumentspublic static java.lang.String substring(java.lang.String s, float begin)
s
starting at index begin
(inclusive, 0-indexed).s
- The base stringbegin
- The start indexString.substring(int)
public static java.lang.String substring(java.lang.String s, float begin, float end)
s
starting at index begin
(inclusive)
and ending at index end
, (exclusive, 0-indexed).s
- The base stringbegin
- The start indexend
- The end indexString.substring(int, int)
public static java.lang.String replace(java.lang.String s, java.lang.String target, java.lang.String replacement)
s
every target} substring by replacement
.s
- The source stringtarget
- The sequence of char values to be replacedreplacement
- The replacement sequence of char valuesString.replace(CharSequence, CharSequence)
public static java.lang.String upper(java.lang.String s)
s
to uppercase.s
- The source stringString.toUpperCase(Locale)
public static java.lang.String lower(java.lang.String s)
s
to lowercase.s
- The source stringString.toLowerCase(Locale)
public static java.lang.String trim(java.lang.String s)
s
.s
- The source stringUtils.strip(java.lang.String)
public static java.lang.String URL_decode(java.lang.String s)
s
- url-encoded stringpublic static java.lang.String URL_encode(java.lang.String s)
concat("data:image/svg+xml,", URL_encode("<svg>...</svg>"));
s
- arbitrary stringpublic static java.lang.String XML_encode(java.lang.String s)
s
- arbitrary stringpublic static long CRC32_checksum(java.lang.String s)
s
- the stringpublic static boolean is_right_hand_traffic(Environment env)
env
- the environmentpublic static boolean is_clockwise(Environment env)
closed and oriented clockwise
,
or non-closed and the 1st, 2nd and last node are in clockwise order
.env
- the environmentpublic static boolean is_anticlockwise(Environment env)
closed and oriented anticlockwise
,
or non-closed and the 1st, 2nd and last node are in anticlockwise order
.env
- the environmentpublic static java.lang.Object print(java.lang.Object o)
o
- the objectpublic static java.lang.Object println(java.lang.Object o)
o
- the objectpublic static int number_of_tags(Environment env)
env
- the environmentpublic static java.lang.Object setting(Environment env, java.lang.String key)
env
- the environmentkey
- setting key (given as layer identifier, e.g. setting::mykey {...})public static LatLon center(Environment env)
env
- the environmentpublic static boolean inside(Environment env, java.lang.String codes)
env
- the environmentcodes
- comma-separated list of ISO3166-1-alpha2 or ISO3166-2 country/subdivision codestrue
if the object is inside territory matching given ISO3166 codespublic static boolean outside(Environment env, java.lang.String codes)
env
- the environmentcodes
- comma-separated list of ISO3166-1-alpha2 or ISO3166-2 country/subdivision codestrue
if the object is outside territory matching given ISO3166 codespublic static boolean at(Environment env, double lat, double lon)
env
- the environmentlat
- latitude, i.e., the north-south position in degreeslon
- longitude, i.e., the east-west position in degreestrue
if the object centroid lies at given lat/lon coordinates