001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2024
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 https://www.gnu.org/licenses/.
027 */
028
029package edu.wisc.ssec.mcidasv.data.adde;
030
031import java.util.ArrayList;
032import java.util.Hashtable;
033import java.util.List;
034
035import ucar.unidata.data.DataChoice;
036import ucar.unidata.data.DataSelection;
037import ucar.unidata.data.DataSourceDescriptor;
038import ucar.unidata.util.TwoFacedObject;
039import ucar.visad.quantities.CommonUnits;
040import visad.Real;
041import visad.RealType;
042import visad.VisADException;
043
044/**
045 * A data source for ADDE point data
046 *
047 * @author Don Murray
048 * @version $Revision$ $Date$
049 */
050
051public class AddePointDataSource extends ucar.unidata.data.point.AddePointDataSource {
052
053    /** list of levels names */
054    private static String[] levelNames = {
055        "SFC", "1000", "925", "850", "700", "500", "400", "300", "250", "200",
056        "150", "100", "70", "50", "30", "20", "10"
057    };
058
059    /** list of level values */
060    private static int[] levelValues = {
061        1001, 1000, 925, 850, 700, 500, 400, 300, 250, 200,
062        150, 100, 70, 50, 30, 20, 10
063    };
064
065    /**
066     * Default constructor.
067     *
068     * @throws VisADException
069     */
070    
071    public AddePointDataSource() throws VisADException {
072        super();
073    }
074
075    /**
076     * Create a new {@code AddePointDataSource} from the parameters
077     * supplied.
078     *
079     * @param descriptor {@code DataSourceDescriptor} for this.
080     * @param source Source URL.
081     * @param properties {@code Hashtable} of properties for the source.
082     *
083     * @throws VisADException  couldn't create the VisAD data
084     */
085    
086    public AddePointDataSource(DataSourceDescriptor descriptor,
087                               String source, Hashtable properties)
088            throws VisADException {
089        super(descriptor, source, properties);
090    }
091
092    /**
093     * Get the list of all levels available from this DataSource
094     *
095     *
096     * @param dataChoice The data choice we are getting levels for
097     * @return  List of all available levels
098     */
099    
100    public List getAllLevels(DataChoice dataChoice, DataSelection dataSelection) {
101        return getLevels();
102    }
103
104    /**
105     * Get the levels property
106     * @return levels;
107     */
108    
109    private List getLevels() {
110        List levels = new ArrayList();
111        try {
112                for (int i = 0; i < levelValues.length; i++) {
113                        levels.add(new TwoFacedObject(levelNames[i],
114                                        new Real(RealType.getRealType("Pressure",
115                                                        CommonUnits.MILLIBAR), levelValues[i],
116                                                        CommonUnits.MILLIBAR)));
117                }
118        } catch (VisADException ve) {}
119        return levels;
120    }
121    
122}
123