本文整理汇总了C++中QGeoCoordinate::setAltitude方法的典型用法代码示例。如果您正苦于以下问题:C++ QGeoCoordinate::setAltitude方法的具体用法?C++ QGeoCoordinate::setAltitude怎么用?C++ QGeoCoordinate::setAltitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QGeoCoordinate
的用法示例。
在下文中一共展示了QGeoCoordinate::setAltitude方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coordinateInterpolation
QGeoCoordinate QGeoProjection::coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
{
QDoubleVector2D s = QGeoProjection::coordToMercator(from);
QDoubleVector2D e = QGeoProjection::coordToMercator(to);
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) * from.altitude() + progress * to.altitude());
return result;
}
示例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;
}
}
示例3: 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_);
}
}
示例4: readNextPosition
void CLbsPositionLogger::readNextPosition()
{
QByteArray line = m_logFile.readLine().trimmed();
if (line.isEmpty()) {
LOG_MODEL_ERROR("CLbsPositionLogger", "no readlien");
return;
}
QList<QByteArray> data = line.split(',');
QGeoCoordinate coordinate;
QGeoPositionInfo info;
bool hasTimestamp = false;
QDateTime timestamp = QDateTime::fromTime_t(data.value(0).toLong(&hasTimestamp), Qt::UTC);
if(hasTimestamp && timestamp.isValid())
info.setTimestamp(timestamp);
double latitude;
bool hasLatitude = false;
latitude = data.value(1).toDouble(&hasLatitude);
if(hasLatitude)
coordinate.setLatitude(latitude);
double longitude;
bool hasLongitude = false;
longitude = data.value(2).toDouble(&hasLongitude);
if(hasLongitude)
coordinate.setLongitude(longitude);
double altitude;
bool hasAltitude = false;
altitude = data.value(3).toDouble(&hasAltitude);
if(hasAltitude)
coordinate.setAltitude(altitude);
info.setCoordinate(coordinate);
double HorizontalAccuracy;
bool hasHorizontalAccuracy = false;
HorizontalAccuracy = data.value(4).toDouble(&hasHorizontalAccuracy);
if(hasHorizontalAccuracy)
info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, HorizontalAccuracy);
double Direction;
bool hasDirection = false;
Direction = data.value(5).toDouble(&hasDirection);
if(hasDirection)
info.setAttribute(QGeoPositionInfo::Direction, Direction);
double GroundSpeed;
bool hasGroundSpeed = false;
GroundSpeed = data.value(6).toDouble(&hasGroundSpeed);
if(hasGroundSpeed)
info.setAttribute(QGeoPositionInfo::GroundSpeed, GroundSpeed);
if (info.isValid()) {
m_lastPosition = info;
emit positionUpdated(info);
}
}
示例5: pan
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);
}
}
示例6: compatiblePlace
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);
}
}
示例7: if
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;
}
示例8: file
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);
}
示例9: geometryChanged
/*!
\internal
*/
void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
}
QDoubleVector2D newTopLeftPoint = QDoubleVector2D(x(),y());
QGeoCoordinate newTopLeft = map()->itemPositionToCoordinate(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);
markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft_);
emit bottomRightChanged(bottomRight_);
}
// Not calling QDeclarativeGeoMapItemBase::geometryChanged() as it will be called from a nested
// call to this function.
}
示例10: dt
void PsyUtils::TPositionInfo2QGeoPositionInfo(TPositionInfoBase &aPosInfoBase, QGeoPositionInfo& aQPosInfo)
{
if (aPosInfoBase.PositionClassType() & EPositionInfoClass ||
aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) {
TPositionInfo *posInfo = static_cast<TPositionInfo*>(&aPosInfoBase);
TPosition pos;
QGeoCoordinate coord;
posInfo->GetPosition(pos);
coord.setLatitude(pos.Latitude());
coord.setLongitude(pos.Longitude());
coord.setAltitude(pos.Altitude());
//store the QGeoCoordinate values
aQPosInfo.setCoordinate(coord);
TDateTime datetime = pos.Time().DateTime();
QDateTime dt(QDate(datetime.Year() , datetime.Month() + 1, datetime.Day() + 1),
QTime(datetime.Hour() , datetime.Minute(), datetime.Second(),
datetime.MicroSecond() / 1000),
Qt::UTC);
//store the time stamp
aQPosInfo.setTimestamp(dt);
//store the horizontal accuracy
aQPosInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
//store the vertical accuracy
aQPosInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, pos.VerticalAccuracy());
if (aPosInfoBase.PositionClassType() & EPositionSatelliteInfoClass) {
TCourse course;
TPositionSatelliteInfo *satInfo = static_cast<TPositionSatelliteInfo*>(&aPosInfoBase);
satInfo->GetCourse(course);
aQPosInfo.setAttribute(QGeoPositionInfo::Direction, course.Heading());
aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, course.Speed());
aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, course.VerticalSpeed());
}
}
if (aPosInfoBase.PositionClassType() & EPositionGenericInfoClass) {
HPositionGenericInfo *genInfo = static_cast<HPositionGenericInfo*>(&aPosInfoBase);
float val;
//check for the horizontal speed
if (genInfo->IsFieldAvailable(EPositionFieldHorizontalSpeed)) {
genInfo->GetValue(EPositionFieldHorizontalSpeed, val);
aQPosInfo.setAttribute(QGeoPositionInfo::GroundSpeed, val);
}
//check for the vertcal speed
if (genInfo->IsFieldAvailable(EPositionFieldVerticalSpeed)) {
genInfo->GetValue(EPositionFieldVerticalSpeed, val);
aQPosInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, val);
}
//check for the magnetic variation
if (genInfo->IsFieldAvailable(EPositionFieldMagneticCourseError)) {
genInfo->GetValue(EPositionFieldMagneticCourseError, val);
aQPosInfo.setAttribute(QGeoPositionInfo::MagneticVariation, val);
}
//check for the heading
if (genInfo->IsFieldAvailable(EPositionFieldHeading)) {
genInfo->GetValue(EPositionFieldHeading, val);
aQPosInfo.setAttribute(QGeoPositionInfo::Direction, val);
}
}
}