4

I'm trying to query the database (DataStore) and want to let the datastore calculate a value for me.

In SQL I would do it like this:

SELECT name, ST_Area(ST_Intersection(the_geom, ....) AS myValue FROM ...

Is there any way, how I can do this with CQL. My current approach is this, but I do not know how to add this calculated field. I need this, as I want to sortBy this field.

DataStore ds = ...
Filter filter = CQL.toFilter("INCLUDE");
SimpleFeatureCollection features = source.getFeatures(filter);

Any idea, how to add my area function to the resultset?

1 Answer 1

1

There is no way to insert a result into the featureCollection at query time using CQL. You could create an SQL view with the result in it and query that.

Or you can iterate through the features returned and calculate the area of the geometry for each one in turn.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.