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


Java Parameters类代码示例

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


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

示例1: testRoutingEvaluator

import com.graphhopper.util.Parameters; //导入依赖的package包/类
static void testRoutingEvaluator() {

		RoutingEvaluator re = new RoutingEvaluator();
		try {
			re.setOsmFile(new File(HeatStressRouting.OSM_FILE));
			re.setWeatherDataFile(new File(HeatStressRouting.WEATHER_DATA));
			re.setWaySegmentsFile(
					new File(HeatStressRouting.WAY_SEGMENT_WEIGHTS));
			re.init();
			re.setSeed(2375737176707274901L);
			re.randomStartsAndDestinations(10);
			re.randomDates(2, LocalDate.of(2015, 6, 1),
					LocalDate.of(2015, 8, 31));
			re.sequentialTimePoints(LocalTime.of(7, 0), LocalTime.of(23, 0),
					240);
			re.setRoutingAlgo(Parameters.Algorithms.DIJKSTRA_BI);
			re.run();
			System.out.println("results size: " + re.getResultRecords().size());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:23,代码来源:Tests.java

示例2: init

import com.graphhopper.util.Parameters; //导入依赖的package包/类
private void init() {
	File ghDirectory  = new File(GHLOCATION);
    //delete GH if it exists
    if(ghDirectory.exists() && ghDirectory.isDirectory()){
        try {

            FileUtils.deleteDirectory(ghDirectory);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // import OpenStreetMap data
    hopper = new GraphHopperOSM();
    hopper.setDataReaderFile(OSM);

    hopper.setGraphHopperLocation(GHLOCATION);
    encoder = new CarFlagEncoder();
    hopper.setEncodingManager(new EncodingManager(encoder));
    hopper.getCHFactoryDecorator().setEnabled(false);
    hopper.importOrLoad();
    
    //for map matching core version 8.2
    opts = AlgorithmOptions.start()
    		.algorithm(Parameters.Algorithms.DIJKSTRA_BI).traversalMode(hopper.getTraversalMode())
            .weighting(new FastestWeighting(encoder))
            .maxVisitedNodes(10000)
            .hints(new HintsMap().put("weighting", "fastest").put("vehicle", encoder.toString()))
    		.build();
}
 
开发者ID:MAGDa-BeuthHS,项目名称:fcd2pgsql,代码行数:31,代码来源:MapMatcher.java

示例3: runRoutingEvaluatorSetting1

import com.graphhopper.util.Parameters; //导入依赖的package包/类
static void runRoutingEvaluatorSetting1() {
	// Setting 1:
	// - 1000 random starts and destinations
	// - 10 Random dates
	// - evaluated every 4 hours in range 07:00 to 23:00
	RoutingEvaluator re = new RoutingEvaluator();
	try {
		re.setOsmFile(new File(HeatStressRouting.OSM_FILE));
		re.setWeatherDataFile(new File(HeatStressRouting.WEATHER_DATA));
		re.setWaySegmentsFile(
				new File(HeatStressRouting.WAY_SEGMENT_WEIGHTS));
		re.setWeights(0.25, 0.75);
		re.init();
		re.setSeed(2375737176707274901L);
		re.randomStartsAndDestinations(1000);
		re.randomDates(10, LocalDate.of(2015, 6, 1),
				LocalDate.of(2015, 8, 31));
		re.sequentialTimePoints(LocalTime.of(7, 0), LocalTime.of(23, 0),
				240);
		re.exportResultsTo(new File(HeatStressRouting.OUT_DIR
				+ "routes_weighted_setting1_1000_10_240min.csv"));
		re.setRoutingAlgo(Parameters.Algorithms.DIJKSTRA_BI);
		re.run();
		System.out.println("results size: " + re.getResultRecords().size());
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:29,代码来源:Tests.java

示例4: runRoutingEvaluatorSetting2

import com.graphhopper.util.Parameters; //导入依赖的package包/类
static void runRoutingEvaluatorSetting2() {
	// Setting 2:
	// - 100 random starts and destinations
	// - 10 Random dates
	// - evaluated every 30 minutes in range 00:00 to 23:30
	RoutingEvaluator re = new RoutingEvaluator();
	try {
		re.setOsmFile(new File(HeatStressRouting.OSM_FILE));
		re.setWeatherDataFile(new File(HeatStressRouting.WEATHER_DATA));
		re.setWaySegmentsFile(
				new File(HeatStressRouting.WAY_SEGMENT_WEIGHTS));
		re.setWeights(0.25, 0.75);
		re.init();
		re.setSeed(2375737176707274901L);
		re.randomStartsAndDestinations(100);
		re.randomDates(10, LocalDate.of(2015, 6, 1),
				LocalDate.of(2015, 8, 31));
		re.sequentialTimePoints(LocalTime.MIN, LocalTime.MAX, 30);
		re.exportResultsTo(new File(HeatStressRouting.OUT_DIR
				+ "routes_weighted_setting2_100_10_30min.csv"));
		re.setRoutingAlgo(Parameters.Algorithms.DIJKSTRA_BI);
		re.run();
		System.out.println("results size: " + re.getResultRecords().size());
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:28,代码来源:Tests.java

示例5: algoOptions

import com.graphhopper.util.Parameters; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> algoOptions() {
    // create hopper instance with CH enabled
    CarFlagEncoder encoder = new CarFlagEncoder();
    TestGraphHopper hopper = new TestGraphHopper();
    hopper.setDataReaderFile("../map-data/leipzig_germany.osm.pbf");
    hopper.setGraphHopperLocation("../target/mapmatchingtest-ch");
    hopper.setEncodingManager(new EncodingManager(encoder));
    hopper.importOrLoad();

    // force CH
    AlgorithmOptions chOpts = AlgorithmOptions.start()
            .maxVisitedNodes(1000)
            .hints(new PMap().put(Parameters.CH.DISABLE, false))
            .build();

    // flexible should fall back to defaults
    AlgorithmOptions flexibleOpts = AlgorithmOptions.start()
            // TODO: fewer nodes than for CH are possible (short routes & different finish condition & higher degree graph)
            // .maxVisitedNodes(20)
            .build();

    return Arrays.asList(new Object[][]{
        {"non-CH", hopper, flexibleOpts},
        {"CH", hopper, chOpts}
    });
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:28,代码来源:MapMatchingTest.java

示例6: testUTurns

import com.graphhopper.util.Parameters; //导入依赖的package包/类
/**
 * This test is to check that U-turns are avoided when it's just measurement
 * error, though do occur when a point goes up a road further than the
 * measurement error. GPX input:
 * https://graphhopper.com/maps/?point=51.343618%2C12.360772&point=51.34401%2C12.361776&point=51.343977%2C12.362886&point=51.344734%2C12.36236&point=51.345233%2C12.362055&layer=Lyrk
 */
@Test
public void testUTurns() {
    // This test requires changing the default heading penalty, which does not work for CH.
    if (parameterName.equals("CH")) {
        return;
    }

    final AlgorithmOptions algoOptions = AlgorithmOptions.start()
            // Reduce penalty to allow U-turns
            .hints(new PMap().put(Parameters.Routing.HEADING_PENALTY, 50))
            .build();

    MapMatching mapMatching = new MapMatching(hopper, algoOptions);
    List<GPXEntry> inputGPXEntries = new GPXFile()
            .doImport("./src/test/resources/tour4-with-uturn.gpx").getEntries();

    // with large measurement error, we expect no U-turn
    mapMatching.setMeasurementErrorSigma(50);
    MatchResult mr = mapMatching.doWork(inputGPXEntries);

    assertEquals(Arrays.asList("Gustav-Adolf-Straße", "Gustav-Adolf-Straße", "Funkenburgstraße",
            "Funkenburgstraße"), fetchStreets(mr.getEdgeMatches()));

    // with small measurement error, we expect the U-turn
    mapMatching.setMeasurementErrorSigma(10);
    mr = mapMatching.doWork(inputGPXEntries);

    assertEquals(
            Arrays.asList("Gustav-Adolf-Straße", "Gustav-Adolf-Straße", "Funkenburgstraße",
                    "Funkenburgstraße", "Funkenburgstraße", "Funkenburgstraße"),
            fetchStreets(mr.getEdgeMatches()));
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:39,代码来源:MapMatchingTest.java

示例7: getName

import com.graphhopper.util.Parameters; //导入依赖的package包/类
@Override
public String getName() {
    return Parameters.Algorithms.DIJKSTRA;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:5,代码来源:DijkstraOneToManyAlgorithm.java

示例8: loadInBackground

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

示例9: RoutingRequest

import com.graphhopper.util.Parameters; //导入依赖的package包/类
protected RoutingRequest(GHPoint start, GHPoint destination,
		WeightingType weightingType, LocalDateTime time) {
	this(start, destination, weightingType, time,
			Parameters.Algorithms.DIJKSTRA_BI, FlagEncoderFactory.FOOT,
			Locale.ENGLISH);
}
 
开发者ID:biggis-project,项目名称:path-optimizer,代码行数:7,代码来源:RoutingRequest.java


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