Hi,
right now we have two pull requests related to the management of the default
value in WMS dimensions:
- jwood106 pull request https://github.com/geoserver/geoserver/pull/377 allows the
specification of a specific value for elevation dimension over raster data.
It changes the DimensionInfo API to store a specific value for the selected default. - ilkkarinne pull request https://github.com/geoserver/geoserver/pull/430 adds two
different strategies to handle the default value of the time dimension, either choosing
the latest value in the sequence, or the closest one to the time the WMS request was made.
There is not configuration in this case, a system variable drives the choice instead.
The two pull requests could coexist, but it seems to me things would be rather messy
if we merged them, with a few ad-hoc solutions to the problem of choosing the
default value for a dimension, and possibly others to come, including;
- fixed value for vectors, time and custom dimensions too
- min/closest to the zero (or other reference point) as the default value for elevation
I’m wondering about having a more general solution then, one in which the two above
patches could be seen as plugins, delivering exactly the same functionality, but
with the option to grow the set of “default value selectors” without having to also grow
the number of ad-hoc changes around.
Idea:
- Following pull 430 approach, but making it more general, create a new DefaultValueStrategy,
which can be used to compute the default value for a given combination of dimension type and layer.
The interface would look something like the following:
interface DefaultValueStrategy implements Serializable {
/**
- Gets the actual value given the resource, the dimension, and the selected values for the already processed dimensions
*/
Object getDefaultValue(ResourceInfo resource, DimensionInfo dimension);
/**
- Returns the capabilities representation of the default value. For example, it could be “current”
*/
String getCapabilitiesRepresentation(ResourceInfo resource, DimensionInfo dimension);
}
These objects would become part of the DimensionInfo, and would be serialized with XStream along with
all the state they need to perform the computation:
interface DimensionInfo {
…
DefaultValueStrategy getDefaultValueStrategy();
void setDefaultValueStrategy(DefaultValueStrategy);
}
and the xml could end up looking something like (having the proper xstream aliases registrations)
for fixed value choice:
or something like this for represting current with the nearest value to the time of the request (which
does not need any inner field):
- In order to locate and create the strategies depending on the current combination of resource and
layer we’d have factories registered in the app-context:
interface DefaultValueStrategyFactory {
/**
- Returns a strategy, or
DimensionDefaultValueStrategy getStrategy(ResourceInfo resource, DimensionInfo dimension);
}
The code implemented by the two pull requests could keep on working as it does now, being layer
specific, or dimension specific, but this would leave us the option of adding more and increase the
generality in the future
- Finally, have the GUI use the above factories to locate the strategies usable for the current resource
and dimension, presenting a drop down, and go back in the app context to find panel implementations
that can handle the configuration of a certain strategy, if a GUI is needed at all:
interface DefaultValueStrategyPanelFactory { // all right, ugly name, suggestions??
FormComponent createUIForStrategy(ResourceInfo resource, DimensionInfo di, DefaultValueStrategy strategy);
}
Opinions?
Cheers
Andrea
–
== GeoSolutions will be closed for seasonal holidays from 23/12/2013 to 06/01/2014 ==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it