Quantcast
Channel: MarsHut
Viewing all articles
Browse latest Browse all 6551

Handling timestamp parameters in custom filter function

$
0
0
Hi all -

I've been using a couple custom filter functions that I wrote, for about a
month now. The framework has worked well for me, but I have one issue that
I haven't been able to work out yet. My function takes in a handful of
parameters. The parameters of String or primitive numeric types are working
great. However I am having trouble with time based <PropertyName>
parameters.

My feature is backed by a PostGIS data store and the table in question uses
"timestamp with time zone" type. So I was thinking I'd use the
java.sql.Timestamp in the FunctionName definition, like this:

parameter("featureStartTime", Timestamp.class)

...and this in the evaluate method:

Timestamp timeParam = super.getParameters().get(index).evaluate(feature,
Timestamp.class);

Unfortunately though, that always returns null. I have confirmed that the
database records indeed to have non null values.

I have also tried to handle these as strings, but in that - somewhat
surprisingly - it returns a "-1" value. I suppose this is the equivalent to
null. Date type also fails - returning null.

As a workaround so far, I have just been changing that field in my test
database to be a varchar and then converting in my code after reading the
param as a string. However, I'm now about ready to move to a production
database that uses the postgresql timestamp, so I can no longer hack my way
around it.

I apologize if the answer is already in the docs/forums somewhere (I assume
it must be) but I have not been able to find it yet. Any help would be
greatly appreciated.

Thanks,

Jeremy

Viewing all articles
Browse latest Browse all 6551

Trending Articles