Run a streaming job to spatially filter the results or perform a nearest neighbors analysis.

post

/spatialviewer/api/v1/spark/streaming

Request

Supported Media Types
Query Parameters
Body ()
Job details
Root Schema : StreamingJobInfo
Type: object
Show Source
  • The time interval in seconds at which streaming data will be divided into batches.
    Example: 15
  • 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
  • The geometry to determine the nearest neighbors or the query area in case of filtering. The geometry has to be in GeoJSON format.
    Example: {"type":"Point", "coordinates":[2.33139, 48.86864]}
  • Hostname to connect to for receiving data. Specify the hostname when the default streamProviderFunctionClass is used that is when the property streamProviderFunctionClass is not specified.
    Example: localhost
  • jar name with the user-defined classes like a custom streamProviderFunctionClass or a custom RecordInfoProvider. 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.
    Example: myjar.jar
  • Number of nearest neighbors. Specify this property if the operation is nearestNeighbors.
    Example: 10
  • The operation to perform on the records. The possible values are filter and nearestNeighbors. The default value is filter.
    Example: filter
  • The job output path. This property is optional if asynchronous is false.
    Example: /user/oracle/spatialviewer/StreamingResult
  • Port to connect to for receiving data. Specify the port when the default streamProviderFunctionClass is used that is when the property streamProviderFunctionClass is not specified.
    Example: 9999
  • The class that provides the spatial information.
    Example: oracle.spatial.spark.vector.recordinfoprovider.GeoJsonRecordInfoProvider
  • The spatial operation to spatially filter the records. The possible values are None, AnyInteract, IsInside, WithinDistance and Contains. The default value is AnyInteract. Specify this property if the operation is filter.
    Example: AnyInteract
  • SRID of the geometries.
    Example: 8307
  • The same type than the JavaDStream. The default value is java.lang.String.
    Example: java.lang.String
  • Maximum duration of the stream in seconds. Optional property.
    Example: 3600
  • Class that will return a org.apache.spark.streaming.api.java.JavaDStream. The JavaDStream is the basic abstraction in Spark Streaming that represents a continuous stream of data. The class has to implement java.util.function.Function <JavaStreamingContext, JavaDStream>. The default implementation of the apply function is as following": "return sc.socketTextStream(host, port).map(record->{return record.toString();});
    Example: mypackage.MyFunction
  • Double value that represents the tolerance used when performing spatial operations.
    Example: 0.05
Back to Top

Response

200 Response

successful request. A response will be received each x seconds as define in the property batchDuration. A line representing the record (using the java toString method of the record class) will be printed for each record.

202 Response

accepted asynchronous request
Body ()
Root Schema : AsyncStreamingJobResponse
Type: object
Show Source
Back to Top

Examples

The following example shows how to run a streaming job by submitting a POST request on the REST resource using cURL.

curl -v -X POST "http://localhost:8045/spatialviewer/api/v1/spark/streaming" -H  "accept: application/json" -H  "content-type: application/json" -d "{  \"operation\": \"filter\",  \"hostname\": \"myhost.example.com\",  \"port\": 7777,  \"recordInfoProviderClass\": \"oracle.spatial.hadoop.vector.console.api.action.CSVRecordInfoProvider\",  \"jarWithNeededClasses\": \"myjar.jar\",  \"geometry\": \"{\\\"type\\\":\\\"Point\\\", \\\"coordinates\\\":[-122.460449, 37.743520]}\",  \"srid\": 8307,  \"tolerance\": 0.05,  \"spatialOperation\":\"WithinDistance\",  \"distance\":5000,  \"batchDuration\": 15,  \"streamDuration\": 60}" 

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

Response Body

A response will be received each x seconds as define in the property batchDuration. A line representing the record (using the java toString method of the record class) will be printed for each record.

Back to Top