Constructor.
Addes a new path metadata object
the new metadata
Loads a json file that contains custom map info.
1.1
public static CustomMapInfo load(final VMDFile file, map: VenueMap, options: WaypointLabelOptions) { //load metadata from json file
const customMapInfo = new CustomMapInfo();
if (file == null) return customMapInfo;
// BaseLogger.logInfo(String.format("Loading VMMS map custom info from path: '%s'", file.getFilePath()));
try { String json = JSONFileLoader.loadJSONFromInputStream(file.getInputStream());
if (json.isEmpty()) return customMapInfo;
JSONObject obj = new JSONObject(json);
JSONArray pointsArray = obj.getJSONArray("points");
for (int i = 0; i < pointsArray.length(); i++) {
try {
JSONObject path = pointsArray.getJSONObject(i);
String id = path.getString("id").replace("-", "_");
String description = path.has("description") ? path.getString("description") : "";
String publicDescription = path.getString("public-description");
Waypoint wp = map.findWaypointWithId(id);
if( wp != null ) {
wp.setDescription(description);
wp.setPublicDescription(publicDescription);
if (!publicDescription.isEmpty()) {
wp.setCanBeAutolabeled(false);
if (options.showDebugInLabels()) {
wp.setPublicDescription(String.format("[*] %s", wp.getPublicDescription()));
}
BaseLogger.logDebug(String.format("Setting description for %s to '%s'", id, wp.getPublicDescription()));
}
}
else
{
BaseLogger.logWarn(String.format("Could not find waypoint with id: %s", id));
}
} catch (Exception e) {
BaseLogger.logError(String.format("Unable to add waypoint: %s", e));
}
}
JSONArray pathsArray = obj.getJSONArray("paths");
for (int i = 0; i < pathsArray.length(); i++) {
try {
JSONObject point = pathsArray.getJSONObject(i);
String p1 = point.getString("p1").replace("-", "_");
String p2 = point.getString("p2").replace("-", "_");
String description = point.has("description") ? point.getString("description") : "";
String description1 = point.getString("description-d1");
String description2 = point.getString("description-d2");
if (!description1.isEmpty() && options.showDebugInLabels()) {
description1 = String.format("[*] %s", description1);
}
if (!description2.isEmpty() && options.showDebugInLabels()) {
description2 = String.format("[*] %s", description2);
}
Waypoint point1 = map.findWaypointWithId(p1);
Waypoint point2 = map.findWaypointWithId(p2);
if (point1 == null) {
BaseLogger.logWarn(String.format("Invalid path with point: %s", p1));
continue;
}
if (point2 == null) {
BaseLogger.logWarn(String.format("Invalid path with point: %s", p2));
continue;
}
//create separate path metadata for each direction of the
PathMetadata pm1 = new PathMetadata(point1, point2, description, description1, description2);
pm1.setCanBeAutolabeled(description1.isEmpty());
customMapInfo.metadata.put(pm1.getPathId(), pm1);
PathMetadata pm2 = new PathMetadata(point2, point1, description, description2, description1);
pm2.setCanBeAutolabeled(description2.isEmpty());
customMapInfo.metadata.put(pm2.getPathId(), pm2);
} catch (Exception e) {
BaseLogger.logError(String.format("Unable to add path: %s", e));
}
}
} catch (JSONException e) { BaseLogger.logError(String.format("Error occurred while parsing custom map info: %s", e.getLocalizedMessage())); }
return customMapInfo; }
Retrieves the metadata associated with two waypoints.
The ID of the first point.
The ID of the second point.
Returns path metadata for the segment.
Generated using TypeDoc
Class that contains custom info that can be used when creating turn by turn directions and auto-labeling waypoints.
Since
2.0.0