List<LngLatAlt> shell = new ArrayList<LngLatAlt>(); for (Coordinate c : polygons[i].getExteriorRing().getCoordinates()) { shell.add(new LngLatAlt(c.x, c.y));
/** * Create a GeoJSON Point from a LatLng. * * @param latLng the LatLng * @return the GeoServiceLatLng */ default LngLatAlt toLngLatAlt(final LatLng latLng) { if (latLng == null) { return null; } return new LngLatAlt(latLng.lng, latLng.lat); } }
public Point(double longitude, double latitude) { coordinates = new LngLatAlt(longitude, latitude); }
public Point(double longitude, double latitude, double altitude, double... additionalElements) { coordinates = new LngLatAlt(longitude, latitude, altitude, additionalElements); }
public Point(double longitude, double latitude, double altitude) { coordinates = new LngLatAlt(longitude, latitude, altitude); }
public Point(double longitude, double latitude, double altitude, double... additionalElements) { coordinates = new LngLatAlt(longitude, latitude, altitude, additionalElements); }
public Point(double longitude, double latitude, double altitude) { coordinates = new LngLatAlt(longitude, latitude, altitude); }
public Point(double longitude, double latitude) { coordinates = new LngLatAlt(longitude, latitude); }
lng = longitude; location = new LngLatAlt(lng, lat); if (latitude == null || longitude == null) { southwest = new LngLatAlt(Double.NaN, Double.NaN); northeast = new LngLatAlt(Double.NaN, Double.NaN); } else { final double confidence = .01; southwest = new LngLatAlt(longitude - confidence, latitude - confidence); northeast = new LngLatAlt(longitude + confidence, latitude + confidence);
public static org.geojson.Polygon toGeoJson(Polygon jtsPolygon) { if (jtsPolygon == null) return null; org.geojson.Polygon geoJsonPoly = new org.geojson.Polygon(Arrays.asList(jtsPolygon.getCoordinates()).stream() .map(p -> new LngLatAlt(p.x, p.y)).collect(Collectors.toList())); geoJsonPoly.setCrs(createCrsForEpsgCode(jtsPolygon.getSRID())); return geoJsonPoly; }
public static org.geojson.Point toGeoJson(Point jtsPoint) { if (jtsPoint == null) return null; org.geojson.Point geoJsonPoint = new org.geojson.Point(new LngLatAlt(jtsPoint.getX(), jtsPoint.getY())); geoJsonPoint.setCrs(createCrsForEpsgCode(jtsPoint.getSRID())); return geoJsonPoint; }
polygon.setBbox(bbox); final List<LngLatAlt> elements = new ArrayList<>(5); elements.add(new LngLatAlt(bbox[SW_LNG], bbox[SW_LAT])); elements.add(new LngLatAlt(bbox[NE_LNG], bbox[SW_LAT])); elements.add(new LngLatAlt(bbox[NE_LNG], bbox[NE_LAT])); elements.add(new LngLatAlt(bbox[SW_LNG], bbox[NE_LAT])); elements.add(new LngLatAlt(bbox[SW_LNG], bbox[SW_LAT])); polygon.add(elements); feature.setBbox(bbox);
protected LngLatAlt deserializeArray(JsonParser jp, DeserializationContext ctxt) throws IOException { LngLatAlt node = new LngLatAlt(); node.setLongitude(extractDouble(jp, ctxt, false)); node.setLatitude(extractDouble(jp, ctxt, false)); node.setAltitude(extractDouble(jp, ctxt, true)); List<Double> additionalElementsList = new ArrayList<Double>(); while (jp.hasCurrentToken() && jp.getCurrentToken() != JsonToken.END_ARRAY) { double element = extractDouble(jp, ctxt, true); if (!Double.isNaN(element)) { additionalElementsList.add(element); } } double[] additionalElements = new double[additionalElementsList.size()]; for (int i = 0; i < additionalElements.length; i++) { additionalElements[i] = additionalElementsList.get(i); } node.setAdditionalElements(additionalElements); return node; }
protected LngLatAlt deserializeArray(JsonParser jp, DeserializationContext ctxt) throws IOException { LngLatAlt node = new LngLatAlt(); node.setLongitude(extractDouble(jp, ctxt, false)); node.setLatitude(extractDouble(jp, ctxt, false)); node.setAltitude(extractDouble(jp, ctxt, true)); List<Double> additionalElementsList = new ArrayList<Double>(); while (jp.hasCurrentToken() && jp.getCurrentToken() != JsonToken.END_ARRAY) { double element = extractDouble(jp, ctxt, true); if (!Double.isNaN(element)) { additionalElementsList.add(element); } } double[] additionalElements = new double[additionalElementsList.size()]; for (int i = 0; i < additionalElements.length; i++) { additionalElements[i] = additionalElementsList.get(i); } node.setAdditionalElements(additionalElements); return node; }
@Test public void transforms_a_submission_to_a_feature_list() throws IOException, XmlPullParserException { Map<String, Feature> features = getFeatures( Pair.of(GEOPOINT, "1 2 3"), Pair.of(GEOTRACE, "1 2;3 4"), Pair.of(GEOSHAPE, "1 2;3 4;5 6;1 2") ).stream().collect(toMap( f -> f.getProperty("field"), f -> f )); assertThat(features.values(), hasSize(3)); assertThat(features.values(), allMatch(feature -> feature.getProperty("key").equals("uuid:39f3dd36-161e-45cb-a1a4-395831d253a7"))); assertThat(features.values(), allMatch(feature -> feature.getProperty("empty").equals("no"))); assertThat(features.get("some-field-1").getGeometry(), is(new Point(2, 1, 3))); assertThat(features.get("some-field-2").getGeometry(), is(new LineString(new LngLatAlt(2, 1), new LngLatAlt(4, 3)))); assertThat(features.get("some-field-3").getGeometry(), is(new Polygon(new LngLatAlt(2, 1), new LngLatAlt(4, 3), new LngLatAlt(6, 5), new LngLatAlt(2, 1)))); }