data_title = 'Vaklodingen_interp';
data_summary = 'Linear interpolation in time of bathymetry and topography measurements along the Dutch coast';
data_keywords = 'bathymetry, coast';
if ispc
    userdir = getenv('USERPROFILE'); % pick another directory
else
    userdir = getenv('HOME');
end
path_main = fullfile(userdir, 'products_interp');
path_sub_netcdf = fullfile('rijkswaterstaat', 'vaklodingen_interp');

publisher_email       = 'Giorgio.Santinelli@deltares.nl';
institution_longname  = 'Rijkswaterstaat Data-ICT-Dienst (RWS DID)';
institution_shortname = 'Rijkswaterstaat';

creator_name       = institution_longname;
creator_url        = 'www.rijkswaterstaat.nl';
creator_email      = 'info@rijkswaterstaat.nl';

processing_level   = 'final';

publisher_name     = getenv('USERNAME');
publisher_domain   = getenv('USERDOMAIN');
publisher_computer = getenv('COMPUTERNAME');
publish_script_id  = '$Header$';
path_data_title    = lower(strrep(data_title, ' ', '_'));
path_netcdf        = fullfile(path_main, 'nc', path_sub_netcdf);
path_sub_kml       = path_sub_netcdf;
path_kml = fullfile(path_main, 'kml', path_sub_kml);
fmt = 'yyyy-mm-ddTHH:MMZ';

switch processing_level
    case 'final'
        url_main_netcdf     = 'http://opendap.deltares.nl/thredds/dodsC/opendap/';
        url_ftp_main_netcdf = 'http://opendap.deltares.nl/thredds/fileServer/opendap/';
        kml_server          = 'kml.deltares.nl';
    case 'preliminary'
        url_main_netcdf     = 'http://dtvirt5.deltares.nl:8080/thredds/dodsC/opendap/';
        url_ftp_main_netcdf = 'http://dtvirt5.deltares.nl:8080/thredds/fileServer/opendap/';
        kml_server          = 'dtvirt5.deltares.nl';
    otherwise
        error('error')

end
nc2kml_surface_imageOverlay(...
    'path_netcdf'   , path_netcdf,...
    'path_kml'      , path_kml,...
    'CBtemplateVer' ,'KML_colorbar_template_vertical.png',...
    'descriptivename', data_title,...
    'description', sprintf('<a href="%s">%s</a> %s provided by <a href="http://www.openearth.nl">OpenEarthTools</a> generated: ', creator_url, institution_shortname, data_title, datestr(nowutc, fmt)),...
    'lowestLevel'   ,15,...
    'filledInTime'  ,false)

url_netcdf = strrep(fullfile(url_main_netcdf, path_sub_netcdf), filesep, '/');
% copy surface overlay kml one level higher and add hard urls
kml_surface_overlay = fullfile(path_kml, 'Surface_overlay.kml');
kml_surface_overlay_copy = [fileparts(kml_surface_overlay) '.kml'];
copyfile(kml_surface_overlay,...
    kml_surface_overlay_copy)

strrep_in_files(kml_surface_overlay_copy,...
    '<href>', sprintf('<href>http://%s', path2os(fullfile([kml_server '/kml/'], [path_sub_kml, filesep]), 'h')))

% nc2kml_surface_imageOverlay(...
%     'path_netcdf'   ,'E:\products\nc\rijkswaterstaat\vaklodingen_filled',...
%     'path_kml'      ,'E:\products\kml\rijkswaterstaat\vaklodingen_filled',...
%     'CBtemplateVer' ,'KML_colorbar_template_vertical.png',...
%     'lowestLevel'   ,15,...
%     'filledInTime'  ,true)
% nc_cf_gridset_overview(...
%     'fileName', [fileparts(kml_surface_overlay) '_overview.kml'],...
%     'load_kml', path_kml,...
%     'kmlPathFcn',@(s) strrep(s, path_kml, ['http://' kml_server '/kml/']),...
%     'datestr','YYYY-mm',...
%     'load_nc', path_netcdf,...
%     'urlPathFcn',@(s) path2os(strrep(s, fullfile(path_main, 'nc'), url_main_netcdf),'http'),...
%     'ftpPathFcn',@(s) path2os(strrep(s, fullfile(path_main, 'nc'), url_ftp_main_netcdf),'http'),...
%     'description', sprintf('<a href="%s">%s</a> %s provided by <a href="http://www.openearth.nl">OpenEarthTools</a> generated: ', creator_url, institution_shortname, data_title, datestr(nowutc, fmt)),...
%     'kmlName', [data_title ' overview']);