/** * Estimates the remaining travel cost from fromNode to toNode using the euclidean distance between them. * * @param fromNode The first node. * @param toNode The second node. * @return The travel cost when traveling between the two given nodes. */ protected double estimateRemainingTravelCost(final Node fromNode, final Node toNode) { double dist = CoordUtils.calcEuclideanDistance(fromNode.getCoord(), toNode.getCoord()) * getMinTravelCostPerLength(); return dist * this.overdoFactor; }
ImaginaryNode(Collection<? extends InitialNode> initialNodes) { this.initialNodes = initialNodes; double sumX = 0.0; double sumY = 0.0; for (InitialNode initialNode : initialNodes) { sumX += initialNode.node.getCoord().getX(); sumY += initialNode.node.getCoord().getY(); } sumX /= initialNodes.size(); sumY /= initialNodes.size(); this.coord = new Coord(sumX, sumY); }
private Set<Node> circularCut(Network network) { Set<Node> nodesToRemove = new HashSet<>(); for (Node n : network.getNodes().values()) { Coord coord = n.getCoord(); double distance = CoordUtils.calcEuclideanDistance(coord, center); if (distance > radius) { nodesToRemove.add(n); } } return nodesToRemove; } }
private Set<Node> rectangularCut(Network network) { Set<Node> nodesToRemove = new HashSet<>(); for (Node n : network.getNodes().values()) { Coord coord = n.getCoord(); double x = coord.getX(); double y = coord.getY(); if (!((x < this.maxX) && (this.minX < x) && (y < this.maxY) && (this.minY < y))) { nodesToRemove.add(n); } } return nodesToRemove; }
public static Map<Id<Node>, Zone> createNodeToZoneMap(Network network, ZoneFinder zoneFinder) { Map<Id<Node>, Zone> nodeToZone = new HashMap<>(); for (Node n : network.getNodes().values()) { nodeToZone.put(n.getId(), zoneFinder.findZone(n.getCoord())); } return nodeToZone; } }
/** * * @param l * @return {@code true} if the Link is not farther away than the * distance specified by the distance filter from the center node of the filter. */ @Override public boolean judgeLink(Link l) { double dist = CoordUtils.calcEuclideanDistance(l.getCoord(), this.distanceFilterNode.getCoord()); return dist < this.distanceFilter; }
private SimpleFeature getFeature(Node node) { Point p = MGC.coord2Point(node.getCoord()); try { return this.builder.buildFeature(null, new Object[]{p,node.getId().toString()}); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } }
public static Map<Id<Link>, Zone> createLinkToZoneMap(Network network, ZoneFinder zoneFinder) { Map<Id<Link>, Zone> linkToZone = new HashMap<>(); for (Link l : network.getLinks().values()) { linkToZone.put(l.getId(), zoneFinder.findZone(l.getToNode().getCoord())); } return linkToZone; }
/** * Helper method for type conversion. * * @param link * @return */ public static LineString createGeotoolsLineString(Link link) { Coordinate fromCoord = MGC.coord2Coordinate( link.getFromNode().getCoord() ) ; Coordinate toCoord = MGC.coord2Coordinate( link.getToNode().getCoord() ) ; LineString theSegment = new GeometryFactory().createLineString(new Coordinate[]{ fromCoord, toCoord }); return theSegment; }
@Override protected void setOrModifyNodeAttributes(Node n, OsmNode node) { if (this.elevationDataParser==null) return; Coord coord = n.getCoord(); double elevation = elevationDataParser.getElevation(n.getCoord()); Coord elevationCoord = CoordUtils.createCoord(coord.getX(), coord.getY(), elevation); n.setCoord(elevationCoord); }
public static double getGradientFactor(Link link) { double gradient = 0.; Double fromNodeZ = link.getFromNode().getCoord().getZ(); Double toNodeZ = link.getToNode().getCoord().getZ(); if ((fromNodeZ != null) && (toNodeZ != null)) { if (toNodeZ > fromNodeZ) { // No positive utility for downhill, only negative for uphill gradient = (toNodeZ - fromNodeZ) / link.getLength(); } } return gradient; }
public SquareGridSystem(Network network, double cellSize) { this.grid = new SquareGrid(network, cellSize); for (Node n : network.getNodes().values()) { Zone zone = grid.getZone(n.getCoord()); zones.put(zone.getId(), zone); } }
private boolean linkToNodeInServiceArea(Link link) { Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord())); if(this.include.contains(p)){ if(exclude.contains(p)){ return false; } return true; } return false; }
private boolean linkToNodeInServiceArea(Link link) { Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord())); if(this.include.contains(p)){ if(exclude.contains(p)){ return false; } return true; } return false; }
private Node addNode(Network net, Node n){ Node newNode = net.getFactory().createNode(n.getId(), n.getCoord()); net.addNode(newNode); return newNode; }
private Network reshuffleNodesAndReturnNetwork(List<Node> nodes) { Network network = NetworkUtils.createNetwork(); Collections.shuffle(nodes); for (Node n : nodes) { System.out.println("Adding node "+ n.getId()); network.addNode(NetworkUtils.createNode(n.getId(), n.getCoord())); } return network; }
@Test public void testNo3DCoord() { // should be done through once "mixed" network as soon as possible 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" ); final Id<Node> zh = Id.createNodeId( "Zurich" ); final Coord zhCoord = read.getNetwork().getNodes().get( zh ).getCoord(); Assert.assertFalse( "did not expect Z", zhCoord.hasZ() ); }