Permalink
Browse files

fixed access to new web service

  • Loading branch information...
camillol committed Nov 1, 2011
1 parent 2c14f07 commit 4152f49255e439d1e0a33350cc24bbd097a2a489
Showing with 12 additions and 10 deletions.
  1. +11 −6 WebDataSource.pde
  2. +1 −4 cs424p3.pde
View
@@ -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");
@@ -139,7 +139,7 @@ class WebDataSource implements DataSource {
}
}
catch (JSONException e) {
- println ("There was an error parsing the JSONObject.");
+ println (e);
}
}
@@ -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");
@@ -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");
@@ -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()
@@ -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");
View
@@ -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();

0 comments on commit 4152f49

Please sign in to comment.