static private Coordinate[] convertLineStringToPoints(Iterable<Point> points) { ArrayList<Coordinate> coords = new ArrayList<>(2); for (Point point : points) { coords.add(new Coordinate(point.getX(), point.getY(), point.getZ())); } return coords.toArray(new Coordinate[coords.size()]); }
static private Coordinate[] convertLineStringToPoints(Iterable<Point> points) { ArrayList<Coordinate> coords = new ArrayList<>(2); for (Point point : points) { coords.add(new Coordinate(point.getX(), point.getY(), point.getZ())); } return coords.toArray(new Coordinate[coords.size()]); }
private void writeGeoPoint(JsonGenerator json, final Point point) throws IOException { json.writeNumber(point.getX()); json.writeNumber(point.getY()); if (point.getZ() != 0) { json.writeNumber(point.getZ()); } }
private void writeGeoPoint(JsonGenerator json, final Point point) throws IOException { json.writeNumber(point.getX()); json.writeNumber(point.getY()); if (point.getZ() != 0) { json.writeNumber(point.getZ()); } }
private String point(final Point point, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { return new StringBuilder(). append(EdmDouble.getInstance().valueToString(point.getX(), isNullable, maxLength, precision, scale, isUnicode)). append(' '). append(EdmDouble.getInstance().valueToString(point.getY(), isNullable, maxLength, precision, scale, isUnicode)). toString(); }
private String point(final Point point, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { return new StringBuilder(). append(EdmDouble.getInstance().valueToString(point.getX(), isNullable, maxLength, precision, scale, isUnicode)). append(' '). append(EdmDouble.getInstance().valueToString(point.getY(), isNullable, maxLength, precision, scale, isUnicode)). toString(); }
private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap) throws XMLStreamException { while (itor.hasNext()) { final Point point = itor.next(); if (wrap) { writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML); } writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML); try { writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + " " + EdmDouble.getInstance().valueToString(point.getY(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); } catch (EdmPrimitiveTypeException e) { throw new XMLStreamException("While serializing point coordinates as double", e); } writer.writeEndElement(); if (wrap) { writer.writeEndElement(); } } }
private void points(final XMLStreamWriter writer, final Iterator<Point> itor, final boolean wrap) throws XMLStreamException { while (itor.hasNext()) { final Point point = itor.next(); if (wrap) { writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML); } writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POS, Constants.NS_GML); try { writer.writeCharacters(EdmDouble.getInstance().valueToString(point.getX(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + " " + EdmDouble.getInstance().valueToString(point.getY(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); } catch (EdmPrimitiveTypeException e) { throw new XMLStreamException("While serializing point coordinates as double", e); } writer.writeEndElement(); if (wrap) { writer.writeEndElement(); } } }
private void point(final JsonGenerator jgen, final Point point) throws IOException { try { jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); } catch (EdmPrimitiveTypeException e) { throw new IllegalArgumentException("While serializing point coordinates as double", e); } }
private void point(final JsonGenerator jgen, final Point point) throws IOException { try { jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getX(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); jgen.writeNumber(EdmDouble.getInstance().valueToString(point.getY(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null)); } catch (EdmPrimitiveTypeException e) { throw new IllegalArgumentException("While serializing point coordinates as double", e); } }
Point point = (Point) geospatial; com.vividsolutions.jts.geom.Point result = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(point.getX(), point.getY(), point.getZ())); return result; } else if (geospatial instanceof LineString) {
Point point = (Point) geospatial; com.vividsolutions.jts.geom.Point result = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(point.getX(), point.getY(), point.getZ())); return result; } else if (geospatial instanceof LineString) {
@Test public void testPolygon() throws EdmPrimitiveTypeException { ODataWKTWriter writer = new ODataWKTWriter(); GeometryFactory factory = new GeometryFactory(); Polygon polygon = factory .createPolygon( factory.createLinearRing(new Coordinate[] { new Coordinate(0, 0), new Coordinate(3, 0), new Coordinate(3, 3), new Coordinate(0, 3), new Coordinate(0, 0) }), new LinearRing[] { factory.createLinearRing( new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1), new Coordinate(2, 2), new Coordinate(1, 2), new Coordinate(1, 1) }) }); //hole first, no space between rings assertEquals("Polygon((1.0 1.0,2.0 1.0,2.0 2.0,1.0 2.0,1.0 1.0)," + "(0.0 0.0,3.0 0.0,3.0 3.0,0.0 3.0,0.0 0.0))", writer.write(polygon)); String uriValue = ODataTypeManager.geometryToODataValueString(polygon, true); org.apache.olingo.commons.api.edm.geo.Polygon olingoPolygon = (org.apache.olingo.commons.api.edm.geo.Polygon) EdmGeometryPolygon.getInstance().valueOfString(uriValue, null, null, null, null, null, EdmGeometryPolygon.getInstance().getDefaultType()); assertEquals(0, olingoPolygon.getExterior().iterator().next().getX(), 0); assertEquals(1, olingoPolygon.getInterior().iterator().next().getX(), 0); }