-1

Good afternoon.

Sorry for my bad english.

I would like to draw fixed lines in the map that would set the starting point with the coordinates, an angle of direction and dimension to the line without setting the end point coordinates.

Example: A line that would start in a given geographical coordinates -12.3456789, -49.3456789 has angle of 123 ° clockwise and has XXkm dimension.

It is possible to add lines like this in KMZ Google Earth?

Please to post it with some example code or suggestions.

1 Answers1

0

KML (or KMZ) only can represent a line as a collection of points with at a minimum a start and end point. https://developers.google.com/kml/documentation/kmlreference#linestring

You could calculate an end point from a starting point, angle of direction (or heading), and distance then represent display it in Google Earth using KML.

For example in the OpenSextant geodesy java library you can create a Geodetic2DArc and calculate the endpoint in 3 lines of java code like this:

Geodetic2DPoint start = new Geodetic2DPoint(new Longitude(-49.3456789, Angle.DEGREES),
            new Latitude(-12.3456789, Angle.DEGREES));
Geodetic2DArc arc = new Geodetic2DArc(start, 5000.0, new Angle(123, Angle.DEGREES));
Geodetic2DPoint endPt = arc.getPoint2();

The distance is in meters so if you want a long line segment then you need a larger distance. Then with the associated Giscore library you could export the line into KML directly with few more lines of java code:

KmlOutputStream kos = new KmlOutputStream(new FileOutputStream("out.kml"));
Feature f = new Feature();
f.setName("line");
List<Point> pts = new ArrayList<Point>(2);
pts.add(new Point(start));
pts.add(new Point(endPt));
f.setGeometry(new Line(pts));
kos.write(f);
kos.close();
CodeMonkey
  • 22,825
  • 4
  • 35
  • 75