void TestGeoDataPack::saveKMLToCache() { GeoDataParser parser( GeoData_KML ); QByteArray array( content.toUtf8() ); QBuffer buffer( &array ); buffer.open( QIODevice::ReadOnly ); if ( !parser.read( &buffer ) ) { qWarning( "Could not parse data!" ); QFAIL( "Could not parse data!" ); return; } GeoDocument* document = parser.releaseDocument(); QVERIFY( document ); qDebug() << " parse Timer " << timer.elapsed(); GeoDataDocument *dataDocument = static_cast<GeoDataDocument*>( document ); QString path = QString( "%1/%2.cache" ); path = path.arg( QCoreApplication::applicationDirPath() ); path = path.arg( QString( "KMLTest" ) ); QFile cacheFile( path ); if ( cacheFile.open( QIODevice::WriteOnly ) ) { QDataStream stream ( &cacheFile ); dataDocument->pack( stream ); cacheFile.close(); qDebug( "Saved kml document to cache: %s", path.toLatin1().data() ); } qDebug() << "write Timer " << timer.elapsed(); delete document; }
void TestGeoDataPack::saveCitiesToCache() { GeoDataParser parser( GeoData_KML ); QFile citiesFile( CITIES_PATH ); citiesFile.open( QIODevice::ReadOnly ); if ( !parser.read( &citiesFile ) ) { qWarning( "Could not parse data!" ); QFAIL( "Could not parse data!" ); return; } GeoDocument* document = parser.releaseDocument(); QVERIFY( document ); qDebug() << "read Timer " << timer.elapsed(); GeoDataDocument *dataDocument = static_cast<GeoDataDocument*>( document ); QString path = QString( "%1/%2.cache" ); path = path.arg( QCoreApplication::applicationDirPath() ); path = path.arg( QString( "CitiesTest" ) ); QFile cacheFile( path ); if ( cacheFile.open( QIODevice::WriteOnly ) ) { QDataStream stream ( &cacheFile ); dataDocument->pack( stream ); cacheFile.close(); qDebug( "Saved kml document to cache: %s", path.toLatin1().data() ); } QVERIFY( cacheFile.size() > 0 ); qDebug() << "write Timer " << timer.elapsed(); delete document; }