private void loadGrid() { String gridCSVFile = this.noiseParams.getReceiverPointsCSVFile(); Map<Id<ReceiverPoint>, Coord> gridPoints = null; try { gridPoints = readCSVFile(gridCSVFile, ",", 0, 1, 2); } catch (IOException e) { e.printStackTrace(); } CoordinateTransformation ct = TransformationFactory.getCoordinateTransformation(this.noiseParams.getReceiverPointsCSVFileCoordinateSystem(), this.scenario.getConfig().global().getCoordinateSystem()); for (Id<ReceiverPoint> id : gridPoints.keySet()) { Coord coord = gridPoints.get(id); Coord transformedCoord = ct.transform(coord); ReceiverPoint rp = new ReceiverPoint(id, transformedCoord); receiverPoints.put(id, rp); } log.info("Total number of receiver points: " + receiverPoints.size()); }
private void dumpTransitSchedule() { try { if ( transitSchedule != null ) { final String inputCRS = config.transit().getInputScheduleCRS(); final String internalCRS = config.global().getCoordinateSystem(); new TransitScheduleWriter(transitSchedule).writeFile(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_TRANSIT_SCHEDULE)); } } catch ( Exception ee ) { log.error("Exception writing transit schedule.", ee); } }
private void dumpFacilities() { // dump facilities try { final String inputCRS = config.facilities().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); new FacilitiesWriter(activityFacilities).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_FACILITIES)); } catch ( Exception ee ) { log.error("Exception writing facilities.", ee); } }
public SnapshotWriter get() { String baseFileName = "googleearth.kmz"; String fileName = controlerIO.getIterationFilename(iteration, baseFileName); String coordSystem = scenario.getConfig().global().getCoordinateSystem(); return new KmlSnapshotWriter(fileName, TransformationFactory.getCoordinateTransformation(coordSystem, TransformationFactory.WGS84)); }
private void loadSnapshotWriters(final String outputDir) { if (this.writer != null) { this.visualizer.addSnapshotWriter(this.writer); } Collection<String> snapshotFormat = this.config.controler().getSnapshotFormat(); if (snapshotFormat.contains("transims")) { String snapshotFile = outputDir + "T.veh"; this.visualizer.addSnapshotWriter(new TransimsSnapshotWriter(snapshotFile)); } if (snapshotFormat.contains("googleearth")) { String snapshotFile = outputDir + "googleearth.kmz"; String coordSystem = this.config.global().getCoordinateSystem(); this.visualizer.addSnapshotWriter(new KmlSnapshotWriter(snapshotFile, TransformationFactory.getCoordinateTransformation(coordSystem, TransformationFactory.WGS84))); } }
final CoordinateTransformation coordTransform = TransformationFactory.getCoordinateTransformation(this.config.global().getCoordinateSystem(),TransformationFactory.WGS84);
private void dumpCounts() { try { if ( counts != null ) { final String inputCRS = config.counts().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); if ( inputCRS == null ) { new CountsWriter(counts).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_COUNTS)); } else { log.info( "re-projecting counts from "+internalCRS+" back to "+inputCRS+" for export" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( internalCRS, inputCRS ); new CountsWriter( transformation , counts).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_COUNTS)); } } } catch ( Exception ee ) { log.error("Exception writing counts.", ee); } }
@Provides @Singleton Counts<Link> provideLinkCounts(Scenario scenario, CountsConfigGroup config) { Counts<Link> counts = (Counts<Link>) scenario.getScenarioElement(Counts.ELEMENT_NAME); if (counts != null) { return counts; } else { counts = new Counts<>(); if (config.getCountsFileName() != null) { final String inputCRS = config.getInputCRS(); final String internalCRS = scenario.getConfig().global().getCoordinateSystem(); MatsimCountsReader counts_parser; if (inputCRS == null) { counts_parser = new MatsimCountsReader(counts); } else { log.info( "re-projecting counts from "+inputCRS+" to "+internalCRS+" for import" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( inputCRS, internalCRS ); counts_parser = new MatsimCountsReader( transformation , counts ); } counts_parser.parse(config.getCountsFileURL(scenario.getConfig().getContext())); } return counts; } }
@Override public void writeExecutedPlans(String outputFile) { final Config config = scenario.getConfig(); final String inputCRS = config.plans().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); if ( inputCRS == null ) { new PopulationWriter(experiencedPopulation, scenario.getNetwork()).write(outputFile); } else { log.info( "re-projecting \"experienced\" population from "+internalCRS+" to "+inputCRS+" for export" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( internalCRS, inputCRS ); new PopulationWriter(transformation, experiencedPopulation, scenario.getNetwork()).write(outputFile); } }
private void loadPopulation() { if ((this.config.plans() != null) && (this.config.plans().getInputFile() != null)) { URL populationFileName = this.config.plans().getInputFileURL(this.config.getContext()); log.info("loading population from " + populationFileName); final String targetCRS = config.global().getCoordinateSystem(); final String internalCRS = config.global().getCoordinateSystem(); final PopulationReader reader = new PopulationReader(targetCRS, internalCRS, this.scenario); reader.putAttributeConverters( attributeConverters ); reader.parse( populationFileName ); PopulationUtils.printPlansCount(this.scenario.getPopulation()) ; } else { log.info("no population file set in config, not able to load population"); } if ((this.config.plans() != null) && (this.config.plans().getInputPersonAttributeFile() != null)) { URL personAttributesURL = this.config.plans().getInputPersonAttributeFileURL(this.config.getContext()); log.info("loading person attributes from " + personAttributesURL); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(this.scenario.getPopulation().getPersonAttributes()); reader.putAttributeConverters( attributeConverters ); reader.parse(personAttributesURL); } else { log.info("no person-attributes file set in config, not loading any person attributes"); } }
@Override public void notifyBeforeMobsim(final BeforeMobsimEvent event) { final boolean writingPlansAtAll = writePlansInterval > 0; final boolean regularWritePlans = writingPlansAtAll && (event.getIteration()>0 && event.getIteration() % writePlansInterval== 0); final boolean earlyIteration = event.getIteration() <= writeMoreUntilIteration ; if ( writingPlansAtAll && (regularWritePlans || earlyIteration) ) { stopwatch.beginOperation("dump all plans"); log.info("dumping plans..."); final String inputCRS = config.plans().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); if ( inputCRS == null ) { new PopulationWriter(population, network).write(controlerIO.getIterationFilename(event.getIteration(), Controler.FILENAME_POPULATION)); } else { log.info( "re-projecting population from "+internalCRS+" back to "+inputCRS+" for export" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( internalCRS, inputCRS ); new PopulationWriter(transformation, population, network).write(controlerIO.getIterationFilename(event.getIteration(), Controler.FILENAME_POPULATION)); } log.info("finished plans dump."); stopwatch.endOperation("dump all plans"); } }
private void loadActivityFacilities() { if ((this.config.facilities() != null) && (this.config.facilities().getInputFile() != null)) { URL facilitiesFileName = this.config.facilities().getInputFileURL(config.getContext()); log.info("loading facilities from " + facilitiesFileName); final String inputCRS = config.facilities().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); MatsimFacilitiesReader reader = new MatsimFacilitiesReader(inputCRS, internalCRS, this.scenario.getActivityFacilities()); reader.putAttributeConverters(attributeConverters); reader.parse(facilitiesFileName); log.info("loaded " + this.scenario.getActivityFacilities().getFacilities().size() + " facilities from " + facilitiesFileName); } else { log.info("no facilities file set in config, therefore not loading any facilities. This is not a problem except if you are using facilities"); } if ((this.config.facilities() != null) && (this.config.facilities().getInputFacilitiesAttributesFile() != null)) { URL facilitiesAttributesURL = ConfigGroup.getInputFileURL(this.config.getContext(), this.config.facilities().getInputFacilitiesAttributesFile()); log.info("loading facility attributes from " + facilitiesAttributesURL); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(this.scenario.getActivityFacilities().getFacilityAttributes()); reader.putAttributeConverters( attributeConverters ); reader.parse(facilitiesAttributesURL); } else { log.info("no facility-attributes file set in config, not loading any facility attributes"); } }
String filename = controlerIO.getIterationFilename(iter, "cadytsPtCountscompare.kmz"); final CoordinateTransformation coordTransform = TransformationFactory.getCoordinateTransformation(scenario.getConfig() .global().getCoordinateSystem(), TransformationFactory.WGS84);
/** * Loads the network into the scenario of this class */ private void loadNetwork() { if ((this.config.network() != null) && (this.config.network().getInputFile() != null)) { URL networkUrl = this.config.network().getInputFileURL(this.config.getContext()); log.info("loading network from " + networkUrl); String inputCRS = config.network().getInputCRS(); MatsimNetworkReader reader = new MatsimNetworkReader( inputCRS, config.global().getCoordinateSystem(), this.scenario.getNetwork()); reader.putAttributeConverters( attributeConverters ); reader.parse(networkUrl); if ((this.config.network().getChangeEventsInputFile()!= null) && this.config.network().isTimeVariantNetwork()) { log.info("loading network change events from " + this.config.network().getChangeEventsInputFileUrl(this.config.getContext()).getFile()); Network network = this.scenario.getNetwork(); List<NetworkChangeEvent> changeEvents = new ArrayList<>() ; NetworkChangeEventsParser parser = new NetworkChangeEventsParser(network,changeEvents); parser.parse(this.config.network().getChangeEventsInputFileUrl(config.getContext())); NetworkUtils.setNetworkChangeEvents(network,changeEvents); } } }
Config config = this.scenario.getConfig(); this.setShowNonMovingItems(ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).isDrawNonMovingItems()); String scenarioCRS = config.global().getCoordinateSystem(); int maxZoom = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).getMaximumZoom(); if (ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.GROUP_NAME, OTFVisConfigGroup.class).isMapOverlayMode()) {
private void loadTransit() throws UncheckedIOException { if ( this.config.transit().getTransitScheduleFile() != null ) { URL transitScheduleFile = this.config.transit().getTransitScheduleFileURL(this.config.getContext()); final String inputCRS = config.transit().getInputScheduleCRS(); final String internalCRS = config.global().getCoordinateSystem(); new TransitScheduleReader( inputCRS, internalCRS, this.scenario).readURL(transitScheduleFile ); } else { log.info("no transit schedule file set in config, not loading any transit schedule"); } if ( this.config.transit().getTransitLinesAttributesFile() != null ) { URL transitLinesAttributesFileName = IOUtils.newUrl(this.config.getContext(), this.config.transit().getTransitLinesAttributesFile()); log.info("loading transit lines attributes from " + transitLinesAttributesFileName); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(this.scenario.getTransitSchedule().getTransitLinesAttributes()); reader.putAttributeConverters( attributeConverters ); reader.parse(transitLinesAttributesFileName); } if ( this.config.transit().getTransitStopsAttributesFile() != null ) { URL transitStopsAttributesURL = IOUtils.newUrl(this.config.getContext(), this.config.transit().getTransitStopsAttributesFile()); log.info("loading transit stop facilities attributes from " + transitStopsAttributesURL); ObjectAttributesXmlReader reader = new ObjectAttributesXmlReader(this.scenario.getTransitSchedule().getTransitStopsAttributes()); reader.putAttributeConverters( attributeConverters ); reader.parse(transitStopsAttributesURL); } }
String filename = controlerIO.getIterationFilename(event.getIteration(), "countscompare.kmz"); CountSimComparisonKMLWriter kmlWriter = new CountSimComparisonKMLWriter( cca.getComparison(), network, TransformationFactory.getCoordinateTransformation(globalConfigGroup.getCoordinateSystem(), TransformationFactory.WGS84)); kmlWriter.setIterationNumber(event.getIteration()); kmlWriter.writeFile(filename); CountsWriter countsWriter = new CountsWriter(TransformationFactory.getCoordinateTransformation(globalConfigGroup.getCoordinateSystem(), TransformationFactory.WGS84), simCounts); countsWriter.write(filename);
final CoordinateTransformation coordTransform = TransformationFactory.getCoordinateTransformation(boardFixture.config.global().getCoordinateSystem(), TransformationFactory.WGS84);