This example illuminates how to obtain the complete result list including polylines for visualization and considering the result list options which have to be enabled according to the API. Please notice that the basic elements are described in the code sample: How to match GPS tracks in principle.
PTV recommends that the deprecated methods are replaced by using matchPositions for future development tasks. The enhancement of attributes is simply applicable without violating the downwards compatibility.
Define the following attributes to be enabled:
Generate class details and enable the existing parameters to be added in the result list.
ResultListOptions details = new ResultListOptions(); details.setPolyline(true); details.setSpeedClass(true); details.setVendorId(true);
Generate class details and enable the existing parameters to be added in the result list.
ResultListOptions details = new ResultListOptions(); details.polyline = true; details.polylineSpecified = true; details.speedClass = true; details.speedClassSpecified = true; details.vendorId = true; details.vendorIdSpecified = true;
The method contains two mandatory arguments as follows:
Call method.
matchPositions = client.matchPositions(trackPositions, details);
Call method.
MatchResult matchPositions = client.matchPositions(trackPositions, details, cxt);
The match result contains the above named properties in addition. Visualize the polyline and list the detailed information in a corresponding table.
List the details.
for (MatchedSegment matchedSegment : matchedLocation.getPath()) { rows[index][1] = matchedSegment.getTileId(); rows[index][2] = matchedSegment.getCountryCode(); rows[index][3] = matchedSegment.getNetworkClass(); rows[index][4] = matchedSegment.getSpeedClass(); rows[index][5] = matchedSegment.getVendorId(); ... }
List the details.
MapMatchTableEntry row = new MapMatchTableEntry { inputID = matchedLocation.inputId, tileID = matchedSegment.tileId, IU = matchedSegment.countryCode, NC = matchedSegment.networkClass, SC = matchedSegment.speedClass, vendorID = matchedSegment.vendorId, startXYN = startXYN, endXYN = endXYN }; MapMatchingTable.Add(row);
The matched segments are displayed by the corresponding polyline.
The following table exemplarily illustrates the relevant attributes including the already mentioned details: speed class and vendorID.
Copyright © 2024 PTV Logistics GmbH All rights reserved. | Imprint