private PlacemarkType createTrack(KmlRoute route, int startIndex, int endIndex) { ObjectFactory objectFactory = new ObjectFactory(); PlacemarkType placemarkType = objectFactory.createPlacemarkType(); placemarkType.setName(TRACK); placemarkType.setDescription(asDescription(route.getDescription())); placemarkType.setStyleUrl("#" + TRACK_LINE_STYLE); // create gx:Track if there are at least two positions with a time stamp if (containTime(route)) { slash.navigation.kml.binding22gx.ObjectFactory gxObjectFactory = new slash.navigation.kml.binding22gx.ObjectFactory(); TrackType trackType = gxObjectFactory.createTrackType(); List<KmlPosition> positions = route.getPositions(); for (int i = startIndex; i < endIndex; i++) { KmlPosition position = positions.get(i); String time = position.hasTime() ? formatDate(position.getTime()) : ""; trackType.getWhen().add(time); } for (int i = startIndex; i < endIndex; i++) { KmlPosition position = positions.get(i); trackType.getCoord().add(createCoordinates(position, true)); } placemarkType.setAbstractGeometryGroup(gxObjectFactory.createTrack(trackType)); } else { LineStringType lineStringType = objectFactory.createLineStringType(); placemarkType.setAbstractGeometryGroup(objectFactory.createLineString(lineStringType)); List<String> coordinates = lineStringType.getCoordinates(); List<KmlPosition> positions = route.getPositions(); for (int i = startIndex; i < endIndex; i++) { KmlPosition position = positions.get(i); coordinates.add(createCoordinates(position, false)); } } return placemarkType; }
private PlacemarkType createSpeedSegment( int currentSegment, int speedClass, List<String> coordinates) { ObjectFactory objectFactory = new ObjectFactory(); PlacemarkType placemarkType = objectFactory.createPlacemarkType(); placemarkType.setName("Segment " + currentSegment); placemarkType.setDescription(getSpeedDescription(speedClass)); placemarkType.setStyleUrl('#' + getSpeedColor(speedClass)); placemarkType.setVisibility(FALSE); LineStringType lineStringType = objectFactory.createLineStringType(); lineStringType.getCoordinates().addAll(coordinates); placemarkType.setAbstractGeometryGroup(objectFactory.createLineString(lineStringType)); return placemarkType; }
private PlacemarkType createRoute(KmlRoute route) { ObjectFactory objectFactory = new ObjectFactory(); PlacemarkType placemarkType = objectFactory.createPlacemarkType(); placemarkType.setName(ROUTE); placemarkType.setDescription(asDescription(route.getDescription())); placemarkType.setStyleUrl("#" + ROUTE_LINE_STYLE); MultiGeometryType multiGeometryType = objectFactory.createMultiGeometryType(); placemarkType.setAbstractGeometryGroup(objectFactory.createMultiGeometry(multiGeometryType)); LineStringType lineStringType = objectFactory.createLineStringType(); multiGeometryType .getAbstractGeometryGroup() .add(objectFactory.createLineString(lineStringType)); List<String> coordinates = lineStringType.getCoordinates(); for (KmlPosition position : route.getPositions()) { coordinates.add(createCoordinates(position, false)); } return placemarkType; }