}
//temporal
DateRange tm = ds.getTimeCoverage();
if (tm != null) {
DateType end = tm.getEnd();
if (end.isPresent()) {
TimeDuration duration = tm.getDuration();
double ndays = -duration.getValueInSeconds()/3600/24;
String reletiveTime = "RELATIVE_START_DATE: "+((int)ndays);
rootElem.addContent( new Element("Keyword", defNS).addContent(reletiveTime));
}
}
// LOOK KLUDGE - these need to be added to the catalog !! see http://gcmd.nasa.gov/Resources/valids/sources.html
Element platform = new Element("Source_Name", defNS);
rootElem.addContent(platform);
platform.addContent( new Element("Short_Name", defNS).addContent("MODELS"));
if (tm != null) {
Element tmElem = new Element("Temporal_Coverage", defNS);
rootElem.addContent(tmElem);
tmElem.addContent(new Element("Start_Date",
defNS).addContent(tm.getStart().toDateString()));
tmElem.addContent(new Element("Stop_Date",
defNS).addContent(tm.getEnd().toDateString()));
}
//geospatial
ThreddsMetadata.GeospatialCoverage geo = ds.getGeospatialCoverage();
if (geo != null) {
Element geoElem = new Element("Spatial_Coverage", defNS);
rootElem.addContent(geoElem);
double eastNormal = LatLonPointImpl.lonNormal(geo.getLonEast());
double westNormal = LatLonPointImpl.lonNormal(geo.getLonWest());
geoElem.addContent(new Element("Southernmost_Latitude",
defNS).addContent(Double.toString(geo.getLatSouth())));
geoElem.addContent(new Element("Northernmost_Latitude",
defNS).addContent(Double.toString(geo.getLatNorth())));
geoElem.addContent(new Element("Westernmost_Longitude",
defNS).addContent(Double.toString(westNormal)));
geoElem.addContent(new Element("Easternmost_Longitude",
defNS).addContent(Double.toString(eastNormal)));
}
/* LOOK
"<Data_Resolution>\n" +
" <Latitude_Resolution>12 Km</Latitude_Resolution>\n" +
" <Longitude_Resolution>12 Km</Longitude_Resolution>\n" +
" <Horizontal_Resolution_Range>10 km - < 50 km or approximately .09 degree - < .5 degree</Horizontal_Resolution_Range>\n" +
" <Temporal_Resolution>6 Hours</Temporal_Resolution>\n" +
" <Temporal_Resolution_Range>Hourly - < Daily</Temporal_Resolution_Range>\n" +
" </Data_Resolution> "
*/
String rights = ds.getDocumentation("rights");
if (rights != null)
rootElem.addContent( new Element("Use_Constraints", defNS).addContent(rights));
// data center
list = ds.getPublishers();
if (list.size() > 0) {
for (int i=0; i<list.size(); i++) {
ThreddsMetadata.Source p = (ThreddsMetadata.Source) list.get(i);
if (p.getNameVocab().getVocabulary().equalsIgnoreCase("DIF")) {
Element dataCenter = new Element("Data_Center", defNS);
rootElem.addContent( dataCenter);
writeDataCenter(p, dataCenter);
break;
}
}
}
String summary = ds.getDocumentation("summary");
if (summary != null) {
String summaryLines = StringUtil.breakTextAtWords( summary,"\n",80);
rootElem.addContent( new Element("Summary", defNS).addContent(summaryLines));
}
URI uri;
String href;
if (ds instanceof InvCatalogRef) { // LOOK !!
InvCatalogRef catref = (InvCatalogRef) ds;
uri = catref.getURI();
href = uri.toString();
int pos = href.lastIndexOf('.');
href = href.substring(0,pos)+".html";
} else {
InvCatalogImpl cat = (InvCatalogImpl) ds.getParentCatalog();
uri = cat.getBaseURI();
String catURL = uri.toString();
int pos = catURL.lastIndexOf('.');
href = catURL.substring(0,pos)+".html";
if (ds.hasAccess())
href = href+"?dataset="+ds.getID();
}
rootElem.addContent( makeRelatedURL("GET DATA", "THREDDS CATALOG", uri.toString()));
rootElem.addContent( makeRelatedURL("GET DATA", "THREDDS DIRECTORY", href));
InvAccess access;
if (null != (access = ds.getAccess(ServiceType.OPENDAP))) {
rootElem.addContent( makeRelatedURL("GET DATA", "OPENDAP DATA", access.getStandardUrlName()));
}
rootElem.addContent(new Element("Metadata_Name", defNS).addContent("CEOS IDN DIF"));
rootElem.addContent(new Element("Metadata_Version", defNS).addContent("9.4"));
DateType today = new DateType(false, new Date());
rootElem.addContent(new Element("DIF_Creation_Date", defNS).addContent(today.toDateString()));
}