当前位置: 首页>>代码示例>>Java>>正文


Java Id类代码示例

本文整理汇总了Java中org.matsim.api.core.v01.Id的典型用法代码示例。如果您正苦于以下问题:Java Id类的具体用法?Java Id怎么用?Java Id使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Id类属于org.matsim.api.core.v01包,在下文中一共展示了Id类的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;
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:24,代码来源:PseudoRouteStopImpl.java

示例2: prepare

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
@Before
public void prepare() {
	ptmConfig = initPTMConfig();
	network = NetworkToolsTest.initNetwork();
	schedule = ScheduleToolsTest.initSchedule();
	ScheduleCleaner.combineChildStopsToParentStop(schedule);
	ScheduleCleaner.removeMapping(schedule);
	ScheduleCleaner.removeNotUsedStopFacilities(schedule);

	Map<Id<RouteShape>, RouteShape> shapes = ShapeToolsTest.initShapes();
	ScheduleRouters scheduleRouters = new ScheduleRoutersGtfsShapes(schedule, network, shapes, ptmConfig.getTransportModeAssignment(), PublicTransitMappingConfigGroup.TravelCostType.linkLength, 10.0, 99);

	new PTMapper(schedule, network).run(ptmConfig, scheduleRouters);

	ScheduleCleaner.removeNotUsedStopFacilities(schedule);
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:17,代码来源:PTMapperShapesTest.java

示例3: createStop

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
private void createStop(Id<TransitStopFacility> stopId, Coord coord, String stopName) {

		//check if coordinates are already used by another facility
		String check = usedCoordinates.put(coord, stopName);
		if(check != null && !check.equals(stopName)) {
			if(check.contains(stopName) || stopName.contains(check)) {
				log.info("Two stop facilities at " + coord + " \"" + check + "\" & \"" + stopName + "\"");
			} else {
				log.warn("Two stop facilities at " + coord + " \"" + check + "\" & \"" + stopName + "\"");
			}
		}

		TransitStopFacility stopFacility = this.scheduleBuilder.createTransitStopFacility(stopId, coord, false);
		stopFacility.setName(stopName);
		this.schedule.addStopFacility(stopFacility);
	}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:17,代码来源:StopReader.java

示例4: convertShapes

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
public static void convertShapes() {
	TransitSchedule schedule = ScheduleTools.readTransitSchedule(inputScheduleFile);

	Map<Id<RouteShape>, RouteShape> shapes = ShapeTools.readShapesFile(gtfsShapeFile, coordSys);
	Map<Id<RouteShape>, RouteShape> shapesToConvert = new HashMap<>();


	for(TransitLine transitLine : schedule.getTransitLines().values()) {
		for(TransitRoute transitRoute : transitLine.getRoutes().values()) {
			Id<RouteShape> id = ScheduleTools.getShapeId(transitRoute);
			shapesToConvert.put(id, shapes.get(id));
		}
	}


	ShapeTools.writeESRIShapeFile(shapesToConvert.values(), coordSys, base + "output/shp/gtfs.shp");
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:18,代码来源:ZVVexample.java

示例5: runMappingShapes

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * Maps a schedule with gtfs shape information to the network
 */
public static void runMappingShapes() {
	System.out.println("===================");
	System.out.println("Run mapping: SHAPES");
	System.out.println("===================");

	TransitSchedule schedule = ScheduleTools.readTransitSchedule(inputScheduleFile);
	Network network = NetworkTools.readNetwork(inputNetworkFile);

	PublicTransitMappingConfigGroup config = PublicTransitMappingConfigGroup.createDefaultConfig();
	Map<Id<RouteShape>, RouteShape> shapes = ShapeTools.readShapesFile(gtfsShapeFile, coordSys);

	ScheduleRouters router = new ScheduleRoutersGtfsShapes(schedule, network, shapes, config.getTransportModeAssignment(), config.getTravelCostType(), 50, 250);

	PTMapper ptMapper = new PTMapper(schedule, network);
	ptMapper.run(config, router);

	NetworkTools.writeNetwork(network, outputNetwork2);
	ScheduleTools.writeTransitSchedule(schedule, outputSchedule2);

	// analysis
	runAnalysis(outputSchedule2, outputNetwork2);
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:26,代码来源:ZVVexample.java

示例6: filterOneRoutePerLine

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
private static void filterOneRoutePerLine(TransitSchedule schedule) {
	for(TransitLine transitLine : new HashSet<>(schedule.getTransitLines().values())) {
		int maxDep = 0;
		Id<TransitRoute> max = null;
		for(TransitRoute transitRoute : transitLine.getRoutes().values()) {
			if(transitRoute.getDepartures().size() > maxDep) {
				maxDep = transitRoute.getDepartures().size();
				max = transitRoute.getId();
			}
		}

		for(TransitRoute t : new HashSet<>(transitLine.getRoutes().values())) {
			if(!t.getId().equals(max)) {
				transitLine.removeRoute(t);
			}
		}
	}
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:19,代码来源:ZVVexample.java

示例7: rerouteViaLink

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * Reroutes the section between two stops that passes the oldlink via the new link
 * @param transitRoute the transit route
 * @param oldLinkId the section between two route stops where this link appears is rerouted
 * @param newLinkId the section is routed via this link
 */
@Override
public void rerouteViaLink(TransitLine transitLine, TransitRoute transitRoute, Id<Link> oldLinkId, Id<Link> newLinkId) {
	List<TransitRouteStop> stopSequence = transitRoute.getStops();
	List<Id<Link>> linkSequence = transitRoute.getRoute().getLinkIds();

	List<Id<Link>> refLinkIds = stopSequence.stream().map(routeStop -> routeStop.getStopFacility().getLinkId()).collect(Collectors.toList());

	if(refLinkIds.contains(oldLinkId)) {
		throw new IllegalArgumentException("Link is referenced to a stop facility, rerouteViaLink cannot be performed. Use changeRefLink instead.");
	} else {
		int i = 0;
		TransitRouteStop fromRouteStop = stopSequence.get(i);
		for(Id<Link> linkId : linkSequence) {
			if(linkId.equals(oldLinkId)) {
				rerouteFromStop(transitLine, transitRoute, fromRouteStop, newLinkId);
				break;
			}
			if(linkId.equals(refLinkIds.get(i))) {
				fromRouteStop = stopSequence.get(i++);
				i++;
			}
		}
	}
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:31,代码来源:BasicScheduleEditor.java

示例8: addPTModeToNetwork

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * Add mode "pt" to any link of the network that is
 * passed by any transitRoute of the schedule.
 */
public static void addPTModeToNetwork(TransitSchedule schedule, Network network) {
	log.info("... Adding mode \"pt\" to all links with public transit");

	Map<Id<Link>, ? extends Link> networkLinks = network.getLinks();
	Set<Id<Link>> transitLinkIds = new HashSet<>();

	for(TransitLine line : schedule.getTransitLines().values()) {
		for(TransitRoute transitRoute : line.getRoutes().values()) {
			if(transitRoute.getRoute() != null) {
				transitLinkIds.addAll(getTransitRouteLinkIds(transitRoute));
			}
		}
	}

	for(Id<Link> transitLinkId : transitLinkIds) {
		Link transitLink = networkLinks.get(transitLinkId);
		if(!transitLink.getAllowedModes().contains(TransportMode.pt)) {
			Set<String> modes = new HashSet<>();
			modes.addAll(transitLink.getAllowedModes());
			modes.add(TransportMode.pt);
			transitLink.setAllowedModes(modes);
		}
	}
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:29,代码来源:ScheduleTools.java

示例9: changeRefLink

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * - Changes the referenced link of a stopfacility. Effectively creates a new child stop facility.
 * ["changeRefLink"] [StopFacilityId] [newlinkId]
 * ["changeRefLink"] [TransitLineId] [TransitRouteId] [ParentId] [newlinkId]
 * ["changeRefLink"] ["allTransitRoutesOnLink"] [linkId] [ParentId] [newlinkId]
 */
@Test
public void changeRefLink() throws Exception {
	TransitSchedule schedule = initSchedule();
	Network network = NetworkToolsTest.initNetwork();

	String[] cmd = new String[]{ScheduleEditor.CHANGE_REF_LINK, ScheduleEditor.ALL_TRANSIT_ROUTES_ON_LINK, "XA", "stop3.link:XA", "XB"};

	new BasicScheduleEditor(schedule, network).executeCmdLine(cmd);

	List<Id<Link>> linkIds = ScheduleTools.getTransitRouteLinkIds(schedule.getTransitLines().get(LINE_B).getRoutes().get(ROUTE_B));

	List<Id<Link>> linkIdsExpected = new ArrayList<>();
	linkIdsExpected.add(Id.createLinkId("EW"));
	linkIdsExpected.add(Id.createLinkId("WD"));
	linkIdsExpected.add(Id.createLinkId("DA"));
	linkIdsExpected.add(Id.createLinkId("AX"));
	linkIdsExpected.add(Id.createLinkId("XB"));
	linkIdsExpected.add(Id.createLinkId("BA"));
	linkIdsExpected.add(Id.createLinkId("AH"));
	linkIdsExpected.add(Id.createLinkId("HZ"));
	linkIdsExpected.add(Id.createLinkId("ZI"));
	linkIdsExpected.add(Id.createLinkId("IB"));

	Assert.assertEquals(linkIdsExpected, linkIds);
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:32,代码来源:BasicScheduleEditorTest.java

示例10: getOppositeLink

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * @return the opposite direction link. <tt>null</tt> if there is no opposite link.
 */
public static Link getOppositeLink(Link link) {
	if(link == null) {
		return null;
	}

	Link oppositeDirectionLink = null;
	Map<Id<Link>, ? extends Link> inLinks = link.getFromNode().getInLinks();
	if(inLinks != null) {
		for(Link inLink : inLinks.values()) {
			if(inLink.getFromNode().equals(link.getToNode())) {
				oppositeDirectionLink = inLink;
			}
		}
	}

	return oppositeDirectionLink;
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:21,代码来源:NetworkTools.java

示例11: rerouteViaLink

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * Possible Commands:
 * - Reroute TransitRoute via new Link
 * ["rerouteViaLink"] [TransitLineId] [TransitRouteId] [oldLinkId] [newLinkId]
 */
@Test
public void rerouteViaLink() throws Exception {
	TransitSchedule schedule = initSchedule();
	Network network = NetworkToolsTest.initNetwork();

	String[] cmd = new String[]{ScheduleEditor.RR_VIA_LINK, LINE_B.toString(), ROUTE_B.toString(), "CX", "CB"};

	new BasicScheduleEditor(schedule, network).executeCmdLine(cmd);

	List<Id<Link>> linkIds = ScheduleTools.getTransitRouteLinkIds(schedule.getTransitLines().get(LINE_B).getRoutes().get(ROUTE_B));

	List<Id<Link>> linkIdsExpected = new ArrayList<>();
	linkIdsExpected.add(Id.createLinkId("EW"));
	linkIdsExpected.add(Id.createLinkId("WD"));
	linkIdsExpected.add(Id.createLinkId("DC"));
	linkIdsExpected.add(Id.createLinkId("CB"));
	linkIdsExpected.add(Id.createLinkId("BX"));
	linkIdsExpected.add(Id.createLinkId("XA"));
	linkIdsExpected.add(Id.createLinkId("AH"));
	linkIdsExpected.add(Id.createLinkId("HZ"));
	linkIdsExpected.add(Id.createLinkId("ZI"));
	linkIdsExpected.add(Id.createLinkId("IB"));

	Assert.assertEquals(linkIdsExpected, linkIds);
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:31,代码来源:BasicScheduleEditorTest.java

示例12: createStopFacility

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * creates a new stop facility and adds it to the schedule
 */
public TransitStopFacility createStopFacility(Id<TransitStopFacility> facilityId, Coord coord, String name, Id<Link> linkId) {
	TransitStopFacility newTransitStopFacility = scheduleFactory.createTransitStopFacility(facilityId, coord, false);
	newTransitStopFacility.setName(name);
	newTransitStopFacility.setLinkId(linkId);
	return newTransitStopFacility;
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:10,代码来源:BasicScheduleEditor.java

示例13: initShapes

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
public static Map<Id<RouteShape>, RouteShape> initShapes() {
	Map<Id<RouteShape>, RouteShape> shapes = new HashMap<>();

	RouteShape shapeA1 = new GtfsShape("A1");
	shapeA1.addPoint(coordE, 1);
	shapeA1.addPoint(coordD, 2);
	shapeA1.addPoint(coordA, 3);
	shapeA1.addPoint(coordX, 4);
	shapeA1.addPoint(coordB, 5);
	shapeA1.addPoint(coordI, 6);
	shapes.put(shapeA1.getId(), shapeA1);

	RouteShape shapeA2 = new GtfsShape("A2");
	shapeA2.addPoint(offset(coordE), 6);
	shapeA2.addPoint(offset(coordD), 5);
	shapeA2.addPoint(offset(coordA), 4);
	shapeA2.addPoint(offset(coordX), 3);
	shapeA2.addPoint(offset(coordB), 2);
	shapeA2.addPoint(offset(coordI), 1);
	shapes.put(shapeA2.getId(), shapeA2);

	RouteShape shapeB = new GtfsShape("B");
	shapeB.addPoint(coordE, 1);
	shapeB.addPoint(coordW, 2);
	shapeB.addPoint(coordD, 3);
	shapeB.addPoint(coordC, 4);
	shapeB.addPoint(coordX, 5);
	shapeB.addPoint(coordA, 6);
	shapeB.addPoint(coordH, 7);
	shapeB.addPoint(coordZ, 8);
	shapeB.addPoint(coordI, 9);
	shapes.put(shapeB.getId(), shapeB);

	return shapes;
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:36,代码来源:ShapeToolsTest.java

示例14: refreshTransitRoute

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
/**
 * "Refreshes" the transit route by routing between all referenced links
 * of the stop facilities.
 */
@Override
public void refreshTransitRoute(TransitLine transitLine, TransitRoute transitRoute) {
	List<TransitRouteStop> routeStops = transitRoute.getStops();
	List<Id<Link>> linkSequence = new ArrayList<>();
	linkSequence.add(routeStops.get(0).getStopFacility().getLinkId());

	// route
	for(int i = 0; i < routeStops.size() - 1; i++) {
		if(routeStops.get(i).getStopFacility().getLinkId() == null) {
			throw new IllegalArgumentException("stop facility " + routeStops.get(i).getStopFacility().getName() + " (" + routeStops.get(i).getStopFacility().getId() + " not referenced!");
		}
		if(routeStops.get(i + 1).getStopFacility().getLinkId() == null) {
			throw new IllegalArgumentException("stop facility " + routeStops.get(i - 1).getStopFacility().getName() + " (" + routeStops.get(i + 1).getStopFacility().getId() + " not referenced!");
		}

		Id<Link> currentLinkId = Id.createLinkId(routeStops.get(i).getStopFacility().getLinkId().toString());

		Link currentLink = network.getLinks().get(currentLinkId);
		Link nextLink = network.getLinks().get(routeStops.get(i + 1).getStopFacility().getLinkId());

		List<Id<Link>> path = PTMapperTools.getLinkIdsFromPath(routers.calcLeastCostPath(currentLink.getToNode().getId(), nextLink.getFromNode().getId(), transitLine, transitRoute));

		if(path != null)
			linkSequence.addAll(path);

		linkSequence.add(nextLink.getId());
	}

	// add link sequence to schedule
	transitRoute.setRoute(RouteUtils.createNetworkRoute(linkSequence, network));
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:36,代码来源:BasicScheduleEditor.java

示例15: removeWay

import org.matsim.api.core.v01.Id; //导入依赖的package包/类
@Override
public void removeWay(Id<Osm.Way> id) {
	Osm.Way w = ways.get(id);
	for(Osm.Node n : w.getNodes()) {
		n.getWays().remove(w.getId());
	}
	removeMemberFromRelations(w);
	ways.remove(id);
}
 
开发者ID:matsim-org,项目名称:pt2matsim,代码行数:10,代码来源:OsmDataImpl.java


注:本文中的org.matsim.api.core.v01.Id类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。