@Test public void toDirectPosition() { Coordinate c = new Coordinate(40,40); DirectPosition wrapper = JTS.toDirectPosition(c, DefaultGeographicCRS.WGS84 ); GeneralDirectPosition expected = new GeneralDirectPosition( DefaultGeographicCRS.WGS84); expected.setOrdinate(0,40); expected.setOrdinate(1,40); assertEquals( expected, wrapper ); }
public static DirectPosition toDirectPosition(final Coordinate point, final CoordinateReferenceSystem crs) { return new AbstractDirectPosition() { public CoordinateReferenceSystem getCoordinateReferenceSystem() { return crs; } public int getDimension() { return crs.getCoordinateSystem().getDimension(); } public double getOrdinate(int dimension) throws IndexOutOfBoundsException { switch (dimension) { case 0: return point.x; case 1: return point.y; case 2: return point.z; default: return Double.NaN; } } public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException { switch (dimension) { case 0: point.x = value; return; case 1: point.y = value; return; case 2: point.z = value; return; default: } } }; }
JTS { public static DirectPosition toDirectPosition(final Coordinate point, final CoordinateReferenceSystem crs) { return new AbstractDirectPosition() { public CoordinateReferenceSystem getCoordinateReferenceSystem() { return crs; } public int getDimension() { return crs.getCoordinateSystem().getDimension(); } public double getOrdinate(int dimension) throws IndexOutOfBoundsException { switch (dimension) { case 0: return point.x; case 1: return point.y; case 2: return point.z; default: return Double.NaN; } } public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException { switch (dimension) { case 0: point.x = value; return; case 1: point.y = value; return; case 2: point.z = value; return; default: } } }; } }
JTS { public static DirectPosition toDirectPosition(final Coordinate point, final CoordinateReferenceSystem crs) { return new AbstractDirectPosition() { public CoordinateReferenceSystem getCoordinateReferenceSystem() { return crs; } public int getDimension() { return crs.getCoordinateSystem().getDimension(); } public double getOrdinate(int dimension) throws IndexOutOfBoundsException { switch (dimension) { case 0: return point.x; case 1: return point.y; case 2: return point.z; default: return Double.NaN; } } public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException { switch (dimension) { case 0: point.x = value; return; case 1: point.y = value; return; case 2: point.z = value; return; default: } } }; } private  JTS(); }
JTS { public static DirectPosition toDirectPosition(final Coordinate point, final CoordinateReferenceSystem crs) { return new AbstractDirectPosition() { public CoordinateReferenceSystem getCoordinateReferenceSystem() { return crs; } public int getDimension() { return crs.getCoordinateSystem().getDimension(); } public double getOrdinate(int dimension) throws IndexOutOfBoundsException { switch (dimension) { case 0: return point.x; case 1: return point.y; case 2: return point.z; default: return Double.NaN; } } public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException { switch (dimension) { case 0: point.x = value; return; case 1: point.y = value; return; case 2: point.z = value; return; default: } } }; } private  JTS(); static Envelope transform(final Envelope envelope, final MathTransform transform); static Envelope transform(final Envelope sourceEnvelope, Envelope targetEnvelope,
            final MathTransform transform, int npoints); static Geometry transform(final Geometry geom, final MathTransform transform); static Coordinate transform(final Coordinate source, Coordinate dest,
            final MathTransform transform); static Envelope toGeographic(final Envelope envelope, final CoordinateReferenceSystem crs); static void xform(final MathTransform transform, final double[] src, final double[] dest); static synchronized double orthodromicDistance(final Coordinate p1, final Coordinate p2,
            final CoordinateReferenceSystem crs); static DirectPosition toDirectPosition(final Coordinate point,
            final CoordinateReferenceSystem crs); static void copy(final Coordinate point, final double[] ordinates); static Geometry shapeToGeometry(final Shape shape, final GeometryFactory factory); static Geometry toGeometry(final Shape shape); static Geometry toGeometry(final Shape shape, final GeometryFactory factory); static Envelope2D getEnvelope2D(final Envelope envelope,
            final CoordinateReferenceSystem crs); static Point toGeometry(DirectPosition position); static Point toGeometry(DirectPosition position, GeometryFactory factory); static Polygon toGeometry(Envelope env); static Polygon toGeometry(final Envelope env, GeometryFactory factory); static ReferencedEnvelope toEnvelope(Geometry geom); static Polygon toGeometry(ReferencedEnvelope bbox); static Polygon toGeometry(BoundingBox bbox, GeometryFactory factory, int npoints); static Polygon toGeometry(BoundingBox bbox); static Polygon toGeometry(BoundingBox bbox, final GeometryFactory factory); static void checkCoordinatesRange(Geometry geom, CoordinateReferenceSystem crs); static Geometry smooth(final Geometry geom, double fit); static Geometry smooth(final Geometry geom, double fit, final GeometryFactory factory); }
JTS { public static DirectPosition toDirectPosition(final Coordinate point, final CoordinateReferenceSystem crs) { return new AbstractDirectPosition() { public CoordinateReferenceSystem getCoordinateReferenceSystem() { return crs; } public int getDimension() { return crs.getCoordinateSystem().getDimension(); } public double getOrdinate(int dimension) throws IndexOutOfBoundsException { switch (dimension) { case 0: return point.x; case 1: return point.y; case 2: return point.z; default: return Double.NaN; } } public void setOrdinate(int dimension, double value) throws IndexOutOfBoundsException { switch (dimension) { case 0: point.x = value; return; case 1: point.y = value; return; case 2: point.z = value; return; default: } } }; } private  JTS(); static Envelope transform(final Envelope envelope, final MathTransform transform); static Envelope transform(final Envelope sourceEnvelope, Envelope targetEnvelope,
            final MathTransform transform, int npoints); static Geometry transform(final Geometry geom, final MathTransform transform); static Coordinate transform(final Coordinate source, Coordinate dest,
            final MathTransform transform); static Envelope toGeographic(final Envelope envelope, final CoordinateReferenceSystem crs); static void xform(final MathTransform transform, final double[] src, final double[] dest); static synchronized double orthodromicDistance(final Coordinate p1, final Coordinate p2,
            final CoordinateReferenceSystem crs); static DirectPosition toDirectPosition(final Coordinate point,
            final CoordinateReferenceSystem crs); static void copy(final Coordinate point, final double[] ordinates); static Geometry shapeToGeometry(final Shape shape, final GeometryFactory factory); static Geometry toGeometry(final Shape shape); static Geometry toGeometry(final Shape shape, final GeometryFactory factory); static Envelope2D getEnvelope2D(final Envelope envelope,
            final CoordinateReferenceSystem crs); static Point toGeometry(DirectPosition position); static Point toGeometry(DirectPosition position, GeometryFactory factory); static Polygon toGeometry(Envelope env); static Polygon toGeometry(final Envelope env, GeometryFactory factory); static ReferencedEnvelope toEnvelope(Geometry geom); static Polygon toGeometry(ReferencedEnvelope bbox); static Polygon toGeometry(BoundingBox bbox, GeometryFactory factory, int npoints); static Polygon toGeometry(BoundingBox bbox); static Polygon toGeometry(BoundingBox bbox, final GeometryFactory factory); static void checkCoordinatesRange(Geometry geom, CoordinateReferenceSystem crs); static Geometry smooth(final Geometry geom, double fit); static Geometry smooth(final Geometry geom, double fit, final GeometryFactory factory);  }