ST_Transformation from EPSG:31256 to EPSG:4326 not possible

155 views
Skip to first unread message

Christoph Hermann

unread,
Jan 29, 2022, 12:04:36 PM1/29/22
to H2 Database
Hello community,

I'm trying to do a coordinate transformation from the Austrian EPSG:31256 to EPSG:4326 with the following code in a h2gis database:

SELECT ST_Transform(ST_GeomFromText('POINT(-38048.66 389405.66)', 31256), 4326) FROM dual;

This gives the following error message

"ST_Transform(conn48: url=jdbc:default:connection user=, POINT (-38048.66 389405.66), 4326): No transformation found from epsg:31256 to epsg:4326"
Exception calling user-defined function: "ST_Transform(conn48: url=jdbc:default:connection user=, POINT (-38048.66 389405.66), 4326): No transformation found from epsg:31256 to epsg:4326"; SQL statement:
SELECT ST_Transform(ST_GeomFromText('POINT(-38048.66 389405.66)', 31256), 4326) FROM dual [90105-197]

Other operations like ST_Within do work (if both geometries have the same SRID).

Doing the same conversion in Java code using just the libraries imported by the Maven artifact org.orbisgis:h2gis-functions:1.3.2 works perfectly fine:

import java.util.List;
import org.cts.CRSFactory;
import org.cts.IllegalCoordinateException;
import org.cts.crs.CRSException;
import org.cts.crs.CoordinateReferenceSystem;
import org.cts.crs.GeodeticCRS;
import org.cts.op.CoordinateOperation;
import org.cts.op.CoordinateOperationFactory;
import org.cts.registry.EPSGRegistry;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;

// test code based on

@QuarkusTest
public class CoordinatesTransformationTest {

@Test
void testConvertAustriaGkEastToGPS() throws CRSException, IllegalCoordinateException {
var crsFactory = new CRSFactory();
crsFactory.getRegistryManager().addRegistry(new EPSGRegistry());
CoordinateReferenceSystem gps = crsFactory.getCRS("EPSG:4326");
CoordinateReferenceSystem austria = crsFactory.getCRS("EPSG:31256");
List<CoordinateOperation> ops = CoordinateOperationFactory
.createCoordinateOperations((GeodeticCRS) austria, (GeodeticCRS) gps);
double[] coord = new double[2];
coord[0] = -38048.66; // Longitude or Easting
coord[1] = 389405.66; // Latitude or Northing
for (var op : ops) {
var transformedCoord = op.transform(coord);
System.out.println("Longitude: " + transformedCoord[0] + " Latitude: " + transformedCoord[1]);
}
}

}

It outputs

Longitude: 15.815805676616735 Latitude: 48.64153355841612

What am I doing wrong in the SQL version?

Any help is appreciated. Thank you very much!

best regards,
Christoph
Reply all
Reply to author
Forward
0 new messages