private ArrayList<org.apache.olingo.commons.api.edm.geo.Point> convertLineStringToPoints( Coordinate[] lineString) { ArrayList<org.apache.olingo.commons.api.edm.geo.Point> points = new ArrayList<>(lineString.length); for (Coordinate c : lineString) { org.apache.olingo.commons.api.edm.geo.Point p = new org.apache.olingo.commons.api.edm.geo.Point(dimension, srid); p.setX(c.x); p.setY(c.y); } return points; }
private ArrayList<org.apache.olingo.commons.api.edm.geo.Point> convertLineStringToPoints( Coordinate[] lineString) { ArrayList<org.apache.olingo.commons.api.edm.geo.Point> points = new ArrayList<>(lineString.length); for (Coordinate c : lineString) { org.apache.olingo.commons.api.edm.geo.Point p = new org.apache.olingo.commons.api.edm.geo.Point(dimension, srid); p.setX(c.x); p.setY(c.y); } return points; }
private Point readGeoPointValue(final String name, final Geospatial.Dimension dimension, JsonNode node, SRID srid) throws DeserializerException, EdmPrimitiveTypeException { if (node.isArray() && (node.size() ==2 || node.size() == 3) && node.get(0).isNumber() && node.get(1).isNumber() && (node.get(2) == null || node.get(2).isNumber())) { Point point = new Point(dimension, srid); point.setX(getDoubleValue(node.get(0).asText())); point.setY(getDoubleValue(node.get(1).asText())); if (node.get(2) != null) { point.setZ(getDoubleValue(node.get(2).asText())); } return point; } throw new DeserializerException("Invalid point value '" + node + "' in property: " + name, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name); }
private Point readGeoPointValue(final String name, final Geospatial.Dimension dimension, JsonNode node) throws DeserializerException, EdmPrimitiveTypeException { if (node.isArray() && (node.size() ==2 || node.size() == 3) && node.get(0).isNumber() && node.get(1).isNumber() && (node.get(2) == null || node.get(2).isNumber())) { Point point = new Point(dimension, null); point.setX(getDoubleValue(node.get(0).asText())); point.setY(getDoubleValue(node.get(1).asText())); if (node.get(2) != null) { point.setZ(getDoubleValue(node.get(2).asText())); } return point; } throw new DeserializerException("Invalid point value '" + node + "' in property: " + name, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name); }
private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) { Point point = null; if (itor.hasNext()) { point = new Point(GeoUtils.getDimension(type), srid); try { point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); } catch (EdmPrimitiveTypeException e) { throw new IllegalArgumentException("While deserializing point coordinates as double", e); } } return point; }
private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final SRID srid) { Point point = null; if (itor.hasNext()) { point = new Point(GeoUtils.getDimension(type), srid); try { point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); point.setY(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); } catch (EdmPrimitiveTypeException e) { throw new IllegalArgumentException("While deserializing point coordinates as double", e); } } return point; }
private List<Point> points(final XMLEventReader reader, final StartElement start, final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List<Point> result = new ArrayList<Point>(); boolean foundEndProperty = false; while (reader.hasNext() && !foundEndProperty) { final XMLEvent event = reader.nextEvent(); if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) { final String[] pointInfo = event.asCharacters().getData().split(" "); final Point point = new Point(GeoUtils.getDimension(type), srid); try { point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); } catch (EdmPrimitiveTypeException e) { throw new XMLStreamException("While deserializing point coordinates as double", e); } result.add(point); } if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) { foundEndProperty = true; } } // handles bad input, e.g. things like <gml:pos/> if (result.isEmpty()) { result.add(new Point(GeoUtils.getDimension(type), srid)); } return result; }
private List<Point> points(final XMLEventReader reader, final StartElement start, final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List<Point> result = new ArrayList<Point>(); boolean foundEndProperty = false; while (reader.hasNext() && !foundEndProperty) { final XMLEvent event = reader.nextEvent(); if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) { final String[] pointInfo = event.asCharacters().getData().split(" "); final Point point = new Point(GeoUtils.getDimension(type), srid); try { point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); point.setY(EdmDouble.getInstance().valueOfString(pointInfo[1], null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class)); } catch (EdmPrimitiveTypeException e) { throw new XMLStreamException("While deserializing point coordinates as double", e); } result.add(point); } if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) { foundEndProperty = true; } } // handles bad input, e.g. things like <gml:pos/> if (result.isEmpty()) { result.add(new Point(GeoUtils.getDimension(type), srid)); } return result; }
private Point newPoint(final SRID srid, final String point, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { final List<String> pointCoo = split(point, ' '); if (pointCoo == null || pointCoo.size() != 2) { throw new EdmPrimitiveTypeException("The literal '" + point + "' has illegal content."); } final Point result = new Point(this.dimension, srid); result.setX(EdmDouble.getInstance().valueOfString(pointCoo.get(0), isNullable, maxLength, precision, scale, isUnicode, Double.class)); result.setY(EdmDouble.getInstance().valueOfString(pointCoo.get(1), isNullable, maxLength, precision, scale, isUnicode, Double.class)); return result; }
private Point newPoint(final SRID srid, final String point, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { final List<String> pointCoo = split(point, ' '); if (pointCoo == null || pointCoo.size() != 2) { throw new EdmPrimitiveTypeException("The literal '" + point + "' has illegal content."); } final Point result = new Point(this.dimension, srid); result.setX(EdmDouble.getInstance().valueOfString(pointCoo.get(0), isNullable, maxLength, precision, scale, isUnicode, Double.class)); result.setY(EdmDouble.getInstance().valueOfString(pointCoo.get(1), isNullable, maxLength, precision, scale, isUnicode, Double.class)); return result; }
dimension, srid); result.setX(point.getX()); result.setY(point.getY()); return result; } else if (geometry instanceof LineString) {
dimension, srid); result.setX(point.getX()); result.setY(point.getY()); return result; } else if (geometry instanceof LineString) {