Caution: The method is deprecated. Please use matchPositions() with the same result.
These sections describe how to obtain the polylines for drawing the matched segments and to return the speed classes in the result list. Only the extended code snippets are presented based on the previous sample: How to match GPS tracks in principle.
 
            In addition to the basic arguments, following two attributes can be enabled:
 Java
Java
            
				Use the method
				matchTrackExtended()
				enabling the attributes
				returnSpeedClass
				and
				returnPolyline
				. Call method
				matchTrackExtended()
				and set the additional parameters true.
			
matchTrack = client.matchTrackExtended(trackPositions, "lux_d", true, true);
 C#
C#
            
				Use the method
				matchTrackExtended()
				enabling the attributes
				returnSpeedClass
				and
				returnPolyline
				. Call method
				matchTrackExtended()
				and set the additional parameters true. At least, add the caller
				context.
			
MatchResult matchTrack = xMapMatchClient.matchTrackExtended(trackPositions, "lux_d", true, true, cxt);
The match result contains the above named properties in addition. Visualize the polyline and list the speed class in a corresponding table.
 Java
Java
            List the speed classes and polylines.
for (MatchedSegment matchedSegment : matchTrack.getCompletePath()) {
	rows[index][0] = matchedSegment.getTileId();
	rows[index][1] = matchedSegment.getSpeedClass();
	String p = "";
	for (Point point : matchedSegment.getPolyline()) {
		p = p + point.getPoint().getX() + "," + point.getPoint().getY()
		+ ";";
	}
	
	rows[index][2] = p;
	index++;
}
	
                Check method runMap(MatchResult matchTrack).
for (MatchedSegment matchedSegment : matchTrack.getCompletePath()) {
	int kmax = matchedSegment.getPolyline().length;
	PlainPoint[] plainPoints = new PlainPoint[kmax];
	int kindex = 0;
	for (Point plainPoint : matchedSegment.getPolyline()) {
		plainPoints[kindex] = plainPoint.getPoint();
		//System.out.println("Point: " + plainPoints[kindex]);
		kindex++;
	}
        
	PlainLineString lineString = new PlainLineString();
	lineString.setPoints(plainPoints);
	lineStrings[lindex] = new LineString();
	lineStrings[lindex].setLineString(lineString);
	lindex++;
}
             C#
C#
            List the speed classes and polylines.
...  
foreach (MatchedSegment matchedSegment in matchedLocation.wrappedPath)  
{  
    String p = "";  
    foreach (xserver.Point point in matchedSegment.wrappedPolyline)  
    {  
        pp = p + point.point.x + "," + point.point.y  
                + ";";  
    }  
  
    CompletePathTableEntry row = new CompletePathTableEntry  
    {  
        id = matchedSegment.tileId,  
        speedClass = matchedSegment.speedClass,  
        linePerSegment = p  
    };  
    MapMatchingTable.Add(row);  
} 
			
                Check method runMap(MatchResult matchTrack).
...  
foreach (MatchedSegment matchedSegment in matchedLocation.wrappedPath)  
{  
  int kmax = matchedSegment.wrappedPolyline.Length;  
  PlainPoint[] plainPoints = new PlainPoint[kmax];  
  int kindex = 0;  
  foreach (xserver.Point plainPoint in matchedSegment.wrappedPolyline)  
  {  
    plainPoints[kindex] = plainPoint.point;  
    kindex++;  
  }  
      
  PlainLineString lineString = new PlainLineString();  
  lineString.wrappedPoints = plainPoints;  
  lineStrings[lindex] = new LineString();  
  lineStrings[lindex].lineString = lineString;  
  lindex++;  
}  
            The matched segments are displayed by the corresponding polyline.
 
            The following table exemplarily illustrates the tile id, the corresponding speed classes and their polylines.
 
            
Copyright © 2025 PTV Logistics GmbH All rights reserved. | Imprint