Ejemplo n.º 1
0
  public void setup() {
    size(900, 700, OPENGL);
    map = new UnfoldingMap(this, new Google.GoogleMapProvider());
    MapUtils.createDefaultEventDispatcher(this, map);

    map.setScaleRange(5, 50000);

    //		map.zoomAndPanTo(14, new Location(32.881, -117.238));

    MapUtils.createDefaultEventDispatcher(this, map);

    List<Feature> countries = GeoJSONReader.loadData(this, countryFile);
    countryMarkers = MapUtils.createSimpleMarkers(countries);

    List<Feature> craters = GeoJSONReader.loadData(this, craterFile);
    craterMarkers = new ArrayList<Marker>();

    for (Feature crater : craters) {
      isOnEarthLand((PointFeature) crater);
      craterMarkers.add(new CraterMarker(crater));
    }
    map.addMarkers(craterMarkers);

    // run in setup to hide craters that are lower than initial value of requestedCraterSize
    cratersToShow();
  } // End Setup
  public void setup() {
    // (1) Initializing canvas and map tiles
    size(900, 700, OPENGL);
    if (offline) {
      map = new UnfoldingMap(this, 200, 50, 650, 600, new MBTilesMapProvider(mbTilesString));
      earthquakesURL = "2.5_week.atom"; // The same feed, but saved August 7, 2015
    } else {
      map = new UnfoldingMap(this, 200, 50, 650, 600, new Google.GoogleMapProvider());
      // IF YOU WANT TO TEST WITH A LOCAL FILE, uncomment the next line
      // earthquakesURL = "2.5_week.atom";
    }
    MapUtils.createDefaultEventDispatcher(this, map);

    // FOR TESTING: Set earthquakesURL to be one of the testing files by uncommenting
    // one of the lines below.  This will work whether you are online or offline
    // earthquakesURL = "test1.atom";
    // earthquakesURL = "test2.atom";

    // Uncomment this line to take the quiz
    earthquakesURL = "quiz2.atom";

    // (2) Reading in earthquake data and geometric properties
    //     STEP 1: load country features and markers
    List<Feature> countries = GeoJSONReader.loadData(this, countryFile);
    countryMarkers = MapUtils.createSimpleMarkers(countries);

    //     STEP 2: read in city data
    List<Feature> cities = GeoJSONReader.loadData(this, cityFile);
    cityMarkers = new ArrayList<Marker>();
    for (Feature city : cities) {
      cityMarkers.add(new CityMarker(city));
    }

    //     STEP 3: read in earthquake RSS feed
    List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL);
    quakeMarkers = new ArrayList<Marker>();

    for (PointFeature feature : earthquakes) {
      // check if LandQuake
      if (isLand(feature)) {
        quakeMarkers.add(new LandQuakeMarker(feature));
      }
      // OceanQuakes
      else {
        quakeMarkers.add(new OceanQuakeMarker(feature));
      }
    }

    // could be used for debugging
    printQuakes();

    // (3) Add markers to map
    //     NOTE: Country markers are not added to the map.  They are used
    //           for their geometric properties
    map.addMarkers(quakeMarkers);
    map.addMarkers(cityMarkers);

    sortAndPrint(20);
  } // End setup
Ejemplo n.º 3
0
  public void setup() {
    // (1) Initializing canvas and map tiles
    size(900, 700, OPENGL);
    if (offline) {
      map = new UnfoldingMap(this, 200, 50, 650, 600, new MBTilesMapProvider(mbTilesString));
      earthquakesURL = "2.5_week.atom"; // The same feed, but saved August 7, 2015
    } else {
      map = new UnfoldingMap(this, 200, 50, 650, 600, new Google.GoogleMapProvider());
      // IF YOU WANT TO TEST WITH A LOCAL FILE, uncomment the next line
      // earthquakesURL = "2.5_week.atom";
    }
    MapUtils.createDefaultEventDispatcher(this, map);

    // (2) Reading in earthquake data and geometric properties
    //     STEP 1: load country features and markers
    List<Feature> countries = GeoJSONReader.loadData(this, countryFile);
    countryMarkers = MapUtils.createSimpleMarkers(countries);

    //     STEP 2: read in city data
    List<Feature> cities = GeoJSONReader.loadData(this, cityFile);
    cityMarkers = new ArrayList<Marker>();
    for (Feature city : cities) {
      System.out.println(
          city.getProperty("name")
              + ", "
              + city.getProperty("country")
              + " Pop: "
              + city.getProperty("population")
              + "Million");
      cityMarkers.add(new CityMarker(city));
    }

    //     STEP 3: read in earthquake RSS feed
    List<PointFeature> earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL);
    quakeMarkers = new ArrayList<Marker>();

    for (PointFeature feature : earthquakes) {
      // check if LandQuake
      if (isLand(feature)) {
        quakeMarkers.add(new LandQuakeMarker(feature));
      }
      // OceanQuakes
      else {
        quakeMarkers.add(new OceanQuakeMarker(feature));
      }
    }

    // could be used for debugging
    printQuakes();

    // (3) Add markers to map
    //     NOTE: Country markers are not added to the map.  They are used
    //           for their geometric properties
    map.addMarkers(quakeMarkers);
    map.addMarkers(cityMarkers);
  } // End setup
Ejemplo n.º 4
0
  public void setup() {
    size(800, 600, OPENGL);
    map = new UnfoldingMap(this, 50, 50, 700, 500, new Google.GoogleMapProvider());
    MapUtils.createDefaultEventDispatcher(this, map);
    lifeExpByCountry = loadLifeExpectancyFromCSV("../data/LifeExpectancyWorldBank.csv");
    countries = GeoJSONReader.loadData(this, "countries.geo.json");
    countryMarkers = MapUtils.createSimpleMarkers(countries);
    map.addMarkers(countryMarkers);

    shadeCountries();
  }
Ejemplo n.º 5
0
  public void setup() {
    // first setup a clean map and draw
    size(800, 600, OPENGL);
    map = new UnfoldingMap(this, 50, 50, 700, 500, new Google.GoogleMapProvider());
    MapUtils.createDefaultEventDispatcher(this, map);

    // Load Life Expectancy from CSV
    lifeExpByCountry = loadLifeExpectancyFromCSV("LifeExpectancyWorldBankModule3.csv");
    println("Loaded " + lifeExpByCountry.size() + " data entries.");

    // Load country polygons and add them as markers
    countries = GeoJSONReader.loadData(this, "countries.geo.json");
    coutryMarkers = MapUtils.createSimpleMarkers(countries);
    map.addMarkers(coutryMarkers);

    // shade country markers by life expectancy
    shadeCountries();
  }
 private void addCountryMarker() {
   List<Feature> countries =
       GeoJSONReader.loadData(p, p.sketchPath("data/data/countries.geo.json"));
   List<Marker> countryMarkers = MapUtils.createSimpleMarkers(countries);
   map.addMarkers(countryMarkers);
 }