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


Java PointList.size方法代码示例

本文整理汇总了Java中com.graphhopper.util.PointList.size方法的典型用法代码示例。如果您正苦于以下问题:Java PointList.size方法的具体用法?Java PointList.size怎么用?Java PointList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.graphhopper.util.PointList的用法示例。


在下文中一共展示了PointList.size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArrivalDirection

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
private ArrivalDirection getArrivalDirection(PointList points, Coordinate destination)
{
	if (points.size() < 2)
		return ArrivalDirection.Unknown;

	int lastIndex = points.size() - 1;
	double lon0 = points.getLon(lastIndex - 1);
	double lat0 = points.getLat(lastIndex - 1);
	double lon1 = points.getLon(lastIndex);
	double lat1 = points.getLat(lastIndex);

	double dist = _distCalc.calcDist(lat1, lon1, destination.y, destination.x);

	if (dist < 1)
		return ArrivalDirection.StraightAhead; 
	else
	{
		double sign = Math.signum((lon1 - lon0) * (destination.y - lat0) - (lat1 - lat0) * (destination.x - lon0));
		if (sign == 0)
			return ArrivalDirection.StraightAhead;
		else if (sign == 1)
			return ArrivalDirection.Left;
		else
			return ArrivalDirection.Right;
	}
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:27,代码来源:RouteResultBuilder.java

示例2: calculateJTSRouteGeom

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
public static Geometry calculateJTSRouteGeom(CHMatrixGeneration cmg,LatLong from, LatLong to) {
	GHResponse rsp = cmg.getResponse(new GHPoint(from.getLatitude(), from.getLongitude()), new GHPoint(to.getLatitude(), to.getLongitude()));

	if (rsp==null || rsp.hasErrors()) {
		return null;
	}

	PointList pointList = rsp.getPoints();
	int n = pointList.size();
	if (n < 2) {
		return null;
	}

	Coordinate[] coords = new Coordinate[n];
	for (int i = 0; i < n; i++) {
		coords[i] = new Coordinate(pointList.getLongitude(i), pointList.getLatitude(i));
	}

	GeometryFactory factory = new GeometryFactory();
	Geometry geometry = factory.createLineString(coords);
	return geometry;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:23,代码来源:CHMatrixGenWithGeomFuncs.java

示例3: getEdgeGeometry

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
public Geometry getEdgeGeometry(int edgeId, int mode, int adjnodeid) 	
{ 	
	EdgeIteratorState iter = mGraphHopper.getGraphHopperStorage().getEdgeIteratorState(edgeId, adjnodeid); 	
	PointList points = iter.fetchWayGeometry(mode); 	
	if (points.size() > 1) 		{ 		
		Coordinate[] coords = new Coordinate[points.size()]; 	
		for (int i = 0; i < points.size(); i++) { 		
			double x = points.getLon(i); 			
			double y = points.getLat(i); 	
			coords[i] = new Coordinate(x, y); 	
		} 		
		return new GeometryFactory().createLineString(coords); 		} 	
	return null; 
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:15,代码来源:RoutingProfile.java

示例4: getHeadingDirection

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
private double getHeadingDirection(GHResponse resp)
{
	PointList points = resp.getBest().getPoints();
	int nPoints = points.size();
	if (nPoints > 1)
	{
		double lon1 = points.getLon(nPoints - 2);
		double lat1 = points.getLat(nPoints - 2);
		double lon2 = points.getLon(nPoints - 1);
		double lat2 = points.getLat(nPoints - 1);
		return Helper.ANGLE_CALC.calcAzimuth(lat1, lon1, lat2, lon2);
	}
	else
		return 0;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:16,代码来源:RoutingProfileManager.java

示例5: getTurnAngle

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
private double getTurnAngle(PointList currEdgeGeom, PointList prevEdgeGeom)
{
	if (currEdgeGeom.size() >= 1 && prevEdgeGeom.size() >= 1)
	{
		int locIndex = prevEdgeGeom.size() - 1;
		double lon0 = prevEdgeGeom.getLon(locIndex - 1);
		double lat0 = prevEdgeGeom.getLat(locIndex - 1);
		double lon1 = prevEdgeGeom.getLon(locIndex);
		double lat1 = prevEdgeGeom.getLat(locIndex);

		double bearingBefore = Math.round(_angleCalc.calcAzimuth(lat0, lon0, lat1, lon1));

		double lon2 = currEdgeGeom.getLon(1);
		double lat2 = currEdgeGeom.getLat(1);

		double bearingAfter = (int)Math.round(_angleCalc.calcAzimuth(lat1, lon1, lat2, lon2));
		//bearingAfter =  _angleCalc.alignOrientation(bearingBefore, bearingAfter);
		double res = Math.abs(bearingBefore - bearingAfter);
		if (res > 180)
		{
			res = 360 - res;
			return res;
		}
		
		return res;
	}

	return 0.0;	
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:30,代码来源:AccelerationWeighting.java

示例6: getEdgeSegments

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
/**
 * Identifies all subways including those between pillar nodes and returns
 * the way segments of all of them.
 * 
 * @param wayId
 *            if of the OSM way
 * @param baseNodeId
 *            id of the base node
 * @param adjNodeId
 *            id of the adjacent node
 * @param edgeState
 * @return the ids of all way segments of the way {@code wayId} between the
 *         base node {@code baseNodeId} and the adjacent node
 *         {@code adjNodeId}
 */
List<WaySegmentId> getEdgeSegments(long wayId, long baseNodeId,
		long adjNodeId, EdgeIteratorState edgeState) {

	OSMData osmData = hopper.getOsmData();

	// if the edge is virtual there are no data available because there is
	// now corresponding OSM way so we just return an empty list
	if (isVirtualEdge(edgeState.getEdge())) {
		logger.debug("virtual edge " + edgeState.getEdge() + ", distance = "
				+ edgeState.getDistance());

		return new ArrayList<>();
	}

	PointList wayPoints = edgeState.fetchWayGeometry(3);
	List<Node> wayNodes = osmData.getWayNodes(wayId);
	List<Long> wayNodeIds = wayNodes.stream().map(Node::getId)
			.collect(Collectors.toList());

	Long optAdjId = wayNodeIds.contains(adjNodeId) ? adjNodeId : null;

	// find the way nodes between the base node and the adjacent node
	List<Node> edgeNodes = wayNodeSearcher.getWayNodes(wayId, wayPoints,
			baseNodeId, optAdjId, edgeState);

	if (edgeNodes.size() != wayPoints.size()) {
		logger.debug("different number of wayNodes found: edgeNodes"
				+ edgeNodes + "\nwayPoints = " + wayPoints);
		return new ArrayList<>();
	}

	return Seq.seq(edgeNodes).sliding(2).map(s -> {
		List<Node> l = s.collect(Collectors.toList());
		return new WaySegmentId(wayId,
				Pair.of(l.get(0).getId(), l.get(1).getId()));
	}).collect(Collectors.toList());
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:53,代码来源:HeatStressWeighting.java

示例7: convertToTree

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
static JsonNode convertToTree(MatchResult result, ObjectMapper objectMapper) {
    ObjectNode root = objectMapper.createObjectNode();
    ObjectNode diary = root.putObject("diary");
    ArrayNode entries = diary.putArray("entries");
    ObjectNode route = entries.addObject();
    ArrayNode links = route.putArray("links");
    for (int emIndex = 0; emIndex < result.getEdgeMatches().size(); emIndex++) {
        ObjectNode link = links.addObject();
        EdgeMatch edgeMatch = result.getEdgeMatches().get(emIndex);
        PointList pointList = edgeMatch.getEdgeState().fetchWayGeometry(emIndex == 0 ? 3 : 2);
        final ObjectNode geometry = link.putObject("geometry");
        if (pointList.size() < 2) {
            geometry.putArray("coordinates").add(objectMapper.convertValue(pointList.toGeoJson().get(0), JsonNode.class));
            geometry.put("type", "Point");
        } else {
            geometry.putArray("coordinates").addAll(objectMapper.convertValue(pointList.toGeoJson(), ArrayNode.class));
            geometry.put("type", "LineString");
        }
        link.put("id", edgeMatch.getEdgeState().getEdge());
        ArrayNode wpts = link.putArray("wpts");
        for (GPXExtension extension : edgeMatch.getGpxExtensions()) {
            ObjectNode wpt = wpts.addObject();
            wpt.put("x", extension.getQueryResult().getSnappedPoint().lon);
            wpt.put("y", extension.getQueryResult().getSnappedPoint().lat);
            wpt.put("timestamp", extension.getEntry().getTime());
        }
    }
    return root;
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:30,代码来源:MatchResultToJson.java

示例8: buildRoads

import com.graphhopper.util.PointList; //导入方法依赖的package包/类
private void buildRoads(Label label) {
	if (label == null || label.edge == -1) {
		return;
	}
	long currentTime;
	final PointList pointList = new PointList();
	int numberOfTransfers = 0;

	double lastLat = Double.NaN;
	double lastLon = Double.NaN;
	Label currentLabel = label;
	currentTime = currentLabel.currentTime;
	do {
		numberOfTransfers += currentLabel.nTransfers;
		final EdgeIteratorState state = storage.getEdgeIteratorState(
				currentLabel.edge, currentLabel.adjNode);
		final PointList geometry = state.fetchWayGeometry(3);
		for (int index = geometry.getSize() - 1; index >= 0; index--) {
			double currentLat = geometry.getLat(index);
			double currentLon = geometry.getLon(index);
			if (Double.doubleToLongBits(currentLat) != Double
					.doubleToLongBits(lastLat)
					&& Double.doubleToLongBits(currentLon) != Double
							.doubleToLongBits(lastLon)) {
				pointList.add(currentLat, currentLon);
			}
			lastLat = currentLat;
			lastLon = currentLon;

		}
		currentLabel = currentLabel.parent;
	} while (currentLabel != null && currentLabel.edge != -1
			&& pointList.size() < 2);
	if (pointList.size() < 2) {
		System.out.println(MessageFormat.format("Point list size is {0}.",
				pointList.size()));
	}

	pointList.reverse();
	final Road road = new Road(currentTime, numberOfTransfers, pointList);

	roads.compute(road.getPointList(), (key, oldRoad) -> {
		if (oldRoad == null) {
			return road;
		} else {
			return oldRoad.increadNumberOfThreads();
		}
	});
	buildRoads(currentLabel);
}
 
开发者ID:highsource,项目名称:roads-to,代码行数:51,代码来源:RoadBuilder.java


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