/*! \internal */ void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (!mapAndSourceItemSet_ || updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) { QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry); return; } QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false); if (newCoordinate.isValid()) setCoordinate(newCoordinate); // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested // call to this function. }
void debug_data() { QTest::addColumn<QGeoCoordinate>("c"); QTest::addColumn<QByteArray>("debugString"); QTest::newRow("uninitialized") << QGeoCoordinate() << QByteArray("QGeoCoordinate(?, ?)"); QTest::newRow("initialized without altitude") << BRISBANE << (QString("QGeoCoordinate(%1, %2)").arg(BRISBANE.latitude()) .arg(BRISBANE.longitude())).toLatin1(); QTest::newRow("invalid initialization") << QGeoCoordinate(-100,-200) << QByteArray("QGeoCoordinate(?, ?)"); QTest::newRow("initialized with altitude") << QGeoCoordinate(1,2,3) << QByteArray("QGeoCoordinate(1, 2, 3)"); }
/*! \internal */ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (updatingGeometry_ || newGeometry == oldGeometry) { QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry); return; } QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(width(), height()) / 2; QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false); if (newCoordinate.isValid()) setCenter(newCoordinate); // Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested // call to this function. }
QT_BEGIN_NAMESPACE QDoubleVector2D QGeoProjection::coordToMercator(const QGeoCoordinate &coord) { const double pi = M_PI; double lon = coord.longitude() / 360.0 + 0.5; double lat = coord.latitude(); lat = 0.5 - (std::log(std::tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0; lat = qMax(0.0, lat); lat = qMin(1.0, lat); return QDoubleVector2D(lon, lat); }
/*! \internal */ void QDeclarativeGeoMapGestureArea::panStateMachine() { PanState lastState = panState_; // Transitions switch (panState_) { case panInactive: if (canStartPan()) { // Update startCoord_ to ensure smooth start for panning when going over startDragDistance QGeoCoordinate newStartCoord = map_->screenPositionToCoordinate(QDoubleVector2D(lastPos_), false); startCoord_.setLongitude(newStartCoord.longitude()); startCoord_.setLatitude(newStartCoord.latitude()); panState_ = panActive; } break; case panActive: if (touchPoints_.count() == 0) { panState_ = panFlick; if (!tryStartFlick()) { panState_ = panInactive; // mark as inactive for use by camera if (pinchState_ == pinchInactive) emit movementStopped(); } } break; case panFlick: if (touchPoints_.count() > 0) { // re touched before movement ended endFlick(); panState_ = panActive; } break; } // Update switch (panState_) { case panInactive: // do nothing break; case panActive: updatePan(); // this ensures 'panStarted' occurs after the pan has actually started if (lastState != panActive) emit panStarted(); break; case panFlick: break; } }
/*! Extends the circle to include \a coordinate */ void QGeoCirclePrivate::extendShape(const QGeoCoordinate &coordinate) { if (!isValid() || !coordinate.isValid() || contains(coordinate)) return; radius = center.distanceTo(coordinate); }
void QGeoAreaMonitorPolling::setCenter(const QGeoCoordinate& coordinate) { if (coordinate.isValid()) { QGeoAreaMonitor::setCenter(coordinate); checkStartStop(); } }
void QGeoMapController::pan(qreal dx, qreal dy) { if (dx == 0 && dy == 0) return; QGeoCameraData cd = map_->cameraData(); QGeoCoordinate coord = map_->itemPositionToCoordinate( QDoubleVector2D(map_->width() / 2 + dx, map_->height() / 2 + dy)); // keep altitude as it was coord.setAltitude(cd.center().altitude()); if (coord.isValid()) { cd.setCenter(coord); map_->setCameraData(cd); } }
void CurrentConditions::reqCurrCond(const QGeoCoordinate& position){ /// Requests the current conditions data. if( position.isValid() ){ QNetworkRequest request(QUrl(QString::fromStdString(std::string("http://forecast.weather.gov/MapClick.php?lat=" + std::to_string(position.latitude()) + "&lon=" + std::to_string(position.longitude()) + "&FcstType=json")))); request.setAttribute(QNetworkRequest::User, QVariant(ReqType::NOAA_JSON_FCAST_CURRCOND)); m_nam->get(request); } // TODO if m_position is not valid. return; }
/*! Sets the height of this geo rectangle in degrees to \a degreesHeight. If \a degreesHeight is less than 0.0 or if this geo rectangle is invalid this function does nothing. To set up the values of an invalid geo rectangle based on the center, width and height you should use setCenter() first in order to make the geo rectangle valid. If the change in height would cause the geo rectangle to cross a pole the height is adjusted such that the geo rectangle only touches the pole. This change is done such that the center coordinate is still at the center of the geo rectangle, which may result in a geo rectangle with a smaller height than might otherwise be expected. If \a degreesHeight is greater than 180.0 then 180.0 is used as the height. */ void QGeoRectangle::setHeight(double degreesHeight) { if (!isValid()) return; if (degreesHeight < 0.0) return; if (degreesHeight >= 180.0) { degreesHeight = 180.0; } Q_D(QGeoRectangle); double tlLon = d->topLeft.longitude(); double brLon = d->bottomRight.longitude(); QGeoCoordinate c = center(); double tlLat = c.latitude() + degreesHeight / 2.0; double brLat = c.latitude() - degreesHeight / 2.0; if (tlLat > 90.0) { brLat = 2* c.latitude() - 90.0; tlLat = 90.0; } if (tlLat < -90.0) { brLat = -90.0; tlLat = -90.0; } if (brLat > 90.0) { tlLat = 90.0; brLat = 90.0; } if (brLat < -90.0) { tlLat = 2 * c.latitude() + 90.0; brLat = -90.0; } d->topLeft = QGeoCoordinate(tlLat, tlLon); d->bottomRight = QGeoCoordinate(brLat, brLon); }
void GpsPosition::positionUpdated(QGeoPositionInfo info) { double latitude, longitude; //qDebug() << "gps info " << info; QGeoCoordinate coord = info.coordinate(); if (coord.isValid()){ longitude = coord.longitude(); latitude = coord.latitude(); qDebug() << "lon = " << longitude << ", lat = " << latitude; if (_isUpdated){ _location->stopUpdates(); _isUpdated = false; } emit findCoord(latitude, longitude); /* set timer */ startTimer(); } }
bool QGeoRouteXmlParser::parseCoordinates(QGeoCoordinate &coord) { QString currentElement = m_reader->name().toString(); m_reader->readNext(); while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == currentElement)) { if (m_reader->tokenType() == QXmlStreamReader::StartElement) { QString name = m_reader->name().toString(); QString value = m_reader->readElementText(); if (name == "Latitude") coord.setLatitude(value.toDouble()); else if (name == "Longitude") coord.setLongitude(value.toDouble()); } m_reader->readNext(); } return true; }
// FIXME: // - not left right / up down flicking, so if map is rotated, will act unintuitively void QDeclarativeGeoMapGestureArea::startFlick(int dx, int dy, int timeMs) { if (timeMs < 0) return; AnimatableCoordinate animationStartCoordinate = map_->mapController()->center(); QGeoCoordinate coordinate = animationStartCoordinate.coordinate(); if (pan_.animation_->state() == QPropertyAnimation::Running) pan_.animation_->stop(); AnimatableCoordinate animationEndCoordinate = map_->mapController()->center(); pan_.animation_->setDuration(timeMs); coordinate.setLongitude(coordinate.longitude() - (dx / pow(2.0, map_->mapController()->zoom()))); coordinate.setLatitude(coordinate.latitude() + (dy / pow(2.0, map_->mapController()->zoom()))); animationEndCoordinate.setCoordinate(coordinate); pan_.animation_->setStartValue(QVariant::fromValue(animationStartCoordinate)); pan_.animation_->setEndValue(QVariant::fromValue(animationEndCoordinate)); pan_.animation_->start(); emit flickStarted(); }
QPlace QPlaceManagerEngineJsonDb::compatiblePlace(const QPlace &original) const { QPlace place; place.setName(original.name()); QGeoLocation location = original.location(); QGeoCoordinate coord = original.location().coordinate(); coord.setAltitude(qQNaN()); location.setCoordinate(coord); location.setBoundingBox(QGeoRectangle()); place.setLocation(location); QList<QPlaceContactDetail> details; foreach (const QString &contactType, original.contactTypes()) place.setContactDetails(contactType, original.contactDetails(contactType)); place.setVisibility(QLocation::UnspecifiedVisibility); QStringList attributeTypes = original.extendedAttributeTypes(); foreach (const QString &attributeType, attributeTypes) place.setExtendedAttribute(attributeType, original.extendedAttribute(attributeType)); QString provider = original.extendedAttribute(QLatin1String("x_provider")).text(); if (!provider.isEmpty()) { QPlaceAttribute alternativeId; alternativeId.setText(original.placeId()); place.setExtendedAttribute(QString::fromLatin1("x_id_") + provider, alternativeId); if (provider == QLatin1String("nokia") || provider == QLatin1String("nokia_mos")) { QStringList nokiaCategoryIds; foreach (const QPlaceCategory &cat, original.categories()) { if (!cat.categoryId().isEmpty()) nokiaCategoryIds.append(cat.categoryId()); } if (!nokiaCategoryIds.isEmpty()) { QPlaceAttribute nokiaCatIds; nokiaCatIds.setText(nokiaCategoryIds.join(QLatin1String(","))); place.setExtendedAttribute(QString::fromLatin1("x_nokia_category_ids"), nokiaCatIds); } }
void OpenstreetmapMapProvider::getTile(const QGeoCoordinate& coord, int zoomLevel) { cancelDownload(); double tilex_exact = long2tilex(coord.longitude(), zoomLevel); double tiley_exact = lat2tiley(coord.latitude(), zoomLevel); Tile info; info.x = tilex_exact; info.y = tiley_exact; info.w = TILE_DIMENSION; info.h = TILE_DIMENSION; info.zoom = zoomLevel; QQueue<Tile> queue; queue.enqueue(info); startDownload(queue); }
QGeoCoordinate QGeoCoordinateInterpolator2D::interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress) { if (start == end) { if (progress < 0.5) { return start; } else { return end; } } QGeoCoordinate s2 = start; QGeoCoordinate e2 = end; QDoubleVector2D s = QGeoProjection::coordToMercator(s2); QDoubleVector2D e = QGeoProjection::coordToMercator(e2); double x = s.x(); if (0.5 < qAbs(e.x() - s.x())) { // handle dateline crossing double ex = e.x(); double sx = s.x(); if (ex < sx) sx -= 1.0; else if (sx < ex) ex -= 1.0; x = (1.0 - progress) * sx + progress * ex; if (!qFuzzyIsNull(x) && (x < 0.0)) x += 1.0; } else { x = (1.0 - progress) * s.x() + progress * e.x(); } double y = (1.0 - progress) * s.y() + progress * e.y(); QGeoCoordinate result = QGeoProjection::mercatorToCoord(QDoubleVector2D(x, y)); result.setAltitude((1.0 - progress) * start.altitude() + progress * end.altitude()); return result; }
void VerticalProfilePresenter::updateMission() { this->invokeViewMethod(PROPERTY(clearWaypoints)); dto::MissionPtr mission = m_service->mission(m_missionId); if (mission.isNull() || mission->count() < 1) return; QGeoCoordinate lastPosition; int distance = 0; int homeAltitude = 0; int minAltitude = INT_MAX; int maxAltitude = INT_MIN; for (const dto::MissionItemPtr& item: m_service->missionItems(mission->id())) { if (!item->isAltitudedItem()) continue; if (item->sequence() == 0) homeAltitude = item->altitude(); if (item->isPositionatedItem()) { if (item->coordinate().isValid() && lastPosition.isValid()) { distance += lastPosition.distanceTo(item->coordinate()); } lastPosition = item->coordinate(); } int altitude = item->isAltitudeRelative() ? homeAltitude + item->altitude() : item->altitude(); if (altitude < minAltitude) minAltitude = altitude; if (altitude > maxAltitude) maxAltitude = altitude; this->invokeViewMethod(PROPERTY(appendWaypoint), distance, altitude); } this->setViewProperty(PROPERTY(minDistance), 0); this->setViewProperty(PROPERTY(maxDistance), distance); this->setViewProperty(PROPERTY(minAltitude), minAltitude); this->setViewProperty(PROPERTY(maxAltitude), maxAltitude); }
void QGeoTiledMapDataPrivate::changeCameraData(const QGeoCameraData &oldCameraData) { double lat = oldCameraData.center().latitude(); if (mapScene_->verticalLock()) { QGeoCoordinate coord = map_->cameraData().center(); coord.setLatitude(lat); map_->cameraData().setCenter(coord); } // For zoomlevel, "snap" 0.05 either side of a whole number. // This is so that when we turn off bilinear scaling, we're // snapped to the exact pixel size of the tiles QGeoCameraData cam = map_->cameraData(); int izl = static_cast<int>(std::floor(cam.zoomLevel())); float delta = cam.zoomLevel() - izl; if (delta > 0.5) { izl++; delta -= 1.0; } if (qAbs(delta) < 0.05) { cam.setZoomLevel(izl); } cameraTiles_->setCamera(cam); mapScene_->setCameraData(cam); mapScene_->setVisibleTiles(cameraTiles_->tiles()); if (tileRequests_) { // don't request tiles that are already built and textured QList<QSharedPointer<QGeoTileTexture> > cachedTiles = tileRequests_->requestTiles(cameraTiles_->tiles() - mapScene_->texturedTiles()); foreach (const QSharedPointer<QGeoTileTexture> &tex, cachedTiles) { mapScene_->addTile(tex->spec, tex); } if (!cachedTiles.isEmpty()) map_->update(); }
void Loco::NewDestination (const QGeoCoordinate & whereTo, const QString & name) { locator->SetMoveStep (normalStep); steppingNormal = true; destination = whereTo; destName = name; QDateTime now = QDateTime::currentDateTime(); mainUi.destination->setText (tr("going to %1 at %2") .arg (name) .arg (whereTo.toString())); double dist = lastLocation.distanceTo (whereTo); mainUi.msgLog->append (tr("At %1 destination %2 (%3) %4 nm %5 mi %6 km") .arg (now.toString("hh:mm:ss")) .arg (name) .arg (whereTo.toString()) .arg (dist/1852.0) .arg (dist/1609.344) .arg (dist/1000.0)); }
bool QGeoCirclePrivate::contains(const QGeoCoordinate &coordinate) const { if (!isValid() || !coordinate.isValid()) return false; // see QTBUG-41447 for details qreal distance = center.distanceTo(coordinate); if (qFuzzyCompare(distance, radius) || distance <= radius) return true; return false; }
QList<QGeoPositionInfo> gpxfile::loadFrom(const QString fileName) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "File open error:" << file.errorString(); // return false; } QXmlStreamReader xml(&file); QList<QGeoPositionInfo> trackList; trackList.clear(); QGeoPositionInfo tp; QGeoCoordinate coord; QDateTime ts; while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if (xml.isStartElement()) { if (xml.name() == "trkpt") { coord.setLongitude(xml.attributes().value("lon").toFloat()); coord.setLatitude(xml.attributes().value("lat").toFloat()); while (xml.readNextStartElement()) { if (xml.name() == "ele") coord.setAltitude(xml.readElementText().toFloat()); else if (xml.name() == "time") ts = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd'T'hh:mm:ss'Z'"); } //ele, time tp.setCoordinate(coord); tp.setTimestamp(ts); trackList.append(tp); } //trkpt } //content } //eof return(trackList); }
void ModelIndexLayer::render(QPainter& painter) { if (mItemModel == NULL) { qDebug() << "Model == NULL"; // Nothing to do. return. return; } foreach(QModelIndex index, mCulled) { QGeoCoordinate coord = mItemModel->data(index, ModelIndexLayer::GeoCoordinateRole).value<QGeoCoordinate>(); if (!coord.isValid()) continue; // prepare the viewport for the delegate QRect vp = markerPosition(coord); painter.save(); painter.setClipRect(vp); painter.setWindow(QRect(0, 0, vp.width(), vp.height())); painter.setViewport(vp); MarkerInfo markerInfo; markerInfo.coord = coord; markerInfo.modelIndex = index; markerInfo.x = vp.left(); markerInfo.y = vp.top(); markerInfo.width = vp.width(); markerInfo.height = vp.height(); if (mSelectionModel != NULL) markerInfo.markerState = mSelectionModel->selection().contains(index) ? MarkerInfo::MarkerStateSelected : MarkerInfo::MarkerStateNone; QVariant v = mItemModel->data(index, ModelIndexLayer::DataRole); mDelegate->paint(painter, markerInfo, v); painter.restore(); } // else skip, this coord is not in view
QDebug operator<<(QDebug dbg, const QGeoCoordinate &coord) { double lat = coord.latitude(); double lng = coord.longitude(); dbg.nospace() << "QGeoCoordinate("; if (qIsNaN(lat)) dbg.nospace() << '?'; else dbg.nospace() << lat; dbg.nospace() << ", "; if (qIsNaN(lng)) dbg.nospace() << '?'; else dbg.nospace() << lng; if (coord.type() == QGeoCoordinate::Coordinate3D) { dbg.nospace() << ", "; dbg.nospace() << coord.altitude(); } dbg.nospace() << ')'; return dbg; }
void MapBox::drawCircle() { if (m_markerObjects.count() < 1) return; QGeoMapPixmapObject * p1 = m_markerObjects.at(0); // center of the circle QGeoCoordinate center = p1->coordinate(); // the circle's radius, in meters, defaults to 3000 km qreal radius = 3000000; // if a 2nd marker object is given, evaluate its distance to the first one to get the circle's radius. if (m_markerObjects.count() >= 2) { QGeoMapPixmapObject * p2 = m_markerObjects.at(1); radius = center.distanceTo(p2->coordinate()); } QGeoMapCircleObject * circle = addCircle(center, radius); m_mapWidget->lastCircle = circle; }
/*! Sets the width of this geo rectangle in degrees to \a degreesWidth. If \a degreesWidth is less than 0.0 or if this geo rectangle is invalid this function does nothing. To set up the values of an invalid geo rectangle based on the center, width and height you should use setCenter() first in order to make the geo rectangle valid. If \a degreesWidth is greater than 360.0 then 360.0 is used as the width, the leftmost longitude of the geo rectangle is set to -180.0 degrees and the rightmost longitude of the geo rectangle is set to 180.0 degrees. */ void QGeoRectangle::setWidth(double degreesWidth) { if (!isValid()) return; if (degreesWidth < 0.0) return; Q_D(QGeoRectangle); if (degreesWidth >= 360.0) { d->topLeft.setLongitude(-180.0); d->bottomRight.setLongitude(180.0); return; } double tlLat = d->topLeft.latitude(); double brLat = d->bottomRight.latitude(); QGeoCoordinate c = center(); double tlLon = c.longitude() - degreesWidth / 2.0; if (tlLon < -180.0) tlLon += 360.0; if (tlLon > 180.0) tlLon -= 360.0; double brLon = c.longitude() + degreesWidth / 2.0; if (brLon < -180.0) brLon += 360.0; if (brLon > 180.0) brLon -= 360.0; d->topLeft = QGeoCoordinate(tlLat, tlLon); d->bottomRight = QGeoCoordinate(brLat, brLon); }
QString QGeoRoutingManagerEngineNokia::updateRouteRequestString(const QGeoRoute &route, const QGeoCoordinate &position) { if (!checkEngineSupport(route.request(), route.travelMode())) return ""; QString requestString = "http://"; requestString += m_host; requestString += "/routing/6.2/getroute.xml"; requestString += "?routeid="; requestString += route.routeId(); requestString += "&pos="; requestString += QString::number(position.latitude()); requestString += ","; requestString += QString::number(position.longitude()); requestString += modesRequestString(route.request(), route.travelMode()); requestString += routeRequestString(route.request()); return requestString; }
void GeolocationClientQt::positionUpdated(const QGeoPositionInfo &geoPosition) { if (!geoPosition.isValid()) return; QGeoCoordinate coord = geoPosition.coordinate(); double latitude = coord.latitude(); double longitude = coord.longitude(); bool providesAltitude = (geoPosition.coordinate().type() == QGeoCoordinate::Coordinate3D); double altitude = coord.altitude(); double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy); bool providesAltitudeAccuracy = geoPosition.hasAttribute(QGeoPositionInfo::VerticalAccuracy); double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy); bool providesHeading = geoPosition.hasAttribute(QGeoPositionInfo::Direction); double heading = geoPosition.attribute(QGeoPositionInfo::Direction); bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed); double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed); #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) double timeStampInSeconds = geoPosition.timestamp().toMSecsSinceEpoch() / 1000; #else QDateTime datetime = geoPosition.timestamp(); double timeStampInSeconds = (datetime.toTime_t() + datetime.time().msec()) / 1000; #endif m_lastPosition = GeolocationPosition::create(timeStampInSeconds, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed); WebCore::Page* page = QWebPagePrivate::core(m_page); page->geolocationController()->positionChanged(m_lastPosition.get()); }
SensorData CzmlReader::writeToSensorData(QJsonObject& data) { QJsonArray positionArray; QJsonObject positionObject; SensorData sensordata; QString id = data["id"].toString(); sensordata.setId(getIdFromCzmlString(id)); positionObject = data["position"].toObject(); positionArray = positionObject["cartographicDegrees"].toArray(); QGeoCoordinate parsedPosition; parsedPosition.setLatitude(positionArray[1].toDouble()); parsedPosition.setLongitude(positionArray[0].toDouble()); sensordata.setPosition(parsedPosition); sensordata.setHeight(positionArray[2].toDouble()); if(data["sensorvalue"].isString()) sensordata.setSensorValue(std::numeric_limits<double>::min()); else sensordata.setSensorValue(data["sensorvalue"].toDouble()); return sensordata; }
/*! Sets the center of this geo rectangle to \a center. If this causes the geo rectangle to cross on of the poles the height of the geo rectangle will be truncated such that the geo rectangle only extends up to the pole. The center of the geo rectangle will be unchanged, and the height will be adjusted such that the center point is at the center of the truncated geo rectangle. */ void QGeoRectangle::setCenter(const QGeoCoordinate ¢er) { Q_D(QGeoRectangle); if (!isValid()) { d->topLeft = center; d->bottomRight = center; return; } double width = this->width(); double height = this->height(); double tlLat = center.latitude() + height / 2.0; double tlLon = center.longitude() - width / 2.0; double brLat = center.latitude() - height / 2.0; double brLon = center.longitude() + width / 2.0; if (tlLon < -180.0) tlLon += 360.0; if (tlLon > 180.0) tlLon -= 360.0; if (brLon < -180.0) brLon += 360.0; if (brLon > 180.0) brLon -= 360.0; if (tlLat > 90.0) { brLat = 2 * center.latitude() - 90.0; tlLat = 90.0; } if (tlLat < -90.0) { brLat = -90.0; tlLat = -90.0; } if (brLat > 90.0) { tlLat = 90.0; brLat = 90.0; } if (brLat < -90.0) { tlLat = 2 * center.latitude() + 90.0; brLat = -90.0; } if (width == 360.0) { tlLon = -180.0; brLon = 180.0; } d->topLeft = QGeoCoordinate(tlLat, tlLon); d->bottomRight = QGeoCoordinate(brLat, brLon); }
void GpsPosition::timeout() { double distance = 0; qDebug() << "\ntimeout\n\n"; QGeoCoordinate coord = _location->lastKnownPosition(true).coordinate(); qDebug() << "SAVED POSITION lat = " << _latitude << " lon = " << _longitude; qDebug() << "LAST POSITION lat = " << coord.latitude() << " lon = " << coord.longitude(); if (coord.isValid()){ distance = Core::DatabaseSqlite::calculate_distance(_latitude, _longitude, coord.latitude(), coord.longitude()); qDebug() << "distancd = " << distance; /* check distance between the last and found coordinates */ if (distance > UPDATE_DISTANCE){ /* distance more then UPDATE_DISTANCE km */ emit findCoord(coord.latitude(), coord.longitude()); } } }