예제 #1
0
void EditPolylineDialog::updatePolyline()
{
    d->m_placemark->setDescription( d->m_description->toPlainText() );
    d->m_placemark->setName( d->m_name->text() );


    GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
    newStyle->lineStyle().setColor( d->m_linesDialog->currentColor() );
    newStyle->lineStyle().setWidth( d->m_linesWidth->value() );
    d->m_placemark->setStyle( newStyle );

    emit polylineUpdated( d->m_placemark );
}
예제 #2
0
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
0
파일: OsmNode.cpp 프로젝트: tbhdwx/marble
void OsmNode::create(GeoDataDocument *document) const
{
    GeoDataFeature::GeoDataVisualCategory const category = OsmPresetLibrary::determineVisualCategory(m_osmData);
    if (category == GeoDataFeature::None ||
       (category >= GeoDataFeature::HighwaySteps && category <= GeoDataFeature::HighwayMotorway)) {
        return;
    }

    GeoDataPlacemark* placemark = new GeoDataPlacemark;
    placemark->setOsmData(m_osmData);
    placemark->setCoordinate(m_coordinates);

    if ((category == GeoDataFeature::TransportCarShare || category == GeoDataFeature::MoneyAtm)
            && m_osmData.containsTagKey("operator")) {
        placemark->setName(m_osmData.tagValue("operator"));
    } else {
        placemark->setName(m_osmData.tagValue("name"));
    }
    placemark->setZoomLevel( 18 );
    placemark->setVisualCategory(category);
    placemark->setStyle( 0 );

    if (category == GeoDataFeature::NaturalTree) {
        qreal const lat = m_coordinates.latitude(GeoDataCoordinates::Degree);
        if (qAbs(lat) > 15) {
            /** @todo Should maybe auto-adjust to MarbleClock at some point */
            QDate const date = QDate::currentDate();
            bool const southernHemisphere = lat < 0;
            QDate const autumnStart = QDate(date.year(), southernHemisphere ? 3 : 9, 15);
            QDate const winterEnd = southernHemisphere ? QDate(date.year(), 8, 15) : QDate(date.year()+1, 2, 15);
            if (date > autumnStart && date < winterEnd) {
                QDate const autumnEnd = QDate(date.year(), southernHemisphere ? 5 : 11, 15);
                QString const season = date < autumnEnd ? "autumn" : "winter";
                GeoDataIconStyle iconStyle = placemark->style()->iconStyle();
                QString const bitmap = QString("bitmaps/osmcarto/symbols/48/individual/tree-29-%1.png").arg(season);
                iconStyle.setIconPath(MarbleDirs::path(bitmap));

                GeoDataStyle* style = new GeoDataStyle(*placemark->style());
                style->setIconStyle(iconStyle);
                placemark->setStyle(style);

            }
        }
    }

    OsmObjectManager::registerId(m_osmData.id());
    document->append(placemark);
}
예제 #4
0
void TourWidgetPrivate::addPlacemark()
{
    // Get the normalized coordinates of the focus point. There will be automatically added a new
    // placemark.
    qreal lat = m_widget->focusPoint().latitude();
    qreal lon = m_widget->focusPoint().longitude();
    GeoDataCoordinates::normalizeLonLat( lon, lat );

    GeoDataDocument *document = new GeoDataDocument;
    if( m_document->id().isEmpty() ) {
        if( m_document->name().isEmpty() ) {
            m_document->setId( "untitled_tour" );
        } else {
            m_document->setId( m_document->name().trimmed().replace( " ", "_" ).toLower() );
        }
    }
    document->setTargetId( m_document->id() );

    GeoDataPlacemark *placemark = new GeoDataPlacemark;
    placemark->setCoordinate( lon, lat );
    placemark->setVisible( true );
    placemark->setBalloonVisible( true );
    GeoDataStyle *newStyle = new GeoDataStyle( *placemark->style() );
    newStyle->iconStyle().setIcon( QImage() );
    newStyle->iconStyle().setIconPath( MarbleDirs::path("bitmaps/redflag_22.png") );
    placemark->setStyle( newStyle );

    document->append( placemark );

    GeoDataCreate *create = new GeoDataCreate;
    create->append( document );
    GeoDataUpdate *update = new GeoDataUpdate;
    update->setCreate( create );
    GeoDataAnimatedUpdate *animatedUpdate = new GeoDataAnimatedUpdate;
    animatedUpdate->setUpdate( update );

    if( m_delegate->editAnimatedUpdate( animatedUpdate ) ) {
        addTourPrimitive( animatedUpdate );
        m_delegate->setDefaultFeatureId( placemark->id() );
    } else {
        delete animatedUpdate;
    }
}
예제 #5
0
void EditPlacemarkDialog::updateTextAnnotation()
{
    d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
    //allow for HTML in the description
    d->m_placemark->setDescriptionCDATA( true );
    d->m_placemark->setName( d->m_header->name() );
    d->m_placemark->setCoordinate( GeoDataCoordinates( d->m_header->longitude(),
                                                                         d->m_header->latitude(),
                                                                         0,
                                                                         GeoDataCoordinates::Degree ) );

    d->m_placemark->setVisible( d->m_isPlacemarkVisible->isChecked() );
    d->m_placemark->setBalloonVisible( d->m_isBalloonVisible->isChecked() );
    d->m_placemark->setId( d->m_header->id() );
    d->m_placemark->setTargetId( d->m_header->targetId() );

    GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );

    QFileInfo fileInfo( d->m_header->iconLink() );
    if ( fileInfo.exists() ) {
        newStyle->iconStyle().setIconPath( d->m_header->iconLink() );
    }

    newStyle->iconStyle().setScale( d->m_iconScale->value() );
    newStyle->labelStyle().setScale( d->m_labelScale->value() );

    newStyle->iconStyle().setColor( d->m_iconColorDialog->currentColor() );
    newStyle->labelStyle().setColor( d->m_labelColorDialog->currentColor() );

    d->m_placemark->setStyle( newStyle );

    emit textAnnotationUpdated( d->m_placemark );
}
예제 #6
0
void EditPolylineDialog::restoreInitial( int result )
{
    if ( result ) {
        return;
    }

    if ( d->m_placemark->name() != d->m_initialName ) {
        d->m_placemark->setName( d->m_initialName );
    }

    if ( d->m_placemark->description() != d->m_initialDescription ) {
        d->m_placemark->setDescription( d->m_initialDescription );
    }

    if ( d->m_placemark->style()->lineStyle() != d->m_initialLineStyle ) {
        GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
        newStyle->setLineStyle( d->m_initialLineStyle );
        d->m_placemark->setStyle( newStyle );
    }

    emit polylineUpdated( d->m_placemark );
}
예제 #7
0
void EditPolygonDialog::updatePolygon()
{
    GeoDataStyle *style = new GeoDataStyle( *d->m_placemark->style() );

    d->m_placemark->setName( d->m_name->text() );
    d->m_placemark->setDescription( d->m_description->toPlainText() );

    style->lineStyle().setWidth( d->m_linesWidth->value() );
    // 0 corresponds to "Filled" and 1 corresponds to "Not Filled".
    style->polyStyle().setFill( !d->m_filledColor->currentIndex() );


    // Adjust the lines/polygon colors.
    // QColorDialog::currentColor() also works even if the color dialog
    // has not been exec'ed, while QColorDialog::selectedColor() does not.
    style->lineStyle().setColor( d->m_linesDialog->currentColor() );
    style->polyStyle().setColor( d->m_polyDialog->currentColor() );


    d->m_placemark->setStyle( style );
    emit polygonUpdated( d->m_placemark );
}
예제 #8
0
PositionTracking::PositionTracking( GeoDataTreeModel *model )
     : QObject( model ),
       d( new PositionTrackingPrivate( model, this ) )
{
    d->m_document.setDocumentRole( TrackingDocument );
    d->m_document.setName("Position Tracking");

    // First point is current position
    d->m_currentPositionPlacemark->setName("Current Position");
    d->m_currentPositionPlacemark->setVisible(false);
    d->m_document.append( d->m_currentPositionPlacemark );

    // Second point is position track
    d->m_currentTrack = new GeoDataTrack;
    d->m_trackSegments->append(d->m_currentTrack);

    d->m_currentTrackPlacemark->setGeometry(d->m_trackSegments);
    d->m_currentTrackPlacemark->setName("Current Track");

    GeoDataStyle style;
    GeoDataLineStyle lineStyle;
    QColor transparentRed = Oxygen::brickRed4;
    transparentRed.setAlpha( 200 );
    lineStyle.setColor( transparentRed );
    lineStyle.setWidth( 4 );
    style.setLineStyle(lineStyle);
    style.setId("track");

    GeoDataStyleMap styleMap;
    styleMap.setId("map-track");
    styleMap.insert("normal", QString("#").append(style.id()));
    d->m_document.addStyleMap(styleMap);
    d->m_document.addStyle(style);
    d->m_document.append( d->m_currentTrackPlacemark );

    d->m_currentTrackPlacemark->setStyleUrl(QString("#").append(styleMap.id()));

    d->m_treeModel->addDocument( &d->m_document );
}
예제 #9
0
void EditPlacemarkDialog::updateTextAnnotation()
{
    d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
    //allow for HTML in the description
    d->m_placemark->setDescriptionCDATA( true );
    d->m_placemark->setName( d->m_header->name() );
    d->m_placemark->setCoordinate( GeoDataCoordinates( d->m_header->longitude(),
                                                                         d->m_header->latitude(),
                                                                         0,
                                                                         GeoDataCoordinates::Degree ) );

    d->m_placemark->setVisible( d->m_isPlacemarkVisible->isChecked() );
    d->m_placemark->setBalloonVisible( d->m_isBalloonVisible->isChecked() );
    d->m_placemark->setId( d->m_header->id() );
    d->m_placemark->setTargetId( d->m_header->targetId() );


    if ( !d->m_header->iconLink().isEmpty() ) {
        QFileInfo fileInfo( d->m_header->iconLink() );

        GeoDataStyle *newStyle = new GeoDataStyle( *d->m_placemark->style() );
        if ( fileInfo.exists() ) {
            newStyle->iconStyle().setIconPath( d->m_header->iconLink() );
        }

        newStyle->iconStyle().setScale( d->m_iconScale->value() );
        newStyle->labelStyle().setScale( d->m_labelScale->value() );
        newStyle->iconStyle().setColor( d->m_iconColorDialog->currentColor() );
        newStyle->labelStyle().setColor( d->m_labelColorDialog->currentColor() );
        d->m_placemark->setStyle( newStyle );
    }
    else {
        QString suitableTag = d->m_osmTagEditorWidget->suitableTag();
        if ( !suitableTag.isEmpty() ) {
            GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::osmVisualCategory( suitableTag );
            d->m_placemark->setVisualCategory( category );
            d->m_placemark->setStyle( 0 );
        }
    }

    emit textAnnotationUpdated( d->m_placemark );
}
예제 #10
0
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" ) );
}