How to Retrieve the Available Metainformation in the Map
This article discusses the use case of retrieving the metainformation at the given map.
Benefits
Useful to be able to know the available content of a map.
Concepts
The metainformation can be retrieved using the getDataInformation operation.
Given a DataInformationRequest object which specifies which fields shall be returned in DataInformationResponse.
Programming Guide
The sample below uses the API to request the available content in a map.
// URL path shared by all used xServer layers
var urlPath = xServerUrl + '/services/rest/XRuntime/experimental/dataInformation';
// We use jQuery to send the request. Be sure to reference jQuery for this to work.
$.ajax(urlPath).always(function(response) {
// The request is expected to return a response of type DataInformationResponse.
if (response) {
print('ProviderInformation: ' + response.mapDescription.providerInformation);
} else {
print('Request did not succeed.');
}
});
The sample below uses the REST API to request the available continents in a map.
// URL path shared by all used xServer layers
var urlPath = xServerUrl + '/services/rest/XRuntime/experimental/dataInformation?continents=true';
// We use jQuery to send the request. Be sure to reference jQuery for this to work.
$.ajax(urlPath).always(function(response) {
// The request is expected to return a response of type DataInformationResponse.
if (response) {
var s = 'Continents: ';
for (var i = 0; i < response.continents.length; i++) {
s += response.continents[i].code + ' (' + response.continents[i].countries.length + ' countries)';
if (i != response.continents.length - 1) {
s += ', ';
}
}
print(s);
} else {
print('Request did not succeed.');
}
});
The sample below uses the REST API to request the properties that are used for toll calculation if detailed toll data is installed.
// URL path shared by all used xServer layers
var urlPath = xServerUrl + '/services/rest/XRuntime/experimental/dataInformation';
var hasDetailedToll = false;
var usedProfileProperties;
// We use jQuery to send the request. Be sure to reference jQuery for this to work.
$.ajax(urlPath).always(function(response) {
if (response) {
if (response.mapFeatures.tollFeatures) {
if (response.mapFeatures.tollFeatures.detailLevel == 'DETAILED' || response.mapFeatures.tollFeatures.detailLevel == 'MIXED') {
hasDetailedToll = true;
}
if (hasDetailedToll && response.mapFeatures.tollFeatures.profileProperties) {
usedProfileProperties = response.mapFeatures.tollFeatures.profileProperties;
}
}
}
});
if (hasDetailedToll) {
print('The following ' + usedProfileProperties.length + ' profile parameters may influence toll price calculation: ' + usedProfileProperties.toString());
} else {
print('For basic toll there is only the static description in the vehicle profile.');
}
The sample below uses the REST API to request the profile properties that may influence the algorithm when PTV_TruckAttributes are enabled.
// URL path shared by all used xServer layers
var urlPath = xServerUrl + '/services/rest/XRuntime/experimental/dataInformation';
var hasTA = false;
var usedProfileProperties;
// We use jQuery to send the request. Be sure to reference jQuery for this to work.
$.ajax(urlPath).always(function(response) {
if (response) {
if (response.mapFeatures.featureLayerThemes) {
for (i = 0; i < response.mapFeatures.featureLayerThemes.length; ++i) {
theme = response.mapFeatures.featureLayerThemes[i];
if (theme.themeId == 'PTV_TruckAttributes') {
hasTA = true;
usedProfileProperties = response.mapFeatures.featureLayerThemes[i].profileProperties;
}
}
}
}
});
if (hasTA) {
print('The following ' + usedProfileProperties.length + ' profile parameters may influence routing with truck attributes: ' + usedProfileProperties.toString());
} else {
print('The feature layer PTV_TruckAttributes appears not to be installed.');
}