Thanks for joining the developer list with a fix, yes please create an
issue in jira, and a PR with your fix. Checking the plugin pom.xml
<https://github.com/geotools/geotools/blob/master/modules/plugin/jdbc/jdbc-hana/pom.xml>
shows Stefan
is the module maintainer and should be in a position to review.

Stay safe!
--
Jody Garnett


On Mon, 11 May 2020 at 08:42, Biskup, Paul <paul.bis...@fit.fichtner.de>
wrote:

> Hi all,
>
>
>
> I’ve been recently using the SAP HANA-datastore in GeoServer, which works
> great.
>
> Unfortunately there is a problem if you publish a HANA-view as a layer and
> try to do a spatial GetFeature-request on this layer. The view can be
> published and displayed as WMS, but if you do a GetFeature-request, you get
> this exception:
>
>
>
> <ows:ExceptionText>java.lang.RuntimeException: java.io.IOException
>
> java.io.IOExceptionSAP DBTech JDBC: [8]: invalid argument: The given SRID
> (-1) does not match the field's SRID (31466) at function
> __st_geomfromwkb__() (at pos 134) </ows:ExceptionText>
>
>
>
> The SRID from the geometry-column in my view is EPSG:31466.
>
>
>
> I have already analyzed the problem and have also found a fix for this
> problem.
>
> The problem is, that in a spatial GetFeature-request the code tries to get
> the SRID from the layer by executing this SQL-Statement:
>
>
>
>                                 "SELECT SRS_ID FROM
> PUBLIC.ST_GEOMETRY_COLUMNS WHERE SCHEMA_NAME = ? AND TABLE_NAME = ? AND
> COLUMN_NAME = ?");
>
>
>
>
> https://github.com/geotools/geotools/blob/b1be2cef1c06058f726bce94ac665ee50b571db6/modules/plugin/jdbc/jdbc-hana/src/main/java/org/geotools/data/hana/HanaDialect.java#L193
> <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgeotools%2Fgeotools%2Fblob%2Fb1be2cef1c06058f726bce94ac665ee50b571db6%2Fmodules%2Fplugin%2Fjdbc%2Fjdbc-hana%2Fsrc%2Fmain%2Fjava%2Forg%2Fgeotools%2Fdata%2Fhana%2FHanaDialect.java%23L193&data=02%7C01%7CPaul.Biskup%40fit.fichtner.de%7C9494b1d03c7e48fa02eb08d7f0e246b8%7Cb43430ce7d754158ab7b1f39e6fe6b3f%7C0%7C0%7C637242726951941780&sdata=4f4%2BDcTKIA7rOBVtrz2faC%2F0LMtM0pBkh1tLZfQlPP4%3D&reserved=0>
>
>
>
> But the PUBLIC.ST_GEOMETRY-view in HANA is only filled for tables and not
> for views. That is why in my request the SRID of the layer can not be found
> and a „-1“ is returned.
>
> Further have I analyzed, that the received SRID is passed in the
> „prepareGeometryValue“-function, which is used to create the sql-statement.
>
>
> https://github.com/geotools/geotools/blob/b1be2cef1c06058f726bce94ac665ee50b571db6/modules/plugin/jdbc/jdbc-hana/src/main/java/org/geotools/data/hana/HanaDialect.java#L732
>
>
>
> There is an easy fix for this problem:
>
> If you change the „prepareGeometryValue“-code like this, the SRID will
> only be passed to the „ST_GeomFromWKB“-function, if it is „>1“:
>
>
>
>     public void prepareGeometryValue(
>
>             Class<? extends Geometry> gClass,
>
>             int dimension,
>
>             int srid,
>
>             Class binding,
>
>             StringBuffer sql) {
>
>         String pattern = null;
>
>         if (srid > -1) {
>
>             pattern = "ST_GeomFromWKB( ? ,{0})";
>
>             sql.append(MessageFormat.format(pattern,
> Integer.toString(srid)));
>
>         } else {
>
>             sql.append("ST_GeomFromWKB( ? )");
>
>         }
>
>     }
>
>
>
> If no SRID is passed, the HANA-function assumes, that the SRID is in the
> same coordinate system as the passed coordinates.
>
> The fix is working in my locally build JDBC-HANA-Datastore and GeoServer.
>
>
>
> Could you please take a look at this and tell me if I should create an
> issue in your JIRA?
>
>
>
> Best regards,
> Paul
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to