Location Wikipedia
Landmarks can include Wikipedia data such as title, image title, URL, description, page summary, and language. The ExternalInfo class handles Wikipedia data.
Check Wikipedia Data Availability
Use the hasWikiInfo method to check if a landmark has Wikipedia data:
auto externalInfo = ExternalInfo::produce();
bool hasExternalInfo = externalInfo->hasWikiInfo(landmark);
Do not modify Wikipedia-related fields in the extraInfo property when changing landmark data.
Get Wikipedia Information
Populate an ExternalInfo object by calling the requestWikiInfo method:
auto externalInfo = ExternalInfo::produce();
externalInfo->requestWikiInfo(
landmark,
yourProgressListenerImpl);
// Wait for the operation to complete (replace with your own synchronization mechanism).
WAIT_UNTIL( std::bind( &YourProgressListenerImpl::IsFinished, yourProgressListenerImpl ), 15000 );
// Data about the page
String title = externalInfo->getWikiPageTitle();
String content = externalInfo->getWikiPageDescription();
String language = externalInfo->getWikiPageLanguage();
String pageUrl = externalInfo->getWikiPageURL();
A requestWikiInfo call can be canceled by calling cancelWikiInfo(). Other request calls can be canceled by calling the corresponding cancel methods with the same progress listener object.
Wikipedia data is provided in the language specified in SDKSettings. See Internationalization for details.
Results:
- Success: Returns
KNoErrorand theExternalInfoobject is populated with data. Get methods will return the content. - Failure: Returns one of these errors and
ExternalInforemains empty:error::KInvalidInput- Landmark does not contain Wikipedia informationerror::KConnection- No internet connection availableerror::KNotFound- Wikipedia information could not be retrievederror::KGeneral- Unspecified error occurred
Get Wikipedia Image Data
Access image details from the ExternalInfo class:
int imgCount = externalInfo->getWikiImagesCount();
String imageUrl = externalInfo->getWikiImageURL(0);
String imageDescription = externalInfo->getWikiImageDescription(0);
String imageTitle = externalInfo->getWikiImageTitle(0);
Retrieve detailed image information using the requestWikiImageInfo method:
String outImageInfo;
externalInfo->requestWikiImageInfo(yourProgressListenerImpl,
0, // image index
outImageInfo);
// Wait for the operation to complete then do something with the info
The requestWikiImageInfo method accepts a progress listener that can also be used to cancel the request by calling the cancelWikiImageInfoRequest method.