On Mon, 16 Mar 2015 04:28:27 AM Andrea Aime wrote:
> I'm not 100% sure, but believe GeoServer is just re-publishing what it's
> getting from the NetCDF driver.
> Daniele (cc'ed), do you know why/under which conditions the netcdf reader
> publishes time periods
> instead of simple time intervals?
>From a quick look at the GeoTools NetCDFReader code, it looks like there will
always be time periods (DateRange instances) for the global time domain in
NetCDF.

It might not be very hard to change the behaviour to special-case this on the
GeoServer side:

diff --git a/src/main/src/main/java/org/geoserver/util/ISO8601Formatter.java 
b/src/main/src/main/java/org/geoserver/util/ISO8601Formatter.java
index 00b6c40..bbb9cc2 100644
--- a/src/main/src/main/java/org/geoserver/util/ISO8601Formatter.java
+++ b/src/main/src/main/java/org/geoserver/util/ISO8601Formatter.java
@@ -46,14 +46,17 @@ public class ISO8601Formatter {
      * Formats the specified object either as a single time, if it's a Date, 
or as a continuous
      * interval, if it's a DateRange (and will throw an {@link 
IllegalArgumentException} otherwise)
      * 
-     * @param date
-     * @return
+     * @param date the date or date range to format
+     * @return string containing date / date range in ISO8601 (as modified by 
OGC WMS) format
      */
     public String format(Object date) {
-        if(date instanceof Date) {
+        if (date instanceof Date) {
             return format((Date) date);
-        } else if(date instanceof DateRange){
+        } else if (date instanceof DateRange) {
             DateRange range = (DateRange) date;
+            if (range.getMinValue().compareTo(range.getMaxValue()) == 0) {
+                return format(range.getMinValue());
+            }
             StringBuilder sb = new StringBuilder();
             format(range.getMinValue(), sb);
             sb.append("/");

That works for my special case.

However I'm still not sure this is the right fix, or even if a fix is needed.
If it is, no problem with working up some tests and submitting
a PR. 

Brad


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to