Beispiel #1
0
 // reset the agent layer's MBR
 public void resetLayers() {
   MBR = roadLayer.getMBR();
   //		MBR.init(740000, 780000, 2000000, 2040000); // 35 22
   MBR.init(740000, 779000, 2009000, 2034000); // 35 22
   //		MBR.init(745000, 775000, 2015000, 2030000);
   this.humanLayer.setMBR(MBR);
   // this.baseLayer.setMBR(MBR);
 }
Beispiel #2
0
 @Override
 public void init(final Envelope env) {
   super.init(env);
   if (env instanceof Envelope3D) {
     this.minz = ((Envelope3D) env).getMinZ();
     this.maxz = ((Envelope3D) env).getMaxZ();
   }
 }
Beispiel #3
0
  /** Read in data and set up the simulation */
  public void start() {
    super.start();
    try {

      GeomVectorField populationLayer = new GeomVectorField(grid_width, grid_height);

      //////////////////////////////////////////////
      ///////////// READING IN DATA ////////////////
      //////////////////////////////////////////////

      readInVectorLayer(baseLayer, dirName + "haiti/haiti_meters.shp", "area", new Bag());
      readInVectorLayer(
          populationLayer,
          dirName + "population/popCentroids_meters.shp",
          "residential areas",
          new Bag());
      readInVectorLayer(roadLayer, dirName + "roads/roads_meters.shp", "road network", new Bag());
      readInVectorLayer(
          waterwayLayer, dirName + "waterways/rivers_meters.shp", "waterways", new Bag());
      readInVectorLayer(
          medicalLayer,
          dirName + "healthFacilities/health_meters.shp",
          "health facilities",
          new Bag());

      //////////////////////////////////////////////
      ////////////////// CLEANUP ///////////////////
      //////////////////////////////////////////////

      // standardize the MBRs so that the visualization lines up

      MBR = roadLayer.getMBR();
      //			MBR.init(740000, 780000, 2000000, 2040000); // 35 22
      MBR.init(740000, 779000, 2009000, 2034000); // 35 22
      //			MBR.init(750000, 772000, 2009500, 2028500); // 22 18
      //			MBR.init(756000, 766000, 2015500, 2022500);
      roadLayer.setMBR(MBR);
      // baseLayer.setMBR(MBR);

      this.grid_width = roadLayer.fieldWidth;
      this.grid_height = roadLayer.fieldHeight;

      // base layer

      landArea = (Geometry) ((MasonGeometry) baseLayer.getGeometries().get(0)).geometry.clone();
      for (Object o : baseLayer.getGeometries()) {
        MasonGeometry g = (MasonGeometry) o;
        landArea = landArea.union(g.geometry);
      }

      // clean up the road network

      System.out.print("Cleaning the road network...");

      roads =
          NetworkUtilities.multipartNetworkCleanup(roadLayer, roadNodes, resolution, fa, random, 0);
      roadNodes = roads.getAllNodes();
      testNetworkForIssues(roads);

      /*			// set up roads as being "open" and assemble the list of potential terminii
      			roadLayer = new GeomVectorField(grid_width, grid_height);
      			for(Object o: roadNodes){
      				GeoNode n = (GeoNode) o;
      				networkLayer.addGeometry(n);

      				boolean potential_terminus = false;

      				// check all roads out of the nodes
      				for(Object ed: roads.getEdgesOut(n)){

      					// set it as being (initially, at least) "open"
      					ListEdge edge = (ListEdge) ed;
      					((MasonGeometry)edge.info).addStringAttribute("open", "OPEN");
      					networkEdgeLayer.addGeometry( (MasonGeometry) edge.info);
      					roadLayer.addGeometry((MasonGeometry) edge.info);
      					((MasonGeometry)edge.info).addAttribute("ListEdge", edge);

      					String type = ((MasonGeometry)edge.info).getStringAttribute("highway");
      					if(type.equals("motorway") || type.equals("primary") || type.equals("trunk"))
      						potential_terminus = true;
      				}

      				// check to see if it's a terminus
      				if(potential_terminus && !MBR.contains(n.geometry.getCoordinate()) && roads.getEdges(n, null).size() == 1){
      					terminus_points.add(n);
      				}

      			}
      */
      // reset MBRS in case it got messed up during all the manipulation
      roadLayer.setMBR(MBR);
      networkLayer.setMBR(MBR);
      networkEdgeLayer.setMBR(MBR);
      waterwayLayer.setMBR(MBR);
      baseLayer.setMBR(MBR);
      medicalLayer.setMBR(MBR);
      humanLayer.setMBR(MBR);
      homesLayer.setMBR(MBR);
      diseasesLayer.setMBR(MBR);

      System.out.println("done");

      /////////////////////
      ///////// Clean up roads for Agents to use ///////////
      /////////////////////

      /*	Network majorRoads = extractMajorRoads();
      		testNetworkForIssues(majorRoads);

      		// assemble list of secondary versus local roads
      		ArrayList <Edge> myEdges = new ArrayList <Edge> ();
      		GeomVectorField secondaryRoadsLayer = new GeomVectorField(grid_width, grid_height);
      		GeomVectorField localRoadsLayer = new GeomVectorField(grid_width, grid_height);
      		for(Object o: majorRoads.allNodes){

      			majorRoadNodesLayer.addGeometry((GeoNode)o);

      			for(Object e: roads.getEdges(o, null)){
      				Edge ed = (Edge) e;

      				myEdges.add(ed);

      				String type = ((MasonGeometry)ed.getInfo()).getStringAttribute("highway");
      				if(type.equals("secondary"))
      						secondaryRoadsLayer.addGeometry((MasonGeometry) ed.getInfo());
      				else if(type.equals("local"))
      						localRoadsLayer.addGeometry((MasonGeometry) ed.getInfo());
      			}
      		}

      */ System.gc();

      //////////////////////////////////////////////
      ////////////////// AGENTS ///////////////////
      //////////////////////////////////////////////

      // set up the agents in the simulation
      setupAgents(populationLayer);
      humanLayer.setMBR(MBR);
      homesLayer.setMBR(MBR);

      /*			// for each of the Agents, set up relevant, environment-specific information
      			int aindex = 0;
      			for(Human a: humans){

      				if(a.familiarRoadNetwork == null){

      					// the Human knows about major roads
      					Network familiar = majorRoads.cloneGraph();

      					// connect the major network to the Human's location
      					connectToMajorNetwork(a.getNode(), familiar);

      					a.familiarRoadNetwork = familiar;

      					// add local roads into the network
      					for(Object o: humanLayer.getObjectsWithinDistance(a, 50)){
      						Human b = (Human) o;
      						if(b == a || b.familiarRoadNetwork != null || b.getNode() != a.getNode()) continue;
      						b.familiarRoadNetwork = familiar.cloneGraph();
      					}

      				}

      				// connect the Human's work into its personal network
      				if(a.getWork() != null)
      					connectToMajorNetwork(getClosestGeoNode(a.getWork()), a.familiarRoadNetwork);

      				// set up its basic paths (fast and quicker and recomputing each time)
      				a.setupPaths();

      				if(aindex % 100 == 0){ // print report of progress
      					System.out.println("..." + aindex + " of " + humans.size());
      				}
      				aindex++;
      			}
      */
      //			Disease d = new Disease();
      Cholera d = new Cholera();
      HumanTeleporter h = humans.get(random.nextInt(humans.size()));
      h.acquireDisease(d);

      // seed the simulation randomly
      //			seedRandom(System.currentTimeMillis());

      // schedule the reporter to run
      //			setupReporter();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #4
0
 /**
  * Initialize an <code>Envelope</code> from an existing 3D Envelope.
  *
  * @param env the 3D Envelope to initialize from
  */
 public void init(final Envelope3D env) {
   super.init(env);
   this.minz = env.minz;
   this.maxz = env.maxz;
 }
 /**
  * Initialize the bounding box with another bounding box.
  *
  * @since 2.4
  */
 public void setBounds(final BoundingBox bbox) {
   ensureCompatibleReferenceSystem(bbox);
   super.init(getJTSEnvelope(bbox));
 }
 /** Sets this envelope to the specified bounding box. */
 public void init(BoundingBox bounds) {
   super.init(
       bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1));
   this.crs = bounds.getCoordinateReferenceSystem();
 }