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


Java Path类代码示例

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


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

示例1: createHopper

import com.graphhopper.routing.Path; //导入依赖的package包/类
/**
 * Helper method to create a {@link HeatStressGraphHopper} instance using
 * the specified files.
 * 
 * @param osmFile
 *            a OSM XML or OSM PBF file (see {@link OSMFileReader})
 * @param weatherDataFile
 *            a CSV file containing the data of the weather station (see
 *            {@link WeatherDataParser})
 * @param waySegmentsFile
 *            a CSV file containing the weighted lines segments (see
 *            {@link WaySegmentParser})
 * @return a {@code HeatStressGraphHopper} instance
 * @throws IOException
 *             if an error occurs while reading one of the specified files
 */
public static HeatStressGraphHopper createHopper(File osmFile,
		File weatherDataFile, File waySegmentsFile) throws IOException {

	java.nio.file.Path ghLocation = Files
			.createTempDirectory("graph_hopper");

	OSMData osmData = new OSMFileReader().read(osmFile);
	WeatherData weatherData = new WeatherDataParser()
			.parse(weatherDataFile);
	WaySegments waySegments = new WaySegmentParser().parse(waySegmentsFile);

	HeatStressGraphHopper hopper = new HeatStressGraphHopper();
	hopper.getCHFactoryDecorator().setEnabled(false);
	hopper.setOSMFile(osmFile.getAbsolutePath());
	hopper.setGraphHopperLocation(ghLocation.toString());
	hopper.setEncodingManager(new EncodingManager(FlagEncoderFactory.FOOT));
	hopper.setOsmData(osmData);
	hopper.setWeatherData(weatherData);
	hopper.setSegments(waySegments);
	hopper.importOrLoad();

	return hopper;

}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:41,代码来源:RoutingHelper.java

示例2: doMapMatching

import com.graphhopper.routing.Path; //导入依赖的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

示例3: RoutingResponse

