% old kustlidar
ncdir = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/kustlidar/'
ncfile = 'http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/kustlidar/catalog.nc'
urlPath = nc_varget(ncfile, 'urlPath');

% S.name(id)

ncfiles = opendap_catalog(ncdir);

kbnames = regexp(ncfiles, '\d{2}[a-z]{2}\d(?=\.)', 'match');
kbnames = cellfun(@(x) x{1}, kbnames, 'uniformoutput', false);

[x y] = cellfun(@(ncfile) deal(nc_attget(ncfile, 'x', 'actual_range'), nc_attget(ncfile, 'y', 'actual_range')), ncfiles, 'uniformoutput', false);


% x = nc_varget(ncfile, 'projectionCoverage_x');
% x = num2cell(x,2);
% y = nc_varget(ncfile, 'projectionCoverage_y');
% y = num2cell(y,2);

figure
url = 'http://opendap.deltares.nl/thredds/dodsC/opendap/deltares/landboundaries/holland_fillable.nc';

plot(nc_varget(url, 'x'), nc_varget(url, 'y'))
hold on
cellfun(@(x,y) rectangle('Position', [min(x) min(y) diff(x) diff(y)]), x, y)

cellfun(@(x,y,name) text(mean(x),mean(y),name, 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'center'), x, y, kbnames);

cellfun(@(x,y,name) text(mean(x),mean(y),kustlidar_definition('x', min(x), 'y', min(y)), 'VerticalAlignment', 'top', 'HorizontalAlignment', 'center'), x, y);