本文整理汇总了Java中com.graphhopper.util.shapes.GHPoint类的典型用法代码示例。如果您正苦于以下问题:Java GHPoint类的具体用法?Java GHPoint怎么用?Java GHPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GHPoint类属于com.graphhopper.util.shapes包,在下文中一共展示了GHPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: route
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* Finds the optimal route between {@code from} and {@code to} at time
* {@code time} using the specified {@link WeightingType}.
*
* @param from
* the start
* @param to
* the destination
* @param time
* the start time
* @param weighting
* edge weighting to use
* @throws IllegalArgumentException
* if time is {@code null} and the weighting type is not
* {@link WeightingType.SHORTEST}
* @return the optimal route as a {@link PathWrapper} or the errors returned
* by GraphHopper
*/
public Result<PathWrapper, List<Throwable>> route(GHPoint from, GHPoint to,
LocalDateTime time, WeightingType weighting) {
if (time == null && weighting != WeightingType.SHORTEST)
throw new IllegalArgumentException(
"if time is null then the weighting type must be 'WeightingType.SHORTEST'");
GHRequest req = new GHRequest(from, to)
.setWeighting(weighting.toString()).setVehicle(encodingManager)
.setLocale(locale).setAlgorithm(routingAlgorithm);
GHResponse rsp;
if (time != null) {
rsp = hopper.route(req, time);
} else {
rsp = hopper.route(req);
}
if (rsp.hasErrors())
return Result.errorOf(rsp.getErrors());
else
return Result.okayOf(rsp.getBest());
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:42,代码来源:RoutingHelper.java
示例2: value
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
@Override
public OptionalDouble value(LocalDateTime time, GHPoint start,
GHPoint place, TimeRange<LocalDateTime> limits,
long minWalkingTime) {
Optional<PathWrapper> path = routingHelper
.route(start, place, time, weightingType).get();
if (path.isPresent()) {
long timeWalk = Math.max(path.get().getTime() - minWalkingTime, 0);
lastWalkingTime = timeWalk;
if (time.plus(timeWalk, ChronoUnit.MILLIS)
.compareTo(limits.getTo()) <= 0) {
// return getThermalComfort().value(time);
return OptionalDouble.of(path.get().getRouteWeight());
}
}
return OptionalDouble.empty();
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:20,代码来源:RoutingObjectiveFunction.java
示例3: mapMatchingTest
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
@Test
public void mapMatchingTest() {
GraphHopperStorage graph = hopper.getGraphHopperStorage();
LocationIndexMatch locationIndex = new LocationIndexMatch(graph,
(LocationIndexTree) hopper.getLocationIndex());
MapMatching mapMatching = new MapMatching(graph, locationIndex,
encoder.getEncoder(EncodingManager.CAR));
mapMatching.setSeparatedSearchDistance(30);
// printOverview(graph, hopper.getLocationIndex(), 51.358735, 12.360574,
// 500);
List<GPXEntry> inputGPXEntries = createRandomGPXEntries(new GHPoint(
51.358735, 12.360574), new GHPoint(51.358594, 12.360032));
MatchResult mr = mapMatching.doWork(inputGPXEntries);
}
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:18,代码来源:GraphHopperTest.java
示例4: testDistantPoints
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* This test is to check behavior over large separated routes: it should
* work if the user sets the maxVisitedNodes large enough. Input path:
* https://graphhopper.com/maps/?point=51.23%2C12.18&point=51.45%2C12.59&layer=Lyrk
*/
@Test
public void testDistantPoints() {
// OK with 1000 visited nodes:
MapMatching mapMatching = new MapMatching(hopper, algoOptions);
List<GPXEntry> inputGPXEntries = createRandomGPXEntries(
new GHPoint(51.23, 12.18),
new GHPoint(51.45, 12.59));
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(57650, mr.getMatchLength(), 1);
assertEquals(2747796, mr.getMatchMillis(), 1);
// not OK when we only allow a small number of visited nodes:
AlgorithmOptions opts = AlgorithmOptions.start(algoOptions).maxVisitedNodes(1).build();
mapMatching = new MapMatching(hopper, opts);
try {
mr = mapMatching.doWork(inputGPXEntries);
fail("Expected sequence to be broken due to maxVisitedNodes being too small");
} catch (RuntimeException e) {
assertTrue(e.getMessage().startsWith("Sequence is broken for submitted track"));
}
}
开发者ID:graphhopper,项目名称:map-matching,代码行数:28,代码来源:MapMatchingTest.java
示例5: calculateMatrixOneByOne
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
public MatrixResult calculateMatrixOneByOne(GHPoint[] points) {
int n = points.length;
MatrixResult ret = new MatrixResult(n);
for (int fromIndex = 0; fromIndex < n; fromIndex++) {
// Loop over TO in reverse order so the first A-B we process doesn't have the same
// location for FROM and TO - this makes it quicker to debug as the first call is no longer a 'dummy' one.
for (int toIndex = n - 1; toIndex >= 0; toIndex--) {
GHPoint from = points[fromIndex];
GHPoint to = points[toIndex];
GHResponse rsp = getResponse(from, to);
if (rsp == null) {
continue;
}
ret.setDistanceMetres(fromIndex, toIndex, rsp.getDistance());
ret.setTimeMilliseconds(fromIndex, toIndex, rsp.getTime());
}
}
return ret;
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:22,代码来源:CHMatrixGeneration.java
示例6: ExamplePointsData
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
ExamplePointsData(int n){
Random r = new Random(123);
points = new GHPoint[n];
// get source points
GHPoint[] src = createPoints();
for(int i =0 ; i< n ; i++){
if(i< src.length){
points[i] = src[i];
}else{
int index = r.nextInt(src.length);
GHPoint srcPnt = src[index];
points[i] = new GHPoint(srcPnt.lat + 0.001*r.nextDouble() - 0.0005, srcPnt.lon+ 0.001*r.nextDouble() - 0.0005);
}
}
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:18,代码来源:ExamplePointsData.java
示例7: calculateJTSRouteGeom
import com.graphhopper.util.shapes.GHPoint; //导入依赖的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
示例8: getNewCarRoute
import com.graphhopper.util.shapes.GHPoint; //导入依赖的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;
}
开发者ID:agentcontest,项目名称:massim,代码行数:39,代码来源:CityMap.java
示例9: doMapMatching
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
public List<GPXEntry> doMapMatching(List<GPXEntry> gpxUnmatched) {
List<GPXEntry> gpxMatched = new ArrayList<GPXEntry>();
MapMatching mapMatching = new MapMatching(hopper, opts);
mapMatching.setMeasurementErrorSigma(50);
// perform map matching, return null if it fails
MatchResult mr = null;
try {
mr = mapMatching.doWork(gpxUnmatched);
}
catch (Exception ex) {
//System.out.println("MapMatching error: " + ex.getMessage());
return null;
}
// get points of matched track
Path path = mapMatching.calcPath(mr);
PointList points = path.calcPoints();
if (points != null && !points.isEmpty()) {
for (GHPoint pt : points) {
// set elevation and time to zero for now
gpxMatched.add(new FCDEntry(pt.lat, pt.lon, 0.0, 0, 0));
}
}
return gpxMatched;
}
开发者ID:MAGDa-BeuthHS,项目名称:fcd2pgsql,代码行数:29,代码来源:MapMatcher.java
示例10: RoutingRequest
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
protected RoutingRequest(GHPoint start, GHPoint destination,
WeightingType weightingType, LocalDateTime time,
String routingAlgorithm, String encodingManager, Locale locale) {
this.start = start;
this.destination = destination;
this.weightingType = weightingType;
this.time = time;
this.routingAlgorithm = routingAlgorithm;
this.encodingManager = encodingManager;
this.locale = locale;
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:12,代码来源:RoutingRequest.java
示例11: RoutingRequestBuilder
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
protected RoutingRequestBuilder(GHPoint start, GHPoint destination,
WeightingType weightingType, LocalDateTime time,
String routingAlgorithm, String encodingManager, Locale locale) {
this(start, destination, weightingType, time);
this.routingAlgorithm = routingAlgorithm;
this.encodingManager = encodingManager;
this.locale = locale;
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:9,代码来源:RoutingRequestBuilder.java
示例12: routePathShortest
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* Finds the shortest route between {@code from} and {@code to}.
*
* @param from
* the start
* @param to
* the destination
* @return the shortest route as a {@link Path} or the errors returned by
* GraphHopper
*/
public Result<Path, List<Throwable>> routePathShortest(GHPoint from,
GHPoint to) {
GHRequest req = new GHRequest(from, to)
.setWeighting(WeightingType.SHORTEST.toString())
.setVehicle(encodingManager).setLocale(locale)
.setAlgorithm(routingAlgorithm);
Pair<GHResponse, List<Path>> rsp = hopper.routePaths(req);
if (rsp.getLeft().hasErrors())
return Result.errorOf(rsp.getLeft().getErrors());
else
return Result.okayOf(rsp.getRight().get(0));
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:25,代码来源:RoutingHelper.java
示例13: toJsonArray
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* Serializes the {@link PointList} as JsonArray of Points, e.g.
* [[49.0118083, 8.4251357], [49.0126868, 8.4065707]].
*
* @param points
* @return
*/
public static JsonArray toJsonArray(PointList points) {
JsonArrayBuilder builder = Json.createArrayBuilder();
for (GHPoint point : points) {
builder.add(toJsonArray(point));
}
return builder.build();
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:15,代码来源:JsonUtils.java
示例14: parseGHPoint
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* Parses a geo coordinate string of the form 'lat,lon' (e.g.
* '49.0118083,8.4251357') where the decimal latitude and longitude values
* are separated by a comma (','). The latitude value must be in range [-90,
* 90] and the longitude value in range [-180, 180].
*
* @param pointStr
* the string to parse, e.g. '49.0118083,8.4251357'
* @return a {@link GHPoint} instance
*
*/
public static Result<GHPoint, ParserException> parseGHPoint(
String pointStr) {
String[] components = pointStr.trim().split(",");
if (components.length != 2)
return Result
.errorOf(new ParserException("wrong number of arguments"));
double lat;
double lon;
try {
lat = Double.parseDouble(components[0]);
lon = Double.parseDouble(components[1]);
} catch (NumberFormatException e) {
return Result.errorOf(
new ParserException("failed to parse coordinate", e));
}
if (lat < -90 || lat > 90)
return Result.errorOf(new ParserException(
"latitude value is not in range [-90, 90]"));
if (lon < -180 || lon > 180)
return Result.errorOf(new ParserException(
"longitude value is not in range [-180, 180]"));
return Result.okayOf(new GHPoint(lat, lon));
}
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:40,代码来源:WebApiUtils.java
示例15: calculatePath
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
public GHResponse calculatePath( final List<GHPoint> points)
{
// StopWatch sw = new StopWatch().start();
GHRequest req = new GHRequest(points).
setAlgorithm(AlgorithmOptions.DIJKSTRA_BI);
req.getHints().
put("instructions", "true");
GHResponse resp = null;
if (hopper != null)
resp = hopper.route(req);
return resp;
}
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:15,代码来源:RouteCalculator.java
示例16: doInBackground
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
protected GHResponse doInBackground( List<GHPoint> ... points )
{
StopWatch sw = new StopWatch().start();
GHRequest req = new GHRequest(points[0]).
setAlgorithm(AlgorithmOptions.DIJKSTRA_BI);
req.getHints().
put("instructions", "false");
GHResponse resp = hopper.route(req);
time = sw.stop().getSeconds();
return resp;
}
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:13,代码来源:RouteCalculator.java
示例17: printMinDistances
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
private void printMinDistances(List<TimeStep<GPXExtension, GPXEntry, Path>> timeSteps) {
TimeStep<GPXExtension, GPXEntry, Path> prevStep = null;
int index = 0;
for (TimeStep<GPXExtension, GPXEntry, Path> ts : timeSteps) {
if (prevStep != null) {
double dist = distanceCalc.calcDist(
prevStep.observation.lat, prevStep.observation.lon,
ts.observation.lat, ts.observation.lon);
double minCand = Double.POSITIVE_INFINITY;
for (GPXExtension prevGPXE : prevStep.candidates) {
for (GPXExtension gpxe : ts.candidates) {
GHPoint psp = prevGPXE.getQueryResult().getSnappedPoint();
GHPoint sp = gpxe.getQueryResult().getSnappedPoint();
double tmpDist = distanceCalc.calcDist(psp.lat, psp.lon, sp.lat, sp.lon);
if (tmpDist < minCand) {
minCand = tmpDist;
}
}
}
logger.debug(index + ": " + Math.round(dist) + "m, minimum candidate: "
+ Math.round(minCand) + "m");
index++;
}
prevStep = ts;
}
}
开发者ID:graphhopper,项目名称:map-matching,代码行数:28,代码来源:MapMatching.java
示例18: testClosePoints
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
/**
* This test is to check behavior over short tracks. GPX input:
* https://graphhopper.com/maps/?point=51.342422%2C12.3613358&point=51.3423281%2C12.3613358&layer=Lyrk
*/
@Test
public void testClosePoints() {
MapMatching mapMatching = new MapMatching(hopper, algoOptions);
List<GPXEntry> inputGPXEntries = createRandomGPXEntries(
new GHPoint(51.342422, 12.3613358),
new GHPoint(51.342328, 12.3613358));
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(3, mr.getMatchLength(), 1);
assertEquals(284, mr.getMatchMillis(), 1);
}
开发者ID:graphhopper,项目名称:map-matching,代码行数:16,代码来源:MapMatchingTest.java
示例19: getResponse
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
public GHResponse getResponse(GHPoint from, GHPoint to) {
// The flag encoder's toString method returns the vehicle type
GHRequest req = new GHRequest(from, to).setVehicle(flagEncoder.toString());
GHResponse rsp = hopper.route(req);
if (rsp.hasErrors()) {
return null;
}
return rsp;
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:11,代码来源:CHMatrixGeneration.java
示例20: queryPositions
import com.graphhopper.util.shapes.GHPoint; //导入依赖的package包/类
private QueryResult[] queryPositions(GHPoint[] points, List<QueryResult> validResults) {
QueryResult[] queryResults = new QueryResult[points.length];
for (int i = 0; i < points.length; i++) {
queryResults[i] = createSnapToResult(points[i].getLat(), points[i].getLon());
if (queryResults[i].isValid()) {
validResults.add(queryResults[i]);
}
}
return queryResults;
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:11,代码来源:CHMatrixGeneration.java
注:本文中的com.graphhopper.util.shapes.GHPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论