use of org.geojson.Point in project geojson-jackson by opendatalab-de.
the class PointTest method itShouldSerializeAPointWithAdditionalAttributes.
@Test
public void itShouldSerializeAPointWithAdditionalAttributes() throws JsonProcessingException {
Point point = new Point(100, 0, 256, 345d, 678d);
assertEquals("{\"type\":\"Point\",\"coordinates\":[100.0,0.0,256.0,345.0,678.0]}", mapper.writeValueAsString(point));
}
use of org.geojson.Point in project geojson-jackson by opendatalab-de.
the class PointTest method itShouldSerializeAPointWithAltitude.
@Test
public void itShouldSerializeAPointWithAltitude() throws Exception {
Point point = new Point(100, 0, 256);
assertEquals("{\"type\":\"Point\",\"coordinates\":[100.0,0.0,256.0]}", mapper.writeValueAsString(point));
}
use of org.geojson.Point in project OpenTripPlanner by opentripplanner.
the class BanoGeocoder method geocode.
/**
*/
@Override
public GeocoderResults geocode(String address, Envelope bbox) {
try {
URL banoUrl = getBanoGeocoderUrl(address, bbox);
URLConnection conn = banoUrl.openConnection();
InputStream in = conn.getInputStream();
FeatureCollection featureCollection = mapper.readValue(in, FeatureCollection.class);
in.close();
List<GeocoderResult> geocoderResults = new ArrayList<GeocoderResult>();
for (Feature feature : featureCollection.getFeatures()) {
GeoJsonObject geom = feature.getGeometry();
if (geom instanceof Point) {
Point p = (Point) geom;
GeocoderResult res = new GeocoderResult();
res.setLat(p.getCoordinates().getLatitude());
res.setLng(p.getCoordinates().getLongitude());
res.setDescription(feature.getProperties().get("label").toString());
/*
* Note: We also have here as properties a break-down of other details, such as
* the house number, street, city, postcode... Can be useful if needed.
*/
geocoderResults.add(res);
} else {
// Should not happen according to the API
}
}
return new GeocoderResults(geocoderResults);
} catch (IOException e) {
LOG.error("Error processing BANO geocoder results", e);
return new GeocoderResults(e.getLocalizedMessage());
}
}
use of org.geojson.Point in project geojson-jackson by opendatalab-de.
the class PointTest method itShouldSerializeAPoint.
@Test
public void itShouldSerializeAPoint() throws Exception {
Point point = new Point(100, 0);
assertEquals("{\"type\":\"Point\",\"coordinates\":[100.0,0.0]}", mapper.writeValueAsString(point));
}
use of org.geojson.Point in project geojson-jackson by opendatalab-de.
the class PointTest method itShouldDeserializeAPoint.
@Test
public void itShouldDeserializeAPoint() throws Exception {
GeoJsonObject value = mapper.readValue("{\"type\":\"Point\",\"coordinates\":[100.0,5.0]}", GeoJsonObject.class);
assertNotNull(value);
assertTrue(value instanceof Point);
Point point = (Point) value;
assertLngLatAlt(100, 5, Double.NaN, point.getCoordinates());
}
Aggregations