本文整理汇总了C++中QGeoCoordinate::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QGeoCoordinate::isValid方法的具体用法?C++ QGeoCoordinate::isValid怎么用?C++ QGeoCoordinate::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QGeoCoordinate
的用法示例。
在下文中一共展示了QGeoCoordinate::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseBoundingBox
bool QGeoRouteXmlParser::parseBoundingBox(QGeoBoundingBox &bounds)
{
Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "BoundingBox");
QGeoCoordinate tl;
QGeoCoordinate br;
m_reader->readNext();
while (!(m_reader->tokenType() == QXmlStreamReader::EndElement && m_reader->name() == "BoundingBox")) {
if (m_reader->tokenType() == QXmlStreamReader::StartElement) {
if (m_reader->name() == "TopLeft") {
QGeoCoordinate coordinates;
if (parseCoordinates(coordinates))
tl = coordinates;
} else if (m_reader->name() == "BottomRight") {
QGeoCoordinate coordinates;
if (parseCoordinates(coordinates))
br = coordinates;
} else {
m_reader->skipCurrentElement();
}
}
m_reader->readNext();
}
if (tl.isValid() && br.isValid()) {
bounds = QGeoBoundingBox(tl, br);
return true;
}
return false;
}
示例2: 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_);
}
}
示例3: dragEnded
/*!
\internal
*/
void QDeclarativeCircleMapItem::dragEnded()
{
QPointF newPoint = QPointF(x(),y()) + QPointF(width(), height()) / 2;
QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid())
setCenter(newCoordinate);
}
示例4: 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;
}
}
示例5: setPath
void QDeclarativeGeoRoute::setPath(const QJSValue &value)
{
if (!value.isArray())
return;
QList<QGeoCoordinate> pathList;
quint32 length = value.property(QStringLiteral("length")).toUInt();
for (quint32 i = 0; i < length; ++i) {
bool ok;
QGeoCoordinate c = parseCoordinate(value.property(i), &ok);
if (!ok || !c.isValid()) {
qmlInfo(this) << "Unsupported path type";
return;
}
pathList.append(c);
}
if (route_.path() == pathList)
return;
route_.setPath(pathList);
emit pathChanged();
}
示例6: setPath
void QDeclarativePolylineMapItem::setPath(const QJSValue &value)
{
if (!value.isArray())
return;
QList<QGeoCoordinate> pathList;
quint32 length = value.property(QStringLiteral("length")).toUInt();
for (quint32 i = 0; i < length; ++i) {
bool ok;
QGeoCoordinate c = parseCoordinate(value.property(i), &ok);
if (!ok || !c.isValid()) {
qmlInfo(this) << "Unsupported path type";
return;
}
pathList.append(c);
}
if (path_ == pathList)
return;
path_ = pathList;
geometry_.markSourceDirty();
updateMapItem();
emit pathChanged();
}
示例7: extendShape
/*!
Extends the circle to include \a coordinate
*/
void QGeoCirclePrivate::extendShape(const QGeoCoordinate &coordinate)
{
if (!isValid() || !coordinate.isValid() || contains(coordinate))
return;
radius = center.distanceTo(coordinate);
}
示例8: setCenter
void QGeoAreaMonitorPolling::setCenter(const QGeoCoordinate& coordinate)
{
if (coordinate.isValid()) {
QGeoAreaMonitor::setCenter(coordinate);
checkStartStop();
}
}
示例9: setCoordinate
void QDeclarativePosition::setCoordinate(const QGeoCoordinate &coordinate)
{
if (m_coordinate == coordinate)
return;
m_coordinate = coordinate;
if (coordinate.type() == QGeoCoordinate::Coordinate3D && !m_altitudeValid) {
m_altitudeValid = true;
emit altitudeValidChanged();
} else if (m_altitudeValid) {
m_altitudeValid = false;
emit altitudeValidChanged();
}
if (coordinate.isValid()) {
if (!m_longitudeValid) {
m_longitudeValid = true;
emit longitudeValidChanged();
}
if (!m_latitudeValid) {
m_latitudeValid = true;
emit latitudeValidChanged();
}
} else {
if (m_longitudeValid) {
m_longitudeValid = false;
emit longitudeValidChanged();
}
if (m_latitudeValid) {
m_latitudeValid = false;
emit latitudeValidChanged();
}
}
emit coordinateChanged();
}
示例10: 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;
}
}
示例11: 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;
}
示例12: xmpGeoCoordinate
QGeoCoordinate QExiv2::geoCoordinate() const
{
// Prefer XMP
QGeoCoordinate gc = xmpGeoCoordinate();
if (!gc.isValid()) {
// Fallback to exif
gc = exifGeoCoordinate();
}
return gc;
}
示例13: contains
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;
}
示例14: defaultHostLocation
QGeoCoordinate GasInfoSettings::defaultHostLocation() const
{
QByteArray ba = value(defaultHostLocationKey).toByteArray();
QDataStream in(&ba, QIODevice::ReadOnly);
QGeoCoordinate location;
in >> location;
if (!location.isValid())
return QGeoCoordinate(39.903924, 116.391432, 0);
else
return location;
}
示例15: geometryChanged
/*!
\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.
}