Skip to main content
Question

Creating polygon from API response

  • January 31, 2020
  • 2 replies
  • 66 views

mattebridges
Contributor
Forum|alt.badge.img+6

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

jdh
Contributor
Forum|alt.badge.img+40
  • 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+6
  • Author
  • Contributor
  • January 31, 2020

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