当前位置: 首页>>代码示例>>C++>>正文


C++ QGeoCoordinate::longitude方法代码示例

本文整理汇总了C++中QGeoCoordinate::longitude方法的典型用法代码示例。如果您正苦于以下问题:C++ QGeoCoordinate::longitude方法的具体用法?C++ QGeoCoordinate::longitude怎么用?C++ QGeoCoordinate::longitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QGeoCoordinate的用法示例。


在下文中一共展示了QGeoCoordinate::longitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setGeo

void MapWidget::setGeo(const QGeoCoordinate &geo)
{
    p->image = QImage(":/qml/Papyrus/files/map-loading.png").scaled(width(),height(),
                                                                  Qt::IgnoreAspectRatio,
                                                                  Qt::SmoothTransformation);

    update();
    if( !geo.latitude() && !geo.longitude() )
        return;
    if( p->reply )
        return;

    init_manager();

    p->geo = geo;
    QString path = "http://maps.google.com/maps/api/staticmap?center=" +
            QString::number(geo.latitude()) + "," + QString::number(geo.longitude()) + "&zoom=15&size=" +
            QString::number(width()) + "x" + QString::number(height()) + "&sensor=false";

    QNetworkRequest request = QNetworkRequest(QUrl(path));
    p->reply = p->manager->get(request);

    connect(p->reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(sslErrors(QList<QSslError>)));
    connect(p->reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)) );

    setToolTip( QString::number(p->geo.latitude()) + ", " + QString::number(p->geo.longitude()) );
}
开发者ID:Aseman-Land,项目名称:Papyrus,代码行数:27,代码来源:mapwidget.cpp

示例2: positionUpdated

void PointInPolygonWidget::positionUpdated(const QGeoPositionInfo &info)
{
    QGeoPositionInfo pos_info = info;
    QGeoCoordinate pos = pos_info.coordinate();

    if (pos.isValid()) {

        ui->xNewPoint->setValue(pos.latitude());
        ui->yNewPoint->setValue(pos.longitude());

        ui->xPoint->setValue(pos.latitude());
        ui->yPoint->setValue(pos.longitude());

        double dist = 0;
        if (is_first_distance_) {
            dist_acc_ = 0;
            is_first_distance_ = false;
        } else {
            if (std::fabs(pos.altitude()) < 1e-3) {
                pos.setAltitude(last_position_.coordinate().altitude());
                pos_info.setCoordinate(pos);
            }
            dist = pos_info.coordinate().distanceTo(last_position_.coordinate());
            if (dist > 10) {
                dist_acc_ += dist;
            }
        }
        last_position_ = pos_info;
    }
}
开发者ID:gogo40,项目名称:GoGo-PointsInAPolygon,代码行数:30,代码来源:point_in_polygon_widget.cpp

示例3: setCenter

/*!
    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 &center)
{
    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);
}
开发者ID:kobolabs,项目名称:qtlocation,代码行数:65,代码来源:qgeorectangle.cpp

示例4: crossEarthPole

static bool crossEarthPole(const QGeoCoordinate &center, qreal distance)
{
    qreal poleLat = 90;
    QGeoCoordinate northPole = QGeoCoordinate(poleLat, center.longitude());
    QGeoCoordinate southPole = QGeoCoordinate(-poleLat, center.longitude());
    // approximate using great circle distance
    qreal distanceToNorthPole = center.distanceTo(northPole);
    qreal distanceToSouthPole = center.distanceTo(southPole);
    if (distanceToNorthPole < distance || distanceToSouthPole < distance)
        return true;
    return false;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:12,代码来源:qdeclarativecirclemapitem.cpp

示例5: setCenter

/*!
    Sets the center of this bounding box to \a center.

    If this causes the bounding box to cross on of the poles the height of the
    bounding box will be truncated such that the bounding box only extends up
    to the pole. The center of the bounding box will be unchanged, and the
    height will be adjusted such that the center point is at the center of the
    truncated bounding box.
*/
void QGeoBoundingBox::setCenter(const QGeoCoordinate &center)
{
    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_ptr->topLeft = QGeoCoordinate(tlLat, tlLon);
    d_ptr->bottomRight = QGeoCoordinate(brLat, brLon);
}
开发者ID:blackberry,项目名称:QtLocationSubset,代码行数:57,代码来源:qgeoboundingbox.cpp

示例6: nsGeoPosition

void
QTMLocationProvider::positionUpdated(const QGeoPositionInfo &geoPosition)
{
    if (!geoPosition.isValid()) {
        NS_WARNING("Invalida geoposition received");
        return;
    }

    QGeoCoordinate coord = geoPosition.coordinate();
    double latitude = coord.latitude();
    double longitude = coord.longitude();
    double altitude = coord.altitude();
    double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy);
    double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy);
    double heading = geoPosition.attribute(QGeoPositionInfo::Direction);

    bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed);
    double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed);

    nsRefPtr<nsGeoPosition> p =
        new nsGeoPosition(latitude, longitude,
                          altitude, accuracy,
                          altitudeAccuracy, heading,
                          speed, geoPosition.timestamp().toTime_t());
    if (mCallback) {
        mCallback->Update(p);
    }
}
开发者ID:PriceTseng,项目名称:mozilla-central,代码行数:28,代码来源:QTMLocationProvider.cpp

