function testresult = grid_orth_getDataFromNetCDFGrid_test()
%GRID_ORTH_GETDATAFROMNETCDFGRID_TEST  test for grid_orth_getdatafromnetcdfgrid
%  
% See also: grid_orth_getDataFromNetCDFGrid

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2009 Deltares
%       Pieter van Geer
%
%       pieter.vangeer@deltares.nl	
%
%       Rotterdamseweg 185
%       2629 HD Delft
%       P.O. 177
%       2600 MH Delft
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 of the License, or (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tools is part of <a href="http://OpenEarth.Deltares.nl">OpenEarthTools</a>.
% OpenEarthTools is an online collaboration to share and manage data and 
% programming tools in an open source, version controlled environment.
% Sign up to recieve regular updates of this function, and to contribute 
% your own tools.

%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% Created: 11 Sep 2009
% Created with Matlab version: 7.8.0.347 (R2009a)

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

MTestCategory.DataAccess;

% plot landboundary
figure(10);clf;axis equal;box on;hold on
ldburl = 'http://opendap.deltares.nl/thredds/dodsC/opendap/deltares/landboundaries/holland_fillable.nc';

disp('check lookup of variable name nc_index:')
nc_index.x = nc_varfind(ldburl, 'attributename', 'standard_name', 'attributevalue', 'projection_x_coordinate')
nc_index.y = nc_varfind(ldburl, 'attributename', 'standard_name', 'attributevalue', 'projection_y_coordinate')

% identify arbitrary polygon
poly = [  101745 561306
 108749 561073
 106414 556170
 108982 550800
 101278 551034
 101511 561540
];

url = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/vaklodingen/vaklodingenKB121_2120.nc';
[X, Y, Z, T] = grid_orth_getDataFromNetCDFGrid('ncfile', url,...
                                            'starttime', datenum([2009 03 10]),...
                                       'searchinterval', -10.*365,...
                                              'polygon', poly);

testresult = nan;

%% 5 graphicla user test

x      = nc_varget(ldburl, nc_index.x);
y      = nc_varget(ldburl, nc_index.y);

surf(X,Y,Z); shading interp;view(2);
hold on
axis(axis)
plot(poly(:,1), poly(:,2), 'r')
tickmap('xy')
title('Testing getDataFromNetCDFGrid.m on Delflandsekust')
plot(x, y, 'k', 'linewidth', 2);


