コード例 #1
0
  public boolean loadNetFromOSM(final String path, final String crs) {
    // REVISAR UTM33N a UTM19N
    //        String UTM19N_PROJCS =
    // "PROJCS[\"WGS_1984_UTM_Zone_19N\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-69],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]";
    //	String crs = UTM19N_PROJCS; // the coordinate reference system to be used.

    this.crs = crs;
    String osm = path;

    Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig());
    Network net = sc.getNetwork();

    CoordinateTransformation ct =
        TransformationFactory.getCoordinateTransformation(TransformationFactory.WGS84, crs);

    OsmNetworkReader onr = new OsmNetworkReader(net, ct); // constructs a new openstreetmap reader
    try {
      onr.parse(osm); // starts the conversion from osm to matsim
    } catch (UncheckedIOException e) {
      e.printStackTrace();
      return false;
    }
    // at this point we already have a matsim network...
    new NetworkCleaner()
        .run(net); // but may be there are isolated (not connected) links. The network cleaner
    // removes those links
    board.setNetwork((NetworkImpl) net);
    board.repaint();
    return true;
  }
コード例 #2
0
 public boolean loadNetFromFile(String path) {
   Config config = ConfigUtils.createConfig();
   Scenario sc = ScenarioUtils.createScenario(config);
   try {
     new MatsimNetworkReader(sc.getNetwork()).readFile(path);
     board.setNetwork((NetworkImpl) sc.getNetwork());
     board.repaint();
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
コード例 #3
0
  private void initBoard() {
    board = new NetBlackboard();
    board.setSize(this.editorPanel.getWidth() - 50, this.editorPanel.getHeight() - 50);
    this.editorPanel.add(board);

    controls = new NetControls(board);
    controls.setSize(this.controlPanel.getWidth(), this.controlPanel.getHeight() - 30);
    controlPanel.add(controls);

    board.setNetControls(controls);
    controls.setNetBlackboard(board);

    this.revalidate();
  }
コード例 #4
0
 public boolean loadCountsFromFile(String path) {
   if (board.net == null) return false;
   board.clearCounts();
   CountsReaderMatsimV1 countsReader = new CountsReaderMatsimV1(board.counts);
   try {
     countsReader.parse(path);
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
コード例 #5
0
 public void cleanNetwork() {
   board.cleanNetwork();
   board.repaint();
 }
コード例 #6
0
 public boolean setNetToBoard(NetworkImpl net) {
   // System.out.println("Asignando red:" + net);
   board.setNetwork(net);
   board.repaint();
   return true;
 }