Hi Mike,

these are the ingredients:
-Create an extension of BaseCoverageResponseDelegate 
-Register it in a custom applicationContext so Spring picks it up:
<bean id="timeseriesJSON" class="myPackage.TimeSeriesJsonOutput">
        <constructor-arg ref="geoServer"/>
    </bean>
-when calling the super constructor, register your custom mime type
-Use reflection to work around the issue with mdFormats 
-The GridCoverage2D which is passed into the encode method can now be 
cast to a GranuleStack, which should contain a coverage for each instant 
in your time series.
-Encode the values of these coverages to your liking, if the WCS request 
comes down to a single pixel, you can simply return those pixel values as a 
json object.

This is an example of the type of WCS request that I use:
http://myhost/geoserver/wcs?SERVICE=WCS&REQUEST=GetCoverage&VERS
ION=2.0.1&coverageId=workspaceX-
myCoverage&FORMAT=application/json&subset=X,http://www.opengis.net/d
ef/crs/EPSG/0/3857(474094.3071525846,474144.3071525846)&subset=Y,
http://www.opengis.net/def/crs/EPSG/0/3857(6609749.836034014,6609799
.836034014)

Below is some sample code which contains the mdFormats hack.

best regards,
Jeroen

public class TimeSeriesJsonOutput extends 
BaseCoverageResponseDelegate implements
        CoverageResponseDelegate {

    private final static String MIME_TYPE = "application/json";
    
    static{
        try {
            Field field = 
GetCoverage.class.getDeclaredField("mdFormats");
            field.setAccessible(true);
            ((Set<String>)field.get(null)).add(MIME_TYPE);
        } catch (NoSuchFieldException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static final Logger LOGGER = 
Logging.getLogger(TimeSeriesJsonOutput.class.getName());

    @SuppressWarnings("serial")
    public TimeSeriesJsonOutput(GeoServer geoserver) {
        super(geoserver, Arrays.asList("TSJSON"), // output formats
                new HashMap<String, String>() { // file extensions
                    {                        
                        put("TSJSON", "json");                       
                        put(MIME_TYPE, "json");
                    }
                }, new HashMap<String, String>() { // mime types
                    {
                        put("TSJSON", MIME_TYPE);                               
       
                    }
                });
    }


    public void encode(GridCoverage2D sourceCoverage, String 
outputFormat,
            Map<String, String> econdingParameters, OutputStream output) 
throws ServiceException,
            IOException {

On Wednesday 12 November 2014 11:39:34 Mike Grogan wrote:
> Wow, I was out for the day after sending this, and I came back to some
> great responses.  Thanks, everyone.
> 
> Jeroen, any tips you have would be greatly appreciated.  I see you have a
> JIRA open on registering custom MIME types ... so any workaround like 
that
> would be great advice.  Code pointers, etc. would be most welcome.
> 
> Jukka and Andrea,
> 
> Thanks for weighing in, too.  As I have told Andrea personally, I think
> GeoSolutions is doing a really good job expanding GeoServer into better
> serving Meteorology / Oceanography data needs.  From the model data
> perspective, visualizing data for all gridcells at a time is important, but
> displaying all data at a point across all forecast times is also important,
> and that is the scope of my current problem.  I could write some 'sidecar'
> application to do this from the same data used by the Image Mosaic, but 
I
> would rather incorporate it into GeoServer via plugin, custom code, etc.
> 
> Thanks,
> 
> Mike
> 
> On Wed, Nov 12, 2014 at 4:44 AM, Jeroen Dries <[email protected]> 
wrote:
> > Hi Jukka,
> > 
> > indeed I use a WCS 2.0 range query  to select a point, this does mean 
that
> > the
> > client request needs to be adapted to the resolution of the coverage. 
In
> > case
> > the area matches multiple pixels, I plan to compute the average band 
value
> > over all pixels, because that is also a valid use case.
> > 
> > I have also used range subsetting for band selection, although I did
> > encounter
> > some inconsistencies in the geoserver implementation which I had to 
work
> > around, but this may have been specific to my custom data backend.
> > 
> > best regards,
> > Jeroen
> > 
> > On Wednesday 12 November 2014 09:29:55 Rahkonen Jukka wrote:
> > > Hi,
> > > 
> > > Well, I was thinking simply X and Y for giving the point to be queried
> > > because I thought that BBOX can't be a point. But I have mostly 
used WCS
> > > 1.0.0. Is it so that in WCS 2.0 core the "slicePoint" can be used for
> > 
> > this?
> > 
> > > And standard range subsetting can be used for selecting what is 
queried,
> > > like list of bands from multiband satellite images?
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to