I am trying to draw a circle on a SceneView and believe my geometry is correct. However the circle is not appearing with a Polyline Symbol. It only appears with a MarkerSymbol which not drawing a continuous circle.
let overlay = GraphicsOverlay()
let point = Point(x: 115, y: 22, spatialReference: .wgs84)
let circleParameters = GeodesicEllipseParameters(center: point, linearUnit: LinearUnit.kilometers, maxPointCount: 360, maxSegmentLength: 0.1, semiAxis1Length: 100, semiAxis2Length: 100)
let geodesicEllipse = GeometryEngine.geodesicEllipse(parameters: circleParameters)
let markerSymbol = SimpleMarkerSymbol(style: SimpleMarkerSymbol.Style.circle, color: .white, size: 2)
let lineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 8)
let circleGraphic = Graphic(geometry: geodesicEllipse, symbol: markerSymbol)
overlay.addGraphic(circleGraphic)
How can I draw a continuous circle on a SceneView given a center Point and a radius?
Solved! Go to Solution.
// Use Polyline
let point = Point(x: 115, y: 22, spatialReference: .wgs84)
let circleParameters = GeodesicEllipseParameters<Polyline>(center: point, linearUnit: LinearUnit.kilometers, maxPointCount: 360, maxSegmentLength: 0.1, semiAxis1Length: 100, semiAxis2Length: 100)
let geodesicEllipse = GeometryEngine.geodesicEllipse(parameters: circleParameters)
let lineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 5)
let circleGraphic = Graphic(geometry: geodesicEllipse, symbol: lineSymbol)
overlay.addGraphic(circleGraphic)
// Use Polygon
let point = Point(x: 115, y: 22, spatialReference: .wgs84)
let circleParameters = GeodesicEllipseParameters<Polygon>(center: point, linearUnit: LinearUnit.kilometers, maxPointCount: 360, maxSegmentLength: 0.1, semiAxis1Length: 100, semiAxis2Length: 100)
let geodesicEllipse = GeometryEngine.geodesicEllipse(parameters: circleParameters)
let lineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 5)
let fillSymbol = SimpleFillSymbol(style: .noFill, outline: lineSymbol)
let circleGraphic = Graphic(geometry: geodesicEllipse, symbol: fillSymbol)
overlay.addGraphic(circleGraphic)
Thanks for the question. We can definitely see the confusion here and we made a change to the API that will go with the next release
Here are a few things
1. The GeodesicEllipseParameters API has an associated type constraint "Geometry". It can be either a protocol, i.e., Multipart, or a concrete type, Multipoint. Long story short, in 200.1 version of the API, it would default to the Multipoint constraint if nothing is passed via the angle brackets.
2. It leads to a problem that the "geodesicEllipse" has a geometry type of Multipoint, which has to be displayed with a marker symbol as a series of points.
3. Instead, you can pass in the type constraint such as <Polygon> or <Polyline>, or even <Multipart>, according to your needs, to enforce the geodesicEllipse to become those respective types.
4. We have received quite a few complaints about this API design being vague and not intuitive both internally and externally, so we immediately made a fix in the 200.2 version of the API. When you use the new version of the API, it will display an error if no type constraint is passed in. 🥲
// Use Polyline
let point = Point(x: 115, y: 22, spatialReference: .wgs84)
let circleParameters = GeodesicEllipseParameters<Polyline>(center: point, linearUnit: LinearUnit.kilometers, maxPointCount: 360, maxSegmentLength: 0.1, semiAxis1Length: 100, semiAxis2Length: 100)
let geodesicEllipse = GeometryEngine.geodesicEllipse(parameters: circleParameters)
let lineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 5)
let circleGraphic = Graphic(geometry: geodesicEllipse, symbol: lineSymbol)
overlay.addGraphic(circleGraphic)
// Use Polygon
let point = Point(x: 115, y: 22, spatialReference: .wgs84)
let circleParameters = GeodesicEllipseParameters<Polygon>(center: point, linearUnit: LinearUnit.kilometers, maxPointCount: 360, maxSegmentLength: 0.1, semiAxis1Length: 100, semiAxis2Length: 100)
let geodesicEllipse = GeometryEngine.geodesicEllipse(parameters: circleParameters)
let lineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 5)
let fillSymbol = SimpleFillSymbol(style: .noFill, outline: lineSymbol)
let circleGraphic = Graphic(geometry: geodesicEllipse, symbol: fillSymbol)
overlay.addGraphic(circleGraphic)
Thanks for the question. We can definitely see the confusion here and we made a change to the API that will go with the next release
Here are a few things
1. The GeodesicEllipseParameters API has an associated type constraint "Geometry". It can be either a protocol, i.e., Multipart, or a concrete type, Multipoint. Long story short, in 200.1 version of the API, it would default to the Multipoint constraint if nothing is passed via the angle brackets.
2. It leads to a problem that the "geodesicEllipse" has a geometry type of Multipoint, which has to be displayed with a marker symbol as a series of points.
3. Instead, you can pass in the type constraint such as <Polygon> or <Polyline>, or even <Multipart>, according to your needs, to enforce the geodesicEllipse to become those respective types.
4. We have received quite a few complaints about this API design being vague and not intuitive both internally and externally, so we immediately made a fix in the 200.2 version of the API. When you use the new version of the API, it will display an error if no type constraint is passed in. 🥲
That's great. Thanks so much for the clarification. Works fine now.