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
// 
https://github.com/orbisgis/cts/wiki/1.-Create-a-new-CoordinateReferenceSystem-from-a-reference-code
// and 
https://geoinformatik.htw-dresden.de/anleitungen/gi-app/JavaKoordinatentransformationen.pdf

@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

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/104321de-d151-44a1-8ba8-9849d375b147n%40googlegroups.com.

Reply via email to