// 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");
  }
 // constructor
 public EarthquakeMarker(PointFeature feature) {
   super(feature.getLocation());
   // Add a radius property and then set the properties
   java.util.HashMap<String, Object> properties = feature.getProperties();
   float magnitude = Float.parseFloat(properties.get("magnitude").toString());
   properties.put("radius", 2 * magnitude);
   setProperties(properties);
   this.radius = 1.75f * getMagnitude();
 }
  // A suggested helper method that takes in an earthquake feature and
  // returns a SimplePointMarker for that earthquake
  // Done: Implement this method and call it from setUp, if it helps
  private SimplePointMarker createMarker(PointFeature feature) {
    // finish implementing and use this method, if it helps.
    SimplePointMarker spm = new SimplePointMarker(feature.getLocation());

    Object magnitudeProp = feature.getProperty("magnitude");

    float magnitude = Float.parseFloat(magnitudeProp.toString());

    if (magnitude < 4.0) {
      spm.setColor(color(0, 0, 255));
      spm.setRadius(5);
    } else if (magnitude >= 4.0 && magnitude < 5) {
      spm.setColor(color(255, 255, 0));
      spm.setRadius(10);
    } else {
      spm.setColor(color(255, 0, 0));
      spm.setRadius(15);
    }
    return spm;
  }