@Override public Attributes getAttributes() { return this.network.getAttributes(); } }
@Override public void startNetwork(final Network network, final BufferedWriter out) throws IOException { out.write("<network"); if (network.getName() != null) { out.write(" name=\"" + network.getName() + "\""); } out.write(">\n\n"); attributesWriter.writeAttributes( "\t" , out , network.getAttributes() ); }
private void startNetwork(final Attributes atts) { if (atts.getValue("type") != null) { log.info("Attribute 'type' is deprecated. There's always only ONE network, where the links and nodes define, which " + "transportation mode is allowed to use it (for the future)"); } this.network.setName(atts.getValue("name")); if (atts.getValue("capDivider") != null) { log.warn("capDivider defined. it will be used but should be gone eventually. " + "-- This is a weird comment, since the matsim public api tells to put this into the network rather than" + " into the ``links''. kai, jun'11"); String capperiod = atts.getValue("capDivider") + ":00:00"; this.network.setCapacityPeriod(Time.parseTime(capperiod)); } currentAttributes = network.getAttributes(); }
@Override public void endTag(final String name, final String content, final Stack<String> context) { switch( name ) { case ATTRIBUTES: if (context.peek().equals(NETWORK)) { String inputCRS = (String) network.getAttributes().getAttribute(ProjectionUtils.INPUT_CRS_ATT); if (inputCRS != null && targetCRS != null) { if (externalInputCRS != null) { // warn or crash? log.warn("coordinate transformation defined both in config and in input file: setting from input file will be used"); } coordinateTransformation = TransformationFactory.getCoordinateTransformation(inputCRS, targetCRS); ProjectionUtils.putCRS(network, targetCRS); } } case ATTRIBUTE: attributesDelegate.endTag(name, content, context); break; } }
@Test public void testNetworkAttributes() { final Scenario sc = createTestNetwork( false ); new NetworkWriter( sc.getNetwork() ).writeV2( utils.getOutputDirectory()+"network.xml" ); final Scenario read = ScenarioUtils.createScenario( ConfigUtils.createConfig() ); new MatsimNetworkReader( read.getNetwork() ).readFile( utils.getOutputDirectory()+"network.xml" ); Assert.assertEquals( "unexpected year in network metadata", sc.getNetwork().getAttributes().getAttribute( "year" ), read.getNetwork().getAttributes().getAttribute( "year" ) ); }
.getAttributes() .getAttribute( "networkAttribute" );
final NetworkFactory factory = network.getFactory(); network.getAttributes().putAttribute( "year" , 2016 );
final NetworkFactory factory = network.getFactory(); network.getAttributes().putAttribute( "networkAttribute" , new StupidClass() );