Hi,

I'm trying to convert a coordinate (2 dimensional) from WGS84 into geocentric, 
cartesian crs using

        public static Coordinate transform(Coordinate c) {
                final Coordinate[] coordinates = new Coordinate[1];
                coordinates[0] = c;
                final CoordinateSequence coordinateSequence = new 
CoordinateArraySequence(
                                coordinates);
                final Geometry geometry = new Point(coordinateSequence, 
geometryFactory);

                try {
                        final Geometry transformedGeometry = 
JTS.transform(geometry,
                                        mathTransform);
                        final Coordinate[] coordinateArray = 
((CoordinateSequence) transformedGeometry)
                                        .toCoordinateArray();
                        return coordinateArray[0];
                } catch (MismatchedDimensionException e) {
                        throw new IllegalArgumentException(e);
                } catch (TransformException e) {
                        throw new IllegalArgumentException(e);
                }
        }

For full code see https://gist.github.com/2787570

Now I pass `new Coordinate (10, 10)` and get the following error

java.lang.IllegalArgumentException: dimension must be <= 3
                at 
com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory.create(CoordinateArraySequenceFactory.java:90)
                at 
org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:93)
                at 
org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:186)
                at 
org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:173)
                at 
org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:88)
                at org.geotools.geometry.jts.JTS.transform(JTS.java:241)
                at 
de.oschrenk.geo.Transformations.transform(Transformations.java:50)

I enabled debugging to see what the geometry looks like and it says `POINT (10 
10)`, which is 2 dimensional


What am I doing wrong?
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to