import com.graphhopper.routing.Path; //导入依赖的package包/类
public RoutingResponse(RoutingRequest request, GHRequest ghRequest,
		GHResponse ghResponse, List<Path> paths) {
	this.request = request;
	this.ghRequest = ghRequest;
	this.ghResponse = ghResponse;
	this.paths = paths;
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:8,代码来源:RoutingResponse.java

示例4: routePaths

import com.graphhopper.routing.Path; //导入依赖的package包/类
/**
 * Calculates the path from specified request visiting the specified
 * locations.
 * 
 * @param request
 * @param time
 * @return the {@link GHResponse} and a list of the found paths
 */
public Pair<GHResponse, List<Path>> routePaths(GHRequest request,
		LocalDateTime time) {
	// add the time to the weightingMap which is passed to the
	// createWeighting method
	request.getHints().put("time", time.toString());

	return routePaths(request);
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:17,代码来源:HeatStressGraphHopper.java

示例5: route

import com.graphhopper.routing.Path; //导入依赖的package包/类
/**
 * Executes a specified {@link RoutingRequest}.
 * 
 * @param request
 *            the {@link RoutingRequest} to performe
 * @return a instance of {@link RoutingResponse} containing the
 *         {@link GHResponse} as well as {@link Path}s returned by
 *         {@link HeatStressGraphHopper#routePaths(GHRequest, LocalDateTime)}
 * 
 * @see HeatStressGraphHopper#routePaths(GHRequest, LocalDateTime)
 */
public RoutingResponse route(final RoutingRequest request) {
	GHRequest req = new GHRequest(request.getStart(),
			request.getDestination())
					.setWeighting(request.getWeightingType().toString())
					.setVehicle(request.getEncodingManager())
					.setLocale(request.getLocale())
					.setAlgorithm(request.getRoutingAlgorithm());

	Pair<GHResponse, List<Path>> rsp = hopper.routePaths(req,
			request.getTime());

	return new RoutingResponse(request, req, rsp.getLeft(), rsp.getRight());

}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:26,代码来源:RoutingHelper.java

示例6: routePathShortest

import com.graphhopper.routing.Path; //导入依赖的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

示例7: NearbySearchResult

import com.graphhopper.routing.Path; //导入依赖的package包/类
public NearbySearchResult(int rank, double score, Node place,
		OptimalTimeFinderResult optimalTimeFinderResult, Path pathOptimal,
		Path pathShortest) {
	super(optimalTimeFinderResult.getOptimalTime(),
			optimalTimeFinderResult.getDistance(),
			optimalTimeFinderResult.getOptimalValue(),
			optimalTimeFinderResult.getDuration(), pathOptimal,
			pathShortest);
	this.rank = rank;
	this.score = score;
	this.place = place;
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:13,代码来源:NearbySearchResult.java

示例8: getOptimalTime

import com.graphhopper.routing.Path; //导入依赖的package包/类
Pair<LocalDateTime, Double> getOptimalTime(Path path,
		TimeRange<LocalDateTime> timeRange, int starts) {

	// the objective function to be passed to the BrentOptimizer
	UnivariateFunction univariateFunction = (x) -> {
		LocalDateTime time = timeRange.getFrom().plusSeconds((long) x);

		Weighting weighting = routingHelper
				.createWeighting(this.weightingType, time);

		OptionalDouble value = objectiveFunctionPath.value(time, path,
				weighting);
		if (value.isPresent()) {
			return value.getAsDouble();
		} else {
			return Double.MAX_VALUE;
		}
	};

	// interval used for optimization is 0 and the duration between the
	// lower and upper bound in seconds
	double lower = 0;
	double upper = timeRange.durationInSeconds() + 1;

	logger.debug("lower = " + lower + ", upper = " + upper);

	BrentOptimizer optimizer = new BrentOptimizer(RELATIVE_THRESHOLD,
			ABSOLUTE_THRESHOLD);
	MultiStartUnivariateOptimizer multiStartOptimizer = new MultiStartUnivariateOptimizer(
			optimizer, starts, rng);
	UnivariatePointValuePair res = multiStartOptimizer.optimize(
			new MaxEval(MAX_EVAL), GOAL_TYPE,
			new SearchInterval(lower, upper),
			new UnivariateObjectiveFunction(univariateFunction));

	return Pair.of(timeRange.getFrom().plusSeconds((long) res.getPoint()),
			res.getValue());
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:39,代码来源:OptimalTimeFinderHeuristic.java

示例9: getEdges

import com.graphhopper.routing.Path; //导入依赖的package包/类
List<GPXEntry> getEdges(int index) {
	Path path = paths.get(index);
	Translation tr = getTranslationMap().get("en");
	InstructionList instr = path.calcInstructions(tr);
	// GPXFile.write(path, "calculated-route.gpx", tr);
	return instr.createGPXList();
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:8,代码来源:GraphHopperTest.java

示例10: loadGraphStorage

import com.graphhopper.routing.Path; //导入依赖的package包/类
public void loadGraphStorage()
    {
        prepareInProgress = true;
        try {
//        logUser("loading graph (" + Constants.VERSION + ") ... ");
            new GHAsyncTask<Void, Void, Path>() {
                protected Path saveDoInBackground(Void... v) throws Exception {
                    GraphHopper tmpHopp = new GraphHopper().forMobile();
                    tmpHopp.setCHEnable(true);
                    tmpHopp.load(new File(Environment.getExternalStorageDirectory() + "/DolphinLocationApp"
                            + "/Routing").getAbsolutePath());
                    log("found graph " + tmpHopp.getGraph().toString() + ", nodes:" + tmpHopp.getGraph().getNodes());
                    hopper = tmpHopp;
                    return null;
                }

                protected void onPostExecute(Path o) {
                    if (hasError()) {
                        Log.i("", "An error happend while creating graph:"
                                + getErrorMessage());
                    } else {
                        Log.i("", "Finished loading graph. Press long to define where to start and end the route.");
                    }

                    finishPrepare();
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        catch (Exception e)
        {

        }
    }
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:34,代码来源:RouteCalculator.java

示例11: write

import com.graphhopper.routing.Path; //导入依赖的package包/类
public static void write(Path path, String gpxFile, Translation translation) {
    BufferedWriter writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(gpxFile));
        writer.append(path.calcInstructions(translation).createGPX());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    } finally {
        Helper.close(writer);
    }
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:12,代码来源:GPXFile.java

示例12: getPaths

import com.graphhopper.routing.Path; //导入依赖的package包/类
public List<Path> getPaths() {
	return paths;
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:4,代码来源:RoutingResponse.java

示例13: doRouting

import com.graphhopper.routing.Path; //导入依赖的package包/类
private Optional<RoutingResultRecord> doRouting(int recordId, int i,
		WeightingType method, Node fromNode, Node toNode, GHPoint from,
		GHPoint to, LocalDateTime time) {

	if (method == WeightingType.SHORTEST) {
		System.out.print("Shortest Path Routing... ");
	} else if (method == WeightingType.TEMPERATURE) {
		System.out.print("Minimum Temperature Routing... ");
	} else if (method == WeightingType.HEAT_INDEX) {
		System.out.print("Minimum Heat Index Routing... ");
	} else if (method == WeightingType.HEAT_INDEX_WEIGHTED) {
		System.out.print("Weighted Minimum Heat Index Routing... ");
	} else {
		throw new IllegalStateException(
				"unsupported weighting method '" + method + "'");
	}

	StopWatch sw = new StopWatch();
	sw.start();

	GHRequest reqShortest = new GHRequest(from, to)
			.setWeighting(method.toString())
			.setVehicle(FlagEncoderFactory.FOOT).setLocale(Locale.GERMAN)
			.setAlgorithm(routingAlgo);

	Pair<GHResponse, List<Path>> resShortest = this.hopper
			.routePaths(reqShortest, time);
	sw.stop();
	System.out.println("done (" + sw.getTime() + " ms)");

	GHResponse rsp = resShortest.getLeft();

	if (rsp.hasErrors()) {
		logger.error("rsp " + method.toString() + " hasErros = "
				+ rsp.getErrors());
		logger.debug("Errors: ");
		rsp.getErrors().forEach(Throwable::getMessage);
		rsp.getErrors().forEach(Throwable::printStackTrace);
		return Optional.empty();
	}
	PathWrapper pathWrapper = rsp.getBest();
	Path path = resShortest.getRight().get(0);
	double dist = pathWrapper.getDistance();
	double costsTemp = routeCostsTemperature(path, time);
	double costsHeatIndex = routeCostsHeatIndex(path, time);
	Duration duration = Duration.ofMillis(pathWrapper.getTime());
	System.out.println("\tDistance: " + dist + ", costsTemperature: "
			+ costsTemp + ", costsHeatIndex: " + costsHeatIndex
			+ ", Duration: " + Utils.formatDuration(duration));

	return Optional.of(new RoutingResultRecord(recordId, i, time,
			method.toString(), fromNode, toNode, dist, costsTemp,
			costsHeatIndex, duration.toMillis(), pathWrapper.getPoints()));
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:55,代码来源:RoutingEvaluator.java

示例14: routeCostsTemperature

import com.graphhopper.routing.Path; //导入依赖的package包/类
private double routeCostsTemperature(Path path, LocalDateTime time) {
	return routeCosts(path,
			createWeighting(WeightingType.TEMPERATURE, time));
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:5,代码来源:RoutingEvaluator.java

示例15: routeCostsHeatIndex

import com.graphhopper.routing.Path; //导入依赖的package包/类
private double routeCostsHeatIndex(Path path, LocalDateTime time) {

		return routeCosts(path,
				createWeighting(WeightingType.HEAT_INDEX, time));
	}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:6,代码来源:RoutingEvaluator.java


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