Search in sources :

Example 1 with LngLat

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;
}
Also used : LngLat(org.openforis.collect.model.LngLat) Coordinate(org.openforis.idm.model.Coordinate) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Document(de.micromata.opengis.kml.v_2_2_0.Document) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem)

Example 2 with LngLat

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;
    }
}
Also used : CoordinateOperations(org.openforis.idm.geospatial.CoordinateOperations) LngLat(org.openforis.collect.model.LngLat) Coordinate(org.openforis.idm.model.Coordinate) CollectSurveyContext(org.openforis.collect.model.CollectSurveyContext) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

LngLat (org.openforis.collect.model.LngLat)2 Coordinate (org.openforis.idm.model.Coordinate)2 Document (de.micromata.opengis.kml.v_2_2_0.Document)1 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)1 FileNotFoundException (java.io.FileNotFoundException)1 CollectSurveyContext (org.openforis.collect.model.CollectSurveyContext)1 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)1 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)1