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