// helper method to test whether a given earthquake is in a given country
  // This will also add the country property to the properties of the earthquake feature if
  // it's in one of the countries.
  // You should not have to modify this code
  private boolean isInCountry(PointFeature earthquake, Marker country) {
    // getting location of feature
    Location checkLoc = earthquake.getLocation();

    // some countries represented it as MultiMarker
    // looping over SimplePolygonMarkers which make them up to use isInsideByLoc
    if (country.getClass() == MultiMarker.class) {

      // looping over markers making up MultiMarker
      for (Marker marker : ((MultiMarker) country).getMarkers()) {

        // checking if inside
        if (((AbstractShapeMarker) marker).isInsideByLocation(checkLoc)) {
          earthquake.addProperty("country", country.getProperty("name"));

          // return if is inside one
          return true;
        }
      }
    }

    // check if inside country represented by SimplePolygonMarker
    else if (((AbstractShapeMarker) country).isInsideByLocation(checkLoc)) {
      earthquake.addProperty("country", country.getProperty("name"));

      return true;
    }
    return false;
  }
Example #2
0
  private void isOnEarthLand(PointFeature crater) {
    for (Marker country : countryMarkers) {
      Location checkLoc = crater.getLocation();

      // some countries represented it as MultiMarker
      // looping over SimplePolygonMarkers which make them up to use isInsideByLoc
      if (country.getClass() == MultiMarker.class) {
        // looping over markers making up MultiMarker
        for (Marker marker : ((MultiMarker) country).getMarkers()) {
          // checking if inside
          if (((AbstractShapeMarker) marker).isInsideByLocation(checkLoc)) {
            crater.addProperty("isOnEarthLand", "true");
            return;
          }
        }
      }
      // check if inside country represented by SimplePolygonMarker
      else if (((AbstractShapeMarker) country).isInsideByLocation(checkLoc)) {
        crater.addProperty("isOnEarthLand", "true");
        return;
      }
    }
    // not inside any country
    crater.addProperty("isOnEarthLand", "false");
  }