MATSIM
NetworkFactoryImpl.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2008, 2011 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 
20 package org.matsim.core.network;
21 
22 import org.apache.logging.log4j.LogManager;
23 import org.apache.logging.log4j.Logger;
24 import org.matsim.api.core.v01.Coord;
25 import org.matsim.api.core.v01.Id;
31 
36 /*deliberately package*/ final class NetworkFactoryImpl implements NetworkFactory {
37 
38  private final static Logger log = LogManager.getLogger(NetworkFactory.class);
39 
40  private final LinkFactory linkFactory;
41 
42  private final Network network;
43 
44  NetworkFactoryImpl(final Network network, final LinkFactory linkFactory) {
45  this.network = network;
46  this.linkFactory = linkFactory;
47  }
48 
49  @Override
50  public Node createNode(final Id<Node> id, final Coord coord) {
51  Node node = NetworkUtils.createNode(id);
52  node.setCoord(coord) ;
53  return node ;
54  }
55 
56  @Override
57  public Link createLink(Id<Link> id, Node fromNode, Node toNode) {
58  return this.linkFactory.createLink(id, fromNode, toNode,
59  this.network, CoordUtils.calcEuclideanDistance(fromNode.getCoord(), toNode.getCoord()), 1.0, 1.0, 1.0);
60  }
61 }