Search in sources :

Example 11 with LngLatAlt

use of org.geojson.LngLatAlt in project geojson-jackson by opendatalab-de.

the class LineStringTest method itShouldDeserializeLineString.

@Test
public void itShouldDeserializeLineString() throws Exception {
    LineString lineString = mapper.readValue("{\"type\":\"LineString\",\"coordinates\":[[100.0,0.0],[101.0,1.0]]}", LineString.class);
    assertNotNull(lineString);
    List<LngLatAlt> coordinates = lineString.getCoordinates();
    PointTest.assertLngLatAlt(100, 0, Double.NaN, coordinates.get(0));
    PointTest.assertLngLatAlt(101, 1, Double.NaN, coordinates.get(1));
}
Also used : LineString(org.geojson.LineString) LngLatAlt(org.geojson.LngLatAlt) Test(org.junit.Test)

Example 12 with LngLatAlt

use of org.geojson.LngLatAlt in project geojson-jackson by opendatalab-de.

the class LngLatAltDeserializerTest method deserializeMongoLngLatAlt.

@Test
public void deserializeMongoLngLatAlt() throws Exception {
    LngLatAlt lngLatAlt = new LngLatAlt(10D, 15D, 5);
    String lngLatAltJson = new ObjectMapper().writeValueAsString(lngLatAlt);
    lngLatAltJson.replace("10.0", "\"10.0\"");
    lngLatAltJson.replace("15.0", "\"15.0\"");
    LngLatAlt lngLatAlt1 = new ObjectMapper().readValue(lngLatAltJson, LngLatAlt.class);
    Assert.assertTrue(lngLatAlt.equals(lngLatAlt));
}
Also used : LngLatAlt(org.geojson.LngLatAlt) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 13 with LngLatAlt

use of org.geojson.LngLatAlt in project geojson-jackson by opendatalab-de.

the class LngLatAltSerializerTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    LngLatAlt position = new LngLatAlt(49.43245, 52.42345, 120.34626);
    String correctJson = "[49.43245,52.42345,120.34626]";
    String producedJson = new ObjectMapper().writeValueAsString(position);
    Assert.assertEquals(correctJson, producedJson);
}
Also used : LngLatAlt(org.geojson.LngLatAlt) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 14 with LngLatAlt

use of org.geojson.LngLatAlt in project collect by openforis.

the class SamplingPointsController method createLngLatAlt.

private LngLatAlt createLngLatAlt(CoordinateOperations coordOpts, Coordinate coord) {
    try {
        Coordinate wgs84Coord = coordOpts.convertToWgs84(coord);
        LngLatAlt lngLatAlt = new LngLatAlt(wgs84Coord.getX(), wgs84Coord.getY());
        return lngLatAlt;
    } catch (Exception e) {
        return null;
    }
}
Also used : Coordinate(org.openforis.idm.model.Coordinate) LngLatAlt(org.geojson.LngLatAlt) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

LngLatAlt (org.geojson.LngLatAlt)14 Test (org.junit.Test)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 MultiPoint (org.geojson.MultiPoint)3 ArrayList (java.util.ArrayList)2 LineString (org.geojson.LineString)2 Coordinate (org.openforis.idm.model.Coordinate)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MultiLineString (org.geojson.MultiLineString)1 MultiPolygon (org.geojson.MultiPolygon)1 Polygon (org.geojson.Polygon)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 CollectSurveyContext (org.openforis.collect.model.CollectSurveyContext)1 SamplingDesignItem (org.openforis.collect.model.SamplingDesignItem)1 SamplingDesignSummaries (org.openforis.collect.model.SamplingDesignSummaries)1 CoordinateOperations (org.openforis.idm.geospatial.CoordinateOperations)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1