Skip to main content
Question

Creating polygon from API response


mattebridges
Contributor
Forum|alt.badge.img+5

Hello - I'm trying to create a polygon from co-ordinates received from an API call. The response body containing the co-ordinates is attached. The response can include shells and holes and I would like to be able to create both of these features if required (the attached example doesn't include shells but we will encounter these in future use).

I think the response form the API is JSON and the workbench I've built to call the API is storing this response in an attribute ('_response_body').

I'm really not sure how I can turn these co-ordinates into a polygon and I would be so grateful for any help.

Thanks in advance and all the best,

Matt

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 31, 2020

jsonpolygon.fmwUnfortunately that response is not a standard geoJSON or esriJSON, so you can't just use the geometryReplacer to create the polygon.

There are two ways to approach this, either convert the response to a standard geoJSON or extract the coordinates and rebuild the polygons.

The second approach is perhaps less efficient, but is far easier to understand.

 

 

A series of JSONFragmenters, or a recursive JSONFragmenter and some listExploders to get one feature per vertex with a common id.

 

 

VertexCreator, LineBuilder, DonutBuilder with the latter two grouped by common id to get the geometry.

 


mattebridges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 31, 2020

@jdh - thank you so much for this - with some minor amendments it's working perfectly. I am VERY grateful.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings