I'm not using postgresql epsg but maybe the code I use to reproject will be
useful to you. Just in case:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.ub.bio.wms;

import com.vividsolutions.jts.geom.Coordinate;
import edu.ub.bio.framework.SystemException;
import edu.ub.bio.wms.datasources.DBConnectionFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;

/**
 *
 * @author ciberado
 */
public class CoordinateTransformationService {

    private CoordinateReferenceSystem sourceCRS;
    private CoordinateReferenceSystem targetCRS;

    public CoordinateTransformationService() {
        try {
            sourceCRS = CRS.decode("EPSG:27573");
            targetCRS = CRS.decode("EPSG:4326");
        } catch (NoSuchAuthorityCodeException ex) {
            throw new SystemException(ex);
        } catch (FactoryException ex) {
            throw new SystemException(ex);
        }
    }

    private Coordinate transform(double x, double y) {
        try {
            MathTransform transform = CRS.findMathTransform(sourceCRS,
targetCRS);
            Coordinate source = new Coordinate(x, y);
            Coordinate destination = new Coordinate();
            JTS.transform(source, destination, transform);
            return destination;
        } catch (TransformException ex) {
            throw new SystemException(ex);
        } catch (FactoryException ex) {
            throw new SystemException(ex);
        }
    }


    public static void main(String[] args) {
        CoordinateTransformationService cts =
                new CoordinateTransformationService();
        System.out.println(cts.transform("3 526 32"));
    }
}


On Mon, Feb 14, 2011 at 4:14 PM, Farrukh Najmi <
farr...@wellfleetsoftware.com> wrote:

>
> I am using a PostGres/PostGIS 8.3 database with gt-epsg-postgresql
> plugin. The EPSG Geodetic Parameter Dataset has been loaded into
> postgres from EPSG version 7.6.
>
> When I try to transform a geometry from EPSG:4326 (2D CRS) to EPSG:4979
> (3D CRS) I get the following:
>
> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
> No transformation available from system "EllipsoidalCS[Ellipsoidal 2D
> CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree]"
> to "EllipsoidalCS[Ellipsoidal 3D CS. Axes: latitude, longitude,
> ellipsoidal height. Orientations: north, east, up. UoM: degree, degree,
> metre.]".
>         at
>
> org.geotools.referencing.operation.AbstractCoordinateOperationFactory.swapAndScaleAxis(AbstractCoordinateOperationFactory.java:278)
>         at
>
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.swapAndScaleAxis(DefaultCoordinateOperationFactory.java:591)
>         at
>
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:780)
>         at
>
> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:239)
>         at
>
> org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:254)
>         at org.geotools.referencing.CRS.findMathTransform(CRS.java:1097)
>         ... 50 more
> Caused by: java.lang.IllegalArgumentException: No source axis match UP.
>         at
>
> org.geotools.referencing.operation.matrix.GeneralMatrix.<init>(GeneralMatrix.java:314)
>         at
>
> org.geotools.referencing.operation.matrix.GeneralMatrix.<init>(GeneralMatrix.java:221)
>         at
>
> org.geotools.referencing.cs.AbstractCS.swapAndScaleAxis(AbstractCS.java:331)
>         at
>
> org.geotools.referencing.operation.AbstractCoordinateOperationFactory.swapAndScaleAxis(AbstractCoordinateOperationFactory.java:276)
>
> It seems to me that 2D to 3D transform should be simple (just add a 0
> value for Z axis). Is there a way to do this? If not, shall I file an
> RFE? Thanks for your help.
>
> --
> Regards,
> Farrukh Najmi
>
> Web: http://www.wellfleetsoftware.com
>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Geotools-gt2-users mailing list
> Geotools-gt2-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to