MATSIM
CalcBoundingBox.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * CalcBoundingBox.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2008 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.core.network.algorithms;
22 
26 
32 public final class CalcBoundingBox implements NetworkRunnable {
33 
34  private double minX = Double.POSITIVE_INFINITY;
35  private double minY = Double.POSITIVE_INFINITY;
36  private double maxX = Double.NEGATIVE_INFINITY;
37  private double maxY = Double.NEGATIVE_INFINITY;
38 
39  @Override
40  public void run(final Network network) {
41  this.minX = Double.POSITIVE_INFINITY;
42  this.minY = Double.POSITIVE_INFINITY;
43  this.maxX = Double.NEGATIVE_INFINITY;
44  this.maxY = Double.NEGATIVE_INFINITY;
45  for (Node n : network.getNodes().values()) {
46  if (n.getCoord().getX() < this.minX) { this.minX = n.getCoord().getX(); }
47  if (n.getCoord().getY() < this.minY) { this.minY = n.getCoord().getY(); }
48  if (n.getCoord().getX() > this.maxX) { this.maxX = n.getCoord().getX(); }
49  if (n.getCoord().getY() > this.maxY) { this.maxY = n.getCoord().getY(); }
50  }
51  }
52 
53  public double getMinX() {
54  return this.minX;
55  }
56 
57  public double getMaxX() {
58  return this.maxX;
59  }
60 
61  public double getMinY() {
62  return this.minY;
63  }
64 
65  public double getMaxY() {
66  return this.maxY;
67  }
68 
69 }
Map< Id< Node >, ? extends Node > getNodes()