コード例 #1
0
  @Override
  public void startTag(String name, Attributes atts, Stack<String> context) {

    if (name.equals("company")) {

      companyName = atts.getValue("name");
      this.companyNames.add(companyName);
      createQuadTrees();

      twowaycarsharingstationsMap = new HashMap<String, CarsharingStation>();
      onewaycarsharingstationsMap = new HashMap<String, CarsharingStation>();

      ffvehiclesMap = new HashMap<CSVehicle, Link>();
      ffvehicleIdMap = new HashMap<String, CSVehicle>();

      owvehicleIdMap = new HashMap<String, CSVehicle>();
      owvehiclesMap = new HashMap<CSVehicle, Link>();

      twvehicleIdMap = new HashMap<String, CSVehicle>();
      twvehiclesMap = new HashMap<CSVehicle, Link>();
      // allVehicles = new HashMap<String, CSVehicle>();
      // companies = new HashMap<String, CompanyContainer>();
    } else if (name.equals("twoway") || name.equals("oneway")) {
      csType = name;
      id = atts.getValue("id");
      String xCoord = atts.getValue("x");
      String yCoord = atts.getValue("y");
      Coord coordStation = new Coord(Double.parseDouble(xCoord), Double.parseDouble(yCoord));

      link = (Link) NetworkUtils.getNearestLinkExactly(network, coordStation);
      vehicles = new ArrayList<StationBasedVehicle>();
      if (name.equals("oneway")) {
        avaialbleParkingSpots = Integer.parseInt(atts.getValue("freeparking"));
        hasOW = true;
      } else hasTW = true;

    } else if (name.equals("freefloating")) {
      hasFF = true;
      String xCoord = atts.getValue("x");
      String yCoord = atts.getValue("y");
      String type = atts.getValue("type");
      Coord coordStation = new Coord(Double.parseDouble(xCoord), Double.parseDouble(yCoord));

      link = (Link) NetworkUtils.getNearestLinkExactly(network, coordStation);
      FFVehicleImpl ffcsvehicle = new FFVehicleImpl(type, atts.getValue("id"), companyName);
      ffVehicleLocationQuadTree.put(link.getCoord().getX(), link.getCoord().getY(), ffcsvehicle);
      ffvehiclesMap.put(ffcsvehicle, link);
      ffvehicleIdMap.put(atts.getValue("id"), ffcsvehicle);
      this.allVehicles.put(atts.getValue("id"), ffcsvehicle);
      allVehicleLocations.put(ffcsvehicle, link);
    } else if (name.equals("vehicle")) {

      StationBasedVehicle vehicle =
          new StationBasedVehicle(
              atts.getValue("type"), atts.getValue("vehicleID"), id, csType, companyName);
      vehicles.add(vehicle);
      this.allVehicles.put(atts.getValue("vehicleID"), vehicle);
      this.allVehicleLocations.put(vehicle, link);
    }
  }
コード例 #2
0
  public void runAccessibilityComputation() {

    final Network network = (Network) this.scenario.getNetwork();

    ProgressBar bar = new ProgressBar(this.measuringPoints.getZones().size());

    for (Zone<Id<Zone>> measurePoint : this.measuringPoints.getZones()) {

      bar.update();

      Coord coord = MGC.point2Coord(measurePoint.getGeometry().getCentroid());
      Point p = measurePoint.getGeometry().getCentroid();
      final Coord coord1 = coord;

      Link nearestLink = NetworkUtils.getNearestLinkExactly(network, coord1);
      final Coord coord2 = coord;
      Node nearestNode = NetworkUtils.getNearestNode(network, coord2);

      Distances distance =
          NetworkUtil.getDistances2NodeViaGivenLink(coord, nearestLink, nearestNode);
      double distanceMeasuringPoint2Road_meter = distance.getDistancePoint2Intersection();

      double walkTravelTime_h =
          distanceMeasuringPoint2Road_meter
              / this.walkSpeedMeterPerHour; // travel time from coord to network (node or link)

      if (boundary.contains(p)) this.freeSpeedGrid.setValue(walkTravelTime_h, p);
    }
  }