/** * Return true if the values of the two {@link Coordinate} are equal when their * first and second ordinates are cast as ints. Ignores 3rd ordinate. * * @param a first coordinate to compare * @param b second coordinate to compare * @return true if the values of the two {@link Coordinate} are equal when their * first and second ordinates are cast as ints */ private static boolean equalAsInts2d(Coordinate a, Coordinate b) { return ((int)a.getOrdinate(0)) == ((int)b.getOrdinate(0)) && ((int)a.getOrdinate(1)) == ((int)b.getOrdinate(1)); }
public static double[] getOrdinate(List<Coordinate> coordinates, int index) { double[] result = new double[coordinates.size()]; int i = 0; for (Coordinate c : coordinates) { result[i] = c.getOrdinate(index); i = i + 1; } return result; }
/** * Scales the given geometry by multiplying the coordinates by the * indicated x, y and z scale factors. * * @param geom Geometry * @param xFactor x scale factor * @param yFactor y scale factor * @param zFactor z scale factor * @return The geometry scaled by the given x, y and z scale factors */ public static Geometry scale(Geometry geom, double xFactor, double yFactor, double zFactor) { if (geom != null) { Geometry scaledGeom = (Geometry) geom.clone(); for (Coordinate c : scaledGeom.getCoordinates()) { c.setOrdinate(Coordinate.X, c.getOrdinate(Coordinate.X) * xFactor); c.setOrdinate(Coordinate.Y, c.getOrdinate(Coordinate.Y) * yFactor); c.setOrdinate(Coordinate.Z, c.getOrdinate(Coordinate.Z) * zFactor); } return scaledGeom; } else { return null; } } }
/** * Scales the given geometry by multiplying the coordinates by the * indicated x, y and z scale factors. * * @param geom Geometry * @param xFactor x scale factor * @param yFactor y scale factor * @param zFactor z scale factor * @return The geometry scaled by the given x, y and z scale factors */ public static Geometry scale(Geometry geom, double xFactor, double yFactor, double zFactor) { if (geom != null) { Geometry scaledGeom = (Geometry) geom.clone(); for (Coordinate c : scaledGeom.getCoordinates()) { c.setOrdinate(Coordinate.X, c.getOrdinate(Coordinate.X) * xFactor); c.setOrdinate(Coordinate.Y, c.getOrdinate(Coordinate.Y) * yFactor); c.setOrdinate(Coordinate.Z, c.getOrdinate(Coordinate.Z) * zFactor); } return scaledGeom; } else { return null; } } }
public static Double ordinate(GeometryType geom, Ordinate ordinate) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (!(g instanceof Point)) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31208, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31208)); } Point p = (Point)g; Coordinate c = p.getCoordinate(); if (c == null) { return null; } double value = c.getOrdinate(ordinate.ordinal()); if (Double.isNaN(value)) { return null; } return value; }
public static Double ordinate(GeometryType geom, Ordinate ordinate) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (!(g instanceof Point)) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31208, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31208)); } Point p = (Point)g; Coordinate c = p.getCoordinate(); if (c == null) { return null; } double value = c.getOrdinate(ordinate.ordinal()); if (Double.isNaN(value)) { return null; } return value; }
public static Double ordinate(GeometryType geom, Ordinate ordinate) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (!(g instanceof Point)) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31208, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31208)); } Point p = (Point)g; Coordinate c = p.getCoordinate(); if (c == null) { return null; } double value = c.getOrdinate(ordinate.ordinal()); if (Double.isNaN(value)) { return null; } return value; }