Skip to content

Commit

Permalink
fixed access to new web service
Browse files Browse the repository at this point in the history
  • Loading branch information
camillol committed Nov 1, 2011
1 parent 2c14f07 commit 4152f49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 11 additions & 6 deletions WebDataSource.pde
Expand Up @@ -116,7 +116,7 @@ class WebDataSource implements DataSource {
maxCountSightings = 0;
totalCountSightings = 0;

String request = baseURL + "/sightingCounts/" + activeFilter.toString();
String request = baseURL + "/sighting/counts/" + activeFilter.toString().replaceAll(" ", "%20");
try {
JSONObject result = new JSONObject(join(loadStrings(request), ""));
JSONArray cities = result.getJSONArray("cities");
Expand All @@ -139,7 +139,7 @@ class WebDataSource implements DataSource {
}
}
catch (JSONException e) {
println ("There was an error parsing the JSONObject.");
println (e);
}
}

Expand Down Expand Up @@ -167,7 +167,7 @@ class WebDataSource implements DataSource {
{
ArrayList<Sighting> sightings = new ArrayList<Sighting>();

String request = baseURL + "/sightingsForCity/" + p.id + "/" + activeFilter.toString();
String request = baseURL + "/sighting/forCity/" + p.id + "/" + activeFilter.toString();
try {
JSONObject result = new JSONObject(join(loadStrings(request), ""));
JSONArray sa = result.getJSONArray("sightings");
Expand Down Expand Up @@ -203,7 +203,7 @@ class WebDataSource implements DataSource {
{
List<Bucket> buckets = new ArrayList();

String request = baseURL + "/sightingCountsByCategory/" + categoryName;
String request = baseURL + "/sighting/countsByCategory/" + categoryName ;
try {
JSONObject result = new JSONObject(join(loadStrings(request), ""));
JSONArray ba = result.getJSONArray("buckets");
Expand Down Expand Up @@ -237,7 +237,12 @@ class WebDataSource implements DataSource {

List<Bucket> sightingCountsBySeason()
{
return sightingCountsByCategoryQuery("season");
String seasonNames[] = {"Winter", "Spring", "Summer", "Fall"};
List<Bucket> buckets = sightingCountsByCategoryQuery("season");
for (Bucket b : buckets) {
b.label = seasonNames[int(b.label)];
}
return buckets;
}

List<Bucket> sightingCountsByMonth()
Expand Down Expand Up @@ -274,7 +279,7 @@ class WebDataSource implements DataSource {
{
List<SightingLite> sightings = new ArrayList(limit);

String request = baseURL + "/sightingsByTime/" + limit + "/" + offset;
String request = baseURL + "/sighting/byTime/" + limit + "/" + offset;
try {
JSONObject result = new JSONObject(join(loadStrings(request), ""));
JSONArray sa = result.getJSONArray("sightings");
Expand Down
5 changes: 1 addition & 4 deletions cs424p3.pde
Expand Up @@ -93,12 +93,9 @@ void setup()

smooth();

println(sketchPath);
println(dataPath(""));

/* load data */
if (sketchPath == null) // applet
data = new WebDataSource(dataPath("jsontest"));
data = new WebDataSource("http://young-mountain-2805.heroku.com/"); //dataPath("jsontest")
else // application
data = new SQLiteDataSource();

Expand Down

0 comments on commit 4152f49

Please sign in to comment.