ucar.unidata.metdata
Class NamedStationTable

java.lang.Object
  extended by ucar.unidata.metdata.StationTableImpl
      extended by ucar.unidata.metdata.NamedStationTable
All Implemented Interfaces:
StationTable

public class NamedStationTable
extends StationTableImpl

Station table that holds a set of NamedStations

Version:
$Revision: 1.46 $ $Date: 2007/06/08 21:10:35 $
Author:
IDV Development Team

Field Summary
 
Fields inherited from class ucar.unidata.metdata.StationTableImpl
byId_, stations
 
Constructor Summary
NamedStationTable()
          Default constructor
NamedStationTable(Element root)
          Create a NamedStationTable from an XML specification
NamedStationTable(String name)
          Create a new NamedStationTable with name
 
Method Summary
static NamedStationTable createStationTable(Element root)
          Creates a station table from an XML file with station information, such as profilerstns.xml
static NamedStationTable createStationTable(String xml)
          Creates a station table from an XML file with station information, such as profilerstns.xml
 void createStationTableFromCsv(String csv)
          Create a station table from a csv string
static NamedStationTable createStationTableFromFile(String filename)
          Create a station table from a file
 void createStationTableFromGempak(String tbl)
          Create a station table from a Gempak table
 void createStationTableFromKmlFile(String filename)
           
static List createStationTables(XmlResourceCollection xrc)
          Create a list of NamedStationTables from a set of resources
 String getCategory()
          Get the Category property.
 String getDescription()
          Get the Description property.
 String getFullName()
          Get the full name of the table.
 String getId()
          Get the Id property.
protected  Map getMap()
          Override the base class method to lazily instantiate the stations from the XML root element if we have not done so already.
 String getName()
          Get the name of the table
static String getStationXml(String name, String category, List stations)
          Get the station xml
 String getType()
          Get the Type property.
 boolean isEmpty()
          Is the table empty?
static void main(String[] args)
          Test a particular file
static List makeMenuItems(List locations, ObjectListener listener)
          Make a set of menu items from the list of locations
 void setCategory(String value)
          Set the Category property.
 void setDescription(String value)
          Set the Description property.
 void setId(String value)
          Set the Id property.
 void setName(String name)
          Set the name of the station table
 void setType(String value)
          Set the Type property.
 String toString()
          Return table name and size
static List xxxxmakeMenuItems(List stations, ObjectListener listener)
          Make stations from the root element.
 
Methods inherited from class ucar.unidata.metdata.StationTableImpl
add, add, get, keySet, remove, remove, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedStationTable

public NamedStationTable(Element root)
Create a NamedStationTable from an XML specification

Parameters:
root - root element for XML

NamedStationTable

public NamedStationTable()
Default constructor


NamedStationTable

public NamedStationTable(String name)
Create a new NamedStationTable with name

Parameters:
name - name of the table
Method Detail

setType

public void setType(String value)
Set the Type property.

Parameters:
value - The new value for Type

getType

public String getType()
Get the Type property.

Returns:
The Type

setName

public void setName(String name)
Set the name of the station table

Parameters:
name - new name

getName

public String getName()
Get the name of the table

Returns:
table name

getFullName

public String getFullName()
Get the full name of the table. This is the category concatenated with the name

Returns:
table name

setCategory

public void setCategory(String value)
Set the Category property.

Parameters:
value - The new value for Category

getCategory

public String getCategory()
Get the Category property.

Returns:
The Category

getStationXml

public static String getStationXml(String name,
                                   String category,
                                   List stations)
Get the station xml

Parameters:
name - name of the document
category - the category
stations - the list of stations
Returns:
the XML as a string

createStationTables

public static List createStationTables(XmlResourceCollection xrc)
Create a list of NamedStationTables from a set of resources

Parameters:
xrc - XML resources
Returns:
List of NamedStationTables

createStationTableFromKmlFile

public void createStationTableFromKmlFile(String filename)
                                   throws Exception
Throws:
Exception

createStationTableFromCsv

public void createStationTableFromCsv(String csv)
                               throws Exception
Create a station table from a csv string

Parameters:
csv - The actual csv text
Throws:
Exception - problem creating table from file

createStationTableFromGempak

public void createStationTableFromGempak(String tbl)
                                  throws Exception
Create a station table from a Gempak table

Parameters:
tbl - The actual Gempak table as text
Throws:
Exception - problem creating table from file

createStationTableFromFile

public static NamedStationTable createStationTableFromFile(String filename)
                                                    throws Exception
Create a station table from a file

Parameters:
filename - filename
Returns:
NamedStationTable
Throws:
Exception - problem creating table from file

createStationTable

public static NamedStationTable createStationTable(String xml)
                                            throws Exception
Creates a station table from an XML file with station information, such as profilerstns.xml

Parameters:
xml - xml
Returns:
a NamedStationTable filled with data if possible
Throws:
Exception - problem creating table

createStationTable

public static NamedStationTable createStationTable(Element root)
Creates a station table from an XML file with station information, such as profilerstns.xml

Parameters:
root - root XML element defining table
Returns:
a NamedStationTable filled with data if possible

getMap

protected Map getMap()
Override the base class method to lazily instantiate the stations from the XML root element if we have not done so already.

Overrides:
getMap in class StationTableImpl
Returns:
the station map

xxxxmakeMenuItems

public static List xxxxmakeMenuItems(List stations,
                                     ObjectListener listener)
Make stations from the root element. if (id == null) { id = ""+childIdx; //stationName; } double lat = Misc.decodeLatLon(XmlUtil.getAttribute(node, ATTR_LAT)); double lon = Misc.decodeLatLon(XmlUtil.getAttribute(node, ATTR_LON)); String elev = XmlUtil.getAttribute(node, ATTR_ELEV, (String) null); double alt = ((elev == null) ? 0.0 : Misc.decodeLatLon(elev)); try { NamedStationImpl station = new NamedStationImpl(id, stationName, lat, lon, alt, elevUnit); NamedNodeMap attrs = node.getAttributes(); int numAttrs = attrs.getLength(); for (int i = 0; i < numAttrs; i++) { Attr attr = (Attr) attrs.item(i); String attrName = attr.getNodeName(); if(attrName.equals(ATTR_ELEV)) { station.addProperty(attrName, new Real(RealType.Altitude, alt, elevUnit)); } else { station.addProperty(attrName, attr.getNodeValue()); } } this.add(station, true); } catch (Exception excp) { System.out.println("bad station id=" + id + "name = " + stationName + "lat = " + lat + "lon = " + lon + "alt = " + alt); } } } catch (Exception exc) { exc.printStackTrace(); } } Make menu items from the list of stations

Parameters:
stations - stations
listener - listener for changes
Returns:
List of menus

makeMenuItems

public static List makeMenuItems(List locations,
                                 ObjectListener listener)
Make a set of menu items from the list of locations

Parameters:
locations - list of locations
listener - listener on the objects
Returns:
a List of menu items

isEmpty

public boolean isEmpty()
Is the table empty?

Returns:
true if no stations are in the table

toString

public String toString()
Return table name and size

Overrides:
toString in class Object
Returns:
string representing name and size

setId

public void setId(String value)
Set the Id property.

Parameters:
value - The new value for Id

getId

public String getId()
Get the Id property.

Returns:
The Id

setDescription

public void setDescription(String value)
Set the Description property.

Parameters:
value - The new value for Description

getDescription

public String getDescription()
Get the Description property.

Returns:
The Description

main

public static void main(String[] args)
                 throws Exception
Test a particular file

Parameters:
args - _more_
Throws:
Exception - _more_