Filter spatially the records using the Spark API
get
/spatialviewer/api/v1/spark/filter
The output can be rendered as image when the input is a spatial index. Note that you can use the service response as data source for the Map API to display the results on map. For example:
// Default http method when fetching remote geospatial contents
OM.gv.setHttpMethod("GET");
tweetsLayer = new OM.layer.VectorLayer("Result",
{
def:{
type:OM.layer.VectorLayer.TYPE_DATAPACK,
url:'http://localhost:8045/spatialviewer/api/v1/spark/filter?indexPath=/user/oracle/spatialviewer/TweetsJune&queryWindow={"type":"Polygon","coordinates":[[-106, 25, -106, 30, -104, 30, -104, 25, -106, 25]]}',
jsonp: true},
boundingTheme: true});
// Default http method when fetching remote geospatial contents
OM.gv.setHttpMethod("GET");
tweetsLayer = new OM.layer.VectorLayer("Result",
{
def:{
type:OM.layer.VectorLayer.TYPE_DATAPACK,
url:'http://localhost:8045/spatialviewer/api/v1/spark/filter?indexPath=/user/oracle/spatialviewer/TweetsJune&queryWindow={"type":"Polygon","coordinates":[[-106, 25, -106, 30, -104, 30, -104, 25, -106, 25]]}',
jsonp: true},
boundingTheme: true});
Request
Query Parameters
-
asynchronous: boolean
if true the operation is runned asynchronously.Default Value:
false
-
attributeName: string
The name of the attribute to render the color of each records depending on his value. The attributeName is required when outputAsImage is set to true.
-
dataPath: string
Path of the file or files in HDFS to categorize. Specify this parameter if useIndex is false.
Example: /user/oracle/spatialviewer/tweetsJune.json -
distance: number(double)
The distance is required when the spatialOperation is WithinDistance. For projected data the distance is in the same unit as the unit of projection. For geodetic data the distance is in meters.
Example: 1000 -
filterIndex: boolean
This parameter is ignore if the output is not an image. If false all the records of the index are rendered.Default Value:
true
-
fullResult: boolean
if false and asynchronously is false then the response contains the location of the results in HDFS and not the actual results.Default Value:
true
-
imgName: string
Set the name of the image to show on the SpatialViewer UI.
-
indexPath: string
The index path in HDFS. Specify this parameter if useIndex is true.
Example: /user/oracle/spatialviewer/TweetsJune -
inputFormatClass: string
The input format class. Optional parameter that can be set if useIndex is false. If the input format class is not specified then the SparkContext's textFile is used.
Example: oracle.spatial.hadoop.vector.geojson.mapred.GeoJsonInputFormat -
isRenderingByAttributeNumber: boolean
if true the attribute attributeName is numerical. If false the attribute attributeName is handle as an attribute with textual values.Default Value:
false
-
jarWithNeededClasses: string
jar name with the user-defined classes like custom RecordInfoProvider or InputFormat. If the InputFormat class or the RecordInfoProvider class is not in the API, or in the hadoop API classes, then a jar with the user-defined classes must be provided. To be able to use this jar the user must add it in the /opt/oracle/oracle-spatial-graph/spatial/web-server/spatialviewer/WEB-INF/lib directory and restart the server. Optional parameter.
Example: myjar.jar -
keyClass: string
Class of the input format keys. This parameter is required if an input format is defined.
Example: org.apache.hadoop.io.LongWritable -
limits: string
Set the limits as JSON string. For example: [{ "lowerLimit": 1, "upperLimit": 2}, { "lowerLimit": 2, "upperLimit": 3}]. The relation with the colors array has to be 1-1. Optional parameter.
-
maxAttributeValue: number
The maximum possible value of the attribute attributeName. Optional parameter.Default Value:
0
-
minAttributeValue: number
The minimum possible value of the attribute attributeName. Optional parameter.Default Value:
0
-
outputAsImage: boolean
if true the result will be rendered as image. In this case an attribute name has to be provided to render the color of each record. Note that to render the result as image the input has to be a spatial index.Default Value:
false
-
outputPath: string
The job output path. Specify this parameter if asynchronous is true.
Example: /user/oracle/spatialviewer/FilterResult -
queryWindow: string
The queryWindow in GeoJSON format.
Note that the query window can be created using the Map API toolbar standard tools like the Rectangle tool:
var queryWindow = toolbar.getBuiltInTool(OM.control.ToolBar.BUILTIN_RECTANGLE).getGeometry().transform(8307).toString();
Example: {"type":"Polygon","coordinates":[[-106, 25, -106, 30, -104, 30, -104, 25, -106, 25]]} -
recordInfoProviderClass: string
The class that provides the spatial information. Specify this parameter if useIndex is false.
Example: oracle.spatial.spark.vector.recordinfoprovider.GeoJsonRecordInfoProvider -
renderColors: string
Sets the possible colors of the attribute. By default the colors are #225d98, #D3D3D3, #ffa500, #600000. Optional parameter.
-
spatialOperation: string
The spatial operation to spatially filter the records. The possible values are None, AnyInteract, IsInside, WithinDistance and Contains. The default value is AnyInteract.
Example: AnyInteract -
srid: integer(int32)
SRID of the geometries. Specify this parameter if useIndex is false.
Example: 8307 -
textAttributeValues: string
Sets the possible text attribute's values sepated by commas. The relation with the colors array has to be 1-1, that is if 5 possible values are defined then 5 colors have to be defined. For example: very high,high,medium,low,very low. Optional parameter.
-
tolerance: number(double)
Double value that represents the tolerance used when performing spatial operations. Specify this parameter if useIndex is false.
Example: 0.05 -
useIndex: boolean
true if an index is used as input, false otherwise.Default Value:
true
-
valueClass: string
Class of the input format values. This parameter is required if an input format is defined.
Example: org.apache.hadoop.io.Text
Response
Supported Media Types
- application/json
200 Response
successful request
Root Schema : RecordsInfo
Type:
Show Source
object
-
copyright(optional):
string
Example:
Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
-
features(optional):
array features
-
geodetic(optional):
boolean
true if the geometries are geodetic, false otherwise.Example:
true
-
srs(optional):
integer(int32)
SRID of the geometries.Example:
8307
-
type(optional):
string
Example:
FeatureCollection
Nested Schema : Feature
Type:
Show Source
object
-
_id(optional):
string
Feature id.Example:
1
-
geometry(optional):
object Geometry
-
type(optional):
string
Example:
Feature
Nested Schema : Geometry
Type:
Show Source
object
-
coordinates(optional):
array coordinates
-
properties(optional):
object properties
Extra fields of the filtered records (see 2.8.2.1 Spatial Indexing Class Structure). For example we can have extra fields named followers_count, friends_count, location and user_id
-
type(optional):
string
Example:
Point
Nested Schema : properties
Type:
object
Extra fields of the filtered records (see 2.8.2.1 Spatial Indexing Class Structure). For example we can have extra fields named followers_count, friends_count, location and user_id
Show Source
-
followers_count(optional):
string
Example:
70
-
friends_count(optional):
string
Example:
51
-
location(optional):
string
Example:
Canada
-
user_id(optional):
string
Example:
5039703
202 Response
accepted asynchronous request
Root Schema : AsyncSparkFilterJobResponse
Type:
Show Source
object
-
o:successCode(optional):
string
The success code.Example:
SV-05011
-
response(optional):
string
The response contains the location of the resource manager web application URL to track the job (see in the configuration the Hadoop parameter yarn.resourcemanager.webapp.address).Example:
http://resource.manager.webapp:8088
-
status(optional):
string
success or errorExample:
success
-
title(optional):
string
Service title.Example:
Spatial Spark filter.
Examples
The following example shows how to filter using a Spark index by submitting a GET request on the REST resource using cURL.
curl -v -X GET "http://localhost:8045/spatialviewer/api/v1/spark/filter?fullResult=true&queryWindow=\{\"type\":\"Polygon\",\"coordinates\":\[\[-106,25,-106,30,-104,30,-104,25,-106,25\]\]\}&useIndex=true&indexPath=/user/oracle/tweetsJune" -H "accept: application/json"
Example of Response Header
The following shows an example of the response header.
HTTP/1.1 200 OK Date: Wed, 15 Nov 2017 17:50:38 GMT Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET, POST, DELETE, PUT Access-Control-Allow-Headers: Content-Type, Accept Transfer-Encoding: chunked Content-Type: application/json
Example of Response Body
The following example shows the contents of the response body in JSON format, including one record:
{"type":"FeatureCollection","copyright":"Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.","srs":8307,"geodetic":true,"features":[{"type":"Feature","_id":"e8fd9cb3-8d1a-4c54-8583-9a4b682de2fd","geometry":{"type":"Point","coordinates":[-105.49998,28.19997]},"properties":{"RECORD_ID":"4789","followers_count":"13","friends_count":"199","location":"Chihuahua","user_id":"4092140"}}]}