Skip to main content

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

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.

 


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


Reply