Hi,
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.
Here is my code (without my API key):
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();
}
}
}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);
}
}
I'd really appreciate if someone could help me figure out what's going on here.