24.8 SDO_GCDR.ELOC_ROUTE
Format
SDO_GCDR.ELOC_ROUTE(
route_preference IN VARCHAR2,
distance_unit IN VARCHAR2,
time_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 CLOB;
or
SDO_GCDR.ELOC_ROUTE(
route_preference IN VARCHAR2,
distance_unit IN VARCHAR2,
time_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 CLOB;
Description
Computes the route between two locations and returns a JSON CLOB object that includes the route distance, route time, and geometry of the route in GeoJSON format.
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
. - time_unit
-
Unit of time.
Supported values are:
hour
,minute
, andsecond
. - 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
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
function can accept one of the
following sets of parameters to determine the route 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.
The following describes the schema for the output JSON object:
{
"type": "object",
"properties": {
"routeResponse": {
"type": "object",
"properties": {
"route": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"distance": {
"type": "string"
},
"distanceUnit": {
"type": "string"
},
"time": {
"type": "string"
},
"timeUnit": {
"type": "string"
},
"geometry": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"coordinates": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
}
}
},
"required": [. .]
}
},
"required": [..]
}
},
"required": [..]
}
},
"required": [..]
}
Example
The following example calls the SDO_GCDR.ELOC_ROUTE
function to compute the fastest route taken by an auto between two geographic coordinates.
Note that the output values for route distance, travel time, and route geometry are
extracted from the resulting JSON object using the JSON_VALUE
and
JSON_QUERY
functions:
WITH x AS
(SELECT SDO_GCDR.ELOC_ROUTE('fastest', 'km', 'minute', -71.46439, 42.75875,-71.46278, 42.7553, 'auto') AS t FROM DUAL)
SELECT json_value(t, '$.routeResponse.route.time') AS TIME,
json_value(t, '$.routeResponse.route.distance') AS DIST,
json_query(t, '$.routeResponse.route.geometry' RETURNING CLOB
) AS GEOM
FROM x;
TIME DIST GEOM
---- ---- ---------------------------------------------------------------------------------------------------
0.7 0.41 {"type":"LineString","coordinates":[[-71.4643900005,42.7587499999],[-71.46439,42.75875],
[-71.46433,42.75862],[-71.46431,42.75858],[-71.46421,42.75837],
[-71.4641,42.75813],[-71.46397,42.75785],[-71.46375,42.75739],
[-71.4637,42.75728],[-71.46368,42.75724],[-71.46359,42.75706],
[-71.46351,42.75689],[-71.46333,42.75656],[-71.46326,42.75639],
[-71.46312,42.75605],[-71.46296,42.75568],[-71.46278,42.7553]]}
Parent topic: SDO_GCDR Package (Geocoding)