use of org.openforis.collect.model.LngLat in project collect by openforis.
the class SamplingPointDataKmlGenerator method generate.
public void generate() {
Kml kml = KmlFactory.createKml();
Document doc = kml.createAndSetDocument();
List<SamplingDesignItem> samplingDesignItems = loadSamplingDesignItems();
for (SamplingDesignItem item : samplingDesignItems) {
Coordinate coordinate = new Coordinate(item.getX(), item.getY(), item.getSrsId());
LngLat lngLatAlt = createLngLat(coordinate);
doc.createAndAddPlacemark().withName(Strings.joinNotBlank(item.getLevelCodes(), "|")).withOpen(true).createAndSetPoint().addToCoordinates(lngLatAlt.getLongitude(), lngLatAlt.getLatitude());
}
this.kml = kml;
}
use of org.openforis.collect.model.LngLat in project collect by openforis.
the class SamplingPointDataKmlGenerator method createLngLat.
private LngLat createLngLat(Coordinate coord) {
try {
CollectSurveyContext surveyContext = survey.getContext();
CoordinateOperations coordOpts = surveyContext.getCoordinateOperations();
Coordinate wgs84Coord = coordOpts.convertToWgs84(coord);
return new LngLat(wgs84Coord.getX(), wgs84Coord.getY());
} catch (Exception e) {
return null;
}
}
Aggregations