void YoursRunner::retrieveRoute( const RouteRequest *route ) { if ( route->size() != 2 ) { return; } GeoDataCoordinates source = route->source(); GeoDataCoordinates destination = route->destination(); double fLon = source.longitude( GeoDataCoordinates::Degree ); double fLat = source.latitude( GeoDataCoordinates::Degree ); double tLon = destination.longitude( GeoDataCoordinates::Degree ); double tLat = destination.latitude( GeoDataCoordinates::Degree ); QString base = "http://www.yournavigation.org/api/1.0/gosmore.php"; //QString base = "http://nroets.dev.openstreetmap.org/demo/gosmore.php"; QString args = "?flat=%1&flon=%2&tlat=%3&tlon=%4"; args = args.arg( fLat, 0, 'f', 6 ).arg( fLon, 0, 'f', 6 ).arg( tLat, 0, 'f', 6 ).arg( tLon, 0, 'f', 6 ); QString preferences = "&v=motorcar&fast=1&layer=mapnik"; QString request = base + args + preferences; // mDebug() << "GET: " << request; m_request = QNetworkRequest( QUrl( request ) ); QEventLoop eventLoop; connect( this, SIGNAL( routeCalculated( GeoDataDocument* ) ), &eventLoop, SLOT( quit() ) ); // @todo FIXME Must currently be done in the main thread, see bug 257376 QTimer::singleShot( 0, this, SLOT( get() ) ); eventLoop.exec(); }
void GeoDataLineStringPrivate::interpolateDateLine( const GeoDataCoordinates & previousCoords, const GeoDataCoordinates & currentCoords, GeoDataCoordinates & previousAtDateLine, GeoDataCoordinates & currentAtDateLine, TessellationFlags f ) { GeoDataCoordinates dateLineCoords; int recursionCounter = 0; // mDebug() << Q_FUNC_INFO; if ( f.testFlag( RespectLatitudeCircle ) && previousCoords.latitude() == currentCoords.latitude() ) { dateLineCoords = currentCoords; } else { dateLineCoords = findDateLine( previousCoords, currentCoords, recursionCounter ); } previousAtDateLine = dateLineCoords; currentAtDateLine = dateLineCoords; if ( previousCoords.longitude() < 0 ) { previousAtDateLine.setLongitude( -M_PI ); currentAtDateLine.setLongitude( +M_PI ); } else { previousAtDateLine.setLongitude( +M_PI ); currentAtDateLine.setLongitude( -M_PI ); } }
void TestGeoDataTrack::simpleParseTest() { GeoDataDocument* dataDocument = parseKml( simpleExampleContent ); GeoDataFolder *folder = dataDocument->folderList().at( 0 ); QCOMPARE( folder->placemarkList().size(), 1 ); GeoDataPlacemark* placemark = folder->placemarkList().at( 0 ); QCOMPARE( placemark->geometry()->geometryId(), GeoDataTrackId ); GeoDataTrack* track = static_cast<GeoDataTrack*>( placemark->geometry() ); QCOMPARE( track->size(), 7 ); { QDateTime when = track->whenList().at( 0 ); QCOMPARE( when, QDateTime( QDate( 2010, 5, 28 ), QTime( 2, 2, 9 ), Qt::UTC ) ); } { GeoDataCoordinates coord = track->coordinatesList().at( 0 ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 ); QCOMPARE( coord.altitude(), 156.000000 ); } { GeoDataCoordinates coord = track->coordinatesAt( QDateTime( QDate( 2010, 5, 28 ), QTime( 2, 2, 9 ), Qt::UTC ) ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 ); QCOMPARE( coord.altitude(), 156.000000 ); } delete dataDocument; }
qreal OsmDatabase::bearing( const GeoDataCoordinates &a, const GeoDataCoordinates &b ) const { qreal delta = b.longitude() - a.longitude(); qreal lat1 = a.latitude(); qreal lat2 = b.latitude(); return fmod( atan2( sin ( delta ) * cos ( lat2 ), cos( lat1 ) * sin( lat2 ) - sin( lat1 ) * cos( lat2 ) * cos ( delta ) ), 2 * M_PI ); }
qreal AlternativeRoutesModelPrivate::bearing( const GeoDataCoordinates &one, const GeoDataCoordinates &two ) { qreal delta = two.longitude() - one.longitude(); qreal lat1 = one.latitude(); qreal lat2 = two.latitude(); return fmod( atan2( sin ( delta ) * cos ( lat2 ), cos( lat1 ) * sin( lat2 ) - sin( lat1 ) * cos( lat2 ) * cos ( delta ) ), 2 * M_PI ); }
void TestGeoDataTrack::withoutTimeTest() { //"Simple Example" from kmlreference; when elements emptied QString content( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<kml xmlns=\"http://www.opengis.net/kml/2.2\"" " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">" "<Folder>" " <Placemark>" " <gx:Track>" " <when></when>" " <when></when>" " <when></when>" " <when></when>" " <when></when>" " <when></when>" " <when></when>" " <gx:coord>-122.207881 37.371915 156.000000</gx:coord>" " <gx:coord>-122.205712 37.373288 152.000000</gx:coord>" " <gx:coord>-122.204678 37.373939 147.000000</gx:coord>" " <gx:coord>-122.203572 37.374630 142.199997</gx:coord>" " <gx:coord>-122.203451 37.374706 141.800003</gx:coord>" " <gx:coord>-122.203329 37.374780 141.199997</gx:coord>" " <gx:coord>-122.203207 37.374857 140.199997</gx:coord>" " </gx:Track>" " </Placemark>" "</Folder>" "</kml>" ); GeoDataDocument* dataDocument = parseKml( content ); GeoDataFolder *folder = dataDocument->folderList().at( 0 ); QCOMPARE( folder->placemarkList().size(), 1 ); GeoDataPlacemark* placemark = folder->placemarkList().at( 0 ); QCOMPARE( placemark->geometry()->geometryId(), GeoDataTrackId ); GeoDataTrack* track = static_cast<GeoDataTrack*>( placemark->geometry() ); QCOMPARE( track->size(), 7 ); { GeoDataCoordinates coord = track->coordinatesList().at( 0 ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 ); QCOMPARE( coord.altitude(), 156.000000 ); } { const GeoDataLineString *lineString = track->lineString(); QCOMPARE( lineString->size(), 7 ); GeoDataCoordinates coord = lineString->at( 0 ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 ); QCOMPARE( coord.altitude(), 156.000000 ); } delete dataDocument; }
void MapScreen::perform_search(QString term, qreal distance) { GeoDataLatLonBox box; GeoDataCoordinates location; setCurrentIndex(indexOf(results_screen)); last_search_term = term; last_search_distance = distance; if (distance > MAX_DISTANCE) { search_manager->findPlacemarks(term); return; } location = navigation_screen->map_widget->focusPoint(); box.setNorth(location.latitude() - km_to_rad(distance)); box.setSouth(location.latitude() + km_to_rad(distance)); box.setEast(location.longitude() - km_to_rad(distance)); box.setWest(location.longitude() + km_to_rad(distance)); qDebug() << "Box north:" << box.north(GeoDataCoordinates::Degree); qDebug() << "Box south:" << box.south(GeoDataCoordinates::Degree); qDebug() << "Box west:" << box.west(GeoDataCoordinates::Degree); qDebug() << "Box east:" << box.east(GeoDataCoordinates::Degree); search_manager->findPlacemarks(term, box); }
TileId TileId::fromCoordinates(const GeoDataCoordinates &coords, int zoomLevel) { if ( zoomLevel < 0 ) { return TileId(); } const int maxLat = 90 * 1000000; const int maxLon = 180 * 1000000; int lat = GeoDataCoordinates::normalizeLat( coords.latitude( GeoDataCoordinates::Degree ), GeoDataCoordinates::Degree ) * 1000000; int lon = GeoDataCoordinates::normalizeLon( coords.longitude( GeoDataCoordinates::Degree ), GeoDataCoordinates::Degree ) * 1000000; int x = 0; int y = 0; for( int i=0; i<zoomLevel; ++i ) { const int deltaLat = maxLat >> i; if( lat <= ( maxLat - deltaLat )) { y += 1<<(zoomLevel-i-1); lat += deltaLat; } const int deltaLon = maxLon >> i; if( lon >= ( maxLon - deltaLon )) { x += 1<<(zoomLevel-i-1); } else { lon += deltaLon; } } return TileId(0, zoomLevel, x, y); }
void GosmoreRunner::reverseGeocoding( const GeoDataCoordinates &coordinates ) { if ( !d->m_gosmoreMapFile.exists() ) { emit reverseGeocodingFinished( coordinates, GeoDataPlacemark() ); return; } QString queryString = "flat=%1&flon=%2&tlat=%1&tlon=%2&fastest=1&v=motorcar"; double lon = coordinates.longitude( GeoDataCoordinates::Degree ); double lat = coordinates.latitude( GeoDataCoordinates::Degree ); queryString = queryString.arg( lat, 0, 'f', 8).arg(lon, 0, 'f', 8 ); QByteArray output = d->retrieveWaypoints( queryString ); GeoDataPlacemark placemark; placemark.setCoordinate( coordinates ); QStringList lines = QString::fromUtf8( output ).split( '\r' ); if ( lines.size() > 2 ) { QStringList fields = lines.at( lines.size()-2 ).split(','); if ( fields.size() >= 5 ) { QString road = fields.last().trimmed(); placemark.setAddress( road ); GeoDataExtendedData extendedData; extendedData.addValue( GeoDataData( "road", road ) ); placemark.setExtendedData( extendedData ); } } emit reverseGeocodingFinished( coordinates, placemark ); }
GeoDataCoordinates MyPaintLayer::approximate(const GeoDataCoordinates &base, qreal angle, qreal dist) const { // This is just a rough estimation that ignores projections. // It only works for short distances. Don't use in real code. GeoDataCoordinates::Unit deg = GeoDataCoordinates::Degree; return GeoDataCoordinates ( base.longitude(deg) + 1.5 * dist * sin(angle), base.latitude(deg) + dist * cos(angle), 0.0, deg); }
void PlacemarkTextAnnotation::move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination ) { Q_UNUSED( source ); qreal lat = destination.latitude(); qreal lon = destination.longitude(); GeoDataCoordinates::normalizeLonLat( lon, lat ); placemark()->setCoordinate( lon, lat ); }
GeoDataCoordinates AlternativeRoutesModelPrivate::coordinates( const GeoDataCoordinates &start, qreal distance, qreal bearing ) { qreal lat1 = start.latitude(); qreal lon1 = start.longitude(); qreal lat2 = asin( sin( lat1 ) * cos( distance ) + cos( lat1 ) * sin( distance ) * cos( bearing ) ); qreal lon2 = lon1 + atan2( sin( bearing ) * sin( distance ) * cos( lat1 ), cos( distance ) - sin( lat1 ) * sin( lat2 ) ); return GeoDataCoordinates( lon2, lat2 ); }
void GosmoreRunner::retrieveRoute( const RouteRequest *route ) { if ( !d->m_gosmoreMapFile.exists() ) { emit routeCalculated( nullptr ); return; } GeoDataLineString* wayPoints = new GeoDataLineString; QByteArray completeOutput; for( int i=0; i<route->size()-1; ++i ) { QString queryString = "flat=%1&flon=%2&tlat=%3&tlon=%4&fastest=1&v=motorcar"; GeoDataCoordinates source = route->at(i); double fLon = source.longitude( GeoDataCoordinates::Degree ); double fLat = source.latitude( GeoDataCoordinates::Degree ); queryString = queryString.arg(fLat, 0, 'f', 8).arg(fLon, 0, 'f', 8); GeoDataCoordinates destination = route->at(i+1); double tLon = destination.longitude( GeoDataCoordinates::Degree ); double tLat = destination.latitude( GeoDataCoordinates::Degree ); queryString = queryString.arg(tLat, 0, 'f', 8).arg(tLon, 0, 'f', 8); QByteArray output; if ( d->m_partialRoutes.contains( queryString ) ) { output = d->m_partialRoutes[queryString]; } else { output = d->retrieveWaypoints( queryString ); } GeoDataLineString points = d->parseGosmoreOutput( output ); d->merge( wayPoints, points ); completeOutput.append( output ); } QVector<GeoDataPlacemark*> instructions = d->parseGosmoreInstructions( completeOutput ); GeoDataDocument* result = d->createDocument( wayPoints, instructions ); emit routeCalculated( result ); }
void PlasmaRunner::collectMatches(QList<Plasma::QueryMatch> &matches, const QString &query, const GeoDataFolder *folder) { const QString queryLower = query.toLower(); QVector<GeoDataFeature*>::const_iterator it = folder->constBegin(); QVector<GeoDataFeature*>::const_iterator end = folder->constEnd(); for (; it != end; ++it) { GeoDataFolder *folder = dynamic_cast<GeoDataFolder*>(*it); if ( folder ) { collectMatches(matches, query, folder); continue; } GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>( *it ); if ( placemark ) { // For short query strings only match exactly, to get a sane number of matches if (query.length() < minContainsMatchLength) { if ( placemark->name().toLower() != queryLower && ( placemark->descriptionIsCDATA() || // TODO: support also with CDATA placemark->description().toLower() != queryLower ) ) { continue; } } else { if ( ! placemark->name().toLower().contains(queryLower) && ( placemark->descriptionIsCDATA() || // TODO: support also with CDATA ! placemark->description().toLower().contains(queryLower) ) ) { continue; } } const GeoDataCoordinates coordinates = placemark->coordinate(); const qreal lon = coordinates.longitude(GeoDataCoordinates::Degree); const qreal lat = coordinates.latitude(GeoDataCoordinates::Degree); const QVariant coordinatesData = QVariantList() << QVariant(lon) << QVariant(lat) << QVariant(placemark->lookAt()->range()*METER2KM); Plasma::QueryMatch match(this); match.setIcon(QIcon::fromTheme(QStringLiteral("marble"))); match.setText(placemark->name()); match.setSubtext(i18n("Show in OpenStreetMap with Marble")); match.setData(coordinatesData); match.setId(placemark->name()+QString::number(lat)+QString::number(lon)); match.setRelevance(1.0); match.setType(Plasma::QueryMatch::ExactMatch); matches << match; } } }
GeoDataLatLonAltBox::GeoDataLatLonAltBox( const GeoDataCoordinates & coordinates ) : GeoDataLatLonBox(), d( new GeoDataLatLonAltBoxPrivate ) { setWest( coordinates.longitude() ); setEast( coordinates.longitude() ); setNorth( coordinates.latitude() ); setSouth( coordinates.latitude() ); d->m_minAltitude = coordinates.altitude(); d->m_maxAltitude = coordinates.altitude(); }
void RoutingLayerPrivate::renderRequest( GeoPainter *painter ) { m_regions.clear(); for ( int i = 0; i < m_routeRequest->size(); ++i ) { GeoDataCoordinates pos = m_routeRequest->at( i ); if ( pos.longitude() != 0.0 && pos.latitude() != 0.0 ) { QPixmap pixmap = m_routeRequest->pixmap( i ); painter->drawPixmap( pos, pixmap ); QRegion region = painter->regionFromRect( pos, pixmap.width(), pixmap.height() ); m_regions.push_front( RequestRegion( i, region ) ); } } }
bool VerticalPerspectiveProjection::screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *viewport, qreal &x, qreal &y, bool &globeHidesPoint ) const { Q_D(const VerticalPerspectiveProjection); d->calculateConstants(viewport->radius()); const qreal P = d->m_P; const qreal deltaLambda = coordinates.longitude() - viewport->centerLongitude(); const qreal phi = coordinates.latitude(); const qreal phi1 = viewport->centerLatitude(); qreal cosC = qSin( phi1 ) * qSin( phi ) + qCos( phi1 ) * qCos( phi ) * qCos( deltaLambda ); // Don't display placemarks that are below 10km altitude and // are on the Earth's backside (where cosC < 1/P) if (cosC < 1/P && coordinates.altitude() < 10000) { globeHidesPoint = true; return false; } // Let (x, y) be the position on the screen of the placemark .. // First determine the position in unit coordinates: qreal k = (P - 1) / (P - cosC); // scale factor x = ( qCos( phi ) * qSin( deltaLambda ) ) * k; y = ( qCos( phi1 ) * qSin( phi ) - qSin( phi1 ) * qCos( phi ) * qCos( deltaLambda ) ) * k; // Transform to screen coordinates qreal pixelAltitude = (coordinates.altitude() + EARTH_RADIUS) * d->m_altitudeToPixel; x *= pixelAltitude; y *= pixelAltitude; // Don't display satellites that are on the Earth's backside: if (cosC < 1/P && x*x+y*y < viewport->radius() * viewport->radius()) { globeHidesPoint = true; return false; } // The remaining placemarks are definetely not on the Earth's backside globeHidesPoint = false; x += viewport->width() / 2; y = viewport->height() / 2 - y; // Skip placemarks that are outside the screen area if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) { return false; } return true; }
void PopupLayer::popup() { GeoDataCoordinates coords = d->m_popupItem->coordinate(); ViewportParams viewport( d->m_widget->viewport()->projection(), coords.longitude(), coords.latitude(), d->m_widget->viewport()->radius(), d->m_widget->viewport()->size() ); qreal sx, sy, lon, lat; viewport.screenCoordinates( coords, sx, sy ); sx = viewport.radius() < viewport.width() ? 0.5 * (viewport.width() + viewport.radius()) : 0.75 * viewport.width(); viewport.geoCoordinates( sx, sy, lon, lat, GeoDataCoordinates::Radian ); coords.setLatitude( lat ); coords.setLongitude( lon ); d->m_widget->centerOn( coords, true ); setVisible( true ); }
void PolylineAnnotation::move( const GeoDataCoordinates &source, const GeoDataCoordinates &destination ) { GeoDataLineString *lineString = static_cast<GeoDataLineString*>( placemark()->geometry() ); GeoDataLineString oldLineString = *lineString; lineString->clear(); const qreal deltaLat = destination.latitude() - source.latitude(); const qreal deltaLon = destination.longitude() - source.longitude(); Quaternion latRectAxis = Quaternion::fromEuler( 0, destination.longitude(), 0); Quaternion latAxis = Quaternion::fromEuler( -deltaLat, 0, 0); Quaternion lonAxis = Quaternion::fromEuler(0, deltaLon, 0); Quaternion rotAxis = latRectAxis * latAxis * latRectAxis.inverse() * lonAxis; qreal lonRotated, latRotated; for ( int i = 0; i < oldLineString.size(); ++i ) { Quaternion qpos = oldLineString.at(i).quaternion(); qpos.rotateAroundAxis(rotAxis); qpos.getSpherical( lonRotated, latRotated ); GeoDataCoordinates movedPoint( lonRotated, latRotated, 0 ); lineString->append( movedPoint ); } }
void OsmNominatimRunner::reverseGeocoding( const GeoDataCoordinates &coordinates ) { m_coordinates = coordinates; QString base = "http://nominatim.openstreetmap.org/reverse?format=xml&addressdetails=1"; // @todo: Alternative URI with addressdetails=1 could be used for shorther placemark name QString query = "&lon=%1&lat=%2&accept-language=%3"; double lon = coordinates.longitude( GeoDataCoordinates::Degree ); double lat = coordinates.latitude( GeoDataCoordinates::Degree ); QString url = QString( base + query ).arg( lon ).arg( lat ).arg( MarbleLocale::languageCode() ); m_reverseGeocodingRequest.setUrl(QUrl(url)); m_reverseGeocodingRequest.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") ); // @todo FIXME Must currently be done in the main thread, see bug 257376 QTimer::singleShot( 0, this, SLOT( startReverseGeocoding() ) ); }
bool KmlLineStringTagWriter::write( const GeoNode *node, GeoWriter& writer ) const { const GeoDataLineString *lineString = static_cast<const GeoDataLineString*>( node ); if ( lineString->size() > 1 ) { writer.writeStartElement( kml::kmlTag_LineString ); writer.writeStartElement( "coordinates" ); // Write altitude for *all* elements, if *any* element // has altitude information (!= 0.0) bool hasAltitude = false; for ( int i = 0; i < lineString->size(); ++i ) { if ( lineString->at( i ).altitude() ) { hasAltitude = true; break; } } for ( int i = 0; i < lineString->size(); ++i ) { GeoDataCoordinates coordinates = lineString->at( i ); if ( i > 0 ) { writer.writeCharacters( " " ); } qreal lon = coordinates.longitude( GeoDataCoordinates::Degree ); writer.writeCharacters( QString::number( lon, 'f', 10 ) ); writer.writeCharacters( "," ); qreal lat = coordinates.latitude( GeoDataCoordinates::Degree ); writer.writeCharacters( QString::number( lat, 'f', 10 ) ); if ( hasAltitude ) { qreal alt = coordinates.altitude(); writer.writeCharacters( "," ); writer.writeCharacters( QString::number( alt, 'f', 2 ) ); } } writer.writeEndElement(); writer.writeEndElement(); return true; } return false; }
bool LambertAzimuthalProjection::screenCoordinates( const GeoDataCoordinates &coordinates, const ViewportParams *viewport, qreal &x, qreal &y, bool &globeHidesPoint ) const { const qreal lambda = coordinates.longitude(); const qreal phi = coordinates.latitude(); const qreal lambdaPrime = viewport->centerLongitude(); const qreal phi1 = viewport->centerLatitude(); qreal cosC = qSin( phi1 ) * qSin( phi ) + qCos( phi1 ) * qCos( phi ) * qCos( lambda - lambdaPrime ); // Prevent division by zero if (cosC <= 0) { globeHidesPoint = true; return false; } qreal k = qSqrt(2 / (1 + cosC)); // Let (x, y) be the position on the screen of the placemark.. x = ( qCos( phi ) * qSin( lambda - lambdaPrime ) ) * k; y = ( qCos( phi1 ) * qSin( phi ) - qSin( phi1 ) * qCos( phi ) * qCos( lambda - lambdaPrime ) ) * k; x *= viewport->radius() / qSqrt(2); y *= viewport->radius() / qSqrt(2); const qint64 radius = clippingRadius() * viewport->radius(); if (x*x + y*y > radius * radius) { globeHidesPoint = true; return false; } globeHidesPoint = false; x += viewport->width() / 2; y = viewport->height() / 2 - y; // Skip placemarks that are outside the screen area if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) { return false; } return true; }
void PlasmaRunner::match(Plasma::RunnerContext &context) { QList<Plasma::QueryMatch> matches; const QString query = context.query(); bool success = false; // TODO: how to estimate that input is in Degree, not Radian? GeoDataCoordinates coordinates = GeoDataCoordinates::fromString(query, success); if (success) { const QVariant coordinatesData = QVariantList() << QVariant(coordinates.longitude(GeoDataCoordinates::Degree)) << QVariant(coordinates.latitude(GeoDataCoordinates::Degree)) << QVariant(0.1); // TODO: make this distance value configurable Plasma::QueryMatch match(this); match.setIcon(QIcon::fromTheme(QStringLiteral("marble"))); match.setText(i18n("Show the coordinates %1 in OpenStreetMap with Marble", query)); match.setData(coordinatesData); match.setId(query); match.setRelevance(1.0); match.setType(Plasma::QueryMatch::ExactMatch); matches << match; } // TODO: BookmarkManager does not yet listen to updates, also does not sync between processes :( // So for now always load on demand, even if expensive possibly BookmarkManager bookmarkManager(new GeoDataTreeModel); bookmarkManager.loadFile( QStringLiteral("bookmarks/bookmarks.kml") ); for (GeoDataFolder* folder: bookmarkManager.folders()) { collectMatches(matches, query, folder); } if ( ! matches.isEmpty() ) { context.addMatches(matches); } }
int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); QApplication app(argc, argv); app.setApplicationName( "Marble Virtual Globe" ); app.setOrganizationName( "KDE" ); app.setOrganizationDomain( "kde.org" ); #if QT_VERSION >= 0x050700 app.setDesktopFileName(QStringLiteral("org.kde.marble-qt")); #endif // Load Qt translation system catalog for libmarblewidget, the plugins and this app loadTranslations(app); app.setApplicationDisplayName(MainWindow::tr("Marble - Virtual Globe")); // For non static builds on mac and win // we need to be sure we can find the qt image // plugins. In mac be sure to look in the // application bundle... #ifdef Q_WS_WIN QApplication::addLibraryPath( QApplication::applicationDirPath() + QDir::separator() + QLatin1String("plugins")); #endif #ifdef Q_OS_MACX QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus); qDebug("Adding qt image plugins to plugin search path..."); CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle); const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding()); CFRelease(myBundleRef); CFRelease(myMacPath); QString myPath(mypPathPtr); // if we are not in a bundle assume that the app is built // as a non bundle app and that image plugins will be // in system Qt frameworks. If the app is a bundle // lets try to set the qt plugin search path... if (myPath.contains(".app")) { myPath += QLatin1String("/Contents/plugins"); QApplication::addLibraryPath( myPath ); qDebug( "Added %s to plugin search path", qPrintable( myPath ) ); } #endif QString marbleDataPath; int dataPathIndex=0; QString mapThemeId; QString tour; QString coordinatesString; QString distanceString; QString geoUriString; MarbleGlobal::Profiles profiles = MarbleGlobal::getInstance()->profiles(); QStringList args = QApplication::arguments(); if ( args.contains( "-h" ) || args.contains( "--help" ) ) { qWarning() << "Usage: marble [options] [files]"; qWarning(); qWarning() << "[files] can be zero, one or more .kml and/or .gpx files to load and show."; qWarning(); qWarning() << "general options:"; qWarning() << " --marbledatapath=<path> .... Overwrite the compile-time path to map themes and other data"; qWarning() << " --geo-uri=<uri> ............ Show map at given geo uri"; qWarning() << " --latlon=<coordinates> ..... Show map at given lat lon coordinates"; qWarning() << " --distance=<value> ......... Set the distance of the observer to the globe (in km)"; qWarning() << " --map=<id> ................. Use map id (e.g. \"earth/openstreetmap/openstreetmap.dgml\")"; qWarning() << " --tour=<file> .............. Load a KML tour from the given file and play it"; qWarning(); qWarning() << "debug options:"; qWarning() << " --debug-info ............... write (more) debugging information to the console"; qWarning() << " --fps ...................... Show the paint performance (paint rate) in the top left corner"; qWarning() << " --runtimeTrace.............. Show the time spent and other debug info of each layer"; qWarning() << " --tile-id................... Write the identifier of texture tiles on top of them"; qWarning() << " --timedemo ................. Measure the paint performance while moving the map and quit"; qWarning() << " --debug-polygons ........... Display the polygon nodes and their index for debugging"; qWarning() << " --debug-levels ............. Display OSM placemarks according to the level selected"; qWarning(); qWarning() << "profile options (note that marble should automatically detect which profile to use. Override that with the options below):"; qWarning() << " --highresolution ........... Enforce the profile for devices with high resolution (e.g. desktop computers)"; qWarning() << " --nohighresolution ......... Deactivate the profile for devices with high resolution (e.g. desktop computers)"; return 0; } for ( int i = 1; i < args.count(); ++i ) { const QString arg = args.at(i); if ( arg == QLatin1String( "--debug-info" ) ) { MarbleDebug::setEnabled( true ); } else if ( arg.startsWith( QLatin1String( "--marbledatapath=" ), Qt::CaseInsensitive ) ) { marbleDataPath = args.at(i).mid(17); } else if ( arg.compare( QLatin1String( "--marbledatapath" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { dataPathIndex = i + 1; marbleDataPath = args.value( dataPathIndex ); ++i; } else if ( arg == QLatin1String( "--highresolution" ) ) { profiles |= MarbleGlobal::HighResolution; } else if ( arg == QLatin1String( "--nohighresolution" ) ) { profiles &= ~MarbleGlobal::HighResolution; } else if ( arg.startsWith( QLatin1String( "--latlon=" ), Qt::CaseInsensitive ) ) { coordinatesString = arg.mid(9); } else if ( arg.compare( QLatin1String( "--latlon" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { ++i; coordinatesString = args.value( i ); } else if ( arg.compare( QLatin1String( "--geo-uri=" ), Qt::CaseInsensitive ) == 0 ) { geoUriString = arg.mid(10); } else if ( arg.compare( QLatin1String( "--geo-uri" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { ++i; geoUriString = args.value(i); } else if ( arg.startsWith( QLatin1String( "--distance=" ), Qt::CaseInsensitive ) ) { distanceString = arg.mid(11); } else if ( arg.compare( QLatin1String( "--distance" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { ++i; distanceString = args.value( i ); } else if ( arg.startsWith( QLatin1String( "--map=" ), Qt::CaseInsensitive ) ) { mapThemeId = arg.mid(6); } else if ( arg.compare( QLatin1String( "--map" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { ++i; mapThemeId = args.value( i ); } else if ( arg.startsWith( QLatin1String( "--tour=" ), Qt::CaseInsensitive ) ) { tour = arg.mid(7); } else if ( arg.compare( QLatin1String( "--tour" ), Qt::CaseInsensitive ) == 0 && i+1 < args.size() ) { ++i; tour = args.value( i ); } } MarbleGlobal::getInstance()->setProfiles( profiles ); MarbleLocale::MeasurementSystem const measurement = (MarbleLocale::MeasurementSystem)QLocale::system().measurementSystem(); MarbleGlobal::getInstance()->locale()->setMeasurementSystem( measurement ); QVariantMap cmdLineSettings; if ( !mapThemeId.isEmpty() ) { cmdLineSettings.insert( QLatin1String("mapTheme"), QVariant(mapThemeId) ); } if ( !coordinatesString.isEmpty() ) { bool success = false; const GeoDataCoordinates coordinates = GeoDataCoordinates::fromString(coordinatesString, success); if ( success ) { QVariantList lonLat; lonLat << QVariant( coordinates.longitude(GeoDataCoordinates::Degree) ) << QVariant( coordinates.latitude(GeoDataCoordinates::Degree) ); cmdLineSettings.insert( QLatin1String("lonlat"), QVariant(lonLat) ); } } if ( !distanceString.isEmpty() ) { bool success = false; const qreal distance = distanceString.toDouble(&success); if ( success ) { cmdLineSettings.insert( QLatin1String("distance"), QVariant(distance) ); } } if ( !tour.isEmpty() ) { cmdLineSettings.insert( QLatin1String("tour"), QVariant(tour) ); } cmdLineSettings.insert( QLatin1String("geo-uri"), QVariant(geoUriString) ); MainWindow *window = new MainWindow( marbleDataPath, cmdLineSettings ); window->setAttribute( Qt::WA_DeleteOnClose, true ); // window->marbleWidget()->rotateTo( 0, 0, -90 ); // window->show(); for ( int i = 1; i < args.count(); ++i ) { const QString arg = args.at(i); if (arg == QLatin1String("--timedemo")) { window->resize(900, 640); MarbleTest marbleTest( window->marbleWidget() ); marbleTest.timeDemo(); return 0; } if (arg == QLatin1String("--fps")) { window->marbleControl()->marbleWidget()->setShowFrameRate( true ); } else if (arg == QLatin1String("--tile-id")) { window->marbleControl()->marbleWidget()->setShowTileId(true); } else if (arg == QLatin1String("--runtimeTrace")) { window->marbleControl()->marbleWidget()->setShowRuntimeTrace( true ); } else if (arg == QLatin1String("--debug-polygons")) { window->marbleControl()->marbleWidget()->setShowDebugPolygons( true ); } else if ( i != dataPathIndex && QFile::exists( arg ) ) { window->addGeoDataFile(arg); } else if (arg == QLatin1String("--debug-levels")) { window->marbleWidget()->setDebugLevelTags(true); } } auto const marbleWidget = window->marbleControl()->marbleWidget(); bool const debugModeEnabled = marbleWidget->showRuntimeTrace() || marbleWidget->showDebugPolygons() || marbleWidget->debugLevelTags() || MarbleDebug::isEnabled(); marbleWidget->inputHandler()->setDebugModeEnabled(debugModeEnabled); return app.exec(); }
int main(int argc, char *argv[]) { #if QT_VERSION < 0x050000 // The GraphicsSystem needs to be set before the instantiation of the // QApplication. Therefore we need to parse the current setting // in this unusual place :-/ QSettings graphicsSettings("KDE", "Marble Virtual Globe"); // keep the parameters here QString const graphicsString = graphicsSettings.value("View/graphicsSystem", "raster").toString(); QApplication::setGraphicsSystem( graphicsString ); #endif QApplication app(argc, argv); app.setApplicationName( "Marble Virtual Globe" ); app.setOrganizationName( "KDE" ); app.setOrganizationDomain( "kde.org" ); // Widget translation #ifdef Q_WS_MAEMO_5 // Work around http://bugreports.qt-project.org/browse/QTBUG-1313 QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString lang( "C" ); QStringList const locales = QStringList() << "LC_ALL" << "LC_MESSAGES" << "LANG" << "LANGUAGE"; foreach( const QString &locale, locales ) { if ( env.contains( locale ) && !env.value( locale ).isEmpty() ) { lang = env.value( locale, "C" ); break; } } lang = lang.section( '_', 0, 0 ); #else QString lang = QLocale::system().name().section('_', 0, 0); #endif QTranslator translator; translator.load( "marble-" + lang, MarbleDirs::path(QString("lang") ) ); app.installTranslator(&translator); // For non static builds on mac and win // we need to be sure we can find the qt image // plugins. In mac be sure to look in the // application bundle... #ifdef Q_WS_WIN QApplication::addLibraryPath( QApplication::applicationDirPath() + QDir::separator() + "plugins" ); #endif #ifdef Q_OS_MACX QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus); qDebug("Adding qt image plugins to plugin search path..."); CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle); const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding()); CFRelease(myBundleRef); CFRelease(myMacPath); QString myPath(mypPathPtr); // if we are not in a bundle assume that the app is built // as a non bundle app and that image plugins will be // in system Qt frameworks. If the app is a bundle // lets try to set the qt plugin search path... if (myPath.contains(".app")) { myPath += "/Contents/plugins"; QApplication::addLibraryPath( myPath ); qDebug( "Added %s to plugin search path", qPrintable( myPath ) ); } #endif QString marbleDataPath; int dataPathIndex=0; QString mapThemeId; QString coordinatesString; QString distanceString; const MarbleGlobal::Profiles profiles = MarbleGlobal::SmallScreen | MarbleGlobal::HighResolution; QStringList args = QApplication::arguments(); if ( args.contains( "-h" ) || args.contains( "--help" ) ) { qWarning() << "Usage: marble [options] [files]"; qWarning(); qWarning() << "[files] can be zero, one or more .kml and/or .gpx files to load and show."; qWarning(); qWarning() << "general options:"; qWarning() << " --marbledatapath=<path> .... Overwrite the compile-time path to map themes and other data"; qWarning() << " --latlon=<coordinates> ..... Show map at given lat lon coordinates"; qWarning() << " --distance=<value> ......... Set the distance of the observer to the globe (in km)"; qWarning() << " --map=<id> ................. Use map id (e.g. \"earth/openstreetmap/openstreetmap.dgml\")"; qWarning(); qWarning() << "debug options:"; qWarning() << " --debug-info ............... write (more) debugging information to the console"; qWarning() << " --fps ...................... Show the paint performance (paint rate) in the top left corner"; qWarning() << " --runtimeTrace.............. Show the time spent and other debug info of each layer"; qWarning() << " --tile-id................... Write the identifier of texture tiles on top of them"; qWarning() << " --timedemo ................. Measure the paint performance while moving the map and quit"; return 0; } for ( int i = 1; i < args.count(); ++i ) { const QString arg = args.at(i); if ( arg == QLatin1String( "--debug-info" ) ) { MarbleDebug::setEnabled( true ); } else if ( arg.startsWith( QLatin1String( "--marbledatapath=" ), Qt::CaseInsensitive ) ) { marbleDataPath = args.at(i).mid(17); } else if ( arg.compare( QLatin1String( "--marbledatapath" ), Qt::CaseInsensitive ) == 0 ) { dataPathIndex = i + 1; marbleDataPath = args.value( dataPathIndex ); ++i; } else if ( arg.startsWith( QLatin1String( "--latlon=" ), Qt::CaseInsensitive ) ) { coordinatesString = arg.mid(9); } else if ( arg.compare( QLatin1String( "--latlon" ), Qt::CaseInsensitive ) == 0 ) { ++i; // TODO: misses an error check if there is a value at all // and error reporting to user (problem also exists with marbledatapath) coordinatesString = args.value( i ); } else if ( arg.startsWith( QLatin1String( "--distance=" ), Qt::CaseInsensitive ) ) { distanceString = arg.mid(11); } else if ( arg.compare( QLatin1String( "--distance" ), Qt::CaseInsensitive ) == 0 ) { ++i; // TODO: misses an error check if there is a value at all // and error reporting to user (problem also exists with marbledatapath) distanceString = args.value( i ); } else if ( arg.startsWith( QLatin1String( "--map=" ), Qt::CaseInsensitive ) ) { mapThemeId = arg.mid(6); } else if ( arg.compare( QLatin1String( "--map" ), Qt::CaseInsensitive ) == 0 ) { ++i; // TODO: misses an error check if there is a value at all // and error reporting to user (problem also exists with marbledatapath) mapThemeId = args.value( i ); } } MarbleGlobal::getInstance()->setProfiles( profiles ); QLocale::MeasurementSystem const measurement = QLocale::system().measurementSystem(); MarbleGlobal::getInstance()->locale()->setMeasurementSystem( measurement ); QVariantMap cmdLineSettings; if ( !mapThemeId.isEmpty() ) { cmdLineSettings.insert( QLatin1String("mapTheme"), QVariant(mapThemeId) ); } if ( !coordinatesString.isEmpty() ) { bool success = false; const GeoDataCoordinates coordinates = GeoDataCoordinates::fromString(coordinatesString, success); if ( success ) { QVariantList lonLat; lonLat << QVariant( coordinates.longitude(GeoDataCoordinates::Degree) ) << QVariant( coordinates.latitude(GeoDataCoordinates::Degree) ); cmdLineSettings.insert( QLatin1String("lonlat"), QVariant(lonLat) ); } } if ( !distanceString.isEmpty() ) { bool success = false; const qreal distance = distanceString.toDouble(&success); if ( success ) { cmdLineSettings.insert( QLatin1String("distance"), QVariant(distance) ); } } MainWindow *window = new MainWindow( marbleDataPath, cmdLineSettings ); window->setAttribute( Qt::WA_DeleteOnClose, true ); // window->marbleWidget()->rotateTo( 0, 0, -90 ); // window->show(); for ( int i = 1; i < args.count(); ++i ) { const QString arg = args.at(i); if ( arg == "--timedemo" ) { window->resize(900, 640); MarbleTest marbleTest( window->marbleWidget() ); marbleTest.timeDemo(); return 0; } else if( arg == "--fps" ) { window->marbleWidget()->setShowFrameRate( true ); } else if ( arg == "--tile-id" ) { window->marbleWidget()->setShowTileId(true); } else if( arg == "--runtimeTrace" ) { window->marbleWidget()->setShowRuntimeTrace( true ); } else if ( i != dataPathIndex && QFile::exists( arg ) ) { window->addGeoDataFile( QFileInfo( arg ).absoluteFilePath() ); } } return app.exec(); }
int main ( int argc, char *argv[] ) { KAboutData aboutData( "marble", 0, ki18n( "Marble Virtual Globe" ), ControlView::applicationVersion().toLatin1(), ki18n( "A World Atlas." ), KAboutData::License_LGPL, ki18n( "(c) 2007-2012" ), // FIXME: use subs() here and replace 2012 by %1 KLocalizedString(), "http://edu.kde.org/marble" ); // Active Development Team of Marble aboutData.addAuthor( ki18n( "Torsten Rahn" ), ki18n( "Developer and Original Author" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Bernhard Beschow" ), ki18n( "WMS Support, Mobile, Performance" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Thibaut Gridel" ), ki18n( "Geodata" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Jens-Michael Hoffmann" ), ki18n( "OpenStreetMap Integration, OSM Namefinder, Download Management" ), "*****@*****.**", "http://www.c-xx.com" ); aboutData.addAuthor( ki18n( "Florian Eßer" ), ki18n( "Elevation Profile" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Wes Hardaker" ), ki18n( "APRS Plugin" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Bastian Holst" ), ki18n( "Online Services support" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Guillaume Martres" ), ki18n( "Satellites" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Rene Kuettner" ), ki18n( "Satellites, Eclipses" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Friedrich W. H. Kossebau" ), ki18n( "Plasma Integration, Bugfixes" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Dennis Nienhüser" ), ki18n( "Routing, Navigation, Mobile" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Niko Sams" ), ki18n( "Routing, Elevation Profile" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Patrick Spendrin" ), ki18n( "Core Developer: KML and Windows support" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Eckhart Wörner" ), ki18n( "Bugfixes" ), "*****@*****.**" ); // Developers: aboutData.addAuthor( ki18n( "Inge Wallin" ), ki18n( "Core Developer and Co-Maintainer" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Henry de Valence" ), ki18n( "Core Developer: Marble Runners, World-Clock Plasmoid" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Pino Toscano" ), ki18n( "Network plugins" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Harshit Jain" ), ki18n( "Planet filter" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Simon Edwards" ), ki18n( "Marble Python Bindings" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Magnus Valle" ), ki18n( "Historical Maps" ), "" ); aboutData.addAuthor( ki18n( "Médéric Boquien" ), ki18n( "Astronomical Observatories" ), "*****@*****.**" ); // ESA Summer of Code in Space aboutData.addAuthor( ki18n( "Rene Kuettner" ), ki18n( "ESA Summer of Code in Space 2012 Project:" " Visualization of planetary satellites" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Guillaume Martres" ), ki18n( "ESA Summer of Code in Space 2011 Project:" " Visualisation of Satellite Orbits" ), "*****@*****.**" ); // Google Summer of Code aboutData.addAuthor( ki18n( "Konstantin Oblaukhov" ), ki18n( "Google Summer of Code 2011 Project:" " OpenStreetMap Vector Rendering" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Daniel Marth" ), ki18n( "Google Summer of Code 2011 Project:" " Marble Touch on MeeGo" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Gaurav Gupta" ), ki18n( "Google Summer of Code 2010 Project:" " Bookmarks" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Harshit Jain " ), ki18n( "Google Summer of Code 2010 Project:" " Time Support" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Siddharth Srivastava" ), ki18n( "Google Summer of Code 2010 Project:" " Turn-by-turn Navigation" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Andrew Manson" ), ki18n( "Google Summer of Code 2009 Project:" " OSM Annotation" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Bastian Holst" ), ki18n( "Google Summer of Code 2009 Project:" " Online Services" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Patrick Spendrin" ), ki18n( "Google Summer of Code 2008 Project:" " Vector Tiles for Marble" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Shashank Singh" ), ki18n( "Google Summer of Code 2008 Project:" " Panoramio / Wikipedia -photo support for Marble" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Carlos Licea" ), ki18n( "Google Summer of Code 2007 Project:" " Equirectangular Projection (\"Flat Map\")" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Andrew Manson" ), ki18n( "Google Summer of Code 2007 Project:" " GPS Support for Marble" ), "*****@*****.**" ); aboutData.addAuthor( ki18n( "Murad Tagirov" ), ki18n( "Google Summer of Code 2007 Project:" " KML Support for Marble" ), "*****@*****.**" ); // Developers aboutData.addAuthor( ki18n( "Simon Schmeisser" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Claudiu Covaci" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "David Roberts" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Nikolas Zimmermann" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Jan Becker" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Stefan Asserhäll" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Laurent Montel" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Mayank Madan" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Prashanth Udupa" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Anne-Marie Mahfouf" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Josef Spillner" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Frerich Raabe" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Frederik Gladhorn" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Fredrik Höglund" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Albert Astals Cid" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Thomas Zander" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Joseph Wenninger" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Kris Thomsen" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Daniel Molkentin" ), ki18n( "Development & Patches" )); aboutData.addAuthor( ki18n( "Christophe Leske" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Sebastian Wiedenroth" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Tim Sutton" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Christian Ehrlicher" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Ralf Habacker" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Steffen Joeris" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Marcus Czeslinski" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Marcus D. Hanwell" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Chitlesh Goorah" ), ki18n( "Platforms & Distributions" )); aboutData.addAuthor( ki18n( "Nuno Pinheiro" ), ki18n( "Artwork" )); aboutData.addAuthor( ki18n( "Torsten Rahn" ), ki18n( "Artwork" )); // Credits aboutData.addCredit( ki18n( "Luis Silva" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Stefan Jordan" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Robert Scott" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Lubos Petrovic" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Benoit Sigoure" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Martin Konold" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Matthias Welwarsky" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Rainer Endres" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Ralf Gesellensetter" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "Tim Alder" ), ki18n( "Various Suggestions & Testing" )); aboutData.addCredit( ki18n( "John Layt" ), ki18n( "Special thanks for providing an" " important source of inspiration by creating" " Marble's predecessor \"Kartographer\"." )); QApplication::setGraphicsSystem( readGraphicsSystem( argc, argv, aboutData ) ); KCmdLineArgs::init( argc, argv, &aboutData ); // Autodetect profiles MarbleGlobal::Profiles profiles = MarbleGlobal::detectProfiles(); KCmdLineOptions options; options.add( "debug-info", ki18n( "Enable debug output" ) ); options.add( "timedemo", ki18n( "Make a time measurement to check performance" ) ); options.add( "fps", ki18n( "Show frame rate" ) ); options.add( "tile-id", ki18n( "Show tile IDs" ) ); options.add( "runtimeTrace", ki18n( "Show time spent in each layer" ) ); options.add( "marbledatapath <data path>", ki18n( "Use a different directory which contains map data" ) ); if( profiles & MarbleGlobal::SmallScreen ) { options.add( "nosmallscreen", ki18n( "Do not use the interface optimized for small screens" ) ); } else { options.add( "smallscreen", ki18n( "Use the interface optimized for small screens" ) ); } if( profiles & MarbleGlobal::HighResolution ) { options.add( "nohighresolution", ki18n( "Do not use the interface optimized for high resolutions" ) ); } else { options.add( "highresolution", ki18n( "Use the interface optimized for high resolutions" ) ); } options.add( "latlon <coordinates>", ki18n( "Show map at given lat lon coordinates" ) ); options.add( "distance <value>", ki18n( "Set the distance of the observer to the globe (in km)" ) ); options.add( "map <id>", ki18n( "Use map id (e.g. \"earth/openstreetmap/openstreetmap.dgml\")" ) ); options.add( "+[file]", ki18n( "One or more placemark files to be opened" ) ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication app; KGlobal::locale()->insertCatalog( "marble_qt" ); if ( args->isSet( "debug-info" ) ) { MarbleDebug::enable = true; } else { MarbleDebug::enable = false; } if ( args->isSet( "smallscreen" ) ) { profiles |= MarbleGlobal::SmallScreen; } else { profiles &= ~MarbleGlobal::SmallScreen; } if ( args->isSet( "highresolution" ) ) { profiles |= MarbleGlobal::HighResolution; } else { profiles &= ~MarbleGlobal::HighResolution; } MarbleGlobal::getInstance()->setProfiles( profiles ); QString marbleDataPath = args->getOption( "marbledatapath" ); if( marbleDataPath.isEmpty() ) { marbleDataPath.clear(); /** @todo: why is this done? */ } MainWindow *window = new MainWindow( marbleDataPath ); window->setAttribute( Qt::WA_DeleteOnClose, true ); window->show(); if ( args->isSet( "timedemo" ) ) { window->resize(900, 640); MarbleTest test( window->marbleWidget() ); test.timeDemo(); return 0; } if ( args->isSet( "fps" ) ) { window->marbleControl()->marbleWidget()->setShowFrameRate( true ); } if ( args->isSet( "tile-id" ) ) { window->marbleControl()->marbleWidget()->setShowTileId( true ); } const QString map = args->getOption( "map" ); if ( !map.isEmpty() ) { window->marbleWidget()->setMapThemeId(map); } const QString coordinatesString = args->getOption( "latlon" ); if ( !coordinatesString.isEmpty() ) { bool success = false; const GeoDataCoordinates coordinates = GeoDataCoordinates::fromString(coordinatesString, success); if ( success ) { const qreal longitude = coordinates.longitude(GeoDataCoordinates::Degree); const qreal latitude = coordinates.latitude(GeoDataCoordinates::Degree); window->marbleWidget()->centerOn(longitude, latitude); } } const QString distance = args->getOption( "distance" ); if ( !distance.isEmpty() ) { bool success = false; const qreal distanceValue = distance.toDouble(&success); if ( success ) window->marbleWidget()->setDistance(distanceValue); } // Read the files that are given on the command line. for ( int i = 0; i < args->count(); ++i ) { // FIXME: Use openUrl( args->url(i) ) instead? if ( QFile::exists( args->arg( i ) ) ) window->marbleControl()->addGeoDataFile( args->arg( i ) ); } return app.exec(); }
void CountryByShape::postQuestion( QObject *gameObject ) { //Find a random placemark Q_ASSERT_X( d->m_countryNames, "CountryByShape::postQuestion", "CountryByShapePrivate::m_countryNames is NULL" ); QVector<GeoDataPlacemark*> countryPlacemarks = d->m_countryNames->placemarkList(); uint randomSeed = uint(QTime::currentTime().msec()); qsrand( randomSeed ); bool found = false; GeoDataPlacemark *placemark =0; GeoDataPoint *point = 0; GeoDataCoordinates coord; GeoDataLatLonAltBox box; QVariantList answerOptions; while ( !found ) { int randomIndex = qrand()%countryPlacemarks.size(); placemark = countryPlacemarks[randomIndex]; point = dynamic_cast<GeoDataPoint*>( placemark->geometry() ); coord = point->coordinates(); if ( point ) { /** * Find the country geometry and fetch corresponding * GeoDataLatLonAltBox to zoom in to that country so that * it fills the viewport. */ Q_ASSERT_X( d->m_countryBoundaries, "CountryByShape::postQuestion", "CountryByShapePrivate::m_countryBoundaries is NULL" ); QVector<GeoDataFeature*>::Iterator i = d->m_countryBoundaries->begin(); QVector<GeoDataFeature*>::Iterator const end = d->m_countryBoundaries->end(); for ( ; i != end; ++i ) { GeoDataPlacemark *country = static_cast<GeoDataPlacemark*>( *i ); GeoDataPolygon *polygon = dynamic_cast<GeoDataPolygon*>( country->geometry() ); GeoDataLinearRing *linearring = dynamic_cast<GeoDataLinearRing*>( country->geometry() ); GeoDataMultiGeometry *multigeom = dynamic_cast<GeoDataMultiGeometry*>( country->geometry() ); if ( polygon && polygon->contains( coord ) && !d->m_continentsAndOceans.contains(country->name(), Qt::CaseSensitive) ) { box = polygon->latLonAltBox(); found = true; break; } if ( linearring && linearring->contains( coord ) && !d->m_continentsAndOceans.contains(country->name(), Qt::CaseSensitive) ) { box = linearring->latLonAltBox(); found = true; break; } if ( multigeom ) { QVector<GeoDataGeometry*>::Iterator iter = multigeom->begin(); QVector<GeoDataGeometry*>::Iterator const end = multigeom->end(); for ( ; iter != end; ++iter ) { GeoDataPolygon *poly = dynamic_cast<GeoDataPolygon*>( *iter ); if ( poly && poly->contains( coord ) && !d->m_continentsAndOceans.contains(country->name(), Qt::CaseSensitive) ) { box = poly->latLonAltBox(); found = true; break; } } } if ( found ) { break; } } } } d->m_marbleWidget->setHighlightEnabled( true ); emit announceHighlight( coord.longitude(GeoDataCoordinates::Degree), coord.latitude(GeoDataCoordinates::Degree), GeoDataCoordinates::Degree ); /** * Now disable the highlight feature so that * the user click doesn't disturbe the highlight * we did to ask question. */ d->m_marbleWidget->setHighlightEnabled( false ); d->m_marbleWidget->centerOn( box, true ); answerOptions << placemark->name() << countryPlacemarks[qrand()%countryPlacemarks.size()]->name() << countryPlacemarks[qrand()%countryPlacemarks.size()]->name() << countryPlacemarks[qrand()%countryPlacemarks.size()]->name(); // Randomize options in list answerOptions for ( int i = 0; i < answerOptions.size(); ++i ) { QVariant option = answerOptions.takeAt( qrand()%answerOptions.size() ); answerOptions.append( option ); } if ( gameObject ) { QMetaObject::invokeMethod( gameObject, "countryByShapeQuestion", Q_ARG(QVariant, QVariant(answerOptions)), Q_ARG(QVariant, QVariant(placemark->name())) ); } }
int CylindricalProjectionPrivate::processTessellation( const GeoDataCoordinates &previousCoords, const GeoDataCoordinates ¤tCoords, int tessellatedNodes, QVector<QPolygonF*> &polygons, const ViewportParams *viewport, TessellationFlags f, int mirrorCount, qreal repeatDistance) const { const bool clampToGround = f.testFlag( FollowGround ); const bool followLatitudeCircle = f.testFlag( RespectLatitudeCircle ) && previousCoords.latitude() == currentCoords.latitude(); // Calculate steps for tessellation: lonDiff and altDiff qreal lonDiff = 0.0; if ( followLatitudeCircle ) { const int previousSign = previousCoords.longitude() > 0 ? 1 : -1; const int currentSign = currentCoords.longitude() > 0 ? 1 : -1; lonDiff = currentCoords.longitude() - previousCoords.longitude(); if ( previousSign != currentSign && fabs(previousCoords.longitude()) + fabs(currentCoords.longitude()) > M_PI ) { if ( previousSign > currentSign ) { // going eastwards -> lonDiff += 2 * M_PI ; } else { // going westwards -> lonDiff -= 2 * M_PI; } } if ( fabs( lonDiff ) == 2 * M_PI ) { return mirrorCount; } } const qreal altDiff = currentCoords.altitude() - previousCoords.altitude(); // Create the tessellation nodes. GeoDataCoordinates previousTessellatedCoords = previousCoords; for ( int i = 1; i <= tessellatedNodes; ++i ) { const qreal t = (qreal)(i) / (qreal)( tessellatedNodes + 1 ); // interpolate the altitude, too const qreal altitude = clampToGround ? 0 : altDiff * t + previousCoords.altitude(); qreal lon = 0.0; qreal lat = 0.0; if ( followLatitudeCircle ) { // To tessellate along latitude circles use the // linear interpolation of the longitude. lon = lonDiff * t + previousCoords.longitude(); lat = previousTessellatedCoords.latitude(); } else { // To tessellate along great circles use the // normalized linear interpolation ("NLERP") for latitude and longitude. const Quaternion itpos = Quaternion::nlerp( previousCoords.quaternion(), currentCoords.quaternion(), t ); itpos. getSpherical( lon, lat ); } const GeoDataCoordinates currentTessellatedCoords( lon, lat, altitude ); Q_Q(const CylindricalProjection); qreal bx, by; q->screenCoordinates( currentTessellatedCoords, viewport, bx, by ); mirrorCount = crossDateLine( previousTessellatedCoords, currentTessellatedCoords, bx, by, polygons, mirrorCount, repeatDistance ); previousTessellatedCoords = currentTessellatedCoords; } // For the clampToGround case add the "current" coordinate after adding all other nodes. GeoDataCoordinates currentModifiedCoords( currentCoords ); if ( clampToGround ) { currentModifiedCoords.setAltitude( 0.0 ); } Q_Q(const CylindricalProjection); qreal bx, by; q->screenCoordinates( currentModifiedCoords, viewport, bx, by ); mirrorCount = crossDateLine( previousTessellatedCoords, currentModifiedCoords, bx, by, polygons, mirrorCount, repeatDistance ); return mirrorCount; }
QString OpenRouteServiceRunner::formatCoordinates(const GeoDataCoordinates &coordinates) { return QStringLiteral("%1,%2") .arg(coordinates.longitude(GeoDataCoordinates::Degree ), 0, 'f', 8) .arg(coordinates.latitude(GeoDataCoordinates::Degree ), 0, 'f', 8); }
void TestTrack::simpleParseTest() { //example track recorded using a Garmin Vista HCx and downloaded using gpsbabel QString content( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<gpx" " version=\"1.0\"" " creator=\"GPSBabel - http://www.gpsbabel.org\"" " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" " xmlns=\"http://www.topografix.com/GPX/1/0\"" " xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">" "<time>2011-07-03T14:19:57Z</time>" "<bounds minlat=\"47.231073193\" minlon=\"12.549449634\" maxlat=\"48.502999926\" maxlon=\"14.302069964\"/>" "<trk>" " <name>test track</name>" "<number>1</number>" "<trkseg>" "<trkpt lat=\"47.231477033\" lon=\"12.560534449\">" " <ele>1130.647705</ele>" " <time>2011-06-24T10:33:40Z</time>" "</trkpt>" "<trkpt lat=\"47.231486840\" lon=\"12.560604354\">" " <ele>1127.763672</ele>" " <time>2011-06-24T10:33:55Z</time>" "</trkpt>" "<trkpt lat=\"47.231497569\" lon=\"12.560612401\">" " <ele>1121.995850</ele>" " <time>2011-06-24T10:34:00Z</time>" "</trkpt>" "</trkseg>" "</trk>" "</gpx>" ); GpxParser parser; QByteArray array( content.toUtf8() ); QBuffer buffer( &array ); buffer.open( QIODevice::ReadOnly ); qDebug() << "Buffer content:" << endl << buffer.buffer(); if ( !parser.read( &buffer ) ) { QFAIL( "Could not parse data!" ); return; } GeoDocument* document = parser.releaseDocument(); QVERIFY( document ); GeoDataDocument *dataDocument = static_cast<GeoDataDocument*>( document ); GeoDataPlacemark* placemark = dataDocument->placemarkList().at( 0 ); QCOMPARE( placemark->geometry()->geometryId(), GeoDataMultiGeometryId ); GeoDataMultiGeometry* multiGeo = static_cast<GeoDataMultiGeometry*>( placemark->geometry() ); GeoDataTrack* track = static_cast<GeoDataTrack*>( &multiGeo->at( 0 ) ); QCOMPARE( track->size(), 3 ); { QDateTime when = track->whenList().at( 0 ); QCOMPARE( when, QDateTime( QDate( 2011, 6, 24 ), QTime( 10, 33, 40 ), Qt::UTC ) ); } { GeoDataCoordinates coord = track->coordinatesAt( 0 ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), 12.560534449 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 47.231477033 ); QCOMPARE( coord.altitude(), 1130.647705 ); } { GeoDataCoordinates coord = track->coordinatesAt( QDateTime( QDate( 2011, 6, 24 ), QTime( 10, 33, 40 ), Qt::UTC ) ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), 12.560534449 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 47.231477033 ); QCOMPARE( coord.altitude(), 1130.647705 ); } { const GeoDataLineString* lineString = track->lineString(); QCOMPARE( lineString->size(), 3 ); GeoDataCoordinates coord = lineString->at( 0 ); QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), 12.560534449 ); QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 47.231477033 ); QCOMPARE( coord.altitude(), 1130.647705 ); } delete document; }