001    /*
002     * This file is part of McIDAS-V
003     *
004     * Copyright 2007-2013
005     * Space Science and Engineering Center (SSEC)
006     * University of Wisconsin - Madison
007     * 1225 W. Dayton Street, Madison, WI 53706, USA
008     * https://www.ssec.wisc.edu/mcidas
009     * 
010     * All Rights Reserved
011     * 
012     * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013     * some McIDAS-V source code is based on IDV and VisAD source code.  
014     * 
015     * McIDAS-V is free software; you can redistribute it and/or modify
016     * it under the terms of the GNU Lesser Public License as published by
017     * the Free Software Foundation; either version 3 of the License, or
018     * (at your option) any later version.
019     * 
020     * McIDAS-V is distributed in the hope that it will be useful,
021     * but WITHOUT ANY WARRANTY; without even the implied warranty of
022     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023     * GNU Lesser Public License for more details.
024     * 
025     * You should have received a copy of the GNU Lesser Public License
026     * along with this program.  If not, see http://www.gnu.org/licenses.
027     */
028    
029    package edu.wisc.ssec.mcidasv.data.adde;
030    
031    
032    import java.util.ArrayList;
033    import java.util.Hashtable;
034    import java.util.List;
035    
036    import ucar.unidata.data.AddeUtil;
037    import ucar.unidata.data.DataChoice;
038    import ucar.unidata.data.DataSelection;
039    import ucar.unidata.data.DataSourceDescriptor;
040    import ucar.unidata.data.point.PointObFactory;
041    import ucar.unidata.util.LogUtil;
042    import ucar.unidata.util.Misc;
043    import ucar.unidata.util.Trace;
044    import ucar.unidata.util.TwoFacedObject;
045    
046    import visad.*;
047    import visad.data.mcidas.PointDataAdapter;
048    import ucar.unidata.geoloc.LatLonPoint;
049    import ucar.unidata.geoloc.LatLonRect;
050    import edu.wisc.ssec.mcidas.adde.AddePointURL;
051    import ucar.visad.quantities.CommonUnits;
052    
053    
054    /**
055     * A data source for ADDE point data
056     *
057     * @author Don Murray
058     * @version $Revision$ $Date$
059     */
060    public class AddePointDataSource extends ucar.unidata.data.point.AddePointDataSource {
061    
062        /** list of levels names */
063        private static String[] levelNames = {
064            "SFC", "1000", "925", "850", "700", "500", "400", "300", "250", "200",
065            "150", "100", "70", "50", "30", "20", "10"
066        };
067    
068        /** list of level values */
069        private static int[] levelValues = {
070            1001, 1000, 925, 850, 700, 500, 400, 300, 250, 200,
071            150, 100, 70, 50, 30, 20, 10
072        };
073    
074        /**
075         * Default constructor.
076         *
077         * @throws VisADException
078         */
079        public AddePointDataSource() throws VisADException {
080            super();
081        }
082    
083        /**
084         * Create a new <code>AddePointDataSource</code> from the parameters
085         * supplied.
086         *
087         * @param descriptor  <code>DataSourceDescriptor</code> for this.
088         * @param source      Source URL
089         * @param properties  <code>Hashtable</code> of properties for the source.
090         *
091         * @throws VisADException  couldn't create the VisAD data
092         */
093        public AddePointDataSource(DataSourceDescriptor descriptor,
094                                   String source, Hashtable properties)
095                throws VisADException {
096            super(descriptor, source, properties);
097        }
098    
099        /**
100         * Get the list of all levels available from this DataSource
101         *
102         *
103         * @param dataChoice The data choice we are getting levels for
104         * @return  List of all available levels
105         */
106        public List getAllLevels(DataChoice dataChoice, DataSelection dataSelection) {
107            return getLevels();
108        }
109    
110        /**
111         * Get the levels property
112         * @return levels;
113         */
114        private List getLevels() {
115            List levels = new ArrayList();
116            try {
117                    for (int i = 0; i < levelValues.length; i++) {
118                            levels.add(new TwoFacedObject(levelNames[i],
119                                            new Real(RealType.getRealType("Pressure",
120                                                            CommonUnits.MILLIBAR), levelValues[i],
121                                                            CommonUnits.MILLIBAR)));
122                    }
123            } catch (VisADException ve) {}
124            return levels;
125        }
126        
127    }
128