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


Java GraphHopper.setEncodingManager方法代码示例

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


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

示例1: get

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
/**
 * 
 * @param osmFile path to the osmFile to use
 * @param workingDir if multiple GH instances are used, then each should have a different workingDir
 * @return graphhopper instance
 */
public static GraphHopper get(String osmFile, String workingDir) {
	GraphHopper hopper;
	// create one GraphHopper instance
	Map<String, String> env = System.getenv();
	if(Boolean.valueOf(env.get("LOW_MEMORY"))) {
		LOGGER.info("Using Graphhopper for mobile due to LOW_MEMORY env.");
		hopper = new GraphHopper().forMobile();
		hopper.setCHPrepareThreads(1);
	} else {
		hopper = new GraphHopper().forServer();
	}
	hopper.setOSMFile(osmFile);
	hopper.setGraphHopperLocation(workingDir);
	hopper.setEncodingManager(new EncodingManager("car"));
	hopper.importOrLoad();
	return hopper;
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:24,代码来源:GraphHopperBuilder.java

示例2: createHopper

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
public static GraphHopper createHopper(boolean memoryMapped, String graphFolder) {
	GraphHopper ret = null;

	ret = new GraphHopper().forDesktop();

	// initialise the encoders ourselves as we can use multiple
	// encoders for same vehicle type corresponding to different
	// times of day (i.e. rush hours)
	ret.setEncodingManager(createEncodingManager(graphFolder));
	
	// don't need to write so disable the lock file (allows us to run out of program files)
	ret.setAllowWrites(false);

	if (memoryMapped) {
		ret.setMemoryMapped();
	}

	ret.setGraphHopperLocation(graphFolder);
	ret.importOrLoad();

	return ret;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:23,代码来源:CHMatrixGeneration.java

示例3: loadInBackground

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
@Override
    public Result loadInBackground() {
        LOGI(TAG, "#loadInBackground; mStartLocation = " + mStartLocation + "; mEndLocation = " + mEndLocation);
        try {


            final GraphHopper hopper = new GraphHopper().forMobile();
            hopper.setInMemory();
            final File mapsforgeFile = AbstractMap.instance().getMapsforgeFile(getContext());
            hopper.setOSMFile(mapsforgeFile.getAbsolutePath());
            hopper.setGraphHopperLocation(mapsforgeFile.getParent());
            hopper.setEncodingManager(new EncodingManager("car"));
            hopper.importOrLoad();
            final GHRequest req =
                    new GHRequest(
                            mStartLocation.getLatitude(),
                            mStartLocation.getLongitude(),
                            mEndLocation.getLatitude(),
                            mEndLocation.getLongitude())
                            .setAlgorithm(Parameters.Algorithms.DIJKSTRA_BI);
            req.getHints().
                    put(Parameters.Routing.INSTRUCTIONS, "false");
//            GHResponse resp = hopper.route(req);
            final GHResponse rsp = hopper.route(req);
            if (rsp.hasErrors()) {
                LOGW(TAG, "GHResponse contains errors!");
                List<Throwable> errors = rsp.getErrors();
                for (int i = 0; i < errors.size(); i++) {
                    LOGE(TAG, "Graphhopper error #" + i, errors.get(i));
                }
                return Result.INTERNAL_ERROR;
            }

//            if (!rsp.isFound()) {
//                LOGW(TAG, "Graphhopper cannot find route!");
//                return Result.NO_ROUTE;
//            }
            else {
                PathWrapper paths = rsp.getBest();
                final List<GeoPoint> geoPoints = new LinkedList<>();
                final PointList points = paths.getPoints();
                double lati, longi, alti;
                for (int i = 0; i < points.getSize(); i++) {
                    lati = points.getLatitude(i);
                    longi = points.getLongitude(i);
                    alti = points.getElevation(i);
                    geoPoints.add(new GeoPoint(lati, longi, alti));
                }
                return new Result(geoPoints);
            }
        } catch (OutOfMemoryError e) {
            LOGE(TAG, "Graphhoper OOM", e);
            return Result.INTERNAL_ERROR;
        }

    }
 
开发者ID:yuviii,项目名称:OfflineMap,代码行数:57,代码来源:RouteLoader.java

示例4: loadInBackground

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
@Override
public Result loadInBackground() {
    LOGI(TAG, "#loadInBackground; mStartLocation = " + mStartLocation + "; mEndLocation = " + mEndLocation);
    try {
        final GraphHopper hopper = new GraphHopper().forMobile();
        hopper.setInMemory(true);
        final File mapsforgeFile = AbstractMap.instance().getMapsforgeFile(getContext());
        hopper.setOSMFile(mapsforgeFile.getAbsolutePath());
        hopper.setGraphHopperLocation(mapsforgeFile.getParent());
        hopper.setEncodingManager(new EncodingManager("car"));
        hopper.importOrLoad();
        final GHRequest req =
                new GHRequest(
                        mStartLocation.getLatitude(),
                        mStartLocation.getLongitude(),
                        mEndLocation.getLatitude(),
                        mEndLocation.getLongitude())
                        .setVehicle("car");
        final GHResponse rsp = hopper.route(req);
        if (rsp.hasErrors()) {
            LOGW(TAG, "GHResponse contains errors!");
            List<Throwable> errors = rsp.getErrors();
            for (int i = 0; i < errors.size(); i++) {
                LOGE(TAG, "Graphhopper error #" + i, errors.get(i));
            }
            return Result.INTERNAL_ERROR;
        }
        if (!rsp.isFound()) {
            LOGW(TAG, "Graphhopper cannot find route!");
            return Result.NO_ROUTE;
        } else {
            final List<GeoPoint> geoPoints = new LinkedList<>();
            final PointList points = rsp.getPoints();
            double lati, longi, alti;
            for (int i = 0; i < points.getSize(); i++) {
                lati = points.getLatitude(i);
                longi = points.getLongitude(i);
                alti = points.getElevation(i);
                geoPoints.add(new GeoPoint(lati, longi, alti));
            }
            return new Result(geoPoints);
        }
    } catch (OutOfMemoryError e) {
        LOGE(TAG, "Graphhoper OOM", e);
        return Result.INTERNAL_ERROR;
    }

}
 
开发者ID:lassana,项目名称:offline-routing-sample,代码行数:49,代码来源:RouteLoader.java


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