/**
  * @param url full URL request
  * @return the list of POI, of null if technical issue.
  */
 public ArrayList<POI> getThem(String url) {
   Log.d(BonusPackHelper.LOG_TAG, "NominatimPOIProvider:get:" + url);
   String jString = BonusPackHelper.requestStringFromUrl(url);
   if (jString == null) {
     Log.e(BonusPackHelper.LOG_TAG, "NominatimPOIProvider: request failed.");
     return null;
   }
   try {
     JSONArray jPlaceIds = new JSONArray(jString);
     int n = jPlaceIds.length();
     ArrayList<POI> pois = new ArrayList<POI>(n);
     Bitmap thumbnail = null;
     for (int i = 0; i < n; i++) {
       JSONObject jPlace = jPlaceIds.getJSONObject(i);
       POI poi = new POI(POI.POI_SERVICE_NOMINATIM);
       poi.mId = jPlace.optLong("osm_id");
       poi.mLocation = new GeoPoint(jPlace.getDouble("lat"), jPlace.getDouble("lon"));
       poi.mCategory = jPlace.optString("class");
       poi.mType = jPlace.getString("type");
       poi.mDescription = jPlace.optString("display_name");
       poi.mThumbnailPath = jPlace.optString("icon", null);
       if (i == 0 && poi.mThumbnailPath != null) {
         // first POI, and we have a thumbnail: load it
         thumbnail = BonusPackHelper.loadBitmap(poi.mThumbnailPath);
       }
       poi.mThumbnail = thumbnail;
       pois.add(poi);
     }
     return pois;
   } catch (JSONException e) {
     e.printStackTrace();
     return null;
   }
 }
Esempio n. 2
0
  public void testGetBearingTo() {

    // assertEquals(195, test_user.getBearingTo(test_wp), 5);
    test_wp.setLocation(39.949120, -76.735165, 0.0); // Kinsley
    test_user.setLocation(39.949778, -76.734095, 0.0); // Parking lot outside kinsley

    assertEquals(240.0, test_user.getBearingTo(test_wp), 15.0);

    test_user.setLocation(39.944201, -76.733221, 0.0);
    assertEquals(345.0, test_user.getBearingTo(test_wp), 15.0);
  }