本文整理汇总了C++中GeoDataDocument::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoDataDocument::setName方法的具体用法?C++ GeoDataDocument::setName怎么用?C++ GeoDataDocument::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoDataDocument
的用法示例。
在下文中一共展示了GeoDataDocument::setName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveTrack
bool PositionTracking::saveTrack( const QString& fileName )
{
if ( fileName.isEmpty() ) {
return false;
}
GeoWriter writer;
//FIXME: a better way to do this?
writer.setDocumentType( kml::kmlTag_nameSpaceOgc22 );
GeoDataDocument *document = new GeoDataDocument;
QFileInfo fileInfo( fileName );
QString name = fileInfo.baseName();
document->setName( name );
foreach( const GeoDataStyle &style, d->m_document.styles() ) {
document->addStyle( style );
}
foreach( const GeoDataStyleMap &map, d->m_document.styleMaps() ) {
document->addStyleMap( map );
}
GeoDataPlacemark *track = new GeoDataPlacemark( *d->m_currentTrackPlacemark );
track->setName( "Track " + name );
document->append( track );
QFile file( fileName );
file.open( QIODevice::WriteOnly );
bool const result = writer.write( &file, document );
file.close();
delete document;
return result;
}
示例2: saveRoute
void RoutingManagerPrivate::saveRoute(const QString &filename)
{
GeoWriter writer;
writer.setDocumentType( kml::kmlTag_nameSpaceOgc22 );
QMutexLocker locker( &m_fileMutex );
QFile file( filename );
if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
mDebug() << "Cannot write to " << file.fileName();
return;
}
GeoDataDocument container;
container.setName(QStringLiteral("Route"));
GeoDataFolder* request = routeRequest();
if ( request ) {
container.append( request );
}
GeoDataDocument *route = m_alternativeRoutesModel.currentRoute();
if ( route ) {
container.append( new GeoDataDocument( *route ) );
}
if ( !writer.write( &file, &container ) ) {
mDebug() << "Can not write route state to " << file.fileName();
}
file.close();
}
示例3: createTour
void TourWidgetPrivate::createTour()
{
if ( overrideModifications() ) {
GeoDataDocument *document = new GeoDataDocument();
document->setDocumentRole( UserDocument );
document->setName( "New Tour" );
document->setId( "new_tour" );
GeoDataTour *tour = new GeoDataTour();
tour->setName( "New Tour" );
GeoDataPlaylist *playlist = new GeoDataPlaylist;
tour->setPlaylist( playlist );
document->append( static_cast<GeoDataFeature*>( tour ) );
m_playback.setBaseUrl( QUrl::fromLocalFile( MarbleDirs::marbleDataPath() ) );
openDocument( document );
m_isChanged = true;
m_tourUi.m_actionSaveTour->setEnabled( true );
}
}
示例4: cleanupLoader
void FileManagerPrivate::cleanupLoader( FileLoader* loader )
{
GeoDataDocument *doc = loader->document();
m_loaderList.removeAll( loader );
if ( loader->isFinished() ) {
if ( doc ) {
if ( doc->name().isEmpty() && !doc->fileName().isEmpty() )
{
QFileInfo file( doc->fileName() );
doc->setName( file.baseName() );
}
m_treeModel->addDocument( doc );
m_fileItemHash.insert( loader->path(), doc );
emit q->fileAdded( loader->path() );
if( loader->recenter() ) {
m_latLonBox |= doc->latLonAltBox();
}
}
if ( !loader->error().isEmpty() ) {
QMessageBox errorBox;
errorBox.setWindowTitle( QObject::tr("File Parsing Error"));
errorBox.setText( loader->error() );
errorBox.setIcon( QMessageBox::Warning );
errorBox.exec();
qWarning() << "File Parsing error " << loader->error();
}
delete loader;
}
if ( m_loaderList.isEmpty() )
{
mDebug() << "Finished loading all placemarks " << m_timer.elapsed();
if ( !m_latLonBox.isEmpty() ) {
emit q->centeredDocument( m_latLonBox );
}
m_latLonBox.clear();
}
}
示例5: retrieveData
void YoursRunner::retrieveData( QNetworkReply *reply )
{
if ( reply->isFinished() ) {
QByteArray data = reply->readAll();
reply->deleteLater();
//mDebug() << "Download completed: " << data;
GeoDataDocument* result = parse( data );
if ( result ) {
QString name = "%1 %2 (Yours)";
QString unit = "m";
qreal length = distance( result );
if ( length == 0.0 ) {
delete result;
emit routeCalculated( 0 );
return;
} else if ( length >= 1000 ) {
length /= 1000.0;
unit = "km";
}
result->setName( name.arg( length, 0, 'f', 1 ).arg( unit ) );
}
emit routeCalculated( result );
}
}
示例6: parse
GeoDataDocument* MapQuestRunner::parse( const QByteArray &content ) const
{
QDomDocument xml;
if ( !xml.setContent( content ) ) {
mDebug() << "Cannot parse xml file with routing instructions.";
return 0;
}
// mDebug() << xml.toString(2);
QDomElement root = xml.documentElement();
GeoDataDocument* result = new GeoDataDocument();
result->setName( "MapQuest" );
GeoDataPlacemark* routePlacemark = new GeoDataPlacemark;
routePlacemark->setName( "Route" );
GeoDataLineString* routeWaypoints = new GeoDataLineString;
QDomNodeList shapePoints = root.elementsByTagName( "shapePoints" );
if ( shapePoints.size() == 1 ) {
QDomNodeList geometry = shapePoints.at( 0 ).toElement().elementsByTagName( "latLng" );
for ( int i=0; i<geometry.size(); ++i ) {
double const lat = geometry.item( i ).namedItem( "lat" ).toElement().text().toDouble();
double const lon = geometry.item( i ).namedItem( "lng" ).toElement().text().toDouble();
GeoDataCoordinates const position( lon, lat, 0.0, GeoDataCoordinates::Degree );
routeWaypoints->append( position );
}
}
routePlacemark->setGeometry( routeWaypoints );
QTime time;
time = time.addSecs( root.elementsByTagName( "time" ).at( 0 ).toElement().text().toInt() );
qreal length = routeWaypoints->length( EARTH_RADIUS );
const QString name = nameString( "MQ", length, time );
const GeoDataExtendedData data = routeData( length, time );
routePlacemark->setExtendedData( data );
result->setName( name );
result->append( routePlacemark );
QMap<int,int> mapping;
QDomNodeList maneuvers = root.elementsByTagName( "maneuverIndexes" );
if ( maneuvers.size() == 1 ) {
maneuvers = maneuvers.at( 0 ).childNodes();
for ( int i=0; i<maneuvers.size(); ++i ) {
mapping[i] = maneuvers.at( i ).toElement().text().toInt();
if ( mapping[i] == routeWaypoints->size() ) {
--mapping[i];
}
}
}
QDomNodeList instructions = root.elementsByTagName( "maneuver" );
unsigned int const lastInstruction = qMax<int>( 0, instructions.length()-1 ); // ignore the last 'Welcome to xy' instruction
for ( unsigned int i = 0; i < lastInstruction; ++i ) {
QDomElement node = instructions.item( i ).toElement();
QDomNodeList maneuver = node.elementsByTagName( "turnType" );
QDomNodeList textNodes = node.elementsByTagName( "narrative" );
QDomNodeList points = node.elementsByTagName( "startPoint" );
QDomNodeList streets = node.elementsByTagName( "streets" );
Q_ASSERT( mapping.contains( i ) );
if ( textNodes.size() == 1 && maneuver.size() == 1 && points.size() == 1 && mapping.contains( i ) ) {
GeoDataPlacemark* instruction = new GeoDataPlacemark;
instruction->setName( textNodes.at( 0 ).toElement().text() );
GeoDataExtendedData extendedData;
GeoDataData turnType;
turnType.setName( "turnType" );
turnType.setValue( maneuverType( maneuver.at( 0 ).toElement().text().toInt() ) );
extendedData.addValue( turnType );
if ( streets.size() == 1 ) {
GeoDataData roadName;
roadName.setName( "roadName" );
roadName.setValue( streets.at( 0 ).toElement().text() );
extendedData.addValue( roadName );
}
instruction->setExtendedData( extendedData );
int const start = mapping[i];
int const end = mapping.contains(i+1) ? mapping[i+1] : routeWaypoints->size()-1;
if ( start >= 0 && start < routeWaypoints->size() && end < routeWaypoints->size() ) {
instruction->setName( textNodes.item( 0 ).toElement().text() );
GeoDataLineString *lineString = new GeoDataLineString;
for ( int j=start; j<=end; ++j ) {
*lineString << GeoDataCoordinates( routeWaypoints->at( j ).longitude(), routeWaypoints->at( j ).latitude() );
}
if ( !lineString->isEmpty() ) {
instruction->setGeometry( lineString );
result->append( instruction );
}
}
}
}
if ( routeWaypoints->size() < 1 ) {
delete result;
result = 0;
}
//.........这里部分代码省略.........
示例7: position
GeoDataDocument *CycleStreetsRunner::parse( const QByteArray &content ) const
{
QDomDocument xml;
if ( !xml.setContent( content ) ) {
mDebug() << "Cannot parse xml file with routing instructions.";
return 0;
}
GeoDataDocument *result = new GeoDataDocument();
result->setName( "CycleStreets" );
GeoDataPlacemark *routePlacemark = new GeoDataPlacemark;
routePlacemark->setName( "Route" );
GeoDataLineString *routeWaypoints = new GeoDataLineString;
QDomNodeList features = xml.elementsByTagName( "gml:featureMember" );
if ( features.isEmpty() ) {
return 0;
}
QDomElement route = features.at( 0 ).toElement().firstChild().toElement();
QDomElement lineString = route.elementsByTagName( "gml:LineString" ).at( 0 ).toElement();
QDomElement coordinates = lineString.toElement().elementsByTagName( "gml:coordinates" ).at( 0 ).toElement();
QStringList coordinatesList = coordinates.text().split( ' ' );
QStringList::iterator iter = coordinatesList.begin();
QStringList::iterator end = coordinatesList.end();
for( ; iter != end; ++iter) {
QStringList coordinate = iter->split(',');
if ( coordinate.size() == 2 ) {
double const lon = coordinate.at( 0 ).toDouble();
double const lat = coordinate.at( 1 ).toDouble();
GeoDataCoordinates const position( lon, lat, 0.0, GeoDataCoordinates::Degree );
routeWaypoints->append( position );
}
}
routePlacemark->setGeometry( routeWaypoints );
QDomElement durationElement = route.elementsByTagName( "cs:time" ).at(0).toElement();
QTime duration;
duration = duration.addSecs( durationElement.text().toInt() );
qreal length = routeWaypoints->length( EARTH_RADIUS );
const QString name = nameString( "CS", length, duration );
const GeoDataExtendedData data = routeData( length, duration );
routePlacemark->setExtendedData( data );
result->setName( name );
result->append( routePlacemark );
int i;
for ( i = 1; i < features.count() && features.at( i ).firstChildElement().tagName() != "cs:segment"; ++i );
for ( ; i < features.count(); ++i) {
QDomElement segment = features.at( i ).toElement();
QString name = segment.elementsByTagName( "cs:name" ).at( 0 ).toElement().text();
QString maneuver = segment.elementsByTagName( "cs:turn" ).at( 0 ).toElement().text();
QStringList points = segment.elementsByTagName( "cs:points" ).at( 0 ).toElement().text().split( ' ' );
QStringList const elevation = segment.elementsByTagName( "cs:elevations" ).at( 0 ).toElement().text().split( ',' );
GeoDataPlacemark *instructions = new GeoDataPlacemark;
QString instructionName;
if ( !maneuver.isEmpty() ) {
instructionName = maneuver.left( 1 ).toUpper() + maneuver.mid( 1 );
} else {
instructionName = "Straight";
}
if ( name != "Short un-named link" && name != "Un-named link" ){
instructionName.append( " into " + name );
}
instructions->setName( instructionName );
GeoDataExtendedData extendedData;
GeoDataData turnType;
turnType.setName( "turnType" );
turnType.setValue( maneuverType( maneuver ) );
extendedData.addValue( turnType );
instructions->setExtendedData( extendedData );
GeoDataLineString *lineString = new GeoDataLineString;
QStringList::iterator iter = points.begin();
QStringList::iterator end = points.end();
for ( int j=0; iter != end; ++iter, ++j ) {
QStringList coordinate = iter->split( ',' );
if ( coordinate.size() == 2 ) {
double const lon = coordinate.at( 0 ).toDouble();
double const lat = coordinate.at( 1 ).toDouble();
double const alt = j < elevation.size() ? elevation[j].toDouble() : 0.0;
lineString->append( GeoDataCoordinates( lon, lat, alt, GeoDataCoordinates::Degree ) );
}
}
instructions->setGeometry( lineString );
result->append( instructions );
}
return result;
}