本文整理汇总了Java中org.matsim.api.core.v01.Id.create方法的典型用法代码示例。如果您正苦于以下问题:Java Id.create方法的具体用法?Java Id.create怎么用?Java Id.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.matsim.api.core.v01.Id
的用法示例。
在下文中一共展示了Id.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1:
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* Constructor. All primitive attribute values of the transitRouteStop are stored
* to make access easier during stop facility replacement.
*/
/*package*/ PseudoRouteStopImpl(int order, TransitRouteStop routeStop, LinkCandidate linkCandidate) {
this.id = Id.create("[" + Integer.toString(order) + "]" + linkCandidate.toString(), PseudoRouteStop.class);
this.linkId = linkCandidate.getLink().getId();
// stop facility values
this.coord = routeStop.getStopFacility().getCoord();
this.parentStopFacilityId = routeStop.getStopFacility().getId();
this.isBlockingLane = routeStop.getStopFacility().getIsBlockingLane();
this.facilityName = routeStop.getStopFacility().getName();
this.stopPostAreaId = routeStop.getStopFacility().getStopPostAreaId();
// route stop values
this.departureOffset = routeStop.getDepartureOffset();
this.arrivalOffset = routeStop.getArrivalOffset();
this.awaitDepartureTime = routeStop.isAwaitDepartureTime();
// link value
this.linkCandidate = linkCandidate;
}
示例2: createStops
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
private void createStops() throws IOException {
log.info(" Read transit stops...");
BufferedReader readsLines = new BufferedReader(new InputStreamReader(new FileInputStream(pathToBFKOORD_GEOFile), "latin1"));
String newLine = readsLines.readLine();
while (newLine != null) {
/*
1−7 INT32 Nummer der Haltestelle
9−18 FLOAT X-Koordinate
20−29 FLOAT Y-Koordinate
31−36 INT16 Z-Koordinate (Tunnel und andere Streckenelemente ohne eigentliche Haltestelle haben keine Z-Koordinate)
38ff CHAR Kommentarzeichen "%"gefolgt vom Klartext des Haltestellennamens (optional zur besseren Lesbarkeit)
*/
Id<TransitStopFacility> stopId = Id.create(newLine.substring(0, 7), TransitStopFacility.class);
double xCoord = Double.parseDouble(newLine.substring(8, 18));
double yCoord = Double.parseDouble(newLine.substring(19, 29));
Coord coord = new Coord(xCoord, yCoord);
if (this.transformation != null) {
coord = this.transformation.transform(coord);
}
String stopName = newLine.substring(39, newLine.length());
createStop(stopId, coord, stopName);
newLine = readsLines.readLine();
}
readsLines.close();
log.info(" Read transit stops... done.");
}
示例3: PseudoRouteStopImpl
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* This constructor is only used to set dummy stops
*/
public PseudoRouteStopImpl(String id) {
if(id.equals(PseudoGraphImpl.SOURCE)) {
this.id = Id.create(PseudoGraphImpl.SOURCE, PseudoRouteStop.class);
this.travelCostToSource = 0;
} else {
this.id = Id.create(PseudoGraphImpl.DESTINATION, PseudoRouteStop.class);
}
previous = null;
this.linkId = null;
// stop facility values
this.coord = null;
this.parentStopFacilityId = null;
this.isBlockingLane = false;
this.facilityName = null;
this.stopPostAreaId = null;
// route stop values
this.departureOffset = 0.0;
this.arrivalOffset = 0.0;
this.awaitDepartureTime = false;
// link value
this.linkCandidate = null;
}
示例4: createId
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
static Id<PublicTransitStop> createId(TransitLine transitLine, TransitRoute transitRoute, TransitRouteStop transitRouteStop) {
return Id.create("[line:" + transitLine.getId() +
"][route:" + transitRoute.getId() +
"][stop:" + transitRouteStop.getStopFacility().getId() +
" arr:" + transitRouteStop.getArrivalOffset() +
" dep:" + transitRouteStop.getDepartureOffset() + "]",
PublicTransitStop.class);
}
示例5: getTransitRouteStops
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* @return the transit route stops of this route. Static schedule needs to be set.
*/
public List<TransitRouteStop> getTransitRouteStops() {
if(schedule == null) {
throw new RuntimeException("Schedule and stopFacilities not yet defined for FPLANRoute!");
}
for(Object[] t : tmpStops) {
Id<TransitStopFacility> stopFacilityId = Id.create((String) t[0], TransitStopFacility.class);
int arrivalTime = (int) t[1];
int departureTime = (int) t[2];
double arrivalDelay = 0.0;
if(arrivalTime > 0 && firstDepartureTime > 0) {
arrivalDelay = arrivalTime + initialDelay - firstDepartureTime;
}
double departureDelay = 0.0;
if(departureTime > 0 && firstDepartureTime > 0) {
departureDelay = departureTime + initialDelay - firstDepartureTime;
} else if(arrivalDelay > 0) {
departureDelay = arrivalDelay + initialDelay;
}
TransitStopFacility stopFacility = schedule.getFacilities().get(stopFacilityId);
TransitRouteStop routeStop = scheduleFactory.createTransitRouteStop(stopFacility, arrivalDelay, departureDelay);
routeStop.setAwaitDepartureTime(true); // Only *T-Lines (currently not implemented) would have this as false...
transitRouteStops.add(routeStop);
}
return transitRouteStops;
}
示例6: createLineId
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
private static Id<TransitLine> createLineId(FPLANRoute route) {
if(route.getOperator().equals("SBB")) {
long firstStopId;
long lastStopId;
// possible S-Bahn number
String sBahnNr = (route.getVehicleTypeId().toString().equals("S") && route.getRouteDescription() != null) ? route.getRouteDescription() : "";
try {
firstStopId = Long.parseLong(route.getFirstStopId());
lastStopId = Long.parseLong(route.getLastStopId());
} catch (NumberFormatException e) {
firstStopId = 0;
lastStopId = 1;
}
if(firstStopId < lastStopId) {
return Id.create("SBB_" + route.getVehicleTypeId() + sBahnNr + "_" + route.getFirstStopId() + "-" + route.getLastStopId(), TransitLine.class);
} else {
return Id.create("SBB_" + route.getVehicleTypeId() + sBahnNr + "_" + route.getLastStopId() + "-" + route.getFirstStopId(), TransitLine.class);
}
}
else if(route.getRouteDescription() == null) {
return Id.create(route.getOperator(), TransitLine.class);
} else {
return Id.create(route.getOperator() + "_line" + route.getRouteDescription(), TransitLine.class);
}
}
示例7: createStopFacilityFromOsmNode
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* creates a TransitStopFacility from an Node
*
* @return the created facility
*/
private TransitStopFacility createStopFacilityFromOsmNode(Osm.Node node, String stopPostAreaId) {
Id<TransitStopFacility> id = Id.create(node.getId(), TransitStopFacility.class);
Coord coord = transformation.transform(node.getCoord());
TransitStopFacility newStopFacility = factory.createTransitStopFacility(id, coord, false);
newStopFacility.setName(node.getValue(Osm.Key.NAME));
if(stopPostAreaId != null) {
newStopFacility.setStopPostAreaId(stopPostAreaId);
}
return newStopFacility;
}
示例8: useCloserRefLinkForChildStopFacility
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* If a link of <tt>comparingLinks</tt> is closer to the stop facility than
* its currently referenced link, the closest link is used.
*
* @return The id of the new closest link or <tt>null</tt> if the existing ref link
* was used.
*/
private static Id<Link> useCloserRefLinkForChildStopFacility(TransitSchedule schedule, Network network, TransitRoute transitRoute, TransitStopFacility stopFacility, Collection<? extends Link> comparingLinks) {
// check if previous link is closer to stop facility
double minDist = CoordTools.distanceStopFacilityToLink(stopFacility, network.getLinks().get(stopFacility.getLinkId()));
Link minLink = null;
for(Link comparingLink : comparingLinks) {
double distCompare = CoordTools.distanceStopFacilityToLink(stopFacility, comparingLink);
if(distCompare < minDist) {
minDist = distCompare;
minLink = comparingLink;
}
}
if(minLink != null) {
TransitStopFacility newChildStopFacility;
String[] split = stopFacility.getId().toString().split(suffixChildStopFacilitiesRegex);
Id<TransitStopFacility> newChildStopFacilityId = Id.create(split[0] + suffixChildStopFacilities + minLink.getId(), TransitStopFacility.class);
if(schedule.getFacilities().containsKey(newChildStopFacilityId)) {
newChildStopFacility = schedule.getFacilities().get(newChildStopFacilityId);
} else {
newChildStopFacility = schedule.getFactory().createTransitStopFacility(newChildStopFacilityId, stopFacility.getCoord(), false);
newChildStopFacility.setName(stopFacility.getName());
newChildStopFacility.setStopPostAreaId(stopFacility.getStopPostAreaId());
newChildStopFacility.setLinkId(minLink.getId());
schedule.addStopFacility(newChildStopFacility);
}
transitRoute.getStop(stopFacility).setStopFacility(newChildStopFacility);
return minLink.getId();
} else {
return null;
}
}
示例9: integrateNetwork
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* Integrates <tt>network B</tt> into <tt>network A</tt>. Network
* A contains all links and nodes of both networks
* after integration.
*/
public static void integrateNetwork(final Network networkA, final Network networkB) {
final NetworkFactory factory = networkA.getFactory();
// Nodes
for(Node node : networkB.getNodes().values()) {
Id<Node> nodeId = Id.create(node.getId().toString(), Node.class);
if(!networkA.getNodes().containsKey(nodeId)) {
Node newNode = factory.createNode(nodeId, node.getCoord());
networkA.addNode(newNode);
}
}
// Links
double capacityFactor = networkA.getCapacityPeriod() / networkB.getCapacityPeriod();
for(Link link : networkB.getLinks().values()) {
Id<Link> linkId = Id.create(link.getId().toString(), Link.class);
if(!networkA.getLinks().containsKey(linkId)) {
Id<Node> fromNodeId = Id.create(link.getFromNode().getId().toString(), Node.class);
Id<Node> toNodeId = Id.create(link.getToNode().getId().toString(), Node.class);
Link newLink = factory.createLink(linkId, networkA.getNodes().get(fromNodeId), networkA.getNodes().get(toNodeId));
newLink.setAllowedModes(link.getAllowedModes());
newLink.setCapacity(link.getCapacity() * capacityFactor);
newLink.setFreespeed(link.getFreespeed());
newLink.setLength(link.getLength());
newLink.setNumberOfLanes(link.getNumberOfLanes());
networkA.addLink(newLink);
}
}
}
示例10: loadShapes
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* Loads shapes (if available) and puts them in {@link #shapes}. A shape is a sequence of points, i.e. a line.
* <p/>
* <br/><br/>
* shapes.txt <i>[https://developers.google.com/transit/gtfs/reference]</i><br/>
* Rules for drawing lines on a map to represent a transit organization's routes.
*/
private void loadShapes() {
// shapes are optional
log.info("Looking for shapes.txt");
try {
CSVReader reader = createCSVReader(root + GtfsDefinitions.Files.SHAPES.fileName);
String[] header = reader.readNext();
Map<String, Integer> col = getIndices(header, GtfsDefinitions.Files.SHAPES.columns, GtfsDefinitions.Files.SHAPES.optionalColumns);
String[] line = reader.readNext();
while(line != null) {
usesShapes = true; // shape file might exists but could be empty
Id<RouteShape> shapeId = Id.create(line[col.get(GtfsDefinitions.SHAPE_ID)], RouteShape.class);
RouteShape currentShape = shapes.get(shapeId);
if(currentShape == null) {
currentShape = new GtfsShape(line[col.get(GtfsDefinitions.SHAPE_ID)]);
shapes.put(shapeId, currentShape);
}
Coord point = new Coord(Double.parseDouble(line[col.get(GtfsDefinitions.SHAPE_PT_LON)]), Double.parseDouble(line[col.get(GtfsDefinitions.SHAPE_PT_LAT)]));
currentShape.addPoint(point, Integer.parseInt(line[col.get(GtfsDefinitions.SHAPE_PT_SEQUENCE)]));
line = reader.readNext();
}
reader.close();
log.info("... shapes.txt loaded");
} catch (IOException e) {
log.info("... no shapes file found.");
} catch (ArrayIndexOutOfBoundsException i) {
throw new RuntimeException("Emtpy line found in shapes.txt");
}
}
示例11: createFacilitiesAndLinkSequences
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
@Override
public void createFacilitiesAndLinkSequences(TransitSchedule schedule) {
TransitScheduleFactory scheduleFactory = schedule.getFactory();
for(PseudoTransitRoute pseudoTransitRoute : pseudoSchedule) {
List<PseudoRouteStop> pseudoStopSequence = pseudoTransitRoute.getPseudoStops();
List<TransitRouteStop> newStopSequence = new ArrayList<>();
for(PseudoRouteStop pseudoStop : pseudoStopSequence) {
String idStr = pseudoStop.getParentStopFacilityId() + PublicTransitMappingStrings.SUFFIX_CHILD_STOP_FACILITIES + pseudoStop.getLinkId();
Id<TransitStopFacility> childStopFacilityId = Id.create(idStr, TransitStopFacility.class);
// if child stop facility for this link has not yet been generated
if(!schedule.getFacilities().containsKey(childStopFacilityId)) {
TransitStopFacility newFacility = scheduleFactory.createTransitStopFacility(
Id.create(childStopFacilityId, TransitStopFacility.class),
pseudoStop.getCoord(),
pseudoStop.isBlockingLane()
);
newFacility.setLinkId(pseudoStop.getLinkId());
newFacility.setName(pseudoStop.getFacilityName());
newFacility.setStopPostAreaId(pseudoStop.getStopPostAreaId());
schedule.addStopFacility(newFacility);
}
// create new TransitRouteStop and add it to the newStopSequence
TransitRouteStop newTransitRouteStop = scheduleFactory.createTransitRouteStop(
schedule.getFacilities().get(childStopFacilityId),
pseudoStop.getArrivalOffset(),
pseudoStop.getDepartureOffset());
newTransitRouteStop.setAwaitDepartureTime(pseudoStop.awaitsDepartureTime());
newStopSequence.add(newTransitRouteStop);
}
// create a new transitRoute
TransitRoute newTransitRoute = scheduleFactory.createTransitRoute(pseudoTransitRoute.getTransitRoute().getId(), null, newStopSequence, pseudoTransitRoute.getTransitRoute().getTransportMode());
// add departures
pseudoTransitRoute.getTransitRoute().getDepartures().values().forEach(newTransitRoute::addDeparture);
// add link sequence
List<Id<Link>> l = pseudoTransitRoute.getNetworkLinkIdList();
newTransitRoute.setRoute(new LinkNetworkRouteImpl(l.get(0), l.subList(1, l.size() - 1), l.get(l.size() - 1)));
// add description
newTransitRoute.setDescription(pseudoTransitRoute.getTransitRoute().getDescription());
// remove the old route
schedule.getTransitLines().get(pseudoTransitRoute.getTransitLineId()).removeRoute(pseudoTransitRoute.getTransitRoute());
// add new route to container
schedule.getTransitLines().get(pseudoTransitRoute.getTransitLineId()).addRoute(newTransitRoute);
//newRoutes.add(new Tuple<>(pseudoTransitRoute.getTransitLineId(), newRoute));
}
}
示例12: createChildStopFacilityId
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
/**
* Creates a standard child facility id
*/
private Id<TransitStopFacility> createChildStopFacilityId(String stopIdStr, String refLinkId) {
return Id.create(getParentId(stopIdStr) + SUFFIX + refLinkId, TransitStopFacility.class);
}
示例13: AbstractPlausibilityWarning
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
public AbstractPlausibilityWarning(Type type, TransitLine transitLine, TransitRoute transitRoute) {
this.id = Id.create(idLong++, PlausibilityWarning.class);
this.type = type;
this.transitLine = transitLine;
this.transitRoute = transitRoute;
}
示例14: createLineId
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
private Id<TransitLine> createLineId(Osm.Relation relation) {
return Id.create(createStringId(relation), TransitLine.class);
}
示例15: Relation
import org.matsim.api.core.v01.Id; //导入方法依赖的package包/类
public Relation(long id, Map<String, String> tags) {
this.id = Id.create(id, Osm.Relation.class);
this.tags = tags;
}