bool LocalMapLayer::isValidPerspective(const GeoDataLatLonBox &candidate) const { if (!mVisible || !mHasContent) { //any perspective is valid if no content is showing return true; } GeoDataLatLonBox box = mLocalMapLogic->currentBox(); if (!candidate.contains(box) && !candidate.intersects(box)) { //No relation - invalid perspective return false; } //Acceptable scales qreal d = diameter(box); qreal zoomOutLimit = d * 4; qreal zoomInLimit = d * 0.25; qreal dCandidate = diameter(candidate); if (dCandidate > zoomOutLimit || dCandidate < zoomInLimit) { //Box is too big or too small return false; } return true; }
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 ) ); }