本文整理汇总了C++中QGeoCoordinate类的典型用法代码示例。如果您正苦于以下问题:C++ QGeoCoordinate类的具体用法?C++ QGeoCoordinate怎么用?C++ QGeoCoordinate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QGeoCoordinate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: map
/*!
\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.
}
示例2: debug_data
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)");
}
示例3: QDoubleVector2D
/*!
\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.
}
示例4: coordToMercator
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);
}
示例5: switch
/*!
\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;
}
}
示例6: 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);
}
示例7: setCenter
void QGeoAreaMonitorPolling::setCenter(const QGeoCoordinate& coordinate)
{
if (coordinate.isValid()) {
QGeoAreaMonitor::setCenter(coordinate);
checkStartStop();
}
}
示例8: 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);
}
}
示例9: reqCurrCond
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;
}
示例10: setCenter
/*!
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);
}
示例11: positionUpdated
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();
}
}
示例12: parseCoordinates
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;
}
示例13: startFlick
// 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();
}
示例14: 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);
}
}
示例15: getTile
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);
}