本文整理汇总了C++中GeoDataDocument::addStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoDataDocument::addStyle方法的具体用法?C++ GeoDataDocument::addStyle怎么用?C++ GeoDataDocument::addStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoDataDocument
的用法示例。
在下文中一共展示了GeoDataDocument::addStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: foreach
GeoDataDocument *OsmParser::createDocument(OsmNodes &nodes, OsmWays &ways, OsmRelations &relations)
{
GeoDataDocument* document = new GeoDataDocument;
GeoDataPolyStyle backgroundPolyStyle;
backgroundPolyStyle.setFill( true );
backgroundPolyStyle.setOutline( false );
backgroundPolyStyle.setColor("#f1eee8");
GeoDataStyle backgroundStyle;
backgroundStyle.setPolyStyle( backgroundPolyStyle );
backgroundStyle.setId( "background" );
document->addStyle( backgroundStyle );
foreach(OsmRelation const &relation, relations) {
relation.create(document, ways, nodes);
}
示例3: parentingTest
void TestGeoData::parentingTest()
{
GeoDataDocument *document = new GeoDataDocument;
GeoDataFolder *folder = new GeoDataFolder;
/// simple parenting test
GeoDataPlacemark *placemark = new GeoDataPlacemark;
placemark->setParent(document);
QCOMPARE(placemark->parent(), document);
/// simple append and child count test
document->append(placemark);
/// appending folder to document before feeding folder
document->append(folder);
QCOMPARE(document->size(), 2);
GeoDataPlacemark *placemark2 = new GeoDataPlacemark;
folder->append(placemark2);
QCOMPARE(folder->size(), 1);
/// retrieve child and check it matches placemark
GeoDataPlacemark *placemarkPtr;
QCOMPARE(document->child(0)->nodeType(), placemark->nodeType());
placemarkPtr = static_cast<GeoDataPlacemark*>(document->child(0));
QCOMPARE(placemarkPtr, placemark);
/// check retrieved placemark matches intented child
int position = document->childPosition(placemarkPtr);
QCOMPARE(position, 0);
/// retrieve child two and check it matches folder
GeoDataFolder *folderPtr;
QCOMPARE(document->child(1)->nodeType(), folder->nodeType());
folderPtr = static_cast<GeoDataFolder*>(document->child(1));
QCOMPARE(folderPtr, folder);
/// check retrieved folder matches intended child
position = document->childPosition(folderPtr);
QCOMPARE(position, 1);
/// retrieve child three and check it matches placemark
QCOMPARE(folderPtr->size(), 1);
placemarkPtr = static_cast<GeoDataPlacemark*>(folderPtr->child(0));
QCOMPARE(placemarkPtr->nodeType(), placemark2->nodeType());
QCOMPARE(placemarkPtr, placemark2);
/// check retrieved placemark matches intended child
QCOMPARE(folderPtr->childPosition(placemarkPtr), 0);
/// Set a style
GeoDataIconStyle iconStyle;
iconStyle.setIconPath( "myicon.png" );
GeoDataStyle* style = new GeoDataStyle;
style->setStyleId( "mystyle" );
style->setIconStyle( iconStyle );
GeoDataObject* noParent = 0;
QCOMPARE( style->parent(), noParent );
QCOMPARE( iconStyle.parent(), noParent );
document->setStyle( style );
QCOMPARE( style->parent(), document ); // Parent should be assigned now
QCOMPARE( style->iconStyle().parent(), style );
QCOMPARE( iconStyle.parent(), noParent ); // setIconStyle copies
QCOMPARE( placemark->style()->parent(), noParent );
placemark->setStyle( style );
QCOMPARE( placemark->style()->parent(), placemark ); // Parent should be assigned now
/// Set a style map
GeoDataStyleMap* styleMap = new GeoDataStyleMap;
styleMap->setStyleId( "mystylemap" );
styleMap->insert( "normal", "#mystyle" );
styleMap->insert( "highlight", "#mystyle" );
document->addStyle( *style );
document->setStyleMap( styleMap );
QCOMPARE( placemark2->style()->parent(), noParent );
placemark2->setStyleUrl( "#mystyle" );
QCOMPARE( placemark2->style()->parent(), document ); // Parent is document, not placemark2
QCOMPARE( iconStyle.iconPath(), QString( "myicon.png" ) );
QCOMPARE( placemark2->style()->iconStyle().iconPath(), QString( "myicon.png" ) );
}