Hi,
To answer #1, SPI is the Java 'Service Provider Interface'. It is one
option on the JVM to provide concrete implementations to interfaces at
runtime[1]. To create the jar, you'd need to compile your class and
make sure to include the file in META-INF/services that Andrea
mentioned. Build tools like Maven can help with compiling, etc.
As a note, we wrote a similar function in GeoMesa[2]. On a good day,
you could add the jar I linked to a GeoServer 2.15.x (newer *may* work,
but things could go wrong) and the function currentDate may work.
I've used it for layers with live data to run queries like "DATE_COL >
currentDate('-PT5m')" to show only the records which have updated in the
last 5 minutes. As the GeoMesa documentation notes, the syntax for the
duration is here[3].
Cheers,
Jim
1. SPI Background: https://www.baeldung.com/java-spi
https://www.journaldev.com/31602/java-spi-service-provider-interface-and-serviceloader
2. Scala code:
https://github.com/locationtech/geomesa/blob/master/geomesa-filter/src/main/scala/org/locationtech/geomesa/filter/function/CurrentDateFunction.scala
Meta-inf line to wire it up:
https://github.com/locationtech/geomesa/blob/master/geomesa-filter/src/main/resources/META-INF/services/org.opengis.filter.expression.Function#L2
Docs:
https://www.geomesa.org/documentation/user/datastores/filter_functions.html#currentdate
Jar:
https://repo1.maven.org/maven2/org/locationtech/geomesa/geomesa-filter_2.11/2.4.0/geomesa-filter_2.11-2.4.0.jar
3.
https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-
On 1/9/20 10:34 AM, steefdam via Geoserver-users wrote:
Hi Andrea,
I know it has been a very long time since this question came up and you
answered it, but I have a question about this topic.
I want to set a CQL filter in GeoServer which compares a date-attribute i.e.
DATE_COL to /now/, with /now/ being a Java function. Very much like this:
DATE_COL > getDateNow()
In your answer to the OP you wrote that it's quite simple:
geowolf wrote
It's really just:
1) create the function, e.g.
https://github.com/geotools/geotools/blob/master/modules/library/main/src/main/java/org/geotools/filter/function/string/ConcatenateFunction.java
2) register the function in SPI, eg.:
https://github.com/geotools/geotools/blob/master/modules/library/main/src/main/resources/META-INF/services/org.opengis.filter.expression.Function#L168
You just create a jar with those two files, drop it in GeoServer, and you
get the extra function available to SLD, WFS and so on
I have two questions about this:
1. What do you mean with registering the function in SPI?
2. Which two files do you need to create a jar?
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html
_______________________________________________
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this
list:
- Earning your support instead of buying it, but Ian Turton:
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines:
http://geoserver.org/comm/userlist-guidelines.html
If you want to request a feature or an improvement, also see this:
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
_______________________________________________
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this
list:
- Earning your support instead of buying it, but Ian Turton:
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines:
http://geoserver.org/comm/userlist-guidelines.html
If you want to request a feature or an improvement, also see this:
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users