示例7: setBottomLeft

/*!
    Sets the bottom left coordinate of this geo rectangle to \a bottomLeft.
*/
void QGeoRectangle::setBottomLeft(const QGeoCoordinate &bottomLeft)
{
    Q_D(QGeoRectangle);

    d->bottomRight.setLatitude(bottomLeft.latitude());
    d->topLeft.setLongitude(bottomLeft.longitude());
}
开发者ID:kobolabs,项目名称:qtlocation,代码行数:10,代码来源:qgeorectangle.cpp

示例8: positionUpdated

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);

    double timeStampInSeconds = geoPosition.timestamp().toMSecsSinceEpoch() / 1000;

    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());
}
开发者ID:wpbest,项目名称:copperspice,代码行数:32,代码来源:GeolocationClientQt.cpp

示例9: QObject

SlippyCoordinates::SlippyCoordinates(QGeoCoordinate location, int zoom, QObject *parent):
    QObject(parent)
{
    this->m_zoom=zoom;

    // for the calculation see:
    // http://wiki.openstreetmap.org/wiki/Tilenames#X_and_Y

    double latitude=location.latitude();
    double longitude=location.longitude();

    qDebug() << "New Coordinates " << latitude << ", " << longitude;
    //check for either to be NaN
    if(latitude!=latitude || longitude!=longitude)
    {
        setValid(false);
        return;
    }

    double mercatorx = ((longitude + 180) / 360);

    double mercatory = (1.0 - (log(tan(latitude/180.0*M_PI) + sec(latitude/180.0*M_PI)) / M_PI)) / 2.0;

    setMercatorPos(QPointF(mercatorx, mercatory));


}
开发者ID:unsanded,项目名称:harbour-mapp,代码行数:27,代码来源:slippycoordinates.cpp

示例10: contains

/*!
    Returns whether the coordinate \a coordinate is contained within this
    bounding box.
*/
bool QGeoBoundingBox::contains(const QGeoCoordinate &coordinate) const
{

    if (!isValid() || !coordinate.isValid())
        return false;

    double left = d_ptr->topLeft.longitude();
    double right = d_ptr->bottomRight.longitude();
    double top = d_ptr->topLeft.latitude();
    double bottom = d_ptr->bottomRight.latitude();

    double lon = coordinate.longitude();
    double lat = coordinate.latitude();

    if (lat > top)
        return false;
    if (lat < bottom)
        return false;

    if ((lat == 90.0) && (top == 90.0))
        return true;

    if ((lat == -90.0) && (bottom == -90.0))
        return true;

    if (left <= right) {
        if ((lon < left) || (lon > right))
            return false;
    } else {
        if ((lon < left) && (lon > right))
            return false;
    }

    return true;
}
开发者ID:blackberry,项目名称:QtLocationSubset,代码行数:39,代码来源:qgeoboundingbox.cpp

示例11: getTiles

void OpenstreetmapMapProvider::getTiles(const QGeoCoordinate& topleft,
    int zoomLevel,
    int width,
    int height)
{
    cancelDownload();

    double       tilex_exact = long2tilex(topleft.longitude(), zoomLevel);
    double       tiley_exact = lat2tiley(topleft.latitude(), zoomLevel);

    int          x_start = (int)floor(tilex_exact);
    int          y_start = (int)floor(tiley_exact);

    int          x_end = (int)floor(tilex_exact) + width / TILE_DIMENSION + 1;
    int          y_end = (int)floor(tiley_exact) + height / TILE_DIMENSION + 1;

    QQueue<Tile> list;

    for (int y = y_start; y <= y_end; y++)
    {
        for (int x = x_start; x <= x_end; x++)
        {
            Tile info;
            info.x    = x * TILE_DIMENSION;
            info.y    = y * TILE_DIMENSION;
            info.w    = TILE_DIMENSION;
            info.h    = TILE_DIMENSION;
            info.zoom = zoomLevel;

            list.enqueue(info);
        }
    }
    startDownload(list);
}
开发者ID:jaapgeurts,项目名称:photostage,代码行数:34,代码来源:openstreetmapmapprovider.cpp

示例12: calculatePeripheralPoints

static void calculatePeripheralPoints(QList<QGeoCoordinate> &path, const QGeoCoordinate &center, qreal distance, int steps)
{
    // Calculate points based on great-circle distance
    // Calculation is the same as GeoCoordinate's atDistanceAndAzimuth function
    // but tweaked here for computing multiple points

    // pre-calculate
    qreal latRad = qgeocoordinate_degToRad(center.latitude());
    qreal lonRad = qgeocoordinate_degToRad(center.longitude());
    qreal cosLatRad = std::cos(latRad);
    qreal sinLatRad = std::sin(latRad);
    qreal ratio = (distance / (qgeocoordinate_EARTH_MEAN_RADIUS * 1000.0));
    qreal cosRatio = std::cos(ratio);
    qreal sinRatio = std::sin(ratio);
    qreal sinLatRad_x_cosRatio = sinLatRad * cosRatio;
    qreal cosLatRad_x_sinRatio = cosLatRad * sinRatio;

    for (int i = 0; i < steps; ++i) {
        qreal azimuthRad = 2 * M_PI * i / steps;
        qreal resultLatRad = std::asin(sinLatRad_x_cosRatio
                                   + cosLatRad_x_sinRatio * std::cos(azimuthRad));
        qreal resultLonRad = lonRad + std::atan2(std::sin(azimuthRad) * cosLatRad_x_sinRatio,
                                       cosRatio - sinLatRad * std::sin(resultLatRad));
        qreal lat2 = qgeocoordinate_radToDeg(resultLatRad);
        qreal lon2 = qgeocoordinate_radToDeg(resultLonRad);
        if (lon2 < -180.0) {
            lon2 += 360.0;
        } else if (lon2 > 180.0) {
            lon2 -= 360.0;
        }
        path << QGeoCoordinate(lat2, lon2, center.altitude());
    }
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:33,代码来源:qdeclarativecirclemapitem.cpp

示例13: addAtForBoundingArea

static bool addAtForBoundingArea(const QGeoShape &area,
                                 QUrlQuery *queryItems)
{
    QGeoCoordinate center;
    switch (area.type()) {
    case QGeoShape::RectangleType:
        center = QGeoRectangle(area).center();
        break;
    case QGeoShape::CircleType:
        center = QGeoCircle(area).center();
        break;
    case QGeoShape::UnknownType:
        break;
    }

    if (!center.isValid()) {
        return false;
    } else {
        queryItems->addQueryItem(QLatin1String("at"),
                                 QString::number(center.latitude()) +
                                 QLatin1Char(',') +
                                 QString::number(center.longitude()));
        return true;
    }
}
开发者ID:agunnarsson,项目名称:qtlocation,代码行数:25,代码来源:qplacemanagerengine_nokiav2.cpp

示例14: dragEnded

/*!
    \internal
*/
void QDeclarativeRectangleMapItem::dragEnded()
{
    QPointF newTopLeftPoint = QPointF(x(),y());
    QGeoCoordinate newTopLeft = map()->screenPositionToCoordinate(newTopLeftPoint, false);
    if (newTopLeft.isValid()) {
        // calculate new geo width while checking for dateline crossing
        const double lonW = bottomRight_.longitude() > topLeft_.longitude() ?
                    bottomRight_.longitude() - topLeft_.longitude() :
                    bottomRight_.longitude() + 360 - topLeft_.longitude();
        const double latH = qAbs(bottomRight_.latitude() - topLeft_.latitude());
        QGeoCoordinate newBottomRight;
        // prevent dragging over valid min and max latitudes
        if (QLocationUtils::isValidLat(newTopLeft.latitude() - latH)) {
            newBottomRight.setLatitude(newTopLeft.latitude() - latH);
        } else {
            newBottomRight.setLatitude(QLocationUtils::clipLat(newTopLeft.latitude() - latH));
            newTopLeft.setLatitude(newBottomRight.latitude() + latH);
        }
        // handle dateline crossing
        newBottomRight.setLongitude(QLocationUtils::wrapLong(newTopLeft.longitude() + lonW));
        newBottomRight.setAltitude(newTopLeft.altitude());
        topLeft_ = newTopLeft;
        bottomRight_ = newBottomRight;
        geometry_.setPreserveGeometry(true, newTopLeft);
        borderGeometry_.setPreserveGeometry(true, newTopLeft);
        geometry_.markSourceDirty();
        borderGeometry_.markSourceDirty();
        updateMapItem();
        emit topLeftChanged(topLeft_);
        emit bottomRightChanged(bottomRight_);
    }
}
开发者ID:amccarthy,项目名称:qtlocation,代码行数:35,代码来源:qdeclarativerectanglemapitem.cpp

示例15: positionUpdated

void MainWindow::positionUpdated(QGeoPositionInfo geoPositionInfo)
{
    if (geoPositionInfo.isValid())
    {
        // Stop regular position updates, because a valid position has been
        // obtained
        locationDataSource->stopUpdates();

        // Get the current location as latitude and longitude
        QGeoCoordinate geoCoordinate = geoPositionInfo.coordinate();
        qreal latitude = geoCoordinate.latitude();
        qreal longitude = geoCoordinate.longitude();



        QString string1;
        QString string2;
     //   QChar c = 'g';

        //build the string for latitude-longitude
        string1.setNum(latitude);
        this->latlng.append(string1);
        string2.setNum(longitude);
        this->latlng.append(",");
        this->latlng.append(string2);


        //send the location request
        sendRequest();
    }
}
开发者ID:kolphi,项目名称:QWeather,代码行数:31,代码来源:mainwindow.cpp


注:本文中的QGeoCoordinate::longitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。