📄 road.java
字号:
/*〤opyright 2008 Nick MallesonThis file is part of RepastCity.RepastCity is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.RepastCity is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with RepastCity. If not, see <http://www.gnu.org/licenses/>. */package repastcity.citycontext;import java.util.ArrayList;import repastcity.ContextCreator;/** Represents road objects. * * @author Nick Malleson */public class Road { private int id; // An autogenerated id from ContextCreater private String identifier; // An identifier which can be used to link Roads (in a spatial GIS) with Edges //(in a Network). Should be found using the column name in a GIS table (e.g. TOID) private String description = ""; private ArrayList<Junction> junctions; // The junctions at either end of the road public Road() { this.id = ContextCreator.generateAgentID(); this.description = "road"; this.junctions = new ArrayList<Junction>(); } public String toString() { return "Agent id: "+id+" description: "+description; } public int getID() { return id; } public void setID(int id) { this.id = id; } /** * Get a unique identifier for this Road. Not the same as ID (which is an autogenerated field common * to every agent used in the model), this identifier is used to link road features in a GIS with * Edges added to the RoadNetwork (a repast Network Projection). * @return the identifier for this Road. * @throws NoIdentifierException if the identifier has not been set correctly. This might occur if * the roads are not initialised correctly (e.g. there is no attribute called 'identifier' present in * the shapefile used to create this Road). */ public String getIdentifier() { if (identifier=="" || identifier == null) { System.err.println("Road: error, the identifier field for this road has not been initialised." + "\n\tIf reading in a shapefile please make sure there is a string collumn called 'identifier' which is" + " unique to each feature"); } return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } /** * Used to tell this Road who it's Junctions (endpoints) are. * @param j the Junction at either end of this Road. */ public void addJunction(Junction j) { if (this.junctions.size()==2) { System.err.println("Road: Error: this Road object already has two Junctions."); } this.junctions.add(j); } public ArrayList<Junction> getJunctions() { if (this.junctions.size()!=2) { System.err.println("Road: Error: This Road does not have two Junctions"); } return this.junctions; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -