本文整理汇总了Java中com.graphhopper.util.PointList类的典型用法代码示例。如果您正苦于以下问题:Java PointList类的具体用法?Java PointList怎么用?Java PointList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PointList类属于com.graphhopper.util包,在下文中一共展示了PointList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: getHillIndex
import com.graphhopper.util.PointList; //导入依赖的package包/类
public byte getHillIndex(PointList points, boolean reverse)
{
SteepnessUtil.computeRouteSplits(points, reverse, distCalc, splits);
double totalVerticalClimb = 0.0;
double excessSteepClimb = 0.0;
double totalDistance = 0.0;
for(RouteSplit split : splits)
{
double gradient = split.Gradient;
if (gradient > 0)
{
double vc = split.VerticalClimb*3.28084;
totalVerticalClimb += vc;
gradient = Math.min(split.Gradient, 30);
}
totalDistance += split.Length*0.000621371;
}
int hillIndex = (int)(100*(totalVerticalClimb + excessSteepClimb)/(5280*totalDistance));
return (hillIndex >= 35) ? 35 : (byte)hillIndex;
}
示例3: processPoints
import com.graphhopper.util.PointList; //导入依赖的package包/类
@Override
public PointList processPoints(PointList points)
{
PointList result = points;
if (points.is3D())
result = ElevationSmoother.smooth(points);
if (_steepnessInfoBuilder != null)
{
// compute steepness information only after elevation data is smoothed.
_steepnessInfoBuilder.addPoints(result);
}
return result;
}
示例4: getPoints
import com.graphhopper.util.PointList; //导入依赖的package包/类
private Point2D[] getPoints(PointList points)
{
List<Point2D> res = new ArrayList<Point2D>(points.getSize());
double lon0 = 0, lat0 = 0, lon1, lat1;
for (int i = 0; i < points.getSize(); i++)
{
lon1 = points.getLon(i);
lat1 = points.getLat(i);
if (i > 0)
{
if (lon0 == lon1 || lat0 == lat1)
continue;
}
Point2D p = new Point2D.Double(lon1, lat1);
res.add(p);
lon0 = lon1;
lat0 = lat1;
}
return res.toArray(new Point2D[res.size()]);
}
示例5: arePolylinesAdjacent
import com.graphhopper.util.PointList; //导入依赖的package包/类
private boolean arePolylinesAdjacent(PointList pl1, PointList pl2)
{
for (int i = 0; i < pl1.getSize(); i++)
{
double lon0 = pl1.getLon(i);
double lat0 = pl1.getLat(i);
for (int j = 0; j < pl2.getSize(); j++)
{
double lon1 = pl2.getLon(j);
double lat1 = pl2.getLat(j);
if (lon0 == lon1 && lat0 == lat1)
return true;
}
}
return false;
}
示例6: RoutingResultRecord
import com.graphhopper.util.PointList; //导入依赖的package包/类
public RoutingResultRecord(int id, int iteration, LocalDateTime timePoint,
String method, Node from, Node to, double dist,
double costTemperature, double costHeatIndex, double duration,
PointList path) {
this.id = id;
this.iteration = iteration;
this.timePoint = timePoint;
this.method = method;
this.from = from;
this.to = to;
this.dist = dist;
this.costTemperature = costTemperature;
this.costHeatIndex = costHeatIndex;
this.duration = duration;
this.path = path;
}
示例7: addLabel
import com.graphhopper.util.PointList; //导入依赖的package包/类
public void addLabel(Label label) {
double lastLat = storage.getNodeAccess().getLat(label.adjNode);
double lastLon = storage.getNodeAccess().getLon(label.adjNode);
final PointList lastPoint = new PointList(1, false);
lastPoint.add(lastLat, lastLon);
labels.compute(lastPoint, (key, oldLabel) -> {
if (oldLabel == null) {
return label;
} else if (label.currentTime < oldLabel.currentTime) {
return label;
} else {
return oldLabel;
}
});
}
示例8: createPolyline
import com.graphhopper.util.PointList; //导入依赖的package包/类
/**
* draws a connected series of line segments specified by a list of LatLongs.
*
* @param pointList
* @param color: the color of the polyline
* @param strokeWidth: the stroke width of the polyline
* @return Polyline
*/
public Polyline createPolyline(PointList pointList, int color, int strokeWidth) {
Paint paintStroke = AndroidGraphicFactory.INSTANCE.createPaint();
paintStroke.setStyle(Style.STROKE);
paintStroke.setStrokeJoin(Join.ROUND);
paintStroke.setStrokeCap(Cap.ROUND);
paintStroke.setColor(color);
// paintStroke.setDashPathEffect(new float[]{25, 25});
paintStroke.setStrokeWidth(strokeWidth);
// TODO: new mapsforge version wants an mapsforge-paint, not an android paint.
// This doesn't seem to support transparceny
//paintStroke.setAlpha(128);
Polyline line = new Polyline((Paint) paintStroke, AndroidGraphicFactory.INSTANCE);
List<LatLong> geoPoints = line.getLatLongs();
PointList tmp = pointList;
for (int i = 0; i < pointList.getSize(); i++) {
geoPoints.add(new LatLong(tmp.getLatitude(i), tmp.getLongitude(i)));
}
return line;
}
示例9: 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;
}
示例10: getNewCarRoute
import com.graphhopper.util.PointList; //导入依赖的package包/类
private Route getNewCarRoute(Location from, Location to){
GHResponse rsp = queryGH(from, to);
if(rsp.hasErrors()) return null;
Route route = new Route();
// points, distance in meters and time in millis of the full path
PointList pointList = rsp.getBest().getPoints();
Iterator<GHPoint3D> pIterator = pointList.iterator();
if (!pIterator.hasNext()) return null;
GHPoint prevPoint = pIterator.next();
double remainder = 0;
Location loc = null;
while (pIterator.hasNext()){
GHPoint nextPoint = pIterator.next();
double length = getLength(prevPoint, nextPoint);
if (length == 0){
prevPoint = nextPoint;
continue;
}
long i = 0;
for (; i * cellSize + remainder < length ; i++) {
loc = getIntermediateLoc(prevPoint, nextPoint, length, i * cellSize + remainder);
if (!from.equals(loc)) {
route.addPoint(loc);
}
}
remainder = i * cellSize + remainder - length;
prevPoint = nextPoint;
}
if (!to.equals(loc)) { route.addPoint(to); }
return route;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: calcWeight
import com.graphhopper.util.PointList; //导入依赖的package包/类
@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
if (prevOrNextEdgeId == -1 )
return 1.0;
if (edgeState instanceof VirtualEdgeIteratorState || prevOrNextEdgeId >= _maxEdges || edgeState.getEdge() >= _maxEdges)
{
//TODO
return 1.0;
}
PointList currEdgeGeom, prevEdgeGeom;
if (reverse)
{
prevEdgeGeom = _ghStorage.getEdgeIteratorState(edgeState.getEdge(), edgeState.getBaseNode()).fetchWayGeometry(3);
currEdgeGeom = _ghStorage.getEdgeIteratorState(prevOrNextEdgeId, edgeState.getBaseNode()).detach(true).fetchWayGeometry(3);
}
else
{
currEdgeGeom = _ghStorage.getEdgeIteratorState(edgeState.getEdge(), edgeState.getAdjNode()).fetchWayGeometry(3);
prevEdgeGeom = _ghStorage.getEdgeIteratorState(prevOrNextEdgeId, edgeState.getBaseNode()).fetchWayGeometry(3);
}
double turnAngle = getTurnAngle(currEdgeGeom, prevEdgeGeom);
if (isFullTurn(turnAngle))
{
// TODO
return 1.0;
}
return 1.0;
}
示例15: processEdge
import com.graphhopper.util.PointList; //导入依赖的package包/类
public void processEdge(ReaderWay way, EdgeIteratorState edge) {
boolean revert = edge.getBaseNode() > edge.getAdjNode();
PointList points = edge.fetchWayGeometry(3, _arrayBuffer);
byte hillIndex = _hillIndexCalc.getHillIndex(points, false);
byte reverseHillIndex = _hillIndexCalc.getHillIndex(points, true);
if (revert)
_storage.setEdgeValue(edge.getEdge(), reverseHillIndex, hillIndex);
else
_storage.setEdgeValue(edge.getEdge(), hillIndex, reverseHillIndex);
}