/* * SPDFUtil.java * * Created on February 2, 2007, 10:54 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package org.autoplot.dods; import org.das2.datum.DatumRange; import org.das2.datum.Units; import java.io.IOException; import java.net.URL; import java.text.ParseException; import java.util.HashMap; import java.util.Map; import org.das2.qds.QDataSet; /** * static methods for helping to use the SPDF dods server. * * @author jbf */ public class SPDFUtil { /** * set up the DodsAdapter based on the metadata returned from the dods server, * interpreting the metadata provided by the SPDF server. */ public static void interpretAttributes( DodsAdapter da ) throws IOException { MetaDataScraper meta= new MetaDataScraper( ); meta.parseURL( new URL( da.getSource().toString()+".html" ) ); Map m= interpretProps( meta.getAttr(da.getVariable()) ); if ( m.containsKey(QDataSet.UNITS) ) { da.setUnits( (Units) m.get(QDataSet.UNITS) ); } if ( m.containsKey(QDataSet.VALID_MIN ) || m.containsKey(QDataSet.VALID_MAX) ) { Double min= (Double) m.get(QDataSet.VALID_MIN ); Double max= (Double) m.get(QDataSet.VALID_MAX ); if ( min==null ) min= Double.NEGATIVE_INFINITY; if ( max==null ) max= Double.POSITIVE_INFINITY; da.setValidRange( min, max ); } StringBuffer constraint= new StringBuffer("?"); constraint.append( da.getVariable() ); int[] ii= meta.getRecDims( da.getVariable() ); for ( int i=0; i