Exemple #1
0
  public void convertTransitSchedule(String file) {

    Config config = ConfigUtils.createConfig();
    config.scenario().setUseTransit(true);
    config.scenario().setUseVehicles(true);
    Scenario scenario = ScenarioUtils.createScenario(config);

    TransitScheduleReader ts = new TransitScheduleReader(scenario);
    ts.readFile(file);

    PointFeatureFactory.Builder builder = new PointFeatureFactory.Builder();
    builder.setName("nodes");
    builder.addAttribute("id", String.class);
    PointFeatureFactory factory = builder.create();

    List<SimpleFeature> features = new ArrayList<SimpleFeature>();

    for (TransitStopFacility stop : scenario.getTransitSchedule().getFacilities().values()) {
      features.add(factory.createPoint(MGC.coord2Coordinate(stop.getCoord())));
    }

    ShapeFileWriter.writeGeometries(
        features,
        "C:/Users/Daniel/Documents/work/shared-svn/studies/countries/cl/Kai_und_Daniel/Visualisierungen/stops.shp");
  }
  void writeGISoutput(Map<Double, double[][]> time2results, String outputPathForGIS)
      throws IOException {

    PointFeatureFactory factory =
        new PointFeatureFactory.Builder()
            .setCrs(this.targetCRS)
            .setName("EmissionPoint")
            .addAttribute("Time", String.class)
            .addAttribute("Emissions", Double.class)
            .create();
    Collection<SimpleFeature> features = new ArrayList<SimpleFeature>();

    for (Double endOfTimeInterval : time2results.keySet()) {
      //			if(endOfTimeInterval < Time.MIDNIGHT){ // time manager in QGIS does not accept time
      // beyond midnight...
      for (int xIndex = 0; xIndex < noOfXbins; xIndex++) {
        for (int yIndex = 0; yIndex < noOfYbins; yIndex++) {
          Coord cellCentroid = findCellCentroid(xIndex, yIndex);
          if (isInVisBoundary(cellCentroid)) {
            String dateTimeString = convertSeconds2dateTimeFormat(endOfTimeInterval);
            double result = time2results.get(endOfTimeInterval)[xIndex][yIndex];
            SimpleFeature feature =
                factory.createPoint(
                    new Coordinate(cellCentroid.getX(), cellCentroid.getY()),
                    new Object[] {dateTimeString, result},
                    null);
            features.add(feature);
          }
        }
      }
      //			}
    }
    ShapeFileWriter.writeGeometries(features, outputPathForGIS);
    logger.info("Finished writing output for GIS to " + outputPathForGIS);
  }
 private void makeVeh() {
   PointFeatureFactory pf =
       new PointFeatureFactory.Builder()
           .setName("vehicle")
           .setCrs(MGC.getCRS("EPSG:32632"))
           .addAttribute("angle", Double.class)
           .addAttribute("speed", Double.class)
           .create();
   Collection<SimpleFeature> features = new ArrayList<SimpleFeature>();
   int id = 0;
   for (LinkInfo li : this.lis) {
     for (SensorDataVehicle veh : li.getVeh()) {
       SimpleFeature ft =
           pf.createPoint(
               new Coordinate(veh.getX(), veh.getY()),
               new Object[] {veh.getAngle(), veh.getSpeed()},
               id++ + "");
       features.add(ft);
     }
   }
   ShapeFileWriter.writeGeometries(features, this.debugDir + "/vehicles.shp");
 }