@@ -4,6 +4,7 @@ |
import java.util.Iterator; |
import javax.xml.soap.MessageFactory; |
import javax.xml.soap.MimeHeaders; |
+import javax.xml.soap.Name; |
import javax.xml.soap.SOAPBody; |
import javax.xml.soap.SOAPBodyElement; |
import javax.xml.soap.SOAPConnection; |
@@ -14,7 +15,7 @@ |
import javax.xml.soap.SOAPPart; |
|
/** |
- * Last Updated: 10-July-2014 |
+ * Last Updated: 11-July-2014 |
* @author Tyler Wible |
* @since 7-July-2014 |
* For more information on all of CDWR's water services, go to: |
@@ -39,7 +40,7 @@ |
|
// Send SOAP Message to SOAP Server |
SOAPMessage dataMessage = GetSMSProvisionalData(stationID, "DISCHRG", beginDate, endDate, dataType); |
- SOAPMessage dataResponse = soapConnection.call(dataMessage, SOAPClient.waterSMSURI); |
+ SOAPMessage dataResponse = soapConnection.call(dataMessage, waterSMSURI); |
System.out.print("Station Data:"); |
dataResponse.writeTo(System.out); |
|
@@ -237,67 +238,63 @@ |
|
// Send SOAP Message to SOAP Server |
SOAPMessage dataMessage = GetSMSCurrentRatingTable(stationID); |
- SOAPMessage dataResponse = soapConnection.call(dataMessage, SOAPClient.waterSMSURI); |
+ SOAPMessage dataResponse = soapConnection.call(dataMessage, waterSMSURI); |
System.out.print("Rating Curve Data:"); |
dataResponse.writeTo(System.out); |
- |
+ //System.out.println(""); |
+ |
SOAPBody replyBody = dataResponse.getSOAPBody(); |
Iterator<?> iter1 = replyBody.getChildElements(); |
ArrayList<String> stationData = new ArrayList<String>(); |
- while (iter1.hasNext()) { |
- //Open <GetSMSTransmittingStationsResponse> |
+ while(iter1.hasNext()){ |
+ //Open <GetSMSCurrentRatingTableResponse > |
SOAPBodyElement bodyElement = (SOAPBodyElement)iter1.next(); |
+ //System.out.println(bodyElement.getValue()); |
Iterator<?> iter2 = bodyElement.getChildElements(); |
- while (iter2.hasNext()) { |
- //Open <GetSMSTransmittingStationsResult> |
+ while(iter2.hasNext()){ |
+ //Open <GetSMSCurrentRatingTableResult> |
SOAPElement child2 = (SOAPElement)iter2.next(); |
+ //System.out.println(child2.getValue()); |
Iterator<?> iter3 = child2.getChildElements(); |
- while (iter3.hasNext()) { |
- //Open <Station> |
+ while(iter3.hasNext()){ |
+ //Open <tableName> |
SOAPElement child3 = (SOAPElement)iter3.next(); |
- Iterator<?> iter4 = child3.getChildElements(); |
-// String currentStationData = ""; |
-// for(int i=0; i<7; i++){//Hopefully ever station has 7 attributes (div, wd, abbrev, variable, transDateTime, resultCount, amount) |
-// SOAPElement child4 = (SOAPElement)iter4.next(); |
-// if(i == 0){ |
-// currentStationData = child4.getValue(); |
-// }else{ |
-// currentStationData = currentStationData + "\t" + child4.getValue(); |
-// } |
-// } |
-// stationData.add(currentStationData); |
-// while (iter4.hasNext()) { |
-// SOAPElement child4 = (SOAPElement)iter4.next(); |
-// String content = child4.getValue(); |
-// System.out.println(content); |
-// finish this part |
-// } |
+ //System.out.println(child3.getValue()); |
+ //Open <tablePoints> |
+ SOAPElement child3b = (SOAPElement)iter3.next(); |
+ //System.out.println(child3b.getValue()); |
+ Iterator<?> iter4 = child3b.getChildElements(); |
+ while(iter4.hasNext()){ |
+ //Open <RatingTablePoints> |
+ SOAPElement child4 = (SOAPElement)iter4.next(); |
+ //System.out.println(child4.getValue()); |
+ Iterator<?> iter5 = child4.getChildElements(); |
+ //Hopefully RatingTablePoint only has 2 attributes (x, y) |
+ SOAPElement child5x = (SOAPElement)iter5.next(); |
+ SOAPElement child5y = (SOAPElement)iter5.next(); |
+ //System.out.println(child5x.getValue()); |
+ //System.out.println(child5y.getValue()); |
+ stationData.add(child5y.getValue() + "\t" + child5x.getValue());//the discharge value followed by the stage value |
+ } |
} |
} |
} |
soapConnection.close(); |
|
//Reformat data |
- String[][] stringArray = new String[stationData.size()][2]; |
+ double[][] stringArray = new double[stationData.size()][2]; |
for(int i=0; i<stationData.size(); i++){ |
String[] currentStationData = stationData.get(i).split("\t"); |
- //Pull out only the data needed to pass between sub-functions |
-// stringArray[i][0] = reformatDate(currentStationData[4], dataType);//date |
- stringArray[i][1] = currentStationData[5];//value |
+ //currentStationData[0] = discharge |
+ //currentStationData[1] = stage |
+ stringArray[i][0] = Double.parseDouble(currentStationData[0]); |
+ stringArray[i][1] = Double.parseDouble(currentStationData[1]); |
} |
|
//Add header to stationData and shift all other data in the list down one index (+1) |
-// stationData.add(0, "div\twd\tStationNameAbbrev\tvariable\tDateTime\tvalue\tNumberOfTransmissionsAggregatedTo" + dataType + "Data"); |
+ stationData.add(0, "x\ty"); |
|
- //Save analysis results |
- String start = "-1"; |
- String end = "-1"; |
- if(stringArray.length > 0){ |
- start = stringArray[0][0]; |
- end = stringArray[stringArray.length - 1][0]; |
- } |
- |
- Object[] returnArray = {stationData, stringArray, start, end}; |
+ Object[] returnArray = {stationData, stringArray}; |
return returnArray; |
} |
/** |
@@ -15,25 +15,19 @@ |
import org.jfree.chart.plot.XYPlot; |
|
/** |
-* Last Updated: 1-July-2014 |
+* Last Updated: 11-July-2014 |
* @author Tyler Wible |
* @since 24-June-2014 |
*/ |
public class guiStageDischarge_Model{ |
String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/CSIP/data/CFA/Timeseries"; |
- String organizationName = "USGS"; |
- String stationID = "06752260";//"06747500";// |
- String stationName = "CACHE LA POUDRE RIVER AT FORT COLLINS, CO"; |
+ String database = "USGS";//"CDWR";//"STORET";//"UserData";// |
+ String stationID = "06752260";//"CLAGRECO";//"000028";// |
+ String stationName = "CACHE LA POUDRE RIVER AT FORT COLLINS, CO";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";// |
|
//Outputs |
String dataSource = "?"; |
- String ratingWarning = "The stage-discharge rating provided in this file should be" + |
- " considered provisional and subject to change until published by USGS. Stage-discharge" + |
- " ratings change over time as the channel features that control" + |
- " the relation between stage and discharge vary. Users are" + |
- " cautioned to consider carefully the applicability of this" + |
- " rating before using it for decisions that concern personal or" + |
- " public safety or operational consequences."; |
+ String ratingWarning = "?"; |
|
//Gets |
public String getStageDischargeGraph() { |
@@ -53,8 +47,8 @@ |
public void setMainFolder(String mainFolder) { |
this.mainFolder = mainFolder; |
} |
- public void setOrganizationName(String organizationName) { |
- this.organizationName = organizationName; |
+ public void setDatabase(String database) { |
+ this.database = database; |
} |
public void setStationName(String stationName) { |
this.stationName = stationName; |
@@ -134,15 +128,15 @@ |
writer.close(); |
System.out.println("Text File located at:\t" + path); |
} |
- public void run() throws IOException{ |
+ public void run() throws IOException, Exception{ |
//Get stage-discharge data |
Data data = new Data(); |
- double[][] stageDischargeData = data.extractStageDischarge(mainFolder, organizationName, stationID); |
+ double[][] stageDischargeData = data.extractStageDischarge(database, stationID); |
|
//Check if any rating curve data exists |
if(stageDischargeData.length == 0){ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
- errorMessage.add("There is no available stage-discharge/rating curve data in the USGS NWIS database for station '" + stationID + "'."); |
+ errorMessage.add("There is no available stage-discharge/rating curve data in the " + database + "database for station '" + stationID + "'."); |
writeError(errorMessage); |
} |
|
@@ -153,12 +147,40 @@ |
Date currentDate = new Date(); |
SimpleDateFormat desiredDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
String today = desiredDateFormat.format(currentDate); |
- this.dataSource = "Stage-Discharge Rating Curve data courtesy of the U.S. Geological Survey, National Water Information System: Web Interface. http://waterdata.usgs.gov/nwis, accessed: " + today; |
+ if(database.equalsIgnoreCase("USGS")){ |
+ this.dataSource = "Stage-Discharge Rating Curve data courtesy of the U.S. Geological Survey, National Water Information System: Web Interface. http://waterdata.usgs.gov/nwis, accessed: " + today; |
+ this.ratingWarning = "The stage-discharge rating provided in this file should be" + |
+ " considered provisional and subject to change until published by USGS. Stage-discharge" + |
+ " ratings change over time as the channel features that control" + |
+ " the relation between stage and discharge vary. Users are" + |
+ " cautioned to consider carefully the applicability of this" + |
+ " rating before using it for decisions that concern personal or" + |
+ " public safety or operational consequences."; |
+ }else if(database.equalsIgnoreCase("CDWR")){ |
+ this.dataSource = "Stage-Discharge Rating Curve data courtesy of the Colorado Division of Water Resources, CDWR. http://www.dwr.state.co.us accessed: " + today; |
+ this.ratingWarning = "All data presented on the Colorado Division of Water Resources" |
+ + " ColoradoWaterSMS web service are provisional and subject to revision. These" |
+ + " data include water levels in lakes and reservoirs, and in streams, rivers," |
+ + " and other water courses; computed stream discharges; and various weather parameters" |
+ + " (temperature, precipitation, etc.). Most data relayed by satellite or other" |
+ + " telemetry have received little or no review prior to being exposed by this web" |
+ + " service. State of Colorado Hydrographic Program Staff visit satellite monitoring" |
+ + " gaging stations on a frequent basis to maintain equipment and ensure correct" |
+ + " operation. They also perform discharge measurements for purposes of calibrating" |
+ + " the stage-discharge relationship at a gage, as well as take note of physical" |
+ + " factors present at the gage which may be affecting the stage-discharge relationship." |
+ + " Nevertheless, inaccuracies in the data may occur because of instrument malfunctions" |
+ + " or physical changes at the measurement site. Subsequent review may result in" |
+ + " significant revisions to the data. Data users are cautioned to consider carefully" |
+ + " the provisional nature of the information before using it for decisions that" |
+ + " concern personal or public safety or the conduct of business that involves" |
+ + " substantial monetary or operational consequences."; |
+ } |
|
- //Save histogram data for JHighCharts |
+ //Save stage/discharge data for JHighCharts |
writeOutput(stageDischargeData); |
} |
- public static void main(String[] args) throws IOException{ |
+ public static void main(String[] args) throws IOException, Exception{ |
guiStageDischarge_Model model = new guiStageDischarge_Model(); |
|
model.run(); |