Java package/function that reads GPX files

Hello all,

I have added an element in my GPX file and would like this element to be available when doing map-matching. I have been looking at the JAVA source code but couldn’t figure out how this is done by GH.

I believe the function that creates GPX entries based on a file is the:

public static List<GPXEntry> createGPXList(InstructionList instructions)

inside the GpxConversions.java file. However, I can’t find the function that parses the GPX file itself.

Any help/suggestion is greatly appreciated.

EDIT: I’m a C++ developer and not very familiar with Java so please be kind.

Can you give an example of what you are trying to achieve?

The createGPXList method creates GPX entries based on the calculated route, not the (gpx input?) file.

Thank you for the response easbar.

I apologize if my post didn’t make sense.

I have an actual driven distance data for each GPS point and would like to replace the linearDistance:

final double linearDistance = distanceCalc.calcDist(prevTimeStep.observation.getPoint().lat, prevTimeStep.observation.getPoint().lon, timeStep.observation.getPoint().lat, timeStep.observation.getPoint().lon) + timeStep.observation.getAccumulatedLinearDistanceToPrevious();

for the:

double transitionLogProbability = probabilities.transitionLogProbability(path.getDistance(), linearDistance);

with the function similar to this:

final double drivenDistance = (timeStep.observation.getDrivenDistance() - prevTimeStep.observation.getDrivenDistance()) + timeStep.observation.getAccumulatedDrivenDistance();

then I can just use:

double transitionLogProbability = probabilities.transitionLogProbability(path.getDistance(), drivenDistance);

So I am thinking of adding this driven distance data in the GPX file in addition to the lon, lat and time (e.g. lon, lat, time and driven distance). I can then just read the GPX file and add the driven distance data in the observation class. However, I can’t seem to figure out how GH is reading input GPX files.

The code that reads the gpx file for the match command is here:

So it is just XML deserialization and it should be easy to adjust the Gpx.java file so it includes a field for the property you like to add to the gpx file.

Exactly what I needed!

Thank you very much for your help.