×
Namespaces

Variants
Actions
(Difference between revisions)

How to import landmarks from file to database

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot addition of Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Adding missing translation link)
 
Line 91: Line 91:
  
 
[[Category:How To]][[Category:Code Examples]]
 
[[Category:How To]][[Category:Code Examples]]
 +
<!-- Translation --> [[ru:Импорт ориентиров]]

Latest revision as of 07:40, 16 December 2011

Article Metadata
Article
Created: Den123 (12 Apr 2008)
Last edited: hamishwillee (16 Dec 2011)

You can use class CPosLandmarkParser for parsing the landmark content, this functionality can be used for importing data from files. The type (e.g. the mime type) must be specified for creating instance of this class. You can use mime type "application/vnd.nokia.landmarkcollection+xml".

The following code snippet demonstrates how to import data from the XML-file to the specified local landmark database. It is necessary to include the following headers:

#include <epos_cposlmdatabasemanager.h>
#include <epos_hposlmdatabaseinfo.h>
#include <epos_cposlandmarkparser.h>

And link against:

LIBRARY  eposlandmarks.lib
LIBRARY eposlmdbmanlib.lib
// db URI
_LIT( KNewDbUri, "file://C:new.ldb" );
TBuf<32> newDbUri( KNewDbUri );
 
// file with landmarks
_LIT( KSrcFile, "C:\\LmBackup\\my_lms.xml" );
 
// db manager
CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager :: NewL();
CleanupStack :: PushL( dbManager );
 
// create database, if necessary
if( !dbManager->DatabaseExistsL( newDbUri ) )
{
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo :: NewLC( newDbUri );
dbManager->CreateDatabaseL( *dbInfo );
CleanupStack :: PopAndDestroy( dbInfo );
}
 
// open DB and init it, if necessary
CPosLandmarkDatabase* db = CPosLandmarkDatabase :: OpenL( newDbUri );
CleanupStack :: PushL( db );
if( db->IsInitializingNeeded() )
ExecuteAndDeleteLD( db->InitializeL() );
 
// clear the database (batch mode)
ExecuteAndDeleteLD( db->RemoveAllLandmarksL() );
 
// MIME type for import & export
_LIT8( KPosMimeTypeLandmarkCollectionXml, "application/vnd.nokia.landmarkcollection+xml" );
 
// Create the parser to be used for importing landmarks
CPosLandmarkParser* parser = CPosLandmarkParser :: NewL( KPosMimeTypeLandmarkCollectionXml );
CleanupStack :: PushL( parser );
 
// import data (batch mode)
parser->SetInputFileL( KSrcFile );
ExecuteAndDeleteLD( db->ImportLandmarksL( *parser, CPosLandmarkDatabase::EDefaultOptions ) );
 
CleanupStack :: PopAndDestroy( 3 ); // parser db dbManager

[edit] Related Links:

This page was last modified on 16 December 2011, at 07:40.
74 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×