On Mon, Oct 2, 2023 at 9:05 AM Carsten Klein <c.kl...@datagis.com> wrote:
> I managed to add a simple function "add", which returns the sum of both > its Double arguments. The add function follows the GeoTools Function > tutorial: it directly implements the Function interface and gets created by > my own FunctionFactory, which is registered via > META-INF/services/org.geotools.filter.FunctionFactory. > > However, only the Java implementation is actually used. GeoTools/GeoServer > makes no attempt to encode the "add" function in SQL when using a > PostgreSQL store. What am I missing? > Because you haven't modified the database code to advertise it can encode the function, and add the code to perform the actual encoding. E.g., in the case of PostGIS: 1) Declaration that functions are supported https://github.com/geotools/geotools/blob/main/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/FilterToSqlHelper.java#L167 2) Actual function encoding: https://github.com/geotools/geotools/blob/main/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/FilterToSqlHelper.java#L522 > Another question: most of the built-in functions do not implement the > Function interface directly but extend FunctionExpressionImpl (which > implements FunctionExpression). According to the docs, these functions must > be registered via META-INF/services/org.geotools.api.filter.Function. So, I > added a "sub" function, returning a - b, which is based on the > FunctionExpression approach (which seems to be quite a bit more comfortable > and newer). Unfortunately, GeoServer/GeoTools seems not to know the new > "sub" function and throws an error when I try to use that function through > a WFS GetFeature request. > The docs are probably pointing you at the wrong registration file, the functions are registered in "org.geotools.api.filter.expression.Function": https://github.com/geotools/geotools/blob/main/modules/library/main/src/main/resources/META-INF/services/org.geotools.api.filter.expression.Function If you spot issues in the docs please contribute fixes for it. Cheers Andrea == GeoServer Professional Services from the experts! Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions Group phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 https://www.geosolutionsgroup.com/ http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail
_______________________________________________ Geoserver-devel mailing list Geoserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-devel