json polyline to feature service

4912
3
12-08-2015 07:33 PM
ElliottCarson
New Contributor III

Hi,

Is it possible to get a json file from a folder with polyline features through GeoEvent (10.2.2) to a feature service.

I've successful done this for point features, but at a loss how this could be done for other feature types; eg polylines and polygons.

For points my Input is shown below:

The json text for a point features is as follows:

[

  {

    "items" : [

  {"x" : 114, "y" : -20, "TITLE" : "Ship 1", "SPEED" : 3.0, "COURSE" : 267, "UPDATED_UTC" : 1449479650000},

  {"x" : 115, "y" : -20, "TITLE" : "Ship 2", "SPEED" : 2.0, "COURSE" : 203, "UPDATED_UTC" : 1449479650000},

  {"x" : 114, "y" : -21, "TITLE" : "Ship 3", "SPEED" : 1.0, "COURSE" : 185, "UPDATED_UTC" : 1449479650000}]

  }

]

Regarding the polyline, I can get the fields in but I'm not successful with the actual feature. I'm unsure how to specify the geometry in the input as well as the in the json file.

The json file example below:

[

  {

    "items" : {"paths" : [[[114.1,-20.0], [114.2,-20.0], [114.3,-20.0]]], 

      "TITLE" : "Hugin Explorer",

      "UPDATED_UTC" : 1449479650000

    }

  }

]

Any help is appreciated.

Regards,

Elliott

0 Kudos
3 Replies
ErikNilsson1
New Contributor II

I think it would be possible. Have a look at the section "Using a Field Calculator Processor to compute a geometry" in Appendix 1 to Tutorial - Introduction to GeoEvent which you can download from here:

http://www.arcgis.com/home/group.html?owner=GeoEventTeam&title=ArcGIS%20GeoEvent%20Gallery&content=a...

Basicly it would be possible to make a string formatted with your polyline coordinates (similar to how they do with points in the exampe) and then map the field  to a geometry using the Field Mapper. I am about to start testing this myself now but have some other problems to solve but I will create another thread about that.

ElliottCarson
New Contributor III

Thanks for the info Erik,

I've tried a few ideas from the appendix link you supplied but have yet to be successful.

Regards,

Elliott

0 Kudos
RJSunderman
Esri Regular Contributor

Elliott -

Please take a look at an update I just posted to the thread Re: How to switch positions on coordinates​.

There is no clean way, using a GeoEvent input's Construct Geometry From Fields capability, to create a polyline or polygon Geometry. The input is only able to take two values, an X coordinate and a Y coordinate, and create a point Geometry. It cannot iterate over a list of coordinates, extract values from different positions in the array, and build a string representation of a polyline or polygon Geometry.

However, because the event data in your file is nearly already formatted as Esri Feature JSON, you can do what you are trying to do without too much effort. What you're missing is a leading {"paths": on the front of your quoted string. The JSON you illustrated, the structure in the file your input is reading, has a value named paths, but the value of paths is just the bracketed JSON.

Rather than using a file input, I am going to use an Receive JSON on a REST Endpoint input to HTTP/POST the data you illustrated to a GeoEvent Service. The only change I made to the data was to explicitly quote the value [[[114.1, ... -20.0]]] to designate that it is a String value.

[{

    "items": {

       "paths" : "[[[114.1,-20.0], [114.2,-20.0], [114.3,-20.0]]]",

       "title": "Hugin Explorer",

       "updated_utc": 1449479650000

    }

}]

Here's the GeoEvent Service:

Capture3.png

And here's the expression in the Field Calculator:

'{"paths":' + paths + '}'

Like in the thread I reference above, the Field Mapper processor is simply mapping the computed String to a field of type Geometry. The coordinates (114.1, -20.0) locate the polyline off the coast of Australia, northwest of the Hamersley Range. If that's not correct you could either flip the coordinates in your input file so that they are X, Y ... or if you have to ... use the regular expression magic illustrated in the other thread and configure a Field Calculator do that for you.

Hope this information helps -

RJ

0 Kudos