Repository navigation
Expand file tree
/
Copy pathSeaLevel.java
More file actions
162 lines (115 loc) · 3.04 KB
/
Copy pathSeaLevel.java
File metadata and controls
162 lines (115 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import org.json.*;
import org.json.simple.JSONValue;
public class SeaLevel {
private static String localFileString = "data/SeaLevelData";
// Comes as a zip file and only records data from part way through 1993 to part way through 2015...
// Need a new data source
private static String fileURL = "http://www.cmar.csiro.au/sealevel/GMSL_SG_2011_up.html";
public static double getAvgRateOfChange (String yearOne, String yearTwo)
{
return 0.0;
}
public static double getAvgRateOfChange (int yearOne, int yearTwo)
{
return 0.0;
}
public static double getAvgRateOfChangeOfRateOfChange (String yearOne, String yearTwo)
{
return 0.0;
}
public static double getAvgRateOfChangeOfRateOfChange (int yearOne, int yearTwo)
{
return 0.0;
}
public static double getAvgRateOfChangeOfRateOfChange (double rateOfChange, String yearOne, String yearTwo)
{
return 0.0;
}
public static double getAvgRateOfChangeOfRateOfChange (double rateOfChange, int yearOne, int yearTwo)
{
return 0.0;
}
public static String getLatestDate ()
{
return "";
}
// Load the file
public static boolean isLoaded () throws MalformedURLException, IOException
{
File seaLevel = null;
Scanner scanSeaLevel = null;
try
{
seaLevel = new File(localFileString);
scanSeaLevel = new Scanner(seaLevel);
}
catch (FileNotFoundException e)
{
InputStream in = null;
try
{
URL url = new URL(fileURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
in = connection.getInputStream();
Files.copy(in, Paths.get(localFileString));
}
finally
{
try
{
seaLevel = new File(localFileString);
scanSeaLevel = new Scanner(seaLevel);
}
catch (FileNotFoundException f)
{
f.printStackTrace();
System.out.println("Bad Request. Check connection and data source.");
return false;
}
}
}
scanSeaLevel.close();
return true;
}
public static double getAvgGMSLVariation (String yearDate)
{
return 0.0;
}
public static double getAvgGMSLVariation (int yearDate)
{
return 0.0;
}
public static double getFutureGSMLVariation (String yearDate, double rateOfChange)
{
return 0.0;
}
public static double getFutureGSMLVariation (int yearDate, double rateOfChange)
{
return 0.0;
}
public static double getFutureGSMLVariation (String yearDate, String yearOne, String yearTwo)
{
return 0.0;
}
public static double getFutureGSMLVariation (int yearDate, int yearOne, int yearTwo)
{
return 0.0;
}
public static double getLatestGSMLVariation ()
{
return 0.0;
}
}