void FoursquareModel::getAdditionalItems( const GeoDataLatLonAltBox& box, qint32 number ) { if( marbleModel()->planetId() != "earth" ) { return; } QString clientId = "YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF"; QString clientSecret = "5L2JDCAYQCEJWY5FNDU4A1RWATE4E5FIIXXRM41YBTFSERUH"; QString apiUrl( "https://api.foursquare.com/v2/venues/search" ); qreal const distanceLon = marbleModel()->planetRadius() * distanceSphere( box.west(), box.north(), box.east(), box.north() ); qreal const distanceLat = marbleModel()->planetRadius() * distanceSphere( box.west(), box.north(), box.west(), box.south() ); qreal const area = distanceLon * distanceLat; if ( area > 10 * 1000 * KM2METER * KM2METER ) { // Large area (> 10.000 km^2) => too large for bbox queries apiUrl += "?ll=" + QString::number( box.center().latitude(Marble::GeoDataCoordinates::Degree) ); apiUrl += ',' + QString::number( box.center().longitude(Marble::GeoDataCoordinates::Degree) ); apiUrl += "&intent=checkin"; } else { apiUrl += "?ne=" + QString::number( box.north(Marble::GeoDataCoordinates::Degree) ); apiUrl += ',' + QString::number( box.east(Marble::GeoDataCoordinates::Degree) ); apiUrl += "&sw=" + QString::number( box.south(Marble::GeoDataCoordinates::Degree) ); apiUrl += ',' + QString::number( box.west(Marble::GeoDataCoordinates::Degree) ); apiUrl += "&intent=browse"; } apiUrl += "&limit=" + QString::number( number ); apiUrl += "&client_id=" + clientId; apiUrl += "&client_secret=" + clientSecret; apiUrl += "&v=20120601"; downloadDescriptionFile( QUrl( apiUrl ) ); }
void OpenCachingModel::getAdditionalItems( const GeoDataLatLonAltBox& box, const MarbleModel *model, qint32 number ) { Q_UNUSED( number ); if( model->planetId() != "earth" ) { return; } // http://www.opencaching.de/doc/xml/xml11.htm QString openCachingUrl( "http://www.opencaching.de/xml/ocxml11.php" ); openCachingUrl += "?modifiedsince=" + m_startDate.toString( "yyyyMMddhhmmss" ); openCachingUrl += "&cache=1&cachedesc=1&picture=0&cachelog=1&removedobject=0"; openCachingUrl += "&lat=" + QString::number( box.center().latitude() * RAD2DEG ); openCachingUrl += "&lon=" + QString::number( box.center().longitude() * RAD2DEG ); openCachingUrl += "&distance=" + QString::number( m_maxDistance ); openCachingUrl += "&charset=utf-8&cdata=0&session=0&zip=0"; downloadDescriptionFile( QUrl( openCachingUrl ) ); }
void PostalCodeModel::getAdditionalItems( const GeoDataLatLonAltBox& box, const MarbleModel *model, qint32 number ) { Q_UNUSED( number ); if( model->planetId() != "earth" ) { return; } double const lat = box.center().latitude( GeoDataCoordinates::Degree ); double const lon = box.center().longitude( GeoDataCoordinates::Degree ); double const radius = qMin<double>( 30.0, box.height() * model->planet()->radius() * METER2KM ); QUrl geonamesUrl( "http://ws.geonames.org/findNearbyPostalCodesJSON" ); geonamesUrl.addQueryItem( "lat", QString::number( lat ) ); geonamesUrl.addQueryItem( "lng", QString::number( lon ) ); geonamesUrl.addQueryItem( "radius", QString::number( radius ) ); geonamesUrl.addQueryItem( "maxRows", QString::number( numberOfItemsOnScreen ) ); downloadDescriptionFile( QUrl( geonamesUrl ) ); }
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 ) ); }