Class DistanceFunction
- All Implemented Interfaces:
ADQLObject
,ADQLOperand
This function computes the arc length along a great circle between two points and returns a numeric value expression in degrees.
The specification (2.1) defines two versions of the DISTANCE function, one that accepts two POINT values (the only supported in 2.0), and a second that accepts four separate numeric values.
Implementation note: In this current implementation, the 2-argument form allows 2 geometries instead of 2 points. The goal is to be more generic. POINT is supposed to be the main expected type of argument, but it could also be a CENTROID (which returns a POINT). Moreover, some extension of this library might want to support DISTANCE between any type of geometries instead of just points.
If an ADQL service implementation declares support for DISTANCE, then it must implement both the two parameter and four parameter forms of the function.
Example:
An expression calculating the distance between two points of coordinates (25,-19.5) and (25.4,-20) could be written as follows:
DISTANCE(POINT(25.0, -19.5), POINT(25.4, -20.0))
, where all numeric values and the returned arc length are in degrees.
The equivalent call to the four parameter form of the function would be:
DISTANCE(25.0, -19.5, 25.4, -20.0)
The DISTANCE function may be applied to any expression that returns a geometric POINT value.
Example:
The distance between two points stored in the database could be calculated as follows:
DISTANCE(t1.base, t2.target)
, where t1.base and t2.target are references to database columns that contain POINT values.
If the geometric arguments are expressed in different coordinate systems, the DISTANCE function is responsible for converting one, or both, of the arguments into a different coordinate system. If the DISTANCE function cannot perform the required conversion then it SHOULD throw an error. Details of the mechanism for reporting the error condition are implementation dependent.
It is assumed that the arguments for the four numeric parameter form all use the same coordinate system.
-
Nested Class Summary
Nested classes/interfaces inherited from class adql.query.operand.function.geometry.GeometryFunction
GeometryFunction.GeometryValue<F extends GeometryFunction>
Nested classes/interfaces inherited from class adql.query.operand.function.ADQLFunction
ADQLFunction.ParameterIterator
-
Field Summary
FieldsFields inherited from class adql.query.operand.function.geometry.GeometryFunction
coordSys
-
Constructor Summary
ConstructorsConstructorDescriptionDistanceFunction
(DistanceFunction toCopy) Builds a DISTANCE function by copying the given one.DistanceFunction
(GeometryFunction.GeometryValue<GeometryFunction> point1, GeometryFunction.GeometryValue<GeometryFunction> point2) Builds a DISTANCE function. -
Method Summary
Modifier and TypeMethodDescriptiongetCopy()
Gets a (deep) copy of this ADQL object.final LanguageFeature
Get the description of this ADQL's Language Feature.getName()
Gets the name of this object in ADQL.int
Gets the number of parameters this function has.getP1()
Gets the first point.getP2()
Gets the second point.getParameter
(int index) Gets the index-th parameter.Gets the list of all parameters of this function.boolean
Tell whether this operand is a geometrical region or not.boolean
Tell whether this operand is numeric or not.boolean
isString()
Tell whether this operand is a string or not.void
setCoordinateSystem
(ADQLOperand coordSys) Changes the coordinate system.final void
Sets the first point.final void
Sets the second point.setParameter
(int index, ADQLOperand replacer) Replaces the index-th parameter by the given one.Methods inherited from class adql.query.operand.function.geometry.GeometryFunction
getCoordinateSystem
Methods inherited from class adql.query.operand.function.ADQLFunction
adqlIterator, getPosition, paramIterator, setPosition, toADQL
-
Field Details
-
FEATURE
Description of this ADQL Feature.- Since:
- 2.0
-
-
Constructor Details
-
DistanceFunction
public DistanceFunction(GeometryFunction.GeometryValue<GeometryFunction> point1, GeometryFunction.GeometryValue<GeometryFunction> point2) throws NullPointerException Builds a DISTANCE function.- Parameters:
point1
- The first point.point2
- The second point.- Throws:
NullPointerException
- If one of the parameters are incorrect.
-
DistanceFunction
Builds a DISTANCE function by copying the given one.- Parameters:
toCopy
- The DISTANCE function to copy.- Throws:
Exception
- If there is an error during the copy.
-
-
Method Details
-
getFeatureDescription
Description copied from interface:ADQLObject
Get the description of this ADQL's Language Feature.Note: Getting this description is generally only useful when discovery optional features so that determining if they are allowed to be used in ADQL queries.
- Returns:
- Description of this ADQL object as an ADQL's feature.
-
setCoordinateSystem
Description copied from class:GeometryFunction
Changes the coordinate system.- Overrides:
setCoordinateSystem
in classGeometryFunction
- Parameters:
coordSys
- Its new coordinate system.- Throws:
UnsupportedOperationException
- If this function is not associated with a coordinate system.
-
getCopy
Description copied from interface:ADQLObject
Gets a (deep) copy of this ADQL object.- Returns:
- The copy of this ADQL object.
- Throws:
Exception
- If there is any error during the copy.
-
getName
Description copied from interface:ADQLObject
Gets the name of this object in ADQL.- Returns:
- The name of this ADQL object.
-
isNumeric
public boolean isNumeric()Description copied from interface:ADQLOperand
Tell whether this operand is numeric or not.- Returns:
- true if this operand is numeric, false otherwise.
-
isString
public boolean isString()Description copied from interface:ADQLOperand
Tell whether this operand is a string or not.- Returns:
- true if this operand is a string, false otherwise.
-
isGeometry
public boolean isGeometry()Description copied from interface:ADQLOperand
Tell whether this operand is a geometrical region or not.- Returns:
- true if this operand is a geometry, false otherwise.
-
getP1
Gets the first point.- Returns:
- A point.
-
setP1
Sets the first point.- Parameters:
p1
- A point.
-
getP2
Gets the second point.- Returns:
- A point.
-
setP2
Sets the second point.- Parameters:
p2
- A point.
-
getParameters
Description copied from class:ADQLFunction
Gets the list of all parameters of this function.- Specified by:
getParameters
in classADQLFunction
- Returns:
- Its parameters list.
-
getNbParameters
public int getNbParameters()Description copied from class:ADQLFunction
Gets the number of parameters this function has.- Specified by:
getNbParameters
in classADQLFunction
- Returns:
- Number of parameters.
-
getParameter
Description copied from class:ADQLFunction
Gets the index-th parameter.- Specified by:
getParameter
in classADQLFunction
- Parameters:
index
- Parameter number.- Returns:
- The corresponding parameter.
- Throws:
ArrayIndexOutOfBoundsException
- If the index is incorrect (index invalid input: '<' 0 || index >= getNbParameters()).
-
setParameter
public ADQLOperand setParameter(int index, ADQLOperand replacer) throws ArrayIndexOutOfBoundsException, NullPointerException, Exception Description copied from class:ADQLFunction
Replaces the index-th parameter by the given one.- Specified by:
setParameter
in classADQLFunction
- Parameters:
index
- Index of the parameter to replace.replacer
- The replacer.- Returns:
- The replaced parameter.
- Throws:
ArrayIndexOutOfBoundsException
- If the index is incorrect (index invalid input: '<' 0 || index >= getNbParameters()).NullPointerException
- If a required parameter must be replaced by a NULL object.Exception
- If another error occurs.
-