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; }
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; }
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(); }
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; }
public void cleanNetwork() { board.cleanNetwork(); board.repaint(); }
public boolean setNetToBoard(NetworkImpl net) { // System.out.println("Asignando red:" + net); board.setNetwork(net); board.repaint(); return true; }