<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Invalid argument from GeometryEngine when drawing an ellipse in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1124336#M2533</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm fairly new to ArcGIS, I do a bit of testing to see if we could use it for our application. I have a basic application displaying a map, and I want to draw an ellipse on it. I managed to draw circles, but for whatever reason I can't figure out, I have an arcGISRuntimeException : Invalid argument from the GeometryEngine when I run it with my ellipse.&lt;/P&gt;&lt;P&gt;Here is my code&amp;nbsp; (without my API key):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;public class App extends Application {

    private MapView mapView;

    public static void main(String[] args) {

        Application.launch(args);
    }

    @Override
    public void start(Stage stage) {

        stage.setTitle("Carto App");
        stage.setWidth(800);
        stage.setHeight(700);
        stage.show();

        StackPane stackPane = new StackPane();
        Scene scene = new Scene(stackPane);
        stage.setScene(scene);

        String yourApiKey =
                "";
        ArcGISRuntimeEnvironment.setApiKey(yourApiKey);

        mapView = new MapView();
        stackPane.getChildren().add(mapView);

        ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_IMAGERY);

        mapView.setMap(map);

        GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
        mapView.getGraphicsOverlays().add(graphicsOverlay);

        EllipseFigure ellipse = new EllipseFigure(new Point(0, 0), 100, 100, 0, 0xFF00FF00);
        Graphic graphic = new Graphic(ellipse.getGeometry(), ellipse.getSymbol());
        graphicsOverlay.getGraphics().add(graphic);
    }


    /**
     * Stops and releases all resources used in application.
     */
    @Override
    public void stop() {

        if (mapView != null) {
            mapView.dispose();
        }
    }
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="java"&gt;public class EllipseFigure {

    private final double semiMajorAxis;
    private final double semiMinorAxis;
    private Point center;
    private double rotAngle;
    private int color;

    public EllipseFigure(Point center, double semiMajorAxis, double semiMinorAxis, double rotAngle, int color) {
        this.center = center;
        this.semiMajorAxis = semiMajorAxis;
        this.rotAngle = rotAngle;
        this.semiMinorAxis = semiMinorAxis;
        this.color = color;
    }

    public Geometry getGeometry() {
        GeodesicEllipseParameters params =
                new GeodesicEllipseParameters(center, semiMajorAxis, semiMinorAxis);
        params.setAngularUnit(new AngularUnit(AngularUnitId.RADIANS));
        params.setAxisDirection(rotAngle);
        return GeometryEngine.ellipseGeodesic(params);
    }

    public Symbol getSymbol() {
        return new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, color, 3);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd really appreciate if someone could help me figure out what's going on here.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Dec 2021 15:11:12 GMT</pubDate>
    <dc:creator>Tone</dc:creator>
    <dc:date>2021-12-09T15:11:12Z</dc:date>
    <item>
      <title>Invalid argument from GeometryEngine when drawing an ellipse</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1124336#M2533</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm fairly new to ArcGIS, I do a bit of testing to see if we could use it for our application. I have a basic application displaying a map, and I want to draw an ellipse on it. I managed to draw circles, but for whatever reason I can't figure out, I have an arcGISRuntimeException : Invalid argument from the GeometryEngine when I run it with my ellipse.&lt;/P&gt;&lt;P&gt;Here is my code&amp;nbsp; (without my API key):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;public class App extends Application {

    private MapView mapView;

    public static void main(String[] args) {

        Application.launch(args);
    }

    @Override
    public void start(Stage stage) {

        stage.setTitle("Carto App");
        stage.setWidth(800);
        stage.setHeight(700);
        stage.show();

        StackPane stackPane = new StackPane();
        Scene scene = new Scene(stackPane);
        stage.setScene(scene);

        String yourApiKey =
                "";
        ArcGISRuntimeEnvironment.setApiKey(yourApiKey);

        mapView = new MapView();
        stackPane.getChildren().add(mapView);

        ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_IMAGERY);

        mapView.setMap(map);

        GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
        mapView.getGraphicsOverlays().add(graphicsOverlay);

        EllipseFigure ellipse = new EllipseFigure(new Point(0, 0), 100, 100, 0, 0xFF00FF00);
        Graphic graphic = new Graphic(ellipse.getGeometry(), ellipse.getSymbol());
        graphicsOverlay.getGraphics().add(graphic);
    }


    /**
     * Stops and releases all resources used in application.
     */
    @Override
    public void stop() {

        if (mapView != null) {
            mapView.dispose();
        }
    }
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="java"&gt;public class EllipseFigure {

    private final double semiMajorAxis;
    private final double semiMinorAxis;
    private Point center;
    private double rotAngle;
    private int color;

    public EllipseFigure(Point center, double semiMajorAxis, double semiMinorAxis, double rotAngle, int color) {
        this.center = center;
        this.semiMajorAxis = semiMajorAxis;
        this.rotAngle = rotAngle;
        this.semiMinorAxis = semiMinorAxis;
        this.color = color;
    }

    public Geometry getGeometry() {
        GeodesicEllipseParameters params =
                new GeodesicEllipseParameters(center, semiMajorAxis, semiMinorAxis);
        params.setAngularUnit(new AngularUnit(AngularUnitId.RADIANS));
        params.setAxisDirection(rotAngle);
        return GeometryEngine.ellipseGeodesic(params);
    }

    public Symbol getSymbol() {
        return new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, color, 3);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd really appreciate if someone could help me figure out what's going on here.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 15:11:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1124336#M2533</guid>
      <dc:creator>Tone</dc:creator>
      <dc:date>2021-12-09T15:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument from GeometryEngine when drawing an ellipse</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1124824#M2535</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/544543"&gt;@Tone&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ellipseGeodesic method is very fussy about its parameters.&amp;nbsp; You need to make sure you set them all and you also need to pass in a center point which has a known spatial reference.&lt;/P&gt;&lt;P&gt;I've created an example ellipse method which should help you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;  private Polygon makeEllipse() {
    // create parameters and set all the parameters
    GeodesicEllipseParameters parameters = new GeodesicEllipseParameters();

    parameters.setCenter(new Point(3,14, SpatialReferences.getWebMercator())); // Note the spatial reference
    parameters.setGeometryType(GeometryType.POLYGON);
    parameters.setSemiAxis1Length(100);
    parameters.setSemiAxis2Length(200);
    parameters.setAxisDirection(45);
    parameters.setMaxPointCount(100);
    parameters.setAngularUnit(new AngularUnit(AngularUnitId.DEGREES));
    parameters.setLinearUnit(new LinearUnit(LinearUnitId.METERS));
    parameters.setMaxSegmentLength(20);

    Polygon ellipsePoly = (Polygon) GeometryEngine.ellipseGeodesic(parameters);

    return ellipsePoly;
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I used the resulting geometry:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;      SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF0063FF, 1);

      SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFF00FF00, lineSymbol);

      Graphic graphic = new Graphic(makeEllipse(), fillSymbol);

      graphicsOverlay.getGraphics().add(graphic);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkBaird_0-1639141634227.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/29391i93915983A3087868/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkBaird_0-1639141634227.png" alt="MarkBaird_0-1639141634227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this helps&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 13:41:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1124824#M2535</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-12-10T13:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument from GeometryEngine when drawing an ellipse</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1125331#M2536</link>
      <description>&lt;P&gt;Ah, I knew I had a problem with the parameters but couldn't figure out what it was.&lt;/P&gt;&lt;P&gt;Thank you &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/48868"&gt;@MarkBaird&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 08:54:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/invalid-argument-from-geometryengine-when-drawing/m-p/1125331#M2536</guid>
      <dc:creator>Tone</dc:creator>
      <dc:date>2021-12-13T08:54:00Z</dc:date>
    </item>
  </channel>
</rss>

