How to retrieve Circle from SketchViewModel

707
3
06-01-2020 12:49 PM
RafaelFreitas
New Contributor II

Hello,

I am using SketchViewModel to create geometries into my Scene View. It seems to be working fine, however I ´ve noticed that when using the tool to draw a circle the graphic on the "create" event is a Polygon. It consists of one ring with many points on it.

I needed to get the radius and center point of this created geometry. I can get the center of it, but since it´s a polygon i couldn´t find the radius of it.

There is any way of converting this polygon to a circle? Or to retrieve a Circle geometry when using 'circle' as drawing tool? Or should I just use another strategy for drawing circles?

Thanks!

0 Kudos
3 Replies
JohnGrayson
Esri Regular Contributor

There's no circle geometry type in the API. If necessary, one option is to call the geometryEngine to get the distance between the center and any one of the points.

0 Kudos
RafaelFreitas
New Contributor II

There is a Circle geometry on documentation.

It is a subclass of polygon but I don`t understand why SketchViewModel returns a polyon with lots of points instead of a Circle when drawing tool is set to 'circle'.

Thanks for the response, I will try to compute this distance!

0 Kudos
JohnGrayson
Esri Regular Contributor

Correct, it's just a Polygon and not a different type of geometry; this means it will always be just 'lots of points'.  The way I like to think of it is that the Circle class facilitates and simplifies how those points get created, just like the sketch related tools. The only additional benefit of returning a Circle instead of a Polygon would be to have some of the Circle specific properties, but it wouldn't change the underlying list of points as those would be exactly the same for both the Circle or Polygon. This sounds like a good enhancement request or ArcGIS Ideas.

0 Kudos