GeometryEngine: Requrie Arc from Buffer not Circle

2354
5
Jump to solution
03-19-2014 11:25 AM
JerrySchultz
New Contributor III
Is there a way in the Java Runtime to specify an ARC as output from the GeometryEngine instead of just the entire circle. I have built 2 concentric circles and then connected them along 2 different angles to get a contained area enclosed within the 2 lines. I need to show only the polygon contained by the 2 lines connection 2 ARCs of different radii, not the entire circles. If anyone has a workaround please let me know.
0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor
I altered my code anyway as it only took a couple of minutes and demonstrates how we can use the "difference" tool to build on what we were looking at.  It's created as follows:

1. Draw the buffer (red),
2. then define another polygon to intersect the arc segment (green)
3. call the intersect operation which results in your arc (yellow) which I changed to be a polygon in this example
4. define another inner buffer (blue)
5. perform a difference on the yellow arc and the inner buffer
6. final polygon in cyan

[ATTACH=CONFIG]32391[/ATTACH]

    //centre of arc where we clicked the map
    Point centrePt = map.toMapPoint(event.getX(), event.getY());
   
    //buffer to get circle as a polygon
    Polygon circle = GeometryEngine.buffer(centrePt, map.getSpatialReference(), 5000000, null);
   
    //create a line of the circle
    //Polyline circleLine = new Polyline();
    //circleLine.addPath(circle, 0, false);
   
    //draw the circle
    SimpleLineSymbol redLine = new SimpleLineSymbol(Color.RED, 2);
    Graphic circleGraphic = new Graphic(circle, redLine);
    graphicsLayer.addGraphic(circleGraphic);
   
    //create intersection geometry
    Polygon intersection = new Polygon();
    intersection.startPath(centrePt);
    intersection.lineTo(centrePt.getX(), centrePt.getY() + 10000000);
    intersection.lineTo(centrePt.getX() + 10000000, centrePt.getY());
   
    //draw intersection geometry
    SimpleLineSymbol greenLine = new SimpleLineSymbol(Color.GREEN, 2);
    Graphic intersectGraphic = new Graphic(intersection, greenLine);
    graphicsLayer.addGraphic(intersectGraphic);
   
    //now we can perform an intersection operation to create the arc
    Polygon arc =  (Polygon) GeometryEngine.intersect(circle, intersection, map.getSpatialReference());
   
    //draw the arc
    SimpleLineSymbol yellowLine = new SimpleLineSymbol(Color.YELLOW, 5);
    Graphic arcGraphic = new Graphic(arc, yellowLine);
    graphicsLayer.addGraphic(arcGraphic);
   
    //create another smaller buffer
    Polygon innerCircle = GeometryEngine.buffer(centrePt, map.getSpatialReference(), 3000000, null);
   
    //and draw it
    SimpleLineSymbol blueSymbol = new SimpleLineSymbol(Color.BLUE, 2);
    Graphic innerCircleGraphic = new Graphic(innerCircle, blueSymbol);
    graphicsLayer.addGraphic(innerCircleGraphic);
   
    //use the difference tool to clip out the inner circle
    Polygon wideArcPoly = (Polygon) GeometryEngine.difference(arc, innerCircle, map.getSpatialReference());
   
    //and draw it with a fill symbol
    SimpleFillSymbol fillSymbol = new SimpleFillSymbol(Color.cyan);
    Graphic widArcGraphic = new Graphic(wideArcPoly,fillSymbol);
    graphicsLayer.addGraphic(widArcGraphic);

View solution in original post

0 Kudos
5 Replies
MarkBaird
Esri Regular Contributor
Take a look at the sample application as it has geometry operations under the Geometry section to get an idea of the capabilities.

The answer to your question is to use an intersect.

[ATTACH=CONFIG]32353[/ATTACH]

So draw your circle using the buffer (red), then define another polygon to intersect the arc segment  (green) and call the intersect operation which results in your arc (yellow)

I've done a quick example below.  The code is a bit shoddy, but you should get the idea:

  private void drawArc(MouseEvent event) {
   
    //centre of arc where we clicked the map
    Point centrePt = map.toMapPoint(event.getX(), event.getY());
   
    //buffer to get circle as a polygon
    Polygon circle = GeometryEngine.buffer(centrePt, map.getSpatialReference(), 5000000, null);
   
    //create a line of the circle
    Polyline circleLine = new Polyline();
    circleLine.addPath(circle, 0, false);
   
    //draw the circle
    SimpleLineSymbol redLine = new SimpleLineSymbol(Color.RED, 2);
    Graphic circleGraphic = new Graphic(circleLine, redLine);
    graphicsLayer.addGraphic(circleGraphic);
   
    //create intersection geometry
    Polygon intersection = new Polygon();
    intersection.startPath(centrePt);
    intersection.lineTo(centrePt.getX(), centrePt.getY() + 10000000);
    intersection.lineTo(centrePt.getX() + 10000000, centrePt.getY());
   
    //draw intersection geometry
    SimpleLineSymbol greenLine = new SimpleLineSymbol(Color.GREEN, 2);
    Graphic intersectGraphic = new Graphic(intersection, greenLine);
    graphicsLayer.addGraphic(intersectGraphic);
   
    //now we can perform an intersection operation to create the arc
    Polyline arc =  (Polyline) GeometryEngine.intersect(circleLine, intersection, map.getSpatialReference());
   
    //draw the arc
    SimpleLineSymbol yellowLine = new SimpleLineSymbol(Color.YELLOW, 5);
    Graphic arcGraphic = new Graphic(arc, yellowLine);
    graphicsLayer.addGraphic(arcGraphic);
  }
0 Kudos
JerrySchultz
New Contributor III
Mark,

Thanks that did the trick.
0 Kudos
JerrySchultz
New Contributor III
Mark,

A second question on the same idea. The end requirement of the "Construct and Arc instead of a Circle" is to build an enclosed shaded POLYGON consisting of an

1) an OUTER ARC
2) an INNER ARC  These are arcs with the same center point but of different radii
3) 2 separate lines that connect the 2 sides

The result is an enclosed polygon. I have successfully built all 4 segments with the suggestion that you provided above. I have then instantiated a new polygon and added all 4 polylines to construct the polygon and shaded it. I'm not getting the single polygon to fill correctly. It is filling the outer arc with a straight line connecting the end points and then filling the inner arc with a straight line connecting that end points. The inside of the polygon that I tried to construct is not filled.

There is also a variation where there is no inner arc, thus the 2 sides start from the center of the arc and form "triangular area with an arc side. This polygon is constructed of 3 sides and I'm getting the arc area filled by connecting the 2 sides and a black line connecting the 2 sides and then no color fill for the triangle itself. Any ideas on what I'm doing wrong to construct the complex polygon?
0 Kudos
MarkBaird
Esri Regular Contributor
It would help if you posted a picture of what you are trying to create... 

Is it something like this?

[ATTACH=CONFIG]32369[/ATTACH]

Mark
0 Kudos
MarkBaird
Esri Regular Contributor
I altered my code anyway as it only took a couple of minutes and demonstrates how we can use the "difference" tool to build on what we were looking at.  It's created as follows:

1. Draw the buffer (red),
2. then define another polygon to intersect the arc segment (green)
3. call the intersect operation which results in your arc (yellow) which I changed to be a polygon in this example
4. define another inner buffer (blue)
5. perform a difference on the yellow arc and the inner buffer
6. final polygon in cyan

[ATTACH=CONFIG]32391[/ATTACH]

    //centre of arc where we clicked the map
    Point centrePt = map.toMapPoint(event.getX(), event.getY());
   
    //buffer to get circle as a polygon
    Polygon circle = GeometryEngine.buffer(centrePt, map.getSpatialReference(), 5000000, null);
   
    //create a line of the circle
    //Polyline circleLine = new Polyline();
    //circleLine.addPath(circle, 0, false);
   
    //draw the circle
    SimpleLineSymbol redLine = new SimpleLineSymbol(Color.RED, 2);
    Graphic circleGraphic = new Graphic(circle, redLine);
    graphicsLayer.addGraphic(circleGraphic);
   
    //create intersection geometry
    Polygon intersection = new Polygon();
    intersection.startPath(centrePt);
    intersection.lineTo(centrePt.getX(), centrePt.getY() + 10000000);
    intersection.lineTo(centrePt.getX() + 10000000, centrePt.getY());
   
    //draw intersection geometry
    SimpleLineSymbol greenLine = new SimpleLineSymbol(Color.GREEN, 2);
    Graphic intersectGraphic = new Graphic(intersection, greenLine);
    graphicsLayer.addGraphic(intersectGraphic);
   
    //now we can perform an intersection operation to create the arc
    Polygon arc =  (Polygon) GeometryEngine.intersect(circle, intersection, map.getSpatialReference());
   
    //draw the arc
    SimpleLineSymbol yellowLine = new SimpleLineSymbol(Color.YELLOW, 5);
    Graphic arcGraphic = new Graphic(arc, yellowLine);
    graphicsLayer.addGraphic(arcGraphic);
   
    //create another smaller buffer
    Polygon innerCircle = GeometryEngine.buffer(centrePt, map.getSpatialReference(), 3000000, null);
   
    //and draw it
    SimpleLineSymbol blueSymbol = new SimpleLineSymbol(Color.BLUE, 2);
    Graphic innerCircleGraphic = new Graphic(innerCircle, blueSymbol);
    graphicsLayer.addGraphic(innerCircleGraphic);
   
    //use the difference tool to clip out the inner circle
    Polygon wideArcPoly = (Polygon) GeometryEngine.difference(arc, innerCircle, map.getSpatialReference());
   
    //and draw it with a fill symbol
    SimpleFillSymbol fillSymbol = new SimpleFillSymbol(Color.cyan);
    Graphic widArcGraphic = new Graphic(wideArcPoly,fillSymbol);
    graphicsLayer.addGraphic(widArcGraphic);
0 Kudos