How to draw a circle with given radius and center in given coordinates?

2219
4
Jump to solution
02-15-2021 11:48 PM
VanyaIvanov
Occasional Contributor

How to draw a circle using Arcgis Java SDK on the arcgis Scene?

0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor

The Buffer operation will help you here:

https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/geometry/GeometryE...

However you need to be careful when using this in 3D if your location is in WGS84 (latitude / longitude) as the buffer used the unit of measure associated with the spatial reference of your point.  This will be in degrees is its WGS84 and you may wonder why your buffers are quite large!

The trick is to work in a Projected Coordinate system for this so you can use metres as your unit of measure.  So imagine you've got a point collected from a click even on your scene, you would convert this before using a buffer:

              // get the point as a web mercator point 
              Point mapPoint = (Point) GeometryEngine.project( wgs84Point, SpatialReferences.getWebMercator());
              System.out.println("SR : " + mapPoint.getSpatialReference().getWKText());

              // 500 metre buffer
              Polygon polygon =GeometryEngine.buffer(mapPoint, 500);

              // some styles
              SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF00FF00, 3);
              SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFFF0000, simpleLineSymbol);

              // make a graphic and draw it!
              Graphic graphic = new Graphic(polygon, simpleFillSymbol);
              graphicsOverlay.getGraphics().add(graphic);

 

Does this help?

View solution in original post

4 Replies
MarkBaird
Esri Regular Contributor

The Buffer operation will help you here:

https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/geometry/GeometryE...

However you need to be careful when using this in 3D if your location is in WGS84 (latitude / longitude) as the buffer used the unit of measure associated with the spatial reference of your point.  This will be in degrees is its WGS84 and you may wonder why your buffers are quite large!

The trick is to work in a Projected Coordinate system for this so you can use metres as your unit of measure.  So imagine you've got a point collected from a click even on your scene, you would convert this before using a buffer:

              // get the point as a web mercator point 
              Point mapPoint = (Point) GeometryEngine.project( wgs84Point, SpatialReferences.getWebMercator());
              System.out.println("SR : " + mapPoint.getSpatialReference().getWKText());

              // 500 metre buffer
              Polygon polygon =GeometryEngine.buffer(mapPoint, 500);

              // some styles
              SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF00FF00, 3);
              SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFFFF0000, simpleLineSymbol);

              // make a graphic and draw it!
              Graphic graphic = new Graphic(polygon, simpleFillSymbol);
              graphicsOverlay.getGraphics().add(graphic);

 

Does this help?

MarkBaird
Esri Regular Contributor

I'm not sure if this relevant to your app, but did you know you can draw domes / spheres in your 3D app like this:

MarkBaird_0-1613473051316.png

You can draw one of these with the following code:

              // dome symbol
              SimpleMarkerSceneSymbol dome = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbol.Style.SPHERE,0x400000FF, 1000, 1000,1000, SceneSymbol.AnchorPosition.CENTER);

              // graphic for the dome
              Graphic domeGraphic = new Graphic(wgs84Point, dome);
              graphicsOverlay.getGraphics().add(domeGraphic);

 

VanyaIvanov
Occasional Contributor

Thank you! It works fine. I have one more qestion. If i have several circles, can i mark their intersection zone in some different color?

0 Kudos
MarkBaird
Esri Regular Contributor