class JTS {

    public static DirectPosition toDirectPosition(final Coordinate point,
            final CoordinateReferenceSystem crs) {
        // GeneralDirectPosition directPosition = new GeneralDirectPosition(crs);
        // copy( point, directPosition.ordinates );
        // return directPosition;
    
        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:
                    // ignore
                }
            }    
        };
    }

    private  JTS();

}