Hi Jody,

thanks for your response :)

Since I will likely not be able to modify/extend FilterToSqlHelper from a GeoTools Filter Function Plugin, it will be best to focus on PostgreSQL functions that can be encoded as

functionName(p1, p2, ... pN)

In that case, PostgisFilterToSQL will translate my Java implemented custom functions to SQL without any further action required? (Given that "encode functions" is enabled.)

I guess, the actual Java implementation is not required to return/evaluate any meaningful results based on the arguments, right? (I won't be able to re-implement e.g. Full Text Search in Java, of course)

Still on track?

Regards,
Carsten


Am 26.09.2023 um 08:31 schrieb Jody Garnett:
You are running alongside the right track :)

To work you implement in java (for any non PostGIS data) and then adjust the PostGIS DataStore code to map those functions to SQL.

  * PostGISDialect
  * PostgisFIlterToSQL
  * FilterToSqlHelper
  * FilterToSqlHelper.visitFunction(function,extraData)
    
<https://github.com/geotools/geotools/blob/main/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/FilterToSqlHelper.java#L522>


You can see the mapping being done from the GeoTools function data structure (which is why you need a java implementation) to the SQL.


--
Jody Garnett


On Sep 25, 2023 at 11:23:00 PM, Carsten Klein <c.kl...@datagis.com> wrote:
Hi there,

I'd like to use some custom PostgreSQL functions as filters in standard
WFS 2.0.0 requests. The goal is to request features filtered by e.g.
Full Text Search or the word_similarity function provided by the pg_trgm
extension (Trigram/Trigraph support).

Since WFS only provides a quite limited set of operators
(PropertyIs[Not]EqualTo, PropertyIsLessThan, PropertyIsLike, etc.), my
idea is to use my own filter functions in order to access those custom
database functions.

In GeoTools, there is a Function tutorial explaining how to create my
own Function Factory and function implementations. However, all samples
and functions I've seen so far are implemented in Java. Is it possible
for these Filter Functions to contribute to the WHERE clause of the
actual SQL statement executed in the database?

For a GeoServer (Data)Store, there is an option "encode functions",
causing all/most filters to be implemented in SQL for performance
reasons. Does this affect Filter Functions from those Filter Factories
as well?

Looking at the Function's interfaces (Expression, ExpressionVisitor,
Function), I don't see any point at which SQL could come into play. Am I
on the right track?

Any advice is appreciated :)

Carsten


_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to