24.9 SDO_GCDR.ELOC_ROUTE_DISTANCE
Format
SDO_GCDR.ELOC_ROUTE_DISTANCE(
route_preference IN VARCHAR2,
distance_unit IN VARCHAR2,
start_address IN VARCHAR2,
end_address IN VARCHAR2,
country IN VARCHAR2,
vehicle_type IN VARCHAR2,
print_request_response IN VARCHAR2 DEFAULT 'FALSE'
) RETURN NUMBER;
or
SDO_GCDR.ELOC_ROUTE_DISTANCE(
route_preference IN VARCHAR2,
distance_unit IN VARCHAR2,
start_longitude IN NUMBER,
start_latitude IN NUMBER,
end_longitude IN NUMBER,
end_latitude IN NUMBER,
vehicle_type IN VARCHAR2,
print_request_response IN VARCHAR2 DEFAULT 'FALSE'
) RETURN NUMBER;
Description
Computes the route distance between two locations.
The input locations can either be single-line addresses or be specified by geographic coordinates.
Parameters
- route_preference
-
Routing preference.
Supported values are:
shortest
,fastest
, andtraffic
. - distance_unit
-
Unit of distance.
Supported values are:
mile
,kilometer
,km
, andmeter
. - start_address
-
Complete start address (not formatted into separate fields).
- end_address
-
Complete end address (not formatted into separate fields).
- country
-
ISO 2-character country code. See Country codes in ISO Online Browsing Platform (OBP) to view the list of supported codes.
- start_longitude
-
Longitude value of the starting point.
- start_latitude
-
Latitude value of the starting point.
- end_longitude
-
Longitude value of the ending point.
- end_latitude
-
Latitude value of the ending point.
- vehicle_type
-
Type of vehicle considered for computing the distance.
Supported values are:
auto
andtruck
- print_request_response
-
Determines if the request sent and response received are to be printed.
By default, the parameter value is
'FALSE'
.
Usage Notes
Note:
TheSDO_GCDR.ELOC_ROUTE_DISTANCE
function is only supported on Oracle Autonomous Database.In order to use this function on your Autonomous Database instance, ensure that you have been granted the required permission. See SDO_GCDR.ELOC_GRANT_ACCESS for more information.
The SDO_GCDR.ELOC_ROUTE_DISTANCE
function can accept one
of the following sets of parameters to compute the distance between two points:
- Using unformatted addresses: Provide the
start_address
andend_address
parameters where the complete address is stored in a single field (that is, unformatted). - Using geographic coordinates: Provide the
start_longitude
,start_latitude
,end_longitude
, andend_latitude
parameters to determine the start and end locations.
Note that each parameter input can be a column from a table or view, or an explicit string or number value.
Examples
The following example computes the shortest route distance (in miles) for a truck between two address locations.
SELECT SDO_GCDR.ELOC_ROUTE_DISTANCE('shortest', 'mile', '1 Oracle Dr, Nashua, NH', '77 Massachusetts Ave, Cambridge, MA', 'US', 'truck') route_dist FROM DUAL;
ROUTE_DIST
----------
33.22
The following example uses longitude and latitude coordinates to compute the fastest route distance (in miles) for an auto between two points.
SELECT SDO_GCDR.ELOC_ROUTE_DISTANCE('fastest', 'mile', -122.39436, 37.79579, -122.40459, 37.74211,'auto') route_dist FROM DUAL;
ROUTE_DIST
----------
4.51
Parent topic: SDO_GCDR Package (Geocoding)