Ejemplo n.º 1
0
void GroundOverlayFrame::update()
{
    GeoDataLatLonBox overlayLatLonBox = m_overlay->latLonBox();
    GeoDataPolygon *poly = dynamic_cast<GeoDataPolygon*>( placemark()->geometry() );
    poly->outerBoundary().clear();

    GeoDataCoordinates rotatedCoord;

    GeoDataCoordinates northWest(overlayLatLonBox.west(), overlayLatLonBox.north());
    rotatedCoord = northWest.rotateAround(overlayLatLonBox.center(), overlayLatLonBox.rotation());
    poly->outerBoundary().append( rotatedCoord );

    GeoDataCoordinates southWest(overlayLatLonBox.west(), overlayLatLonBox.south());
    rotatedCoord = southWest.rotateAround(overlayLatLonBox.center(), overlayLatLonBox.rotation());
    poly->outerBoundary().append( rotatedCoord );

    GeoDataCoordinates southEast(overlayLatLonBox.east(), overlayLatLonBox.south());
    rotatedCoord = southEast.rotateAround(overlayLatLonBox.center(), overlayLatLonBox.rotation());
    poly->outerBoundary().append( rotatedCoord );

    GeoDataCoordinates northEast(overlayLatLonBox.east(), overlayLatLonBox.north());
    rotatedCoord = northEast.rotateAround(overlayLatLonBox.center(), overlayLatLonBox.rotation());
    poly->outerBoundary().append( rotatedCoord );
}
Ejemplo n.º 2
0
void TestGeoDataLatLonAltBox::testDefaultConstruction()
{
    GeoDataLatLonBox const latLonBox;

    QCOMPARE( latLonBox.north(), 0.0 );
    QCOMPARE( latLonBox.south(), 0.0 );
    QCOMPARE( latLonBox.east(), 0.0 );
    QCOMPARE( latLonBox.west(), 0.0 );
    QCOMPARE( latLonBox.rotation(), 0.0 );
    QCOMPARE( latLonBox.width(), 0.0 );
    QCOMPARE( latLonBox.height(), 0.0 );
    QVERIFY( !latLonBox.crossesDateLine() );
    QCOMPARE( latLonBox.center(), GeoDataCoordinates( 0, 0 ) );
    QVERIFY( latLonBox.isNull() );
    QVERIFY( latLonBox.isEmpty() );

    QVERIFY( (latLonBox|latLonBox).isNull() );
    QVERIFY( (latLonBox|latLonBox).isEmpty() );
    QVERIFY( !latLonBox.intersects( latLonBox ) );


    GeoDataLatLonAltBox const latLonAltBox;

    QCOMPARE( latLonAltBox.north(), 0.0 );
    QCOMPARE( latLonAltBox.south(), 0.0 );
    QCOMPARE( latLonAltBox.east(), 0.0 );
    QCOMPARE( latLonAltBox.west(), 0.0 );
    QCOMPARE( latLonAltBox.rotation(), 0.0 );
    QCOMPARE( latLonAltBox.width(), 0.0 );
    QCOMPARE( latLonAltBox.height(), 0.0 );
    QVERIFY( !latLonAltBox.crossesDateLine() );
    QCOMPARE( latLonAltBox.center(), GeoDataCoordinates( 0, 0, 0 ) );
    QVERIFY( latLonAltBox.isNull() );
    QVERIFY( latLonAltBox.isEmpty() );
    QCOMPARE( latLonAltBox.minAltitude(), 0.0 );
    QCOMPARE( latLonAltBox.maxAltitude(), 0.0 );
    QCOMPARE( latLonAltBox.altitudeMode(), ClampToGround );

    QVERIFY( (latLonAltBox|latLonAltBox).isNull() );
    QVERIFY( (latLonAltBox|latLonAltBox).isEmpty() );
    QVERIFY( !latLonAltBox.intersects( latLonAltBox ) );
}
Ejemplo n.º 3
0
DatabaseQuery::DatabaseQuery( const MarbleModel* model, const QString &searchTerm, const GeoDataLatLonBox &preferred ) :
    m_queryType( BroadSearch ), m_resultFormat( AddressFormat ), m_searchTerm( searchTerm.trimmed() ),
    m_category( OsmPlacemark::UnknownCategory )
{
    if ( model && model->positionTracking()->status() == PositionProviderStatusAvailable ) {
        m_position = model->positionTracking()->currentLocation();
        m_resultFormat = DistanceFormat;
    } else if ( !preferred.isEmpty() ) {
        m_position = preferred.center();
        m_resultFormat = AddressFormat;
    } else {
        m_resultFormat = AddressFormat;
    }

    QStringList terms = m_searchTerm.split(QLatin1Char(','), QString::SkipEmptyParts );

    QRegExp streetAndHouse( "^(.*)\\s+(\\d+\\D?)$" );
    if ( streetAndHouse.indexIn( terms.first() ) != -1 ) {
        if ( streetAndHouse.capturedTexts().size() == 3 ) {
            terms.removeFirst();
            terms.push_front( streetAndHouse.capturedTexts().at( 1 ) );
            terms.push_front( streetAndHouse.capturedTexts().at( 2 ) );
        }
    }

    Q_ASSERT( terms.size() > 0 );
    if ( terms.size() == 1 ) {
        m_queryType = isPointOfInterest( m_searchTerm ) ? CategorySearch : BroadSearch;
    } else if ( terms.size() == 2 ) {
        m_street = terms.first().trimmed();
        m_region = terms.last().trimmed();
        m_queryType = isPointOfInterest( m_street ) ? CategorySearch : AddressSearch;
    } else {
        m_houseNumber = terms.first().trimmed();
        m_street = terms.at( 1 ).trimmed();
        m_region = terms.last().trimmed(); // skips 2, 3, ..., if any
        m_queryType = AddressSearch;
    }
}