You can use the org.geotools.referencing.GeodeticCalculator to do this,
something like:

private void createPolygon(Point centre, Point start, Point end) {
    ArrayList<Coordinate> coords = new ArrayList<>();
    coords.add(start.getCoordinate());
    CALC.setStartingGeographicPoint(centre.getX(), centre.getY());
    CALC.setDestinationGeographicPoint(start.getX(), start.getY());
    double bearing1 = CALC.getAzimuth();
    double radius = CALC.getOrthodromicDistance();
    CALC.setDestinationGeographicPoint(end.getX(), end.getY());
    double bearing2 = CALC.getAzimuth();

    double angle = bearing2 - bearing1;
    int nSteps = 10;
    double dStep = angle / nSteps;
    coords.add(start.getCoordinate());
    for (int i = 0; i < nSteps; i++) {
      CALC.setDirection((bearing1 + (i * dStep)), radius);
      Point2D p = CALC.getDestinationGeographicPoint();
      coords.add(new Coordinate(p.getX(), p.getY()));
    }
    coords.add(end.getCoordinate());
    LineString line = GF.createLineString(coords.toArray(new Coordinate[]
{}));
    WKTWriter writer = new WKTWriter();
    System.out.println(writer.write(centre));
    System.out.println(writer.write(start));
    System.out.println(writer.write(end));
    System.out.println(writer.write(line));
  }

Where CALC is a GeodeticCalculator and GF is a GeometryFactory will give
you:

[image: arc.png]

Ian

On Mon, 3 Feb 2020 at 09:21, <paul.m...@lfv.se> wrote:

> Hi list,
>
> I would like to draw a circle arc in WGS84 coordinates
>
> I have an arc start point (lat/lon in WGS84),
>
> an arc end point (lat/lon in WGS84),
>
> an arc center point (lat/lon in WGS84),
>
> a bearing from the center point to the start point
>
> the arc radius in meter.
>
> Now I would like to calculate several points (WGS84 lat/lon) on the arc.
>
> Is there a way to do it with Geotools, if so how?
>
>
>
> I appreciate your help,
>
> Paul
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>


-- 
Ian Turton
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to