Select to view content in your preferred language

Best way to create geom from this feed

218
4
01-23-2025 11:58 PM
SimonGIS
Regular Contributor

I have a HTTP feed using this open endpoint

When I use the option to flatten the schema, I always end up with lots of records and the incidentid for Tracking field seems to be ignored.

If I then leave it and write out to a table without flattening, it just creates the neccessary records that correspond to the packets in the feed.

I then attempted to use the Field Calculator - Construct an Esri Geometry object, but struggled to get it to work with the nested values.

The location field has values like this:

{"lon":150.81224,"lat":-34.01287}

Arcade attempts:

$feature.location[0] - this returns:
text: "{"
 
$feature.location['lat'] - this returns:
 Test execution error: Execution error - Cannot access value using a key of this type. Verify test data.
 
Can anyone point out the best way to work with what is quite a simple feed?
Thanks

 

 

 

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor

@SimonGIS are you specifying a Root node when deriving the schema?  Ex:

JakeSkinner_1-1737720248822.png

You should then be able to create geometry from the location_lon and location_lat fields:

JakeSkinner_2-1737720288441.png

 

PeterNasuti
Esri Contributor

Hi @SimonGIS thanks for posting!

You will need to specify on the Configure HTTP Poller > Confirm Schema page:

  • a root node of results
    • This tells Velocity to only process data and records from within the "results" array
  • check the box of Flatten
    • This reduces the "{"lon": 150.82906,"lat": -34.06914}" string down to location_lon and location_lat field

Additional documentation on flattening and root nodes available here

Snag_c43119cb.png

Then, click next and proceed to Identify Key Fields and specify the geometry fields:

Snag_c4316e15.png

The above is the expected way to configure geometry from this source provided.

Regarding your query about Arcade, Arcade is evaluating that value of "{"lon":150.81224,"lat":-34.01287}" as a string rather than a dictionary. Therefore when you call "$feature.location[0]" it is calling for the 0 index value of the string which is the { character that starts the string. To convert a string to a dictionary in Arcade use the dictionary function.

0 Kudos
SimonGIS
Regular Contributor

Thanks Jake and @PeterNasuti - I should have elaborated and provided more workings. 

I can confirm I initially followed the exact same steps as above, but in this workflow I get duplicate records being recorded and the Track_ID seems to fail.  Starting from scratch:

SimonGIS_4-1737756682108.png

 

Note below I am using the incidentID as the Track_ID

SimonGIS_0-1737755538541.png

Schedule every minute and output to a feature service for testing:

SimonGIS_2-1737756227803.png

At time of writing, there are 9 unique records in the feed.  The feed has initialised 4 times, and I have 4 duplicate sets of records:

SimonGIS_3-1737756602265.png

If I repeat and ignore the date field entirely - same result.

If I remove the flatten option and don't enable geometry = works fine and no duplicate geometries in the table service.  Everything syncs up.

 

I would prefer to get it working all within the feed before resulting to using Arcade.  Am I missing something before going down that path?

0 Kudos
PeterNasuti
Esri Contributor

 Hi @SimonGIS thanks for the additional details - send me an email at pnasuti@esri.com and we will get a product engineer assigned to help investigate what you have reported. Please also log a support ticket for tracking purposes.