protected Geometry createSubGeomInstance(String token, boolean haveM) throws SQLException { return new Point(token, haveM); }
protected Geometry createSubGeomInstance(String token, boolean haveM) throws SQLException { return new Point(token, haveM); }
/** * Creates a PostGIS Point object corresponding to the provided coordinates. * * @param latitude * The latitude measured in degrees. * @param longitude * The longitude measured in degrees. * @return The Point object. */ public Point createPoint(double latitude, double longitude) { Point result; result = new Point(longitude, latitude); result.srid = 4326; return result; } }
/** * Creates a PostGIS Point object corresponding to the provided coordinates. * * @param latitude * The latitude measured in degrees. * @param longitude * The longitude measured in degrees. * @return The Point object. */ public Point createPoint(double latitude, double longitude) { Point result; result = new Point(longitude, latitude); result.srid = 4326; return result; } }
private Polygon createWayBbox(double left, double right, double bottom, double top) { Point[] points; LinearRing ring; Polygon bbox; points = new Point[5]; points[0] = new Point(left, bottom); points[1] = new Point(left, top); points[2] = new Point(right, top); points[3] = new Point(right, bottom); points[4] = new Point(left, bottom); ring = new LinearRing(points); bbox = new Polygon(new LinearRing[] {ring}); bbox.srid = 4326; return bbox; }
private Polygon createWayBbox(double left, double right, double bottom, double top) { Point[] points; LinearRing ring; Polygon bbox; points = new Point[5]; points[0] = new Point(left, bottom); points[1] = new Point(left, top); points[2] = new Point(right, top); points[3] = new Point(right, bottom); points[4] = new Point(left, bottom); ring = new LinearRing(points); bbox = new Polygon(new LinearRing[] {ring}); bbox.srid = 4326; return bbox; }
private Point[] toPoints(Coordinate[] coordinates) { Point[] points = new Point[coordinates.length]; for (int i = 0; i < coordinates.length; i++) { Coordinate c = coordinates[i]; Point pt; if (Double.isNaN(c.z)) { pt = new Point(c.x, c.y); } else { pt = new Point(c.x, c.y, c.z); } if (c instanceof MCoordinate) { MCoordinate mc = (MCoordinate) c; if (!Double.isNaN(mc.m)) { pt.setM(mc.m); } } points[i] = pt; } return points; }
/** * @param value The text representation of this LinearRing * @param haveM Hint whether we have a measure. This is given to us by other * "parent" Polygon, and is passed further to our parent. * @throws SQLException when a SQLException occurs */ protected LinearRing(String value, boolean haveM) throws SQLException { super(LINEARRING); String valueNoParans = GeometryTokenizer.removeLeadingAndTrailingStrings(value.trim(), "(", ")"); List<String> tokens = GeometryTokenizer.tokenize(valueNoParans, ','); int npoints = tokens.size(); Point[] points = new Point[npoints]; for (int p = 0; p < npoints; p++) { points[p] = new Point(tokens.get(p), haveM); } this.dimension = points[0].dimension; // fetch haveMeasure from subpoint because haveM does only work with // 2d+M, not with 3d+M geometries this.haveMeasure = points[0].haveMeasure; this.subgeoms = points; }
/** * @param value The text representation of this LinearRing * @param haveM Hint whether we have a measure. This is given to us by other * "parent" Polygon, and is passed further to our parent. * @throws SQLException when a SQLException occurs */ protected LinearRing(String value, boolean haveM) throws SQLException { super(LINEARRING); String valueNoParans = GeometryTokenizer.removeLeadingAndTrailingStrings(value.trim(), "(", ")"); List<String> tokens = GeometryTokenizer.tokenize(valueNoParans, ','); int npoints = tokens.size(); Point[] points = new Point[npoints]; for (int p = 0; p < npoints; p++) { points[p] = new Point(tokens.get(p), haveM); } this.dimension = points[0].dimension; // fetch haveMeasure from subpoint because haveM does only work with // 2d+M, not with 3d+M geometries this.haveMeasure = points[0].haveMeasure; this.subgeoms = points; }
public void setValue(String value) throws SQLException { int srid = Geometry.UNKNOWN_SRID; value = value.trim(); if (value.startsWith("SRID=")) { String[] temp = PGgeometry.splitSRID(value); value = temp[1].trim(); srid = Geometry.parseSRID(Integer.parseInt(temp[0].substring(5))); } String myPrefix = getPrefix(); if (value.startsWith(myPrefix)) { value = value.substring(myPrefix.length()).trim(); } String valueNoParans = GeometryTokenizer.removeLeadingAndTrailingStrings(value.trim(), "(", ")"); List<String> tokens = GeometryTokenizer.tokenize(valueNoParans, ','); llb = new Point(tokens.get(0)); urt = new Point(tokens.get(1)); if (srid != Geometry.UNKNOWN_SRID) { llb.setSrid(srid); urt.setSrid(srid); } }
public void setValue(String value) throws SQLException { int srid = Geometry.UNKNOWN_SRID; value = value.trim(); if (value.startsWith("SRID=")) { String[] temp = PGgeometry.splitSRID(value); value = temp[1].trim(); srid = Geometry.parseSRID(Integer.parseInt(temp[0].substring(5))); } String myPrefix = getPrefix(); if (value.startsWith(myPrefix)) { value = value.substring(myPrefix.length()).trim(); } String valueNoParans = GeometryTokenizer.removeLeadingAndTrailingStrings(value.trim(), "(", ")"); List<String> tokens = GeometryTokenizer.tokenize(valueNoParans, ','); llb = new Point(tokens.get(0)); urt = new Point(tokens.get(1)); if (srid != Geometry.UNKNOWN_SRID) { llb.setSrid(srid); urt.setSrid(srid); } }
/** * @param nodeId * Id of the node. * @return Point object */ public Point createPoint(long nodeId) { NodeLocation nodeLocation = locationStore.getNodeLocation(nodeId); Point point = new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude()); point.srid = 4326; return point; }
private Point parsePoint(ValueGetter data, boolean haveZ, boolean haveM) { double X = data.getDouble(); double Y = data.getDouble(); Point result; if (haveZ) { double Z = data.getDouble(); result = new Point(X, Y, Z); } else { result = new Point(X, Y); } if (haveM) { result.setM(data.getDouble()); } return result; }
/** * @param nodeId * Id of the node. * @return Point object */ public Point createPoint(long nodeId) { NodeLocation nodeLocation = locationStore.getNodeLocation(nodeId); Point point = new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude()); point.srid = 4326; return point; }
private Point parsePoint(ValueGetter data, boolean haveZ, boolean haveM) { double X = data.getDouble(); double Y = data.getDouble(); Point result; if (haveZ) { double Z = data.getDouble(); result = new Point(X, Y, Z); } else { result = new Point(X, Y); } if (haveM) { result.setM(data.getDouble()); } return result; }
private Point convertJTSPoint(com.vividsolutions.jts.geom.Point point) { org.postgis.Point pgPoint = new org.postgis.Point(); pgPoint.srid = point.getSRID(); pgPoint.x = point.getX(); pgPoint.y = point.getY(); Coordinate coordinate = point.getCoordinate(); if (Double.isNaN(coordinate.z)) { pgPoint.dimension = 2; } else { pgPoint.z = coordinate.z; pgPoint.dimension = 3; } pgPoint.haveMeasure = false; if (coordinate instanceof MCoordinate && !Double.isNaN(((MCoordinate) coordinate).m)) { pgPoint.m = ((MCoordinate) coordinate).m; pgPoint.haveMeasure = true; } return pgPoint; }
/** * Builds a linestring geometry object from the node references in the * specified way. Unknown nodes will be ignored. * * @param way * The way to create the linestring for. * @return The linestring representing the way. */ public LineString createWayLinestring(Way way) { List<Point> linePoints; linePoints = new ArrayList<Point>(); for (WayNode wayNode : way.getWayNodes()) { NodeLocation nodeLocation; nodeLocation = locationStore.getNodeLocation(wayNode.getNodeId()); if (nodeLocation.isValid()) { linePoints.add(new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude())); } else { return null; } } return createLinestring(linePoints); }
linePoints.add(new Point(nodeLocation.getLongitude(), nodeLocation.getLatitude())); } else { return null;
private static org.postgis.Point convert(Point point) { org.postgis.Point pgPoint = new org.postgis.Point(); pgPoint.srid = point.getSRID(); pgPoint.dimension = point.is3D() ? 3 : 2; pgPoint.haveMeasure = false; pgPoint.x = point.getX(); pgPoint.y = point.getY(); if (point.is3D()) { pgPoint.z = point.getZ(); } if (point.isMeasured()) { pgPoint.m = point.getM(); pgPoint.haveMeasure = true; } return pgPoint; }
private static org.postgis.Point convert(Point point) { org.postgis.Point pgPoint = new org.postgis.Point(); pgPoint.srid = point.getSRID(); pgPoint.dimension = point.is3D() ? 3 : 2; pgPoint.haveMeasure = false; pgPoint.x = point.getX(); pgPoint.y = point.getY(); if (point.is3D()) { pgPoint.z = point.getZ(); } if (point.isMeasured()) { pgPoint.m = point.getM(); pgPoint.haveMeasure = true; } return pgPoint; }