Search in sources :

Example 1 with UTMRef

use of uk.me.jstott.jcoord.UTMRef in project eol-globi-data by jhpoelen.

the class StudyImporterForSimons method getOrCreateSampleLocation.

private Location getOrCreateSampleLocation(LabeledCSVParser csvParser, Map<String, String> columnToNormalizedTermMapper) throws StudyImporterException {
    Double northing = parseAsDouble(csvParser, columnToNormalizedTermMapper.get(NORTHING));
    Double easting = parseAsDouble(csvParser, columnToNormalizedTermMapper.get(EASTING));
    Double latitude = null;
    Double longitude = null;
    if (easting != null && northing != null) {
        UTMRef utmRef = new UTMRef(easting, northing, 'R', 16);
        LatLng latLng = utmRef.toLatLng();
        latitude = latLng.getLat();
        longitude = latLng.getLng();
    }
    Double depth = parseAsDouble(csvParser, columnToNormalizedTermMapper.get(DEPTH));
    Double altitude = depth == null ? null : -depth;
    try {
        return nodeFactory.getOrCreateLocation(new LocationImpl(latitude, longitude, altitude, null));
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to create location", e);
    }
}
Also used : LocationImpl(org.eol.globi.domain.LocationImpl) UTMRef(uk.me.jstott.jcoord.UTMRef) LatLng(uk.me.jstott.jcoord.LatLng)

Example 2 with UTMRef

use of uk.me.jstott.jcoord.UTMRef in project eol-globi-data by jhpoelen.

the class StudyImporterForSimonsTest method convertLatLongIntoUMT.

@Test
public void convertLatLongIntoUMT() {
    LatLng latLng = new LatLng(30.031055, -88.066406);
    UTMRef utmRef = latLng.toUTMRef();
    assertEquals(397176.66307791235, utmRef.getEasting());
    assertEquals(3322705.434795696, utmRef.getNorthing());
    assertEquals('R', utmRef.getLatZone());
    assertEquals(16, utmRef.getLngZone());
}
Also used : UTMRef(uk.me.jstott.jcoord.UTMRef) LatLng(uk.me.jstott.jcoord.LatLng) Test(org.junit.Test)

Aggregations

LatLng (uk.me.jstott.jcoord.LatLng)2 UTMRef (uk.me.jstott.jcoord.UTMRef)2 LocationImpl (org.eol.globi.domain.LocationImpl)1 Test (org.junit.Test)1