summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2015-01-16 10:20:34 +1000
committerAaron McCarthy <mccarthy.aaron@gmail.com>2015-01-20 02:46:21 +0100
commitc549b13656fe7bde5536961f168f0f1a68ea3490 (patch)
treee779d64e3cab36d7edcd4ae82387f4881d92b5ff
parent9ef638cd502ccf0caa536b4627497767bece0670 (diff)
downloadqtlocation-c549b13656fe7bde5536961f168f0f1a68ea3490.tar.gz
Better names for incorrectly named Map functions.
The functions to transform between coordinates and position on screen were incorrect. Documentation and function names did not match implementation. New functions with better names have been added and documentation updated to match implementation. Old invalid functions have been deprecated. Related private symbols have been renamed to match their purpose. [ChangeLog][QtLocation][Important Behavior Changes] Functions in Map item which are used transform between coordinates and screen position have been deprecated due to confusing naming. Change-Id: Ic501cd81220414800bc2247eae9f510954ee469f Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--examples/location/mapviewer/content/map/Marker.qml5
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp16
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp50
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h8
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp14
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp2
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp10
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp10
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp8
-rw-r--r--src/imports/location/qgeomapitemgeometry.cpp4
-rw-r--r--src/location/maps/qgeomap.cpp8
-rw-r--r--src/location/maps/qgeomap_p.h4
-rw-r--r--src/location/maps/qgeomapcontroller.cpp2
-rw-r--r--src/location/maps/qgeomapdata_p.h4
-rw-r--r--src/location/maps/qgeomapscene.cpp18
-rw-r--r--src/location/maps/qgeomapscene_p.h4
-rw-r--r--src/location/maps/qgeotiledmapdata.cpp16
-rw-r--r--src/location/maps/qgeotiledmapdata_p.h4
-rw-r--r--src/location/maps/qgeotiledmapdata_p_p.h4
-rw-r--r--tests/auto/declarative_ui/tst_map.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml36
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml96
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml10
-rw-r--r--tests/auto/qgeomapscene/tst_qgeomapscene.cpp4
25 files changed, 180 insertions, 169 deletions
diff --git a/examples/location/mapviewer/content/map/Marker.qml b/examples/location/mapviewer/content/map/Marker.qml
index 0793f13e..6f6af7f0 100644
--- a/examples/location/mapviewer/content/map/Marker.qml
+++ b/examples/location/mapviewer/content/map/Marker.qml
@@ -85,8 +85,9 @@ MapQuickItem {
onPressAndHold:{
if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
&& Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
- lastX = map.toScreenPosition(marker.coordinate).x
- lastY = map.toScreenPosition(marker.coordinate).y
+ var p = map.fromCoordinate(marker.coordinate)
+ lastX = p.x
+ lastY = p.y
map.markerPopup()
}
}
diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 71329305..51486f06 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -145,7 +145,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
return;
}
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
QPainterPath ppi = srcPath_;
@@ -164,9 +164,9 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
// calculate actual width of map on screen in pixels
QGeoCoordinate mapCenter(0, map.cameraData().center().longitude());
- QDoubleVector2D midPoint = map.coordinateToScreenPosition(mapCenter, false);
+ QDoubleVector2D midPoint = map.coordinateToItemPosition(mapCenter, false);
QDoubleVector2D midPointPlusOne = QDoubleVector2D(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map.screenPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map.itemPositionToCoordinate(midPointPlusOne, false);
double geoDistance = coord1.longitude() - map.cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360.0;
@@ -560,7 +560,7 @@ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(width(), height()) / 2;
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid())
setCenter(newCoordinate);
@@ -605,19 +605,19 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
return;
QList<int> wrapPathIndex;
// calculate actual width of map on screen in pixels
- QDoubleVector2D midPoint = map()->coordinateToScreenPosition(map()->cameraData().center(), false);
+ QDoubleVector2D midPoint = map()->coordinateToItemPosition(map()->cameraData().center(), false);
QDoubleVector2D midPointPlusOne(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map()->screenPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map()->itemPositionToCoordinate(midPointPlusOne, false);
qreal geoDistance = coord1.longitude() - map()->cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360;
qreal mapWidth = 360.0 / geoDistance;
mapWidth = qMin(static_cast<int>(mapWidth), map()->width());
- QDoubleVector2D prev = map()->coordinateToScreenPosition(path.at(0), false);
+ QDoubleVector2D prev = map()->coordinateToItemPosition(path.at(0), false);
// find the points in path where wrapping occurs
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QDoubleVector2D point = map()->coordinateToScreenPosition(path.at(index), false);
+ QDoubleVector2D point = map()->coordinateToItemPosition(path.at(index), false);
if ( (qAbs(point.x() - prev.x())) >= mapWidth/2.0 ) {
wrapPathIndex << index;
if (wrapPathIndex.size() == 2 || !(crossNorthPole && crossSouthPole))
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 74dc7e2b..80e39d0c 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
When the map is displayed, each possible geographic coordinate that is
visible will map to some pixel X and Y coordinate on the screen. To perform
conversions between these two, Map provides the \l toCoordinate and
- \l toScreenPosition functions, which are of general utility.
+ \l fromCoordinate functions, which are of general utility.
\section2 Map Objects
@@ -708,42 +708,48 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes()
}
/*!
- \qmlmethod QtLocation::Map::toCoordinate(QPointF screenPosition)
+ \qmlmethod QtLocation::Map::toCoordinate(QPointF position)
- Returns the coordinate which corresponds to the screen position
- \a screenPosition.
+ Returns the coordinate which corresponds to the \a position relative to the map item.
- Returns an invalid coordinate if \a screenPosition is not within
- the current viewport.
+ Returns an invalid coordinate if \a position is not within the current viewport.
*/
-
-QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &screenPosition) const
+QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &position) const
{
if (map_)
- return map_->screenPositionToCoordinate(QDoubleVector2D(screenPosition));
+ return map_->itemPositionToCoordinate(QDoubleVector2D(position));
else
return QGeoCoordinate();
}
/*!
-\qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
+ \qmlmethod QtLocation::Map::fromCoordinate(coordinate coordinate)
- Returns the screen position which corresponds to the coordinate
- \a coordinate.
+ Returns the position relative to the map item which corresponds to the \a coordinate.
- Returns an invalid QPointF if \a coordinate is not within the
- current viewport.
+ Returns an invalid QPointF if \a coordinate is not within the current viewport.
*/
-
-QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
+QPointF QDeclarativeGeoMap::fromCoordinate(const QGeoCoordinate &coordinate) const
{
if (map_)
- return map_->coordinateToScreenPosition(coordinate).toPointF();
+ return map_->coordinateToItemPosition(coordinate).toPointF();
else
return QPointF(qQNaN(), qQNaN());
}
/*!
+ \qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
+ \obsolete
+
+ This function is missed named and is equilavent to \l {fromCoordinate}, which should be used
+ instead.
+*/
+QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
+{
+ return fromCoordinate(coordinate);
+}
+
+/*!
\qmlmethod void QtLocation::Map::pan(int dx, int dy)
Starts panning the map by \a dx pixels along the x-axis and
@@ -1042,8 +1048,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
case QGeoShape::RectangleType:
{
QGeoRectangle rect = shape;
- QDoubleVector2D topLeftPoint = map_->coordinateToScreenPosition(rect.topLeft(), false);
- QDoubleVector2D botRightPoint = map_->coordinateToScreenPosition(rect.bottomRight(), false);
+ QDoubleVector2D topLeftPoint = map_->coordinateToItemPosition(rect.topLeft(), false);
+ QDoubleVector2D botRightPoint = map_->coordinateToItemPosition(rect.bottomRight(), false);
bboxWidth = qAbs(topLeftPoint.x() - botRightPoint.x());
bboxHeight = qAbs(topLeftPoint.y() - botRightPoint.y());
centerCoordinate = rect.center();
@@ -1054,8 +1060,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
QGeoCircle circle = shape;
centerCoordinate = circle.center();
QGeoCoordinate edge = centerCoordinate.atDistanceAndAzimuth(circle.radius(), 90);
- QDoubleVector2D centerPoint = map_->coordinateToScreenPosition(centerCoordinate, false);
- QDoubleVector2D edgePoint = map_->coordinateToScreenPosition(edge, false);
+ QDoubleVector2D centerPoint = map_->coordinateToItemPosition(centerCoordinate, false);
+ QDoubleVector2D edgePoint = map_->coordinateToItemPosition(edge, false);
bboxWidth = qAbs(centerPoint.x() - edgePoint.x()) * 2;
bboxHeight = bboxWidth;
break;
@@ -1171,7 +1177,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
// position camera to the center of bounding box
QGeoCoordinate coordinate;
- coordinate = map_->screenPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
+ coordinate = map_->itemPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
setProperty("center", QVariant::fromValue(coordinate));
// adjust zoom
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index cc3e6311..9ba23e53 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -139,8 +139,12 @@ public:
Q_INVOKABLE void clearMapItems();
QList<QObject *> mapItems();
- Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &screenPosition) const;
- Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
+ Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &position) const;
+ Q_INVOKABLE QPointF fromCoordinate(const QGeoCoordinate &coordinate) const;
+
+#if QT_DEPRECATED_SINCE(5,5)
+ QT_DEPRECATED Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
+#endif
// callback for map mouse areas
bool mouseEvent(QMouseEvent *event);
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index 1d161036..0fbf5557 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -748,7 +748,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 2) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
+ touchCenterCoord_ = map_->itemPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startTwoTouchPoints();
touchPointState_ = touchPoints2;
}
@@ -757,7 +757,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 1) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
+ touchCenterCoord_ = map_->itemPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startOneTouchPoint();
touchPointState_ = touchPoints1;
}
@@ -785,7 +785,7 @@ void QDeclarativeGeoMapGestureArea::startOneTouchPoint()
sceneStartPoint1_ = declarativeMap_->mapFromScene(touchPoints_.at(0).scenePos());
lastPos_ = sceneStartPoint1_;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(sceneStartPoint1_), false);
+ QGeoCoordinate startCoord = map_->itemPositionToCoordinate(QDoubleVector2D(sceneStartPoint1_), false);
// ensures a smooth transition for panning
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
@@ -813,7 +813,7 @@ void QDeclarativeGeoMapGestureArea::startTwoTouchPoints()
QPointF startPos = (sceneStartPoint1_ + sceneStartPoint2_) * 0.5;
lastPos_ = startPos;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(startPos), false);
+ QGeoCoordinate startCoord = map_->itemPositionToCoordinate(QDoubleVector2D(startPos), false);
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
startCoord_.setLatitude(startCoord_.latitude() + startCoord.latitude() -
@@ -999,7 +999,7 @@ void QDeclarativeGeoMapGestureArea::panStateMachine()
case panInactive:
if (canStartPan()) {
// Update startCoord_ to ensure smooth start for panning when going over startDragDistance
- QGeoCoordinate newStartCoord = map_->screenPositionToCoordinate(QDoubleVector2D(lastPos_), false);
+ QGeoCoordinate newStartCoord = map_->itemPositionToCoordinate(QDoubleVector2D(lastPos_), false);
startCoord_.setLongitude(newStartCoord.longitude());
startCoord_.setLatitude(newStartCoord.latitude());
panState_ = panActive;
@@ -1064,13 +1064,13 @@ bool QDeclarativeGeoMapGestureArea::canStartPan()
*/
void QDeclarativeGeoMapGestureArea::updatePan()
{
- QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false).toPointF();
+ QPointF startPoint = map_->coordinateToItemPosition(startCoord_, false).toPointF();
int dx = static_cast<int>(sceneCenter_.x() - startPoint.x());
int dy = static_cast<int>(sceneCenter_.y() - startPoint.y());
QPointF mapCenterPoint;
mapCenterPoint.setY(map_->height() / 2.0 - dy);
mapCenterPoint.setX(map_->width() / 2.0 - dx);
- QGeoCoordinate animationStartCoordinate = map_->screenPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
+ QGeoCoordinate animationStartCoordinate = map_->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
map_->mapController()->setCenter(animationStartCoordinate);
}
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index 3657ea10..64df17cb 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -171,7 +171,7 @@ void QDeclarativeGeoMapItemBase::setPositionOnMap(const QGeoCoordinate &coordina
if (!map_ || !quickMap_)
return;
- QPointF topLeft = map_->coordinateToScreenPosition(coordinate, false).toPointF() - offset;
+ QPointF topLeft = map_->coordinateToItemPosition(coordinate, false).toPointF() - offset;
setPosition(topLeft);
}
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 89fc47f2..c0bd3db1 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -173,7 +173,7 @@ void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, con
return;
}
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
if (newCoordinate.isValid())
setCoordinate(newCoordinate);
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index 020ccf67..9c9e14dc 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -160,7 +160,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
double unwrapBelowX = 0;
if (preserveGeometry_ )
- unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -168,7 +168,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -202,7 +202,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
srcPath_ = srcPath_.simplified();
sourceBounds_ = srcPath_.boundingRect();
- geoLeftBound_ = map.screenPositionToCoordinate(QDoubleVector2D(minX, 0), false);
+ geoLeftBound_ = map.itemPositionToCoordinate(QDoubleVector2D(minX, 0), false);
}
/*!
@@ -218,7 +218,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
return;
}
- QDoubleVector2D origin = map.coordinateToScreenPosition(srcOrigin_, false);
+ QDoubleVector2D origin = map.coordinateToItemPosition(srcOrigin_, false);
// Create the viewport rect in the same coordinate system
// as the actual points
@@ -609,7 +609,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index c1f32be0..a25ff7be 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -201,7 +201,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
double unwrapBelowX = 0;
if (preserveGeometry_)
- unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -209,7 +209,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -254,7 +254,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
}
sourceBounds_ = QRectF(QPointF(minX, minY), QPointF(maxX, maxY));
- geoLeftBound_ = map.screenPositionToCoordinate(
+ geoLeftBound_ = map.itemPositionToCoordinate(
QDoubleVector2D(minX + origin.x(), minY + origin.y()), false);
}
@@ -381,7 +381,7 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
if (!screenDirty_)
return;
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
if (!qIsFinite(origin.x()) || !qIsFinite(origin.y())) {
clear();
@@ -607,7 +607,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 8898be15..49ae6cc2 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -128,8 +128,8 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
if (!screenDirty_ && !sourceDirty_)
return;
- QDoubleVector2D tl = map.coordinateToScreenPosition(topLeft, false);
- QDoubleVector2D br = map.coordinateToScreenPosition(bottomRight, false);
+ QDoubleVector2D tl = map.coordinateToItemPosition(topLeft, false);
+ QDoubleVector2D br = map.coordinateToItemPosition(bottomRight, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -139,7 +139,7 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
return;
if ( preserveGeometry_ ) {
- double unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ double unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
if (br.x() < unwrapBelowX)
br.setX(tl.x() + screenBounds_.width());
}
@@ -423,7 +423,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
}
QDoubleVector2D newTopLeftPoint = QDoubleVector2D(x(),y());
- QGeoCoordinate newTopLeft = map()->screenPositionToCoordinate(newTopLeftPoint, false);
+ 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() ?
diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp
index db8a4db0..ac9cac5d 100644
--- a/src/imports/location/qgeomapitemgeometry.cpp
+++ b/src/imports/location/qgeomapitemgeometry.cpp
@@ -119,14 +119,14 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map,
const QGeoCoordinate &fromCoord,
const QGeoCoordinate &toCoord)
{
- QGeoCoordinate mapMid = map.screenPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0));
+ QGeoCoordinate mapMid = map.itemPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0));
double halfGeoDist = toCoord.longitude() - fromCoord.longitude();
if (toCoord.longitude() < fromCoord.longitude())
halfGeoDist += 360;
halfGeoDist /= 2.0;
QGeoCoordinate geoDelta = QGeoCoordinate(0,
QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist));
- QDoubleVector2D halfScreenDist = map.coordinateToScreenPosition(geoDelta, false)
+ QDoubleVector2D halfScreenDist = map.coordinateToItemPosition(geoDelta, false)
- QDoubleVector2D(map.width()/2.0, 0);
return halfScreenDist.x() * 2.0;
}
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 93eafd68..31fe29d2 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -120,14 +120,14 @@ QGeoCameraData QGeoMap::cameraData() const
return mapData_->cameraData();
}
-QGeoCoordinate QGeoMap::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
+QGeoCoordinate QGeoMap::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
- return mapData_->screenPositionToCoordinate(pos, clipToViewport);
+ return mapData_->itemPositionToCoordinate(pos, clipToViewport);
}
-QDoubleVector2D QGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoMap::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
- return mapData_->coordinateToScreenPosition(coordinate, clipToViewport);
+ return mapData_->coordinateToItemPosition(coordinate, clipToViewport);
}
void QGeoMap::update()
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index f9d5e2ea..7d62358b 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -89,8 +89,8 @@ public:
QGeoCameraData cameraData() const;
QGeoCameraCapabilities cameraCapabilities() const;
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
diff --git a/src/location/maps/qgeomapcontroller.cpp b/src/location/maps/qgeomapcontroller.cpp
index be39f136..ae739cb4 100644
--- a/src/location/maps/qgeomapcontroller.cpp
+++ b/src/location/maps/qgeomapcontroller.cpp
@@ -196,7 +196,7 @@ void QGeoMapController::pan(qreal dx, qreal dy)
if (dx == 0 && dy == 0)
return;
QGeoCameraData cd = map_->cameraData();
- QGeoCoordinate coord = map_->screenPositionToCoordinate(
+ QGeoCoordinate coord = map_->itemPositionToCoordinate(
QDoubleVector2D(map_->width() / 2 + dx,
map_->height() / 2 + dy));
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/maps/qgeomapdata_p.h
index f7d3c059..bc4b5dfc 100644
--- a/src/location/maps/qgeomapdata_p.h
+++ b/src/location/maps/qgeomapdata_p.h
@@ -88,8 +88,8 @@ public:
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
- virtual QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
- virtual QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
+ virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
+ virtual QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
QString pluginString();
QGeoCameraCapabilities cameraCapabilities();
diff --git a/src/location/maps/qgeomapscene.cpp b/src/location/maps/qgeomapscene.cpp
index a1645464..93523f27 100644
--- a/src/location/maps/qgeomapscene.cpp
+++ b/src/location/maps/qgeomapscene.cpp
@@ -109,8 +109,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
- QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D itemPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToItemPosition(const QDoubleVector2D &mercator) const;
void setVisibleTiles(const QSet<QGeoTileSpec> &tiles);
void removeTiles(const QSet<QGeoTileSpec> &oldTiles);
@@ -172,16 +172,16 @@ void QGeoMapScene::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileText
d->addTile(spec, texture);
}
-QDoubleVector2D QGeoMapScene::screenPositionToMercator(const QDoubleVector2D &pos) const
+QDoubleVector2D QGeoMapScene::itemPositionToMercator(const QDoubleVector2D &pos) const
{
Q_D(const QGeoMapScene);
- return d->screenPositionToMercator(pos);
+ return d->itemPositionToMercator(pos);
}
-QDoubleVector2D QGeoMapScene::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScene::mercatorToItemPosition(const QDoubleVector2D &mercator) const
{
Q_D(const QGeoMapScene);
- return d->mercatorToScreenPosition(mercator);
+ return d->mercatorToItemPosition(mercator);
}
bool QGeoMapScene::verticalLock() const
@@ -227,7 +227,7 @@ QGeoMapScenePrivate::~QGeoMapScenePrivate()
{
}
-QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QDoubleVector2D &pos) const
+QDoubleVector2D QGeoMapScenePrivate::itemPositionToMercator(const QDoubleVector2D &pos) const
{
double x = mercatorWidth_ * (((pos.x() - screenOffsetX_) / screenWidth_) - 0.5);
x += mercatorCenterX_;
@@ -246,7 +246,7 @@ QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QDoubleVecto
return QDoubleVector2D(x, y);
}
-QDoubleVector2D QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScenePrivate::mercatorToItemPosition(const QDoubleVector2D &mercator) const
{
double mx = sideLength_ * mercator.x();
@@ -468,7 +468,7 @@ void QGeoMapScenePrivate::setupCamera()
// mercatorWidth_ and mercatorHeight_ define the ratio for
// mercator and screen coordinate conversion,
- // see mercatorToScreenPosition() and screenPositionToMercator()
+ // see mercatorToItemPosition() and itemPositionToMercator()
if (aspectRatio > 1.0) {
mercatorHeight_ = a;
mercatorWidth_ = a * aspectRatio;
diff --git a/src/location/maps/qgeomapscene_p.h b/src/location/maps/qgeomapscene_p.h
index 8164c347..12d5c1bc 100644
--- a/src/location/maps/qgeomapscene_p.h
+++ b/src/location/maps/qgeomapscene_p.h
@@ -85,8 +85,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
- QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D itemPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToItemPosition(const QDoubleVector2D &mercator) const;
QSGNode *updateSceneGraph(QSGNode *oldNode, QQuickWindow *window);
diff --git a/src/location/maps/qgeotiledmapdata.cpp b/src/location/maps/qgeotiledmapdata.cpp
index c14fe337..7fb5da1b 100644
--- a/src/location/maps/qgeotiledmapdata.cpp
+++ b/src/location/maps/qgeotiledmapdata.cpp
@@ -139,7 +139,7 @@ void QGeoTiledMapData::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles
Q_UNUSED(visibleTiles);
}
-QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
+QGeoCoordinate QGeoTiledMapData::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
if (clipToViewport) {
@@ -150,13 +150,13 @@ QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QDoubleVector2
return QGeoCoordinate();
}
- return d->screenPositionToCoordinate(pos);
+ return d->itemPositionToCoordinate(pos);
}
-QDoubleVector2D QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoTiledMapData::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
- QDoubleVector2D pos = d->coordinateToScreenPosition(coordinate);
+ QDoubleVector2D pos = d->coordinateToItemPosition(coordinate);
if (clipToViewport) {
int w = width();
@@ -318,14 +318,14 @@ QSGNode *QGeoTiledMapDataPrivate::updateSceneGraph(QSGNode *oldNode, QQuickWindo
return mapScene_->updateSceneGraph(oldNode, window);
}
-QGeoCoordinate QGeoTiledMapDataPrivate::screenPositionToCoordinate(const QDoubleVector2D &pos) const
+QGeoCoordinate QGeoTiledMapDataPrivate::itemPositionToCoordinate(const QDoubleVector2D &pos) const
{
- return QGeoProjection::mercatorToCoord(mapScene_->screenPositionToMercator(pos));
+ return QGeoProjection::mercatorToCoord(mapScene_->itemPositionToMercator(pos));
}
-QDoubleVector2D QGeoTiledMapDataPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+QDoubleVector2D QGeoTiledMapDataPrivate::coordinateToItemPosition(const QGeoCoordinate &coordinate) const
{
- return mapScene_->mercatorToScreenPosition(QGeoProjection::coordToMercator(coordinate));
+ return mapScene_->mercatorToItemPosition(QGeoProjection::coordToMercator(coordinate));
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmapdata_p.h b/src/location/maps/qgeotiledmapdata_p.h
index 204e735f..d5438286 100644
--- a/src/location/maps/qgeotiledmapdata_p.h
+++ b/src/location/maps/qgeotiledmapdata_p.h
@@ -80,8 +80,8 @@ public:
void newTileFetched(const QGeoTileSpec &spec);
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void prefetchTiles();
// Alternative to exposing this is to make tileFetched a slot, but then requestManager would
diff --git a/src/location/maps/qgeotiledmapdata_p_p.h b/src/location/maps/qgeotiledmapdata_p_p.h
index 9a7760e9..631d52ba 100644
--- a/src/location/maps/qgeotiledmapdata_p_p.h
+++ b/src/location/maps/qgeotiledmapdata_p_p.h
@@ -89,8 +89,8 @@ public:
void changeMapVersion(int mapVersion);
void resized(int width, int height);
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate) const;
void newTileFetched(const QGeoTileSpec &spec);
QSet<QGeoTileSpec> visibleTiles();
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 02fd6360..a225a5f4 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -256,22 +256,22 @@ Item {
compare(coordinateMap.center.latitude, 50)
compare(coordinateMap.center.longitude, 50)
// valid to screen position
- var point = coordinateMap.toScreenPosition(coordinateMap.center)
+ var point = coordinateMap.fromCoordinate(coordinateMap.center)
verify (point.x > 495 && point.x < 505)
verify (point.y > 495 && point.y < 505)
// valid coordinate without altitude
- point = coordinateMap.toScreenPosition(altitudelessCoordinate)
+ point = coordinateMap.fromCoordinate(altitudelessCoordinate)
verify (point.x > 495 && point.x < 505)
verify (point.y > 495 && point.y < 505)
// out of map area
- point = coordinateMap.toScreenPosition(coordinate4)
+ point = coordinateMap.fromCoordinate(coordinate4)
verify(isNaN(point.x))
verify(isNaN(point.y))
// invalid coordinates
- point = coordinateMap.toScreenPosition(invalidCoordinate)
+ point = coordinateMap.fromCoordinate(invalidCoordinate)
verify(isNaN(point.x))
verify(isNaN(point.y))
- point = coordinateMap.toScreenPosition(null)
+ point = coordinateMap.fromCoordinate(null)
verify(isNaN(point.x))
verify(isNaN(point.y))
// valid point to coordinate
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 1076b6cc..a0103a02 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -246,7 +246,7 @@ Item {
// sanity check that the coordinate conversion works, as
// rest of the case relies on it. for robustness cut
// a little slack with fuzzy compare
- var mapcenter = map.toScreenPosition(map.center)
+ var mapcenter = map.fromCoordinate(map.center)
verify (fuzzy_compare(mapcenter.x, 100, 2))
verify (fuzzy_compare(mapcenter.y, 100, 2))
@@ -256,7 +256,7 @@ Item {
// click rect
map.center = preMapRect.topLeft
- var point = map.toScreenPosition(preMapRect.topLeft)
+ var point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 1)
mouseClick(map, 1, 1) // no item hit
@@ -265,7 +265,7 @@ Item {
// click circle, overlaps and is above rect
map.center = preMapCircle.center
- point = map.toScreenPosition(preMapCircle.center)
+ point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 1)
compare(preMapCircleClicked.count, 1)
@@ -279,14 +279,14 @@ Item {
// click quick item
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
- point = map.toScreenPosition(preMapQuickItem.coordinate)
+ point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 1)
// click polygon
compare (preMapPolygonClicked.count, 0)
map.center = preMapPolygon.path[1]
- point = map.toScreenPosition(preMapPolygon.path[1])
+ point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 1)
@@ -295,12 +295,12 @@ Item {
clear_data()
compare (map.mapItems.length, 0)
map.center = preMapRect.topLeft
- point = map.toScreenPosition(preMapRect.topLeft)
+ point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 0)
visualInspectionPoint()
map.center = preMapCircle.center
- point = map.toScreenPosition(preMapCircle.center)
+ point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 0)
compare(preMapCircleClicked.count, 0)
@@ -310,11 +310,11 @@ Item {
compare(preMapCircleClicked.count, 0)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
- point = map.toScreenPosition(preMapQuickItem.coordinate)
+ point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapPolygon.path[1]
- point = map.toScreenPosition(preMapPolygon.path[1])
+ point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 0)
@@ -329,11 +329,11 @@ Item {
compare (map.mapItems.length, 6)
visualInspectionPoint()
map.center = preMapRect.topLeft
- point = map.toScreenPosition(preMapRect.topLeft)
+ point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapRectClicked.count, 1)
map.center = preMapCircle.center
- point = map.toScreenPosition(preMapCircle.center)
+ point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
compare(preMapRectClicked.count, 1)
compare(preMapCircleClicked.count, 1)
@@ -343,11 +343,11 @@ Item {
compare(preMapCircleClicked.count, 1)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
- point = map.toScreenPosition(preMapQuickItem.coordinate)
+ point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(preMapQuickItemClicked.count, 1)
map.center = preMapPolygon.path[1]
- point = map.toScreenPosition(preMapPolygon.path[1])
+ point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
compare(preMapPolygonClicked.count, 1)
@@ -356,7 +356,7 @@ Item {
map.addMapItem(extMapCircle)
map.center = extMapCircle.center
visualInspectionPoint();
- point = map.toScreenPosition(extMapCircle.center)
+ point = map.fromCoordinate(extMapCircle.center)
mouseClick(map, point.x, point.y)
compare(extMapCircleClicked.count, 1)
mouseClick(map, point.x, -5)
@@ -366,7 +366,7 @@ Item {
map.addMapItem(extMapQuickItem)
map.center = extMapQuickItem.coordinate
visualInspectionPoint();
- point = map.toScreenPosition(extMapQuickItem.coordinate)
+ point = map.fromCoordinate(extMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
compare(extMapQuickItemClicked.count, 1)
mouseClick(map, map.width + 5, point.y + 5)
@@ -380,7 +380,7 @@ Item {
compare (preMapRectActiveChanged.count, 0)
map.center = preMapRect.topLeft
var i
- var point = map.toScreenPosition(preMapRect.topLeft)
+ var point = map.fromCoordinate(preMapRect.topLeft)
var targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
for (i = 0; i < 50; i += 1) {
@@ -401,7 +401,7 @@ Item {
// drag circle
compare (preMapCircleActiveChanged.count, 0)
map.center = preMapCircle.center
- point = map.toScreenPosition(preMapCircle.center)
+ point = map.fromCoordinate(preMapCircle.center)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x, point.y)
for (i = 0; i < 50; i += 1) {
@@ -419,7 +419,7 @@ Item {
// drag quick item
compare (preMapQuickItemActiveChanged.count, 0)
map.center = preMapQuickItem.coordinate
- point = map.toScreenPosition(preMapQuickItem.coordinate)
+ point = map.fromCoordinate(preMapQuickItem.coordinate)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
for (i = 0; i < 50; i += 1) {
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 2455d34c..f633e14c 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -308,7 +308,7 @@ Item {
function test_aa_precondition() {
wait(10)
// sanity check that the coordinate conversion works
- var mapcenter = map.toScreenPosition(map.center)
+ var mapcenter = map.fromCoordinate(map.center)
verify (fuzzy_compare(mapcenter.x, 100, 2))
verify (fuzzy_compare(mapcenter.y, 100, 2))
}
@@ -319,7 +319,7 @@ Item {
compare (extMapPolygon.border.width, 1.0)
compare (extMapPolygonClicked.count, 0)
map.center = extMapPolygon.path[1]
- var point = map.toScreenPosition(extMapPolygon.path[1])
+ var point = map.fromCoordinate(extMapPolygon.path[1])
map.addMapItem(extMapPolygon)
verify(extMapPolygon.path.length == 2)
mouseClick(map, point.x - 5, point.y)
@@ -352,7 +352,7 @@ Item {
map.clearMapItems()
clear_data()
compare (extMapPolyline.line.width, 1.0)
- var point = map.toScreenPosition(extMapPolyline.path[1])
+ var point = map.fromCoordinate(extMapPolyline.path[1])
map.addMapItem(extMapPolyline0) // mustn't crash or ill-behave
verify(extMapPolyline0.path.length == 0)
map.addMapItem(extMapPolyline)
@@ -418,17 +418,17 @@ Item {
map.addMapItem(extMapRectDateline)
verify(extMapRectDateline.topLeft.longitude == 175)
verify(extMapRectDateline.bottomRight.longitude == -175)
- var point = map.toScreenPosition(extMapRectDateline.topLeft)
+ var point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapRectDateline.bottomRight)
+ point = map.fromCoordinate(extMapRectDateline.bottomRight)
verify(point.x > map.width / 2.0)
// move item away from dataline by directly setting its coords
extMapRectDateline.bottomRight.longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapRectDateline.bottomRight)
+ point = map.fromCoordinate(extMapRectDateline.bottomRight)
verify(point.x > map.width / 2.0)
// move item edge onto dateline
extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude
- point = map.toScreenPosition(extMapRectDateline.topLeft)
+ point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x == map.width / 2.0)
// drag item back onto dateline
mousePress(map, point.x + 5, point.y + 5)
@@ -438,9 +438,9 @@ Item {
mouseMove(map, point.x + 5 - i, point.y + 5 )
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
- point = map.toScreenPosition(extMapRectDateline.topLeft)
+ point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapRectDateline.bottomRight)
+ point = map.fromCoordinate(extMapRectDateline.bottomRight)
verify(point.x > map.width / 2.0)
map.removeMapItem(extMapRectDateline)
@@ -448,10 +448,10 @@ Item {
map.addMapItem(extMapCircleDateline)
verify(extMapCircleDateline.center.longitude === 180)
map.center = datelineCoordinate
- point = map.toScreenPosition(extMapCircleDateline.center)
+ point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x == map.width / 2.0)
extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapCircleDateline.center)
+ point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x > map.width / 2.0)
mousePress(map, point.x, point.y)
for (i=0; i < 40; i += 4) {
@@ -459,7 +459,7 @@ Item {
mouseMove(map, point.x - i, point.y)
}
mouseRelease(map, point.x - i, point.y)
- point = map.toScreenPosition(extMapCircleDateline.center)
+ point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x < map.width / 2.0)
map.removeMapItem(extMapCircleDateline)
@@ -467,10 +467,10 @@ Item {
map.addMapItem(extMapQuickItemDateline)
map.center = datelineCoordinate
verify(extMapQuickItemDateline.coordinate.longitude === 175)
- point = map.toScreenPosition(extMapQuickItemDateline.coordinate)
+ point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapQuickItemDateline.coordinate)
+ point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x > map.width / 2.0)
mousePress(map, point.x + 5, point.y + 5)
for (i=0; i < 50; i += 5) {
@@ -478,7 +478,7 @@ Item {
mouseMove(map, point.x + 5 - i, point.y + 5 )
}
mouseRelease(map, point.x + 5 - i, point.y + 5)
- point = map.toScreenPosition(extMapQuickItemDateline.coordinate)
+ point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
map.removeMapItem(extMapQuickItemDateline)
@@ -489,29 +489,29 @@ Item {
verify(extMapPolygonDateline.path[1].longitude == -175)
verify(extMapPolygonDateline.path[2].longitude == -175)
verify(extMapPolygonDateline.path[3].longitude == 175)
- point = map.toScreenPosition(extMapPolygonDateline.path[0])
+ point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[1])
+ point = map.fromCoordinate(extMapPolygonDateline.path[1])
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[2])
+ point = map.fromCoordinate(extMapPolygonDateline.path[2])
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[3])
+ point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x < map.width / 2.0)
extMapPolygonDateline.path[1].longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapPolygonDateline.path[1])
+ point = map.fromCoordinate(extMapPolygonDateline.path[1])
verify(point.x > map.width / 2.0)
extMapPolygonDateline.path[2].longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapPolygonDateline.path[2])
+ point = map.fromCoordinate(extMapPolygonDateline.path[2])
verify(point.x > map.width / 2.0)
var path = extMapPolygonDateline.path;
path[0].longitude = datelineCoordinate.longitude;
extMapPolygonDateline.path = path;
- point = map.toScreenPosition(extMapPolygonDateline.path[0])
+ point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x == map.width / 2.0)
path = extMapPolygonDateline.path;
path[3].longitude = datelineCoordinate.longitude;
extMapPolygonDateline.path = path;
- point = map.toScreenPosition(extMapPolygonDateline.path[3])
+ point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x == map.width / 2.0)
mousePress(map, point.x + 5, point.y - 5)
for (i=0; i < 16; i += 2) {
@@ -519,13 +519,13 @@ Item {
mouseMove(map, point.x + 5 - i, point.y - 5 )
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
- point = map.toScreenPosition(extMapPolygonDateline.path[0])
+ point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[1])
+ point = map.fromCoordinate(extMapPolygonDateline.path[1])
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[2])
+ point = map.fromCoordinate(extMapPolygonDateline.path[2])
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonDateline.path[3])
+ point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x < map.width / 2.0)
map.removeMapItem(extMapPolygonDateline)
@@ -534,17 +534,17 @@ Item {
map.center = datelineCoordinate
verify(extMapPolylineDateline.path[0].longitude == 175)
verify(extMapPolylineDateline.path[1].longitude == -175)
- point = map.toScreenPosition(extMapPolylineDateline.path[0])
+ point = map.fromCoordinate(extMapPolylineDateline.path[0])
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapPolylineDateline.path[1])
+ point = map.fromCoordinate(extMapPolylineDateline.path[1])
verify(point.x > map.width / 2.0)
extMapPolylineDateline.path[1].longitude = datelineCoordinateRight.longitude
- point = map.toScreenPosition(extMapPolylineDateline.path[1])
+ point = map.fromCoordinate(extMapPolylineDateline.path[1])
verify(point.x > map.width / 2.0)
var path = extMapPolygonDateline.path;
path[0].longitude = datelineCoordinate.longitude;
extMapPolylineDateline.path = path;
- point = map.toScreenPosition(extMapPolylineDateline.path[0])
+ point = map.fromCoordinate(extMapPolylineDateline.path[0])
verify(point.x == map.width / 2.0)
map.removeMapItem(extMapPolylineDateline)
@@ -553,9 +553,9 @@ Item {
map.addMapItem(extMapRouteDateline)
verify(extMapRouteDateline.route.path[0].longitude == 175)
verify(extMapRouteDateline.route.path[1].longitude == -175)
- point = map.toScreenPosition(extMapRouteDateline.route.path[0])
+ point = map.fromCoordinate(extMapRouteDateline.route.path[0])
verify(point.x < map.width / 2.0)
- point = map.toScreenPosition(extMapRouteDateline.route.path[1])
+ point = map.fromCoordinate(extMapRouteDateline.route.path[1])
verify(point.x > map.width / 2.0)
map.removeMapItem(extMapRouteDateline)
}
@@ -599,16 +599,16 @@ Item {
map.addMapItem(extMapRectEdge)
verify(extMapRectEdge.topLeft.longitude == -15)
verify(extMapRectEdge.bottomRight.longitude == -5)
- var point = map.toScreenPosition(extMapRectEdge.topLeft)
+ var point = map.fromCoordinate(extMapRectEdge.topLeft)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapRectEdge.bottomRight)
+ point = map.fromCoordinate(extMapRectEdge.bottomRight)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
var originalWidth = extMapRectEdge.width;
verify(originalWidth < map.width / 2.0)
// drag item onto map border
- point = map.toScreenPosition(extMapRectEdge.topLeft)
+ point = map.fromCoordinate(extMapRectEdge.topLeft)
mousePress(map, point.x + 5, point.y + 5)
var i
for (i=0; i < 20; i += 2) {
@@ -620,7 +620,7 @@ Item {
// out of the map border, but in the future culling may take place
// so tests for points outside the map border are ignored,
// instead we check the item width
- point = map.toScreenPosition(extMapRectEdge.topLeft)
+ point = map.fromCoordinate(extMapRectEdge.topLeft)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
compare(extMapRectEdge.width, originalWidth)
@@ -630,19 +630,19 @@ Item {
map.addMapItem(extMapCircleEdge)
map.center = datelineCoordinate
verify(extMapCircleEdge.center.longitude == -15)
- var point = map.toScreenPosition(extMapCircleEdge.center)
+ var point = map.fromCoordinate(extMapCircleEdge.center)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
originalWidth = extMapCircleEdge.width;
verify(originalWidth < map.width / 2.0)
- point = map.toScreenPosition(extMapCircleEdge.center)
+ point = map.fromCoordinate(extMapCircleEdge.center)
mousePress(map, point.x, point.y)
for (i=0; i < 20; i += 2) {
wait(1)
mouseMove(map, point.x + i, point.y)
}
mouseRelease(map, point.x + i, point.y)
- point = map.toScreenPosition(extMapCircleEdge.center)
+ point = map.fromCoordinate(extMapCircleEdge.center)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
fuzzy_compare(extMapCircleEdge.width, originalWidth)
@@ -652,7 +652,7 @@ Item {
map.addMapItem(extMapQuickItemEdge)
map.center = datelineCoordinate
verify(extMapQuickItemEdge.coordinate.longitude == -15)
- point = map.toScreenPosition(extMapQuickItemEdge.coordinate)
+ point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
originalWidth = extMapQuickItemEdge.width;
@@ -663,7 +663,7 @@ Item {
mouseMove(map, point.x + 5 + i, point.y + 5)
}
mouseRelease(map, point.x + 5 + i, point.y + 5)
- point = map.toScreenPosition(extMapQuickItemEdge.coordinate)
+ point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
compare(extMapQuickItemEdge.width, originalWidth)
@@ -676,16 +676,16 @@ Item {
verify(extMapPolygonEdge.path[1].longitude == -5)
verify(extMapPolygonEdge.path[2].longitude == -5)
verify(extMapPolygonEdge.path[3].longitude == -15)
- point = map.toScreenPosition(extMapPolygonEdge.path[0])
+ point = map.fromCoordinate(extMapPolygonEdge.path[0])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonEdge.path[1])
+ point = map.fromCoordinate(extMapPolygonEdge.path[1])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonEdge.path[2])
+ point = map.fromCoordinate(extMapPolygonEdge.path[2])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonEdge.path[3])
+ point = map.fromCoordinate(extMapPolygonEdge.path[3])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
originalWidth = extMapPolygonEdge.width;
@@ -696,10 +696,10 @@ Item {
mouseMove(map, point.x + 5 + i, point.y - 5)
}
mouseRelease(map, point.x + 5 + i, point.y - 5)
- point = map.toScreenPosition(extMapPolygonEdge.path[0])
+ point = map.fromCoordinate(extMapPolygonEdge.path[0])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
- point = map.toScreenPosition(extMapPolygonEdge.path[3])
+ point = map.fromCoordinate(extMapPolygonEdge.path[3])
verify(point.x < map.width)
verify(point.x > map.width / 2.0)
compare(extMapPolygonEdge.width, originalWidth)
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index 5d2145e8..b135a49a 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -232,7 +232,7 @@ Item {
// sanity check that the coordinate conversion works, as
// rest of the case relies on it. for robustness cut
// a little slack with fuzzy compare
- var mapcenter = map.toScreenPosition(map.center)
+ var mapcenter = map.fromCoordinate(map.center)
verify (fuzzy_compare(mapcenter.x, 100, 2))
verify (fuzzy_compare(mapcenter.y, 100, 2))
@@ -474,7 +474,7 @@ Item {
mapCircleBottomRight = itemBottomRight;
itemTopLeft = preMapQuickItem.coordinate
- var preMapQuickItemScreenPosition = map.toScreenPosition(preMapQuickItem.coordinate)
+ var preMapQuickItemScreenPosition = map.fromCoordinate(preMapQuickItem.coordinate)
preMapQuickItemScreenPosition.x += preMapQuickItem.sourceItem.width
preMapQuickItemScreenPosition.y += preMapQuickItem.sourceItem.height
itemBottomRight = map.toCoordinate(preMapQuickItemScreenPosition)
@@ -497,14 +497,14 @@ Item {
function min_max_bounds_from_list(coorindates){
var i = 0
- var point = map.toScreenPosition(coorindates[0])
+ var point = map.fromCoordinate(coorindates[0])
var minX = point.x
var minY = point.y
var maxX = point.x
var maxY = point.y
for (i=1; i < coorindates.length; ++i) {
- point = map.toScreenPosition(coorindates[i])
+ point = map.fromCoordinate(coorindates[i])
if (point.x < minX)
minX = point.x
if (point.x > maxX)
@@ -582,7 +582,7 @@ Item {
}
function is_coord_on_screen(coord) {
- return is_point_on_screen(map.toScreenPosition(coord))
+ return is_point_on_screen(map.fromCoordinate(coord))
}
function is_point_on_screen(point) {
diff --git a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
index 36e7b146..3c8a5f2c 100644
--- a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
+++ b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
@@ -336,7 +336,7 @@ class tst_QGeoMapScene : public QObject
mapGeometry.setVisibleTiles(ct.tiles());
QDoubleVector2D point(screenX,screenY);
- QDoubleVector2D mecartorPos = mapGeometry.screenPositionToMercator(point);
+ QDoubleVector2D mecartorPos = mapGeometry.itemPositionToMercator(point);
QCOMPARE(mecartorPos.x(),mercatorX);
QCOMPARE(mecartorPos.y(),mercatorY);
@@ -376,7 +376,7 @@ class tst_QGeoMapScene : public QObject
mapGeometry.setVisibleTiles(ct.tiles());
QDoubleVector2D mercatorPos(mercatorX, mercatorY);
- QPointF point = mapGeometry.mercatorToScreenPosition(mercatorPos).toPointF();
+ QPointF point = mapGeometry.mercatorToItemPosition(mercatorPos).toPointF();
QCOMPARE(point.x(), screenX);
QCOMPARE(point.y(), screenY);