Package ucar.unidata.metdata
Class NamedStationTable
java.lang.Object
ucar.unidata.metdata.StationTableImpl
ucar.unidata.metdata.NamedStationTable
- All Implemented Interfaces:
StationTable
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
FieldsModifier and TypeFieldDescriptionstatic final String
Key for bulletin id in propertiesstatic final String
Key for country in propertiesstatic final String
Key for priority propertiesstatic final String
Key for Station number in propertiesstatic final String
Key for priority propertiesstatic final String
Key for state in propertiesFields inherited from class ucar.unidata.metdata.StationTableImpl
byId_, stations
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorNamedStationTable
(String name) Create a new NamedStationTable withname
NamedStationTable
(Element root) Create a NamedStationTable from an XML specification -
Method Summary
Modifier and TypeMethodDescriptionstatic NamedStationTable
createStationTable
(String xml) Creates a station table from an XML file with station information, such as profilerstns.xmlstatic NamedStationTable
createStationTable
(Element root) Creates a station table from an XML file with station information, such as profilerstns.xmlvoid
Create a station table from a Gempak bulletin tablevoid
Create a station table from a csv stringstatic NamedStationTable
createStationTableFromFile
(String filename) Create a station table from a filevoid
Create a station table from a Gempak tablevoid
createStationTableFromKmlFile
(String filename) Create a station table from KMLstatic List
Create a list of NamedStationTables from a set of resourcesGet the Category property.Get the Description property.Get the full name of the table.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.getName()
Get the name of the tablestatic String
getStationXml
(String name, String category, List stations) Get the station xmlgetType()
Get the Type property.boolean
isEmpty()
Is the table empty?static void
Test a particular filemakeMenuItems
(List locations, ObjectListener listener) Make a set of menu items from the list of locationsvoid
setCategory
(String value) Set the Category property.void
setDescription
(String value) Set the Description property.void
Set the Id property.void
Set the name of the station tablevoid
Set the Type property.toString()
Return table name and sizestatic List
xxxxmakeMenuItems
(List stations, ObjectListener listener) Make stations from the root element.
-
Field Details
-
KEY_IDNUMBER
Key for Station number in properties- See Also:
-
KEY_STATE
Key for state in properties- See Also:
-
KEY_COUNTRY
Key for country in properties- See Also:
-
KEY_BULLETIN
Key for bulletin id in properties- See Also:
-
KEY_PRIORITY
Key for priority properties- See Also:
-
KEY_EXTRA
Key for priority properties- See Also:
-
-
Constructor Details
-
NamedStationTable
Create a NamedStationTable from an XML specification- Parameters:
root
- root element for XML
-
NamedStationTable
public NamedStationTable()Default constructor -
NamedStationTable
Create a new NamedStationTable withname
- Parameters:
name
- name of the table
-
-
Method Details
-
setType
Set the Type property.- Parameters:
value
- The new value for Type
-
getType
Get the Type property.- Returns:
- The Type
-
setName
Set the name of the station table- Parameters:
name
- new name
-
getName
Get the name of the table- Returns:
- table name
-
getFullName
Get the full name of the table. This is the category concatenated with the name- Returns:
- table name
-
setCategory
Set the Category property.- Parameters:
value
- The new value for Category
-
getCategory
Get the Category property.- Returns:
- The Category
-
getStationXml
Get the station xml- Parameters:
name
- name of the documentcategory
- the categorystations
- the list of stations- Returns:
- the XML as a string
-
createStationTables
Create a list of NamedStationTables from a set of resources- Parameters:
xrc
- XML resources- Returns:
- List of NamedStationTables
-
createStationTableFromKmlFile
Create a station table from KML- Parameters:
filename
-- Throws:
Exception
- problem reading th estation
-
createStationTableFromCsv
Create a station table from a csv string- Parameters:
csv
- The actual csv text- Throws:
Exception
- problem creating table from file
-
createStationTableFromGempak
Create a station table from a Gempak table- Parameters:
tbl
- The actual Gempak table as text- Throws:
Exception
- problem creating table from file
-
createStationTableFromBulletin
Create a station table from a Gempak bulletin table- Parameters:
tbl
- The actual Gempak bulletin table as text- Throws:
Exception
- problem creating table from file
-
createStationTableFromFile
Create a station table from a file- Parameters:
filename
- filename- Returns:
- NamedStationTable
- Throws:
Exception
- problem creating table from file
-
createStationTable
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
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
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 classStationTableImpl
- Returns:
- the station map
-
xxxxmakeMenuItems
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 invalid input: '<' 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
- stationslistener
- listener for changes- Returns:
- List of menus
-
makeMenuItems
Make a set of menu items from the list of locations- Parameters:
locations
- list of locationslistener
- 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
Return table name and size -
setId
Set the Id property.- Parameters:
value
- The new value for Id
-
getId
Get the Id property.- Returns:
- The Id
-
setDescription
Set the Description property.- Parameters:
value
- The new value for Description
-
getDescription
Get the Description property.- Returns:
- The Description
-
main
Test a particular file- Parameters:
args
- test the file- Throws:
Exception
- problem reading the file
-