本文整理汇总了Java中com.graphhopper.util.GPXEntry类的典型用法代码示例。如果您正苦于以下问题:Java GPXEntry类的具体用法?Java GPXEntry怎么用?Java GPXEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GPXEntry类属于com.graphhopper.util包,在下文中一共展示了GPXEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDestinationFrom
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
public GPXEntry getDestinationFrom(GPXEntry v) {
// assert time.after(v.time);
double x = getX();
double y = getY();
double z = getZ();
Vector3D mirror = new Vector3D(y, x, z);
// Velocity newv = new Velocity(
// new Vector3D(v.getY(), v.getX(), v.getZ()), v.time.getTime());
// reference:
// http://stackoverflow.com/questions/3917340/geotools-how-to-do-dead-reckoning-and-course-calculations-using-geotools-class
GeodeticCalculator calc = new GeodeticCalculator();
// It's odd! setStartingGeographicPoint accept longitude first
calc.setStartingGeographicPoint(v.lon, v.lat);
// calc.setDirection(FastMath.toDegrees(Math.PI / 2 - v.getAzimuth()),
// v.getHorizontalSpeed() * diff);
calc.setDirection(FastMath.toDegrees(mirror.getAlpha()), getNorm());
Point2D p = calc.getDestinationGeographicPoint();
// It's odd! getDestinationGeographicPoint returns longitude first
return new GPXEntry(p.getY(), p.getX(), getZ(), time.getTime());
}
示例2: localize
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
@Override
public GeoPoint localize(List<GeoPoint> steps) {
List<GPXEntry> entries = new ArrayList<GPXEntry>();
for (GeoPoint step : steps) {
entries.add(step.toGPXEntry());
}
MatchResult mr = null;
try {
mr = mapMatching.doWork(entries);
} catch (RuntimeException e) {
e.printStackTrace();
return null;
}
return null;
}
示例3: mapMatchingTest
import com.graphhopper.util.GPXEntry; //导入依赖的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);
}
示例4: getGpxExtension
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
private List<GPXExtension> getGpxExtension() {
List<GPXExtension> list = new ArrayList<>();
QueryResult queryResult1 = new QueryResult(-3.4445, -38.9990) {
@Override
public GHPoint3D getSnappedPoint() {
return new GHPoint3D(-3.4446, -38.9996, 0);
}
};
QueryResult queryResult2 = new QueryResult(-3.4445, -38.9990) {
@Override
public GHPoint3D getSnappedPoint() {
return new GHPoint3D(-3.4449, -38.9999, 0);
}
};
list.add(new GPXExtension(new GPXEntry(-3.4446, -38.9996, 100000), queryResult1));
list.add(new GPXExtension(new GPXEntry(-3.4448, -38.9999, 100001), queryResult2));
return list;
}
示例5: testDistantPoints
import com.graphhopper.util.GPXEntry; //导入依赖的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"));
}
}
示例6: testLoop
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
/**
* This test is to check that loops are maintained. GPX input:
* https://graphhopper.com/maps/?point=51.343657%2C12.360708&point=51.344982%2C12.364066&point=51.344841%2C12.361223&point=51.342781%2C12.361867&layer=Lyrk
*/
@Test
public void testLoop() {
MapMatching mapMatching = new MapMatching(hopper, algoOptions);
// Need to reduce GPS accuracy because too many GPX are filtered out otherwise.
mapMatching.setMeasurementErrorSigma(40);
List<GPXEntry> inputGPXEntries = new GPXFile()
.doImport("./src/test/resources/tour2-with-loop.gpx").getEntries();
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(
Arrays.asList("Gustav-Adolf-Straße", "Gustav-Adolf-Straße", "Gustav-Adolf-Straße",
"Leibnizstraße", "Hinrichsenstraße", "Hinrichsenstraße",
"Tschaikowskistraße", "Tschaikowskistraße"),
fetchStreets(mr.getEdgeMatches()));
assertEquals(mr.getGpxEntriesLength(), mr.getMatchLength(), 5);
// TODO why is there such a big difference for millis?
assertEquals(mr.getGpxEntriesMillis(), mr.getMatchMillis(), 6000);
}
示例7: testIssue70
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
@Test
public void testIssue70() {
CarFlagEncoder encoder = new CarFlagEncoder();
TestGraphHopper hopper = new TestGraphHopper();
hopper.setDataReaderFile("../map-data/issue-70.osm.gz");
hopper.setGraphHopperLocation("../target/mapmatchingtest-70");
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.importOrLoad();
AlgorithmOptions opts = AlgorithmOptions.start().build();
MapMatching mapMatching = new MapMatching(hopper, opts);
List<GPXEntry> inputGPXEntries = new GPXFile().
doImport("./src/test/resources/issue-70.gpx").getEntries();
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(Arrays.asList("Милана Видака", "Милана Видака", "Милана Видака",
"Бранка Радичевића", "Бранка Радичевића", "Здравка Челара"),
fetchStreets(mr.getEdgeMatches()));
// TODO: length/time
}
示例8: doMapMatching
import com.graphhopper.util.GPXEntry; //导入依赖的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;
}
示例9: getEdges
import com.graphhopper.util.GPXEntry; //导入依赖的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();
}
示例10: GPXExtension
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
/**
* Creates an undirected candidate for a real node.
*/
public GPXExtension(GPXEntry entry, QueryResult queryResult) {
this.entry = entry;
this.queryResult = queryResult;
this.isDirected = false;
this.incomingVirtualEdge = null;
this.outgoingVirtualEdge = null;
}
示例11: testClosePoints
import com.graphhopper.util.GPXEntry; //导入依赖的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);
}
示例12: testSmallSeparatedSearchDistance
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
/**
* This test is to check what happens when two GPX entries are on one edge
* which is longer than 'separatedSearchDistance' - which is always 66m. GPX
* input:
* https://graphhopper.com/maps/?point=51.359723%2C12.360108&point=51.358748%2C12.358798&point=51.358001%2C12.357597&point=51.358709%2C12.356511&layer=Lyrk
*/
@Test
public void testSmallSeparatedSearchDistance() {
List<GPXEntry> inputGPXEntries = new GPXFile()
.doImport("./src/test/resources/tour3-with-long-edge.gpx").getEntries();
MapMatching mapMatching = new MapMatching(hopper, algoOptions);
mapMatching.setMeasurementErrorSigma(20);
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(Arrays.asList("Weinligstraße", "Weinligstraße", "Weinligstraße",
"Fechnerstraße", "Fechnerstraße"), fetchStreets(mr.getEdgeMatches()));
assertEquals(mr.getGpxEntriesLength(), mr.getMatchLength(), 11); // TODO: this should be around 300m according to Google ... need to check
assertEquals(mr.getGpxEntriesMillis(), mr.getMatchMillis(), 3000);
}
示例13: testLoop2
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
/**
* This test is to check that loops are maintained. GPX input:
* https://graphhopper.com/maps/?point=51.342439%2C12.361615&point=51.343719%2C12.362784&point=51.343933%2C12.361781&point=51.342325%2C12.362607&layer=Lyrk
*/
@Test
public void testLoop2() {
MapMatching mapMatching = new MapMatching(hopper, algoOptions);
// TODO smaller sigma like 40m leads to U-turn at Tschaikowskistraße
mapMatching.setMeasurementErrorSigma(50);
List<GPXEntry> inputGPXEntries = new GPXFile()
.doImport("./src/test/resources/tour-with-loop.gpx").getEntries();
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(Arrays.asList("Jahnallee, B 87, B 181", "Jahnallee, B 87, B 181",
"Jahnallee, B 87, B 181", "Jahnallee, B 87, B 181", "Funkenburgstraße",
"Gustav-Adolf-Straße", "Tschaikowskistraße", "Jahnallee, B 87, B 181",
"Lessingstraße", "Lessingstraße"), fetchStreets(mr.getEdgeMatches()));
}
示例14: testUTurns
import com.graphhopper.util.GPXEntry; //导入依赖的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()));
}
示例15: testIssue13
import com.graphhopper.util.GPXEntry; //导入依赖的package包/类
@Test
public void testIssue13() {
CarFlagEncoder encoder = new CarFlagEncoder();
TestGraphHopper hopper = new TestGraphHopper();
hopper.setDataReaderFile("../map-data/map-issue13.osm.gz");
hopper.setGraphHopperLocation("../target/mapmatchingtest-13");
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.importOrLoad();
AlgorithmOptions opts = AlgorithmOptions.start().build();
MapMatching mapMatching = new MapMatching(hopper, opts);
List<GPXEntry> inputGPXEntries = new GPXFile().
doImport("./src/test/resources/issue-13.gpx").getEntries();
MatchResult mr = mapMatching.doWork(inputGPXEntries);
// make sure no virtual edges are returned
int edgeCount = hopper.getGraphHopperStorage().getAllEdges().getMaxId();
for (EdgeMatch em : mr.getEdgeMatches()) {
assertTrue("result contains virtual edges:" + em.getEdgeState().toString(),
em.getEdgeState().getEdge() < edgeCount);
}
// create street names
assertEquals(Arrays.asList("", "", "", "", "", ""),
fetchStreets(mr.getEdgeMatches()));
assertEquals(mr.getGpxEntriesLength(), mr.getMatchLength(), 2.5);
assertEquals(28790, mr.getMatchMillis(), 50);
}