summaryrefslogtreecommitdiffstats
path: root/src/location
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2011-09-09 15:12:43 +1000
committerAaron McCarthy <aaron.mccarthy@nokia.com>2011-09-09 15:24:34 +1000
commit5f42e961560a54a2d3978b42478cd90bc8c6927d (patch)
treeac23cb069e85786fbae0d1c11731330ea697e321 /src/location
parent3b55bbd1fbac94def3718133db574823948c3b01 (diff)
Squashed commit of the following:
commit 142bae21d2c938ea29ebfaf8cafd5b1791ae1f6e Merge: 1eac7c4 3b55bbd Author: Aaron McCarthy <aaron.mccarthy@nokia.com> Date: Fri Sep 9 12:41:26 2011 +1000 Merge remote branch 'origin/places' into maps-merge Conflicts: examples/declarative/flickr/qmllocationflickr.cpp examples/declarative/landmarkmap/landmarkmap.pro examples/declarative/landmarkmap/qmllandmarkmap.cpp examples/declarative/mapviewer/mapviewer.pro examples/declarative/mapviewer/qmlmapviewer.cpp examples/examples.pro src/3rdparty/proj.pri src/imports/location/location.cpp src/imports/location/location.pro src/imports/location/qdeclarativegeomapcircleobject.cpp src/imports/location/qdeclarativegeomapcircleobject_p.h src/imports/location/qdeclarativegeomapgroupobject.cpp src/imports/location/qdeclarativegeomapgroupobject_p.h src/imports/location/qdeclarativegeomapmousearea_p.h src/imports/location/qdeclarativegeomapobject.cpp src/imports/location/qdeclarativegeomapobject_p.h src/imports/location/qdeclarativegeomapobjectborder.cpp src/imports/location/qdeclarativegeomappixmapobject.cpp src/imports/location/qdeclarativegeomappixmapobject_p.h src/imports/location/qdeclarativegeomappolygonobject.cpp src/imports/location/qdeclarativegeomappolygonobject_p.h src/imports/location/qdeclarativegeomappolylineobject.cpp src/imports/location/qdeclarativegeomappolylineobject_p.h src/imports/location/qdeclarativegeomaprectangleobject.cpp src/imports/location/qdeclarativegeomaprectangleobject_p.h src/imports/location/qdeclarativegeomaprouteobject.cpp src/imports/location/qdeclarativegeomaprouteobject_p.h src/imports/location/qdeclarativegeomaptextobject.cpp src/imports/location/qdeclarativegeomaptextobject_p.h src/imports/location/qdeclarativegeoserviceprovider_p.h src/imports/location/qdeclarativegraphicsgeomap.cpp src/imports/location/qdeclarativegraphicsgeomap_p.h src/imports/location/qdeclarativelandmarkcategorymodel_p.h src/imports/location/qdeclarativelandmarkfilters_p.h src/imports/location/qdeclarativelandmarkmodel_p.h src/location/location.pro src/location/maps/qgeomapcircleobject.cpp src/location/maps/qgeomapcircleobject.h src/location/maps/qgeomapcircleobject_p.h src/location/maps/qgeomapcustomobject.cpp src/location/maps/qgeomapcustomobject.h src/location/maps/qgeomapcustomobject_p.h src/location/maps/qgeomapdata.cpp src/location/maps/qgeomapdata.h src/location/maps/qgeomapgroupobject.cpp src/location/maps/qgeomapgroupobject.h src/location/maps/qgeomapobject.cpp src/location/maps/qgeomapobject.h src/location/maps/qgeomapobjectengine_p.cpp src/location/maps/qgeomapobjectengine_p.h src/location/maps/qgeomapobjectinfo.cpp src/location/maps/qgeomapoverlay.cpp src/location/maps/qgeomappingmanagerengine.cpp src/location/maps/qgeomappixmapobject.cpp src/location/maps/qgeomappixmapobject.h src/location/maps/qgeomappixmapobject_p.h src/location/maps/qgeomappolygonobject.cpp src/location/maps/qgeomappolygonobject.h src/location/maps/qgeomappolygonobject_p.h src/location/maps/qgeomappolylineobject.cpp src/location/maps/qgeomappolylineobject.h src/location/maps/qgeomappolylineobject_p.h src/location/maps/qgeomaprectangleobject.cpp src/location/maps/qgeomaprectangleobject.h src/location/maps/qgeomaprectangleobject_p.h src/location/maps/qgeomaprouteobject.cpp src/location/maps/qgeomaprouteobject_p.h src/location/maps/qgeomaptextobject.cpp src/location/maps/qgeomaptextobject.h src/location/maps/qgeomaptextobject_p.h src/location/maps/qgraphicsgeomap.cpp src/location/maps/qgraphicsgeomap.h src/location/maps/tiled/makepoly_p.h src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h src/location/maps/tiled/qgeotiledmapdata.cpp src/location/maps/tiled/qgeotiledmapdata.h src/location/maps/tiled/qgeotiledmapdata_p.h src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmapobjectinfo_p.h src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp src/location/maps/tiled/qgeotiledmappingmanagerengine.h src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmaprequest.cpp src/location/maps/tiled/qgeotiledmaprequest_p.h src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp src/location/mapsgl/cameradata.h src/location/mapsgl/map.h src/location/mapsgl/map2d/projection2d_p.h src/location/mapsgl/map3d/map3d_p.h src/location/mapsgl/map3d/spheregeometry_p.h src/location/mapsgl/map3d/viewport.cpp src/location/mapsgl/map3d/viewport_p.h src/location/mapsgl/map3d/viewportcamera_p.h src/location/mapsgl/map3d/viewporttiles_p.h src/location/mapsgl/map3d/viewporttiles_p_p.h src/location/mapsgl/map3d/viewporttilesnew.cpp src/location/mapsgl/map3d/viewporttilesold_p.h src/location/mapsgl/mapitem.h src/location/mapsgl/mapsphere_p.h src/location/mapsgl/projection_p.h src/location/mapsgl/tile.cpp src/location/mapsgl/tile.h src/location/mapsgl/tilecamera.h src/location/mapsgl/tilespec.cpp src/location/mapsgl/tilespec.h src/location/projwrapper_p.cpp src/location/projwrapper_p.h src/plugins/geoservices/nokia/nokia.pro src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.h src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp tests/auto/auto.pro tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro tests/auto/testplugin/qgeosearchmanagerplugins.pro tests/auto/testplugin/testplugin.pro tests/declarativetestplugin/location.pro tests/declarativetestplugin/locationtest.cpp tests/declarativetestplugin/qdeclarativelocationtestmodel.cpp tests/declarativetestplugin/qdeclarativelocationtestmodel_p.h tests/tests.pro Change-Id: I23e2a324ad64ea1abe026c72569d578dcc664e75 commit 1eac7c46f40a1007e11841d7b9fc7934da3e3f45 Author: Aaron McCarthy <aaron.mccarthy@nokia.com> Date: Fri Sep 9 10:37:30 2011 +1000 Rename project files. Change-Id: Idc1d7f3fcf4f5fdbf38af3842928cdfada1b7ee8 commit db2d91abf29e52236358e67dabbabbf4568f5d84 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 20:53:35 2011 +1000 Revert "temp check" This reverts commit 82f1370d2d29bfb95663a740d2b566fa22093388. commit 82f1370d2d29bfb95663a740d2b566fa22093388 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 20:40:42 2011 +1000 temp check Change-Id: I1d497a44d9422dd9b08554ccaad80ac80a0b8bae commit 19276939b4b56281e8b5f5f418afa76383ff91b9 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 20:20:51 2011 +1000 clear color more obvious Change-Id: I7609c4218a8d5112d7ff361b4b5515d418770364 commit 4a179d3a08e07ac3e32e0c2f555ddb2eed21b636 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 19:53:55 2011 +1000 more qdebugs Change-Id: If1cede53f8d38e799e7da4ffee92e3dbb93af764 commit 3e63c9f5fe1062294734082ec4fd94c5badf0213 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 19:11:47 2011 +1000 qdebugs more visible Change-Id: Ibd2acc57ce22bdf743b9a440ec77e59a2dc576bd commit 2c1f5c8cb245155e09677f3e3e592ac64a9ffc56 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 18:39:39 2011 +1000 Some qdebugs always needed. Change-Id: I2af97585e7e4a14bf1f2ca9dccc5280e31d453b4 commit 3e1a6a12571ed056b9141475d6214c464a6693f7 Author: juhvu <qt-info@nokia.com> Date: Thu Sep 8 14:41:21 2011 +1000 Check qsgengine availability earlier. Change-Id: I65f3902f1829ff7869831135f574873ea4265374 commit cb71264ee7a573033985cc1eab8452cf29a34c65 Author: David Laing <david.laing@nokia.com> Date: Wed Sep 7 14:59:19 2011 +1000 First pass at improved intersection code. The old code has some dependencies on some QPainter specific code that we might not be able to rely on in the very near future. This could do with some testing. commit 09f101e685f48154c5bede732c147dee027dffd5 Author: David Laing <david.laing@nokia.com> Date: Wed Sep 7 13:54:18 2011 +1000 Removes accidentally added tex files. commit 675fa4c57a0f537ce5f30c06ffcf0f00e56a18ab Author: David Laing <david.laing@nokia.com> Date: Wed Sep 7 13:48:33 2011 +1000 Refactors the code to remove the deprecated parts of Maps. Also changes the new mapping code to make use of the existing maps plugin system. commit f873103da192c1ba5195018bdc8222c148d0c4c8 Author: juhvu <qt-info@nokia.com> Date: Tue Sep 6 14:14:39 2011 +1000 test plugin import fix Change-Id: Ib8f2fec09e38ebef43895a145520399ac470a7b7 commit 29719cdc6ebc62045ae8083836ce418ab21ba11b Author: juhvu <qt-info@nokia.com> Date: Tue Sep 6 11:19:07 2011 +1000 Temp hack to resolve the QML startup assert. Change-Id: I01ba9be3e1c92e032885dc71140a62392dbbfbc4 commit 680954a85ea69ed4146a66b726f8775b03fec311 Author: Xizhi Zhu <xizhi.zhu@nokia.com> Date: Mon Jun 27 16:48:29 2011 +0300 Fix copy2build output path for QML plugin. commit b309375dff7bc23b1759dfed1edcad609b7647f9 Author: David Laing <david.laing@nokia.com> Date: Fri Sep 2 14:14:30 2011 +1000 Cleans up the includes in the C++ code. commit 8b5328e06db5c5799f47feb57fa0ea33a65b9d74 Author: David Laing <david.laing@nokia.com> Date: Fri Sep 2 12:54:33 2011 +1000 Fixes some compile warnings for the new maps code. commit 43c7b2b76e3e634f0066a7cb012ea0eab4c4eb53 Author: David Laing <david.laing@nokia.com> Date: Fri Sep 2 11:42:21 2011 +1000 Further cleans up naming of files. commit ecfd70736d7bf3b7233940024756c81d73487d39 Author: David Laing <david.laing@nokia.com> Date: Thu Sep 1 17:40:48 2011 +1000 Adds licenses and sorts out private/public headers. commit f0a394389c3dc8c51f48e44c78300886f595887e Author: juhvu <qt-info@nokia.com> Date: Thu Sep 1 14:05:25 2011 +1000 Possible to run qml basic map without tweaks to qtdeclarative. Means that no map items or mouseareas will work. Change-Id: I6c6d1013462eb8424b5ec9eeb9e7779bb0cb5f25 commit 383983f2a2b4674332b63bb81da1b17fe11db3fa Author: David Laing <david.laing@nokia.com> Date: Wed Aug 31 16:13:32 2011 +1000 Removes unused debug output. commit 8bf2fc191b172525c3750205d0b0d3fcedf17a78 Merge: fea668d fa36fb7 Author: juhvu <qt-info@nokia.com> Date: Wed Aug 31 16:01:32 2011 +1000 Merge branch 'experimental_scenegraphing2' of scm.dev.nokia.troll.no:qt/dalaings-qtlocation-staging-experimental into experimental_scenegraphing2 commit fea668d9f69ef13ce79029869a9e440b65cb7230 Author: juhvu <qt-info@nokia.com> Date: Wed Aug 31 16:00:23 2011 +1000 Don't wait for texture when creating map item node. Change-Id: Ib5dbee82dbb27ba7bb18ef65df4ba401e8894818 commit fa36fb7905585c80109b262fd718aa71df31e882 Author: David Laing <david.laing@nokia.com> Date: Wed Aug 31 15:57:29 2011 +1000 Modifies the 2D map to take into account the window size. Previously we were setting various values based on the window sizes we were using for testing, which was never going to work in the long term. We might want to try to find out the DPI of the display and take that into account later on as well. commit d2ae0f0bde89b0ddb8278ba9595818fa9e37a004 Author: David Laing <david.laing@nokia.com> Date: Wed Aug 31 14:27:02 2011 +1000 Cleans up some of rendering code that was commented out. commit ba55afb9f39c60f0412f0f0a9a9bed98dcab2e0d Author: juhvu <qt-info@nokia.com> Date: Mon Aug 29 15:52:22 2011 +1000 Added zoomLevel to mapItems (much more joyous thingies now). Change-Id: Icd58b60920a8453fb5f26d0155ff027d86d11b73 commit f43db647753f8fa5ed9fa90c5c5a580d527bf4f1 Author: juhvu <qt-info@nokia.com> Date: Mon Aug 29 14:24:56 2011 +1000 Better working support for adding map items with Q_INVOKABLEs. Change-Id: I3c47a76369bd0968537c8490f9079f880aa54f26 commit d849ff492db227ab96ebca99dbaad9610cdc6130 Author: David Laing <david.laing@nokia.com> Date: Mon Aug 29 13:44:25 2011 +1000 Flips MapItem textures so they're drawn correctly. This was initially written to work with QPixmaps, which have a y-axis that points in the other direction. commit 5b60ed1d15f7fca457d347102d290664481eef0c Author: David Laing <david.laing@nokia.com> Date: Mon Aug 29 11:59:32 2011 +1000 Quick and dirty fix for map item rendering. We now draw the map, disable the depth test, draw the objects, then re-enable the depth dest. It's a bit dirty but it seems to work. Some of the map3d system test was modified to make it easier to check what works and what doesn't while this is played with. It'll probably change back once we've gotten this down. commit bccbfa89a0cab133871e29e735ee2724e88830c0 Author: juhvu <qt-info@nokia.com> Date: Fri Aug 26 16:22:43 2011 +1000 Solved map item threading -related crashes. However refactoring will be needed, this commit pinpointed and workarounded the issues but real solutions will follow shortly. Change-Id: I734ba79f36033f1d290f498f04310400a4074c57 commit 17f72db36f5084973ec470128a3edb1415f601ef Author: David Laing <david.laing@nokia.com> Date: Fri Aug 26 15:41:38 2011 +1000 Compilation fix. Also updates the include path in the map3d example / system test. commit a3fcbf90a599b8973331dab9fb75172027372651 Author: David Laing <david.laing@nokia.com> Date: Fri Aug 26 15:09:21 2011 +1000 Adds a copy of map3d to the system tests. This way the version in examples can be made into a nicely behaving example while the version in system tests can be used for benchmarking and verification. commit 496d8f4fe752c4f2c8899c5be6b34a91a03c01e9 Author: David Laing <david.laing@nokia.com> Date: Fri Aug 26 15:06:05 2011 +1000 Renames the maps3d directory to mapsgl. commit 23cce283c44cc98282150d76930d4e34d2ece683 Author: David Laing <david.laing@nokia.com> Date: Thu Aug 25 16:54:06 2011 +1000 Adds initial support for coordinate - screen conversions. The screen -> coordinate conversion could still be improved. commit 33d688d2b19a7b3fa80c12ff4284bb0efd39d6e6 Author: Cristian Adam <cristian.adam@nokia.com> Date: Wed Aug 24 12:00:51 2011 +0200 Buildfix for MSVC. commit a8490395427b460ada4eda118a6d22f2a067843f Author: David Laing <david.laing@nokia.com> Date: Wed Aug 24 16:10:26 2011 +1000 One last little change for the declarative texture problem. This change trades off correct behaviour for up to twice the memory consumption - once in the texture and once in the image - although we should be able to have both. I need to get my declarative environment up to scratch so I can figure this out properly. commit 3caea5c919bd2aa2c2e652a06270ea638dc82c25 Author: David Laing <david.laing@nokia.com> Date: Wed Aug 24 15:54:33 2011 +1000 Attempts to fix a bug introduced by the last commit. The last commit was a little less rendering-thread aware than it should have been - hopefully this fixes it. commit cc0f1d797097ad27bb537c5638b7e6e46318c423 Author: David Laing <david.laing@nokia.com> Date: Wed Aug 24 15:03:42 2011 +1000 Makes the tile cache eviction rendering-thread-aware. Some things weren't being cleaned up previously because we needed to clean them up in the rendering thread. The MapSphere class had a method for this but TileCache has the information. The cleanup is now done in TileCache, however the interface between the two classes for this task could do with some neatening. commit a7ac61adf978565e8e25adc2474f89e4414fc3a4 Author: David Laing <david.laing@nokia.com> Date: Wed Aug 24 11:01:17 2011 +1000 Refactors the code to separate the 2D and 3D mapping classes. Quite a few optimizations and other fixes are included. Now that this refactoring is done I should be able to make smaller and more frequent commits rather than these monsters... commit 01873d37f8eae15eccf424cc39e7810312d0b412 Author: Cristian Adam <cristian.adam@nokia.com> Date: Tue Aug 23 20:43:56 2011 +0200 Texture display "beautification" commit 87abf218bafaa98e55beaa050a14526427c88152 Author: Cristian Adam <cristian.adam@nokia.com> Date: Mon Aug 22 20:18:15 2011 +0200 Fixed for 2D map. commit f44f8dc61670bf21efa4b6e84fa8fa2291d16f95 Author: Cristian Adam <cristian.adam@nokia.com> Date: Fri Aug 19 19:25:10 2011 +0200 Compilation bugfix and some mouse navigation for map3d. commit bd929f6f11a16ff681d5fc543caf33f494fdbd27 Merge: 024214c ee5cd33 Author: Cristian Adam <cristian.adam@nokia.com> Date: Fri Aug 19 10:01:59 2011 +0200 Merge branch 'experimental_scenegraphing2' of scm.dev.nokia.troll.no:qt/dalaings-qtlocation-staging-experimental into experimental_scenegraphing2 commit ee5cd339b1f72df506905ee815988a65623584c5 Author: juhvu <qt-info@nokia.com> Date: Fri Aug 19 15:00:58 2011 +1000 First success on texturized map objects. Change-Id: Ied9276da69a047e578cee614318e7d6a6a5d4e6d commit 25f7f641787a43f16a7c379c5e0e0735296524a9 Author: juhvu <qt-info@nokia.com> Date: Fri Aug 19 09:37:08 2011 +1000 Interim commit for arbitrary QML map item support. Change-Id: Ica29abb6f9cd74e6c6fbdc028f31cd25957546f9 Conflicts: src/location/maps3d/mapsphere.cpp src/location/maps3d/mapsphere.h commit 6f7aa4e2eec65ee855992a22d019202234de4f9b Author: juhvu <qt-info@nokia.com> Date: Fri Aug 19 09:03:30 2011 +1000 Few changes to get QML Map example running. Change-Id: Iaada49719341b9c48682f2a5a87eb03986d8272d commit 024214cbc524584e719cc6e5baf67cfe68764918 Author: Cristian Adam <cristian.adam@nokia.com> Date: Thu Aug 18 19:23:01 2011 +0200 Bugfixes to build for Windows. commit 0c3b8d7250fcbef3c1ca6a8c538cf7440f6d3dae Author: David Laing <david.laing@nokia.com> Date: Thu Aug 18 17:36:57 2011 +1000 Adds preliminary support for map items. Dummy items at the moment, projected onto the map. - need to look at drawing items in a second pass to avoid rendering glitches - need to handle non-projected objects, which will probably involve yet another pass, possibly with an ortho projection - need to handle the texture stuff from Juha commit 8289b3227873576c9fa32bb117633135d89f5800 Author: David Laing <david.laing@nokia.com> Date: Thu Aug 18 17:31:46 2011 +1000 Improves the behaviour of the tile provider. - Queued connection between the cache and the provider - Provider aborts replies that are no longer going to be used commit 473bef88f86322d575936b1312a976a65ce116df Author: David Laing <david.laing@nokia.com> Date: Thu Aug 18 13:41:09 2011 +1000 Updates some of the rendering mutex related changes. commit 398a37255d09a862fae58760918ac6b3c4ef4ac7 Author: David Laing <david.laing@nokia.com> Date: Tue Aug 16 14:58:06 2011 +1000 Reworked the maps to allow for 2D Map projections There are numerous other changes and optimizations in here. commit 1a8844780b0e02f90e6929c1edaeaef80c288a3f Author: juhvu <qt-info@nokia.com> Date: Tue Aug 9 10:34:23 2011 +1000 Stop timers when stopping too. Change-Id: I0334eea1cfd6a0a9cdcb23bc9120b10a9f90b913 commit a4671b1517d3fc10107dd4b6da70f784a11d5855 Author: juhvu <qt-info@nokia.com> Date: Tue Aug 9 10:30:48 2011 +1000 Took out some asserts in maps. Change-Id: I0dd48f0c30ae9e2f958f1b750a1713315ec1d681 commit e524908c6b977307408d6992a1cb7d5c6c7874c5 Author: juhvu <qt-info@nokia.com> Date: Tue Aug 9 10:15:28 2011 +1000 Map (3D) zoom and flick working at same time. Change-Id: I4862882cfe9b23bcef88873372a7178635dc9485 commit 30aef46a61e8414985533f7b8eaaa7cf5578993f Author: juhvu <qt-info@nokia.com> Date: Mon Aug 8 16:27:03 2011 +1000 Fixed Map (3D) mousewheel (QSGItem event type changed) and flickable. Change-Id: If79463b84630ce8d96525a095fbb0167903a8ca5 commit 037eb28953eb78a628710aba487e78240805ea93 Author: juhvu <qt-info@nokia.com> Date: Fri Aug 5 14:15:36 2011 +1000 Corrected Map flick to work even with very short (<200ms) flicks. Change-Id: Ic6fc294d6f3517090578b3e66d1ddf425df845f5 commit ad28c2c32b1a14093e6a09d4fd3a0c100976366c Author: David Laing <david.laing@nokia.com> Date: Thu Aug 18 11:13:48 2011 +1000 Re-adding the non-revert parts of 6c39b17 commit 9f948f41b19e605e400d3303314a7d844a4a0a8c Author: David Laing <david.laing@nokia.com> Date: Thu Aug 18 11:13:04 2011 +1000 Revert "Revert "Further improvements to the camera / sphere intersect code."" This reverts commit 6c39b175188a8cddf290c3cf2aac2ea61835b109. commit 6c39b175188a8cddf290c3cf2aac2ea61835b109 Author: juhvu <qt-info@nokia.com> Date: Fri Aug 5 13:06:44 2011 +1000 Revert "Further improvements to the camera / sphere intersect code." This reverts commit 78b01bf94e196b3130e1b75d746dcd6a8cbbc8c2. Conflicts: src/location/maps3d/mapsphere.cpp Also improved the example application. Dodgy to do it in revert commit but forgot the thing and ran out of time. Change-Id: I0aaa934b5d93a4a9846304a5553276a0937439e8 commit c5bef97778e635722ee255b0da4366b3606fa44f Author: juhvu <qt-info@nokia.com> Date: Thu Aug 4 15:57:10 2011 +1000 Rough version of Map scene node thread protection. Change-Id: Ida38cd02fbfe42ac8908df54f8aad4ac61da28d4 commit 78b01bf94e196b3130e1b75d746dcd6a8cbbc8c2 Author: David Laing <david.laing@nokia.com> Date: Thu Aug 4 15:09:02 2011 +1000 Further improvements to the camera / sphere intersect code. Increased correctness, added some optimizations. commit 3c78999378e73167dacf72f511b4f75c0ed43b0f Author: juhvu <qt-info@nokia.com> Date: Thu Aug 4 13:26:54 2011 +1000 Added tilt support for Map(3D) pinch area. Change-Id: I17a3ee333f2ef594df3cc4f5d38604a77414ea2a commit 13d57872c57b62ee857a25eab65803552d813497 Author: juhvu <qt-info@nokia.com> Date: Thu Aug 4 10:53:09 2011 +1000 Added gesture option support for map pinch area. Change-Id: I2ca45d48626528f1c000d395d9dadfc3e665f8f2 commit 0a0d98d3f8b67946d601518beb8b15f671cba458 Author: juhvu <qt-info@nokia.com> Date: Thu Aug 4 09:57:43 2011 +1000 Improved the rotation for Map3D. Change-Id: I9f77ee2018cc878fdad56508a2037510ec405746 commit 0002c36d984516ffa2c6aa8e5ac0aa6e637d4b6e Author: juhvu <qt-info@nokia.com> Date: Wed Aug 3 16:08:48 2011 +1000 Radical pinch zooming improvements for Map3D. Change-Id: I402c712d577d5f3737271d6b34c79862cd838c44 commit 0fec6b84da9c9cbc99fa91452f7957b93ca7364a Author: juhvu <qt-info@nokia.com> Date: Tue Aug 2 13:29:53 2011 +1000 Fix for pinching gen - changed qapp->notify to canvas->sendEvent. Change-Id: I8e68b5d120ace5652cef4f4ad0b46b949d2e28bd commit fbbb3016c212214e18afa58452bd96253c0779ee Author: juhvu <qt-info@nokia.com> Date: Tue Aug 2 10:51:51 2011 +1000 Forgot .pro file for the testplugin. Change-Id: Iad18fa5e988b730c54e8deea7b4cea1bcbea3e98 commit c8ae01f629a6a5798bfd187c6c67d9fe31482155 Author: juhvu <qt-info@nokia.com> Date: Tue Aug 2 09:47:24 2011 +1000 Put pinchgenerator into test plugin. Change-Id: Ia401fb7d1ee7bc9bbd4decaa39b446a5dda81693 commit 4767ad9b4f37a1ac90f12b288df73f14469c616e Author: juhvu <qt-info@nokia.com> Date: Mon Aug 1 15:40:05 2011 +1000 First version of pinch generator. Change-Id: I3eff3559b6750e086de914b166545b66742a04c8 commit 2121ca14e5b8d7e0679711bac35cbc79df2f1fb1 Author: David Laing <david.laing@nokia.com> Date: Fri Jul 29 15:14:35 2011 +1000 Improves the sphere / plan intersection code. Now using a much improved algorithm - less code / memory time is needed to get results which are correct in more cases. commit 5e5e88471797a1d2de8c161cc00e26da1528c13c Author: juhvu <qt-info@nokia.com> Date: Fri Jul 29 11:40:06 2011 +1000 Map 3D pinch event support. Change-Id: I2196e59c581b6a17ccb87f2550102bce70e967f2 commit 7135d6717ff225445c7ec99d22a243f577e02b8b Author: juhvu <qt-info@nokia.com> Date: Thu Jul 28 16:15:41 2011 +1000 First version of 3D Map pinching. Change-Id: I834def992b01e6701cbc48cc49c86527033e7e26 commit 8380676866d777bda65d77148869cfb0ef787352 Merge: addf553 b36eae4 Author: juhvu <qt-info@nokia.com> Date: Wed Jul 27 15:41:47 2011 +1000 Merge branch 'experimental_scenegraphing' of scm.dev.nokia.troll.no:qt/dalaings-qtlocation-staging-experimental into experimental_scenegraphing Conflicts: src/location/maps3d/cameradata.cpp Change-Id: Ia822a689a1ea65e2bdadbd5dcf7e606f6091d3dd commit addf5532dc4b267ee7a4a8b26ce3e052c3f9f655 Author: juhvu <qt-info@nokia.com> Date: Wed Jul 27 15:38:30 2011 +1000 Added rough draft of Map 3D flicking. Change-Id: Ia9ed0723a906b52490cc5b05fd11d9569adfc285 commit b36eae47ba5a8f3809a088ddb9bfcdb511a4776e Author: David Laing <david.laing@nokia.com> Date: Tue Jul 26 11:34:39 2011 +1000 Fixes a bug with the relationship between zoom and distance. Was using z^2 instead of 2^z. commit 3fe3c2146615906cb8726d7326213cfc98de5821 Author: David Laing <david.laing@nokia.com> Date: Tue Jul 26 11:34:17 2011 +1000 Adds animation support to the C++ demo. commit 39f26af1d7f7b4bb59bb59b3ecef18f6481fbd51 Author: juhvu <qt-info@nokia.com> Date: Tue Jul 26 09:58:00 2011 +1000 Update Map3D backend. Change-Id: Ie1e3f730fb9505b42fa664f1da5f8af0c3818435 commit ff0bb0b48e27b3f9a9e92c6cc05dbfdd8f6106bf Author: juhvu <qt-info@nokia.com> Date: Mon Jul 25 15:38:18 2011 +1000 QtLocation to compile with qml2 header changes. Change-Id: Ia1724740fdcd6f6a4114737dea47b981658aa71e commit a3c4b9c1550ece97531954073bd0e0063695bf50 Author: David Laing <david.laing@nokia.com> Date: Tue Jul 26 09:34:22 2011 +1000 Switches the viewport-to-tiles backend to the stable version The new and improved version isn't ready quite yet. commit e32743ea59c4df2cd5e7cd67b63364e2cd653019 Author: David Laing <david.laing@nokia.com> Date: Mon Jul 25 16:37:45 2011 +1000 Fixes some camera bugs. The bearing rotation was being applied twice, and the coordinate interpolation was moving in the wrong direction i.e. from the end to the start. Fixed now. commit 62ed7d29e2e739d7ba82c5c280ec599a674ad513 Merge: 358d9ec 685693e Author: David Laing <david.laing@nokia.com> Date: Mon Jul 25 15:27:38 2011 +1000 Merge branch 'experimental_scenegraphing' of scm.dev.nokia.troll.no:qt/dalaings-qtlocation-staging-experimental into experimental_scenegraphing commit 358d9ecbea2b142238ff6696e40eb7012f387510 Author: David Laing <david.laing@nokia.com> Date: Mon Jul 25 15:25:49 2011 +1000 Another bulk update of backend stuff. - Quite a bit of refactoring - Adds scripting for the map example (for testing / profiling) - Adds switchable camera->tiles strategies - Including the start of the new approach - Adds interpolators for the camera commit 685693e68bdfc2d909063a344e5963ea753daf27 Author: juhvu <qt-info@nokia.com> Date: Mon Jul 25 14:20:35 2011 +1000 Small pinch update. Change-Id: I1fe08805200e8391963cf8ea513dc7fb843bcc0d commit 9d8f663ac423efe9d206936b367d84ac270cfdaa Author: juhvu <qt-info@nokia.com> Date: Fri Jul 22 15:38:42 2011 +1000 Simple mouse wheel support for Map 3d. Change-Id: I0d466cd923d62494870b952102ccb447203e7876 commit d3a57442cb921fab1cf1ae50e525308ae37513a5 Author: juhvu <qt-info@nokia.com> Date: Fri Jul 22 14:52:51 2011 +1000 Regular MouseArea integration to 3D Map element. Change-Id: Ib6fd5040a94c0a0dafe33de77254791d695809ea commit 7c7d6efcc3ce0ea3cc77e1523ac238d36b1cf544 Author: juhvu <qt-info@nokia.com> Date: Mon Jul 11 12:54:53 2011 +1000 Intermediate idea commit Map::MouseArea integration. Change-Id: I6f3ce7e15e540943581aa678f421a45418a8d763 commit dc9545e75f3c0dc60fdf60d323f46e5159e8506b Author: juhvu <qt-info@nokia.com> Date: Tue Jul 5 16:13:25 2011 +1000 Added the sphere/map toggle to map3d qml example. commit abbc8d5b33537856e13f0b1787c4202d29d1471d Author: juhvu <qt-info@nokia.com> Date: Tue Jul 5 13:23:30 2011 +1000 Anchors to work with 3d map element. commit 19048b9260b3e51a1fb9aa8c04eb10f32f37ce56 Author: juhvu <qt-info@nokia.com> Date: Tue Jul 5 10:57:11 2011 +1000 Restored gl context defaults after rendering underlay (warnings). commit 220c3feec0aefce34ec73db23d90f853876dfabd Merge: 708b242 1f375c2 Author: juhvu <qt-info@nokia.com> Date: Mon Jul 4 12:01:42 2011 +1000 Merge branch 'experimental_scenegraphing' of scm.dev.nokia.troll.no:qt/dalaings-qtlocation-staging-experimental into experimental_scenegraphing commit 708b2423dc6e4474a77f85cb16dc121d05359d56 Author: juhvu <qt-info@nokia.com> Date: Mon Jul 4 12:01:10 2011 +1000 Simplified QSG rendering for Map element. commit 1f375c2ebbbe66eecbb36f9d0b3bfe2f0506bfb8 Author: David Laing <david.laing@nokia.com> Date: Mon Jul 4 11:45:23 2011 +1000 Massive update to 3D maps code. Still need to rework TileCamera so we have a camera API with user-friendly goodness. commit eeaa93cd262581cadc674daa03267a4b96ca7053 Author: juhvu <qt-info@nokia.com> Date: Fri Jul 1 14:37:08 2011 +1000 Cube tests for QSG underlay. commit 04991ff06f733f554f701e9bf1ae7f1e3a9b1aa0 Author: juhvu <qt-info@nokia.com> Date: Mon Jun 27 15:37:07 2011 +1000 Modified tile camera. commit c39ef64e914ba40929821d7c115bdff9ae73c675 Author: juhvu <qt-info@nokia.com> Date: Tue Jun 21 10:48:17 2011 +1000 Map3D element to run 3d map. commit 049466a6581af6a78bd02ca316ceb379b76fbad9 Author: David Laing <david.laing@nokia.com> Date: Fri Jun 17 16:47:00 2011 +1000 Removing example executable. commit 8de142a35f3f6630cc7114e08e4e5c4234515fce Author: David Laing <david.laing@nokia.com> Date: Fri Jun 17 16:44:59 2011 +1000 Adding initial code dump. commit 2ccd4851439daf76165187c20c1981b305782957 Merge: f9a921e 54c829a Author: David Laing <david.laing@nokia.com> Date: Fri Jun 17 16:11:31 2011 +1000 Merge branch 'master' into experimental_scenegraphing commit f9a921e84f19c52d7ea7452a47f8aa0c0417852b Author: juhvu <qt-info@nokia.com> Date: Tue Jun 14 15:51:19 2011 +1000 Map3D object visible in QML. commit 416fdb11c2649f72a04cfe9c64d5fdc4cc175aa3 Author: juhvu <qt-info@nokia.com> Date: Fri Jun 10 15:47:12 2011 +1000 Some maps scenegraphing drafting. Change-Id: I96b5c5a396f371e7e9acf983441d674a55b44368
Diffstat (limited to 'src/location')
-rw-r--r--src/location/location.pro10
-rw-r--r--src/location/maps/maps.pri49
-rw-r--r--src/location/maps/qgeomapcircleobject.cpp340
-rw-r--r--src/location/maps/qgeomapcircleobject.h110
-rw-r--r--src/location/maps/qgeomapcircleobject_p.h66
-rw-r--r--src/location/maps/qgeomapcustomobject.cpp294
-rw-r--r--src/location/maps/qgeomapcustomobject_p.h65
-rw-r--r--src/location/maps/qgeomapdata.cpp836
-rw-r--r--src/location/maps/qgeomapdata.h171
-rw-r--r--src/location/maps/qgeomapgroupobject.cpp316
-rw-r--r--src/location/maps/qgeomapobject.cpp534
-rw-r--r--src/location/maps/qgeomapobject.h154
-rw-r--r--src/location/maps/qgeomapobjectengine_p.cpp1182
-rw-r--r--src/location/maps/qgeomapobjectengine_p.h175
-rw-r--r--src/location/maps/qgeomapobjectinfo.cpp264
-rw-r--r--src/location/maps/qgeomapoverlay.cpp114
-rw-r--r--src/location/maps/qgeomappingmanager.cpp104
-rw-r--r--src/location/maps/qgeomappingmanager.h33
-rw-r--r--src/location/maps/qgeomappingmanager_p.h4
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp257
-rw-r--r--src/location/maps/qgeomappingmanagerengine.h44
-rw-r--r--src/location/maps/qgeomappingmanagerengine_p.h21
-rw-r--r--src/location/maps/qgeomappixmapobject.cpp222
-rw-r--r--src/location/maps/qgeomappixmapobject.h91
-rw-r--r--src/location/maps/qgeomappixmapobject_p.h64
-rw-r--r--src/location/maps/qgeomappolygonobject.cpp212
-rw-r--r--src/location/maps/qgeomappolygonobject.h90
-rw-r--r--src/location/maps/qgeomappolygonobject_p.h66
-rw-r--r--src/location/maps/qgeomappolylineobject.cpp178
-rw-r--r--src/location/maps/qgeomappolylineobject_p.h64
-rw-r--r--src/location/maps/qgeomaprectangleobject.cpp299
-rw-r--r--src/location/maps/qgeomaprectangleobject.h101
-rw-r--r--src/location/maps/qgeomaprectangleobject_p.h65
-rw-r--r--src/location/maps/qgeomaprouteobject.cpp224
-rw-r--r--src/location/maps/qgeomaprouteobject_p.h64
-rw-r--r--src/location/maps/qgeomaptextobject.cpp374
-rw-r--r--src/location/maps/qgeomaptextobject.h115
-rw-r--r--src/location/maps/qgeomaptextobject_p.h70
-rw-r--r--src/location/maps/qgeotiledmapreply.cpp (renamed from src/location/maps/tiled/qgeotiledmapreply.cpp)14
-rw-r--r--src/location/maps/qgeotiledmapreply.h (renamed from src/location/maps/tiled/qgeotiledmapreply.h)8
-rw-r--r--src/location/maps/qgeotiledmapreply_p.h (renamed from src/location/maps/tiled/qgeotiledmapreply_p.h)6
-rw-r--r--src/location/maps/qgraphicsgeomap.cpp821
-rw-r--r--src/location/maps/qgraphicsgeomap.h172
-rw-r--r--src/location/maps/tiled/makepoly_p.h138
-rw-r--r--src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp106
-rw-r--r--src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h85
-rw-r--r--src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h85
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata.cpp1431
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata.h115
-rw-r--r--src/location/maps/tiled/qgeotiledmapdata_p.h168
-rw-r--r--src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp137
-rw-r--r--src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h81
-rw-r--r--src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp259
-rw-r--r--src/location/maps/tiled/qgeotiledmapobjectinfo_p.h109
-rw-r--r--src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp188
-rw-r--r--src/location/maps/tiled/qgeotiledmappingmanagerengine.h83
-rw-r--r--src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h84
-rw-r--r--src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp136
-rw-r--r--src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp128
-rw-r--r--src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp147
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest.cpp266
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest.h90
-rw-r--r--src/location/maps/tiled/qgeotiledmaprequest_p.h84
-rw-r--r--src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp142
-rw-r--r--src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp169
-rw-r--r--src/location/maps/tiled/tiled.pri40
-rw-r--r--src/location/mapsgl/cameradata.cpp290
-rw-r--r--src/location/mapsgl/cameradata.h (renamed from src/location/maps/qgeomapcustomobject.h)77
-rw-r--r--src/location/mapsgl/frustum.cpp206
-rw-r--r--src/location/mapsgl/frustum_p.h145
-rw-r--r--src/location/mapsgl/map.cpp402
-rw-r--r--src/location/mapsgl/map.h (renamed from src/location/maps/qgeomapobjectinfo.h)88
-rw-r--r--src/location/mapsgl/map2d/map2d.pri11
-rw-r--r--src/location/mapsgl/map2d/map2d_p.cpp660
-rw-r--r--src/location/mapsgl/map2d/map2d_p.h161
-rw-r--r--src/location/mapsgl/map2d/projection2d_p.cpp109
-rw-r--r--src/location/mapsgl/map2d/projection2d_p.h (renamed from src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h)38
-rw-r--r--src/location/mapsgl/map3d/map3d.pri26
-rw-r--r--src/location/mapsgl/map3d/map3d_p.cpp221
-rw-r--r--src/location/mapsgl/map3d/map3d_p.h (renamed from src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h)50
-rw-r--r--src/location/mapsgl/map3d/projection3d_p.cpp128
-rw-r--r--src/location/mapsgl/map3d/projection3d_p.h (renamed from src/location/maps/qgraphicsgeomap_p.h)38
-rw-r--r--src/location/mapsgl/map3d/sphere.cpp1234
-rw-r--r--src/location/mapsgl/map3d/sphere_p.h177
-rw-r--r--src/location/mapsgl/map3d/spheregeometry.cpp208
-rw-r--r--src/location/mapsgl/map3d/spheregeometry_p.h (renamed from src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h)62
-rw-r--r--src/location/mapsgl/map3d/viewport.cpp (renamed from src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp)105
-rw-r--r--src/location/mapsgl/map3d/viewport_p.h (renamed from src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h)62
-rw-r--r--src/location/mapsgl/map3d/viewportcamera.cpp166
-rw-r--r--src/location/mapsgl/map3d/viewportcamera_p.h111
-rw-r--r--src/location/mapsgl/map3d/viewporttiles.cpp424
-rw-r--r--src/location/mapsgl/map3d/viewporttiles_p.h (renamed from src/location/maps/qgeomapobjectinfo_p.h)36
-rw-r--r--src/location/mapsgl/map3d/viewporttiles_p_p.h (renamed from src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h)53
-rw-r--r--src/location/mapsgl/map3d/viewporttilesnew.cpp (renamed from src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp)95
-rw-r--r--src/location/mapsgl/map3d/viewporttilesnew_p.h (renamed from src/location/maps/qgeomapoverlay_p.h)30
-rw-r--r--src/location/mapsgl/map3d/viewporttilesold.cpp690
-rw-r--r--src/location/mapsgl/map3d/viewporttilesold_p.h (renamed from src/location/projwrapper_p.h)97
-rw-r--r--src/location/mapsgl/map_p.h154
-rw-r--r--src/location/mapsgl/mapitem.cpp167
-rw-r--r--src/location/mapsgl/mapitem.h (renamed from src/location/maps/qgeomapobject_p.h)77
-rw-r--r--src/location/mapsgl/mapsgl.pri33
-rw-r--r--src/location/mapsgl/mapsphere.cpp234
-rw-r--r--src/location/mapsgl/mapsphere_p.h (renamed from src/location/maps/qgeomapdata_p.h)90
-rw-r--r--src/location/mapsgl/projection.cpp117
-rw-r--r--src/location/mapsgl/projection_p.h (renamed from src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h)47
-rw-r--r--src/location/mapsgl/tile.cpp (renamed from src/location/maps/qgeomappolylineobject.h)90
-rw-r--r--src/location/mapsgl/tile.h (renamed from src/location/maps/qgeomapoverlay.h)54
-rw-r--r--src/location/mapsgl/tilecache.cpp455
-rw-r--r--src/location/mapsgl/tilecache.h134
-rw-r--r--src/location/mapsgl/tilecamera.cpp261
-rw-r--r--src/location/mapsgl/tilecamera.h (renamed from src/location/maps/qgeomapgroupobject.h)73
-rw-r--r--src/location/mapsgl/tilespec.cpp (renamed from src/location/maps/qgeomaprouteobject.h)114
-rw-r--r--src/location/mapsgl/tilespec.h (renamed from src/location/maps/qgeomapgroupobject_p.h)47
-rw-r--r--src/location/projwrapper_p.cpp267
114 files changed, 8044 insertions, 13304 deletions
diff --git a/src/location/location.pro b/src/location/location.pro
index 8e6d89ba..63fd8ce0 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -17,15 +17,9 @@ load(qt_module_config)
HEADERS += qtlocationversion.h
include(maps/maps.pri)
+include(mapsgl/mapsgl.pri)
include(places/places.pri)
-contains(proj_enabled, yes) {
- LIBS += -lproj
-} else {
- include($$PWD/../3rdparty/proj.pri)
- LIBS += -L$$OUT_PWD/../3rdparty -lproj
-}
-
PUBLIC_HEADERS += \
qgeoaddress.h \
qgeoareamonitor.h \
@@ -51,7 +45,6 @@ PRIVATE_HEADERS += \
qlocationutils_p.h \
qnmeapositioninfosource_p.h \
qgeoareamonitor_polling_p.h \
- projwrapper_p.h \
qgeocoordinate_p.h
symbian {
@@ -145,7 +138,6 @@ SOURCES += \
qlocationutils.cpp \
qnmeapositioninfosource.cpp \
qgeoareamonitor_polling.cpp \
- projwrapper_p.cpp \
qgeopositioninfosourcefactory.cpp
symbian {
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri
index ffe5bd8e..01603279 100644
--- a/src/location/maps/maps.pri
+++ b/src/location/maps/maps.pri
@@ -1,28 +1,13 @@
INCLUDEPATH += maps
-include(tiled/tiled.pri)
-
PUBLIC_HEADERS += \
maps/qgeocodingmanager.h \
maps/qgeocodingmanagerengine.h \
maps/qgeocodereply.h \
maps/qgeomaneuver.h \
- maps/qgeomapcircleobject.h \
- maps/qgeomapcustomobject.h \
- maps/qgeomapdata.h \
- maps/qgeomapgroupobject.h \
- maps/qgeomapobject.h \
- maps/qgeomapobjectinfo.h \
- maps/qgeomapoverlay.h \
maps/qgeomappingmanager.h \
maps/qgeomappingmanagerengine.h \
- maps/qgeomappixmapobject.h \
- maps/qgeomappolygonobject.h \
- maps/qgeomappolylineobject.h \
- maps/qgeomaprectangleobject.h \
- maps/qgeomaprouteobject.h \
- maps/qgeomaptextobject.h \
maps/qgeoroute.h \
maps/qgeoroutereply.h \
maps/qgeorouterequest.h \
@@ -31,28 +16,15 @@ PUBLIC_HEADERS += \
maps/qgeoroutingmanagerengine.h \
maps/qgeoserviceprovider.h \
maps/qgeoserviceproviderfactory.h \
- maps/qgraphicsgeomap.h
+ maps/qgeotiledmapreply.h
PRIVATE_HEADERS += \
maps/qgeocodingmanager_p.h \
maps/qgeocodingmanagerengine_p.h \
maps/qgeocodereply_p.h \
maps/qgeomaneuver_p.h \
- maps/qgeomapcircleobject_p.h \
- maps/qgeomapcustomobject_p.h \
- maps/qgeomapdata_p.h \
- maps/qgeomapgroupobject_p.h \
- maps/qgeomapobject_p.h \
- maps/qgeomapobjectinfo_p.h \
- maps/qgeomapoverlay_p.h \
maps/qgeomappingmanager_p.h \
maps/qgeomappingmanagerengine_p.h \
- maps/qgeomappixmapobject_p.h \
- maps/qgeomappolygonobject_p.h \
- maps/qgeomappolylineobject_p.h \
- maps/qgeomaprectangleobject_p.h \
- maps/qgeomaprouteobject_p.h \
- maps/qgeomaptextobject_p.h \
maps/qgeoroute_p.h \
maps/qgeoroutereply_p.h \
maps/qgeorouterequest_p.h \
@@ -60,28 +32,15 @@ PRIVATE_HEADERS += \
maps/qgeoroutingmanager_p.h \
maps/qgeoroutingmanagerengine_p.h \
maps/qgeoserviceprovider_p.h \
- maps/qgraphicsgeomap_p.h \
- maps/qgeomapobjectengine_p.h
+ maps/qgeotiledmapreply_p.h
SOURCES += \
maps/qgeocodingmanager.cpp \
maps/qgeocodingmanagerengine.cpp \
maps/qgeocodereply.cpp \
maps/qgeomaneuver.cpp \
- maps/qgeomapcircleobject.cpp \
- maps/qgeomapcustomobject.cpp \
- maps/qgeomapdata.cpp \
- maps/qgeomapgroupobject.cpp \
- maps/qgeomapobject.cpp \
- maps/qgeomapoverlay.cpp \
maps/qgeomappingmanager.cpp \
maps/qgeomappingmanagerengine.cpp \
- maps/qgeomappixmapobject.cpp \
- maps/qgeomappolygonobject.cpp \
- maps/qgeomappolylineobject.cpp \
- maps/qgeomaprectangleobject.cpp \
- maps/qgeomaprouteobject.cpp \
- maps/qgeomaptextobject.cpp \
maps/qgeoroute.cpp \
maps/qgeoroutereply.cpp \
maps/qgeorouterequest.cpp \
@@ -90,6 +49,4 @@ SOURCES += \
maps/qgeoroutingmanagerengine.cpp \
maps/qgeoserviceprovider.cpp \
maps/qgeoserviceproviderfactory.cpp \
- maps/qgraphicsgeomap.cpp \
- maps/qgeomapobjectinfo.cpp \
- maps/qgeomapobjectengine_p.cpp
+ maps/qgeotiledmapreply.cpp
diff --git a/src/location/maps/qgeomapcircleobject.cpp b/src/location/maps/qgeomapcircleobject.cpp
deleted file mode 100644
index 9da75184..00000000
--- a/src/location/maps/qgeomapcircleobject.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapcircleobject.h"
-#include "qgeomapcircleobject_p.h"
-
-#include "qgeocoordinate.h"
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapCircleObject
- \brief The QGeoMapCircleObject class is a QGeoMapObject used to draw the region
- within a given distance of a coordinate.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The circle is specified by either a valid QGeoBoundingCircle instance or a
- valid QGeoCoordinate instance and a qreal with value greater than 0.0,
- which represent the center of the circle and the radius of the circle in
- metres respectively.
-
- The circle may appear as an ellipse on maps which use the Mercator
- projection. This is done so that the circle accurately covers all points at
- a distance of the radius or less from the center.
-*/
-
-/*!
- Constructs a new circle object.
-*/
-QGeoMapCircleObject::QGeoMapCircleObject()
- : d_ptr(new QGeoMapCircleObjectPrivate())
-{
- setUnits(QGeoMapObject::MeterUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Constructs a new circle object based on the circle \a circle.
-*/
-QGeoMapCircleObject::QGeoMapCircleObject(const QGeoBoundingCircle &circle)
- : d_ptr(new QGeoMapCircleObjectPrivate())
-{
- d_ptr->circle = circle;
- setUnits(QGeoMapObject::MeterUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Constructs a new circle object with a center at coordinate \a center
- and a radius in meters of \a radius.
-*/
-QGeoMapCircleObject::QGeoMapCircleObject(const QGeoCoordinate &center, qreal radius)
- : d_ptr(new QGeoMapCircleObjectPrivate())
-{
- d_ptr->circle = QGeoBoundingCircle(center, radius);
- setUnits(QGeoMapObject::MeterUnit);
- setTransformType(QGeoMapObject::ExactTransform);
- setOrigin(center);
-}
-
-/*!
- Destroys this circle object.
-*/
-QGeoMapCircleObject::~QGeoMapCircleObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapCircleObject::type() const
-{
- return QGeoMapObject::CircleType;
-}
-
-/*!
- \property QGeoMapCircleObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw an outline around the circle. The circle is
- filled using the QGeoMapCircleObject::brush property.
-
- The pen will be treated as a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-void QGeoMapCircleObject::setPen(const QPen &pen)
-{
- QPen newPen = pen;
- newPen.setCosmetic(true);
- const QPen oldPen = d_ptr->pen;
-
- if (oldPen == newPen)
- return;
-
- d_ptr->pen = newPen;
- emit penChanged(newPen);
-}
-
-QPen QGeoMapCircleObject::pen() const
-{
- return d_ptr->pen;
-}
-
-/*!
- \reimp
- */
-bool QGeoMapCircleObject::contains(const QGeoCoordinate &coordinate) const
-{
- return d_ptr->circle.contains(coordinate);
-}
-
-/*!
- \property QGeoMapCircleObject::brush
- \brief This property holds the brush that will be used to draw this object.
-
- The brush is used to fill in circle.
-
- The outline around the perimeter of the circle is drawn using the
- QGeoMapCircleObject::pen property.
-*/
-void QGeoMapCircleObject::setBrush(const QBrush &brush)
-{
- if (d_ptr->brush != brush) {
- d_ptr->brush = brush;
- emit brushChanged(brush);
- }
-}
-
-QBrush QGeoMapCircleObject::brush() const
-{
- return d_ptr->brush;
-}
-
-/*!
- \property QGeoMapCircleObject::pointCount
- \brief This property holds the number of vertices used in an approximate polygon.
-
- \since 1.2
-
- For a circle using ExactTransform, this property describes the number
- of sides that should be used to generate a polygonal approximation which
- is then transformed vertex-by-vertex into screen coordinates.
-*/
-quint32 QGeoMapCircleObject::pointCount() const
-{
- return d_ptr->pointCount;
-}
-
-void QGeoMapCircleObject::setPointCount(quint32 pointCount)
-{
- d_ptr->pointCount = pointCount;
-}
-
-/*!
- Returns a QGeoBoundingCircle instance which corresponds to the circle that
- will be drawn by this object.
-
- This is equivalent to
- \code
- QGeoMapCircleObject *object;
- // setup object
- QGeoBoundingCircle(object->center(), object->radius());
- \endcode
-*/
-QGeoBoundingCircle QGeoMapCircleObject::circle() const
-{
- return d_ptr->circle;
-}
-
-/*!
- Sets the circle that will be drawn by this object to \a circle.
-
- This is equivalent to
- \code
- QGeoMapCircleObject *object;
- // setup object
- object->setCenter(circle.center());
- object->setRadius(circle.radius());
- \endcode
-*/
-void QGeoMapCircleObject::setCircle(const QGeoBoundingCircle &circle)
-{
- QGeoBoundingCircle oldCircle = d_ptr->circle;
-
- if (oldCircle == circle)
- return;
-
- d_ptr->circle = circle;
- setOrigin(circle.center());
- setRadius(circle.radius());
-
- if (oldCircle.center() != d_ptr->circle.center())
- emit centerChanged(d_ptr->circle.center());
-
- if (oldCircle.radius() != d_ptr->circle.radius())
- emit radiusChanged(d_ptr->circle.radius());
-}
-
-/*!
- \property QGeoMapCircleObject::center
-
- \brief This property holds the coordinate of the center of the circle to be
- drawn by this circle object.
-
- The default value of this property is an invalid coordinate. While the
- value of this property is invalid the circle object will not be displayed.
-*/
-void QGeoMapCircleObject::setCenter(const QGeoCoordinate &center)
-{
- if (d_ptr->circle.center() != center) {
- d_ptr->circle.setCenter(center);
- setOrigin(center);
- emit centerChanged(center);
- }
-}
-
-QGeoCoordinate QGeoMapCircleObject::center() const
-{
- return d_ptr->circle.center();
-}
-
-/*!
- \property QGeoMapCircleObject::radius
- \brief This property holds the radius in metres of the circle that will be
- drawn by this circle object.
-
- The default value of this property is -1.0. While the value of this
- property is not greater than 0 the circle object will not be displayed.
-*/
-void QGeoMapCircleObject::setRadius(qreal radius)
-{
- if (d_ptr->circle.radius() != radius) {
- d_ptr->circle.setRadius(radius);
- emit radiusChanged(radius);
- }
-}
-
-qreal QGeoMapCircleObject::radius() const
-{
- return d_ptr->circle.radius();
-}
-
-/*!
-\fn void QGeoMapCircleObject::centerChanged(const QGeoCoordinate &center)
-
- This signal is emitted when the center of the circle object has
- changed.
-
- The new value is \a center.
-*/
-
-/*!
-\fn void QGeoMapCircleObject::radiusChanged(qreal radius)
-
- This signal is emitted when the radius of the circle object has
- changed.
-
- The new value is \a radius.
-*/
-
-/*!
-\fn void QGeoMapCircleObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw the edge of
- the circle object has changed.
-
- The new value is \a pen.
-*/
-
-/*!
-\fn void QGeoMapCircleObject::brushChanged(const QBrush &brush)
-
- This signal is emitted when the brush used to fill the inside of
- the circle object has changed.
-
- The new value is \a brush.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapCircleObjectPrivate::QGeoMapCircleObjectPrivate() :
- pointCount(120)
-{
- pen.setCosmetic(true);
-}
-
-QGeoMapCircleObjectPrivate::~QGeoMapCircleObjectPrivate()
-{
-}
-
-#include "moc_qgeomapcircleobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomapcircleobject.h b/src/location/maps/qgeomapcircleobject.h
deleted file mode 100644
index 5fce4504..00000000
--- a/src/location/maps/qgeomapcircleobject.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPCIRCLEOBJECT_H
-#define QGEOMAPCIRCLEOBJECT_H
-
-#include "qgeomapobject.h"
-
-#include <QMetaType>
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoBoundingCircle;
-class QGeoMapCircleObjectPrivate;
-
-class Q_LOCATION_EXPORT QGeoMapCircleObject : public QGeoMapObject
-{
- Q_OBJECT
-public:
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
- Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
- Q_PROPERTY(quint32 pointCount READ pointCount WRITE setPointCount)
-
- QGeoMapCircleObject();
- QGeoMapCircleObject(const QGeoBoundingCircle &circle);
- QGeoMapCircleObject(const QGeoCoordinate &center, qreal radius);
- ~QGeoMapCircleObject();
-
- QGeoMapObject::Type type() const;
-
- QGeoBoundingCircle circle() const;
- void setCircle(const QGeoBoundingCircle &circle);
-
- bool contains(const QGeoCoordinate &coordinate) const;
-
- QGeoCoordinate center() const;
- void setCenter(const QGeoCoordinate &center);
-
- qreal radius() const;
- void setRadius(qreal radius);
-
- QPen pen() const;
- void setPen(const QPen &pen);
-
- QBrush brush() const;
- void setBrush(const QBrush &brush);
-
- quint32 pointCount() const;
- void setPointCount(quint32 pointCount);
-
-Q_SIGNALS:
- void centerChanged(const QGeoCoordinate &center);
- void radiusChanged(qreal radius);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
-
-private:
- QGeoMapCircleObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapCircleObject)
- Q_DISABLE_COPY(QGeoMapCircleObject)
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(qreal)
-
-#endif
diff --git a/src/location/maps/qgeomapcircleobject_p.h b/src/location/maps/qgeomapcircleobject_p.h
deleted file mode 100644
index 565f6b3c..00000000
--- a/src/location/maps/qgeomapcircleobject_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPCIRCLEOBJECT_P_H
-#define QGEOMAPCIRCLEOBJECT_P_H
-
-#include <QPen>
-#include <QBrush>
-
-#include "qgeoboundingcircle.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapCircleObjectPrivate
-{
-public:
- QGeoMapCircleObjectPrivate();
- ~QGeoMapCircleObjectPrivate();
-
- QGeoBoundingCircle circle;
- QPen pen;
- QBrush brush;
- quint32 pointCount;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomapcustomobject.cpp b/src/location/maps/qgeomapcustomobject.cpp
deleted file mode 100644
index 77203818..00000000
--- a/src/location/maps/qgeomapcustomobject.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapcustomobject.h"
-#include "qgeomapcustomobject_p.h"
-#include "qgeoboundingbox.h"
-
-#include <QGraphicsItem>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapCustomObject
- \brief The QGeoMapCustomObject class is a QGeoMapObject used to draw
- a QGraphicsItem on a map.
-
- \inmodule QtLocation
-
- \ingroup maps-mapping-objects
- \since 1.2
-
- Any arbitrary QGraphicsItem can be associated with a QGeoMapCustomObject, and to
- this end it contains support for interpreting the coordinates of the
- QGraphicsItem in a variety of different ways.
-
- For example, the following code creates a QGraphicsEllipseItem and a
- QGeoMapCustomObject to display it. The EllipseItem extends from the origin point,
- out 20 meters to the east and 30 metres south.
-
- \code
- QGraphicsEllipseItem *ellipseItem = new QGraphicsEllipseItem;
- ellipseItem->setRect(0, 0, 20, 30);
-
- QGeoMapCustomObject *mapObject = new QGeoMapCustomObject;
- mapObject->setGraphicsItem(ellipseItem);
- mapObject->setUnits(QGeoMapObject::MeterUnit);
- mapObject->setOrigin(QGeoCoordinate(-27.5796, 153.1));
- \endcode
-
- \section2 Units and coordinates
-
- The local units and coordinates of the QGraphicsItem are transformed
- onto the map based on the \a units, \a origin, \a transformType and
- \a transform properties. Several systems are available, including
- pixels, meters and seconds of arc.
-
- It should be noted that both pixel and meter coordinate systems are south-
- oriented (ie, positive Y axis faces south on the map). However, the
- RelativeArcSeconds unit system faces north to align with the standard
- latitude grid. The Y axis can be flipped if necessary by making use of the
- GraphicsItem's \a transform property
-
- \code
- QTransform northFlip;
- northFlip.scale(0, -1);
-
- ellipseItem->setTransform(northFlip);
- \endcode
-
- \section2 Transform methods
-
- Normally, the GraphicsItem will be transformed into map coordinates using
- a bilinear interpolation. Another option is the ExactTransform, which
- converts the GraphicsItem exactly into map coordinates, but is only available
- for certain subclasses of QGraphicsItem. Other interpolation methods may
- be provided in future for greater accuracy near poles and in different
- map projections, without the limitations of ExactTransform.
-
- Calling setUnits() or setting the units property will result in the
- default value of transformType being restored. See QGeoMapObject::transformType
- for more details.
-
- \section2 Caveats
-
- Other than the coordinate system features, there are a few differences
- with using QGraphicsItems on a map compared to using them on a standard
- QGraphicsScene. One of the most important of these is the use of the
- \a update() function. When an application changes anything that has an
- effect upon the appearance, size, shape etc of the QGraphicsItem, it
- must call \a QGeoMapCustomObject::update() to ensure that the map is updated.
-
- Another is the use of child items of a QGraphicsItem. These are supported
- in more or less the same manner as in QGraphicsScene, with the exception
- of use in concert with \a ExactTransform -- any object with transformType
- set to \a ExactTransform will not have children of its QGraphicsItem drawn
- on the map.
-*/
-
-/*!
- Constructs a new custom object.
-*/
-QGeoMapCustomObject::QGeoMapCustomObject()
- : d_ptr(new QGeoMapCustomObjectPrivate())
-{
-}
-
-/*!
- Constructs a new custom object which will draw a QGraphicsItem at an
- offset of \a offset pixels from the coordinate \a coordinate.
-*/
-QGeoMapCustomObject::QGeoMapCustomObject(const QGeoCoordinate &coordinate, const QPoint &offset)
- : d_ptr(new QGeoMapCustomObjectPrivate())
-{
- setOrigin(coordinate);
- d_ptr->offset = offset;
-}
-
-/*!
- Destroys this custom object.
-*/
-QGeoMapCustomObject::~QGeoMapCustomObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapCustomObject::type() const
-{
- return QGeoMapObject::CustomType;
-}
-
-/*!
- If the graphics item is modified this
- method should be called immediately afterwards to inform
- the map that an update is required. .
-
- This method causes the triggerUpdate() signal to be emitted.
-*/
-void QGeoMapCustomObject::update()
-{
- emit triggerUpdate();
-}
-
-/*!
-\fn void QGeoMapCustomObject::triggerUpdate()
-
- This signal indicates that the graphics item has
- changed and that the map needs to be updated.
-*/
-
-/*!
- \property QGeoMapCustomObject::graphicsItem
- \brief This property holds the graphics item which will
- be drawn by this custom object.
-
- If the graphics item is 0 then nothing will be drawn.
-*/
-
-QGraphicsItem* QGeoMapCustomObject::graphicsItem() const
-{
- return d_ptr->graphicsItem;
-}
-
-void QGeoMapCustomObject::setGraphicsItem(QGraphicsItem *graphicsItem)
-{
- if (d_ptr->graphicsItem == graphicsItem)
- return;
-
- d_ptr->graphicsItem = graphicsItem;
-
- emit graphicsItemChanged(graphicsItem);
-}
-
-/*!
-\fn void QGeoMapCustomObject::graphicsItemChanged(QGraphicsItem *graphicsItem)
-
- This signal is emitted when the graphics item which this custom object
- draws is changed.
-
- The new value will be \a graphicsItem.
-*/
-
-/*!
- \property QGeoMapCustomObject::offset
- \brief This property holds the offset in pixels at which the graphics
- item will be drawn by this custom object.
-
- The default value of this property is QPoint(0, 0). If this value is not
- changed the upper left coordinate of the graphics item will be drawn at the
- coordinate specified by QGeoMapCustomObject::coordinate.
-
- The offset is in pixels and is independent of the zoom level of the map.
-*/
-QPoint QGeoMapCustomObject::offset() const
-{
- return d_ptr->offset;
-// QPointF pt = d_ptr->offset;
-//
-// QPoint rounded;
-// rounded.setX(int(pt.x() > 0 ? pt.x() + 0.5 : pt.x() - 0.5));
-// rounded.setY(int(pt.y() > 0 ? pt.y() + 0.5 : pt.y() - 0.5));
-//
-// return rounded;
-}
-
-void QGeoMapCustomObject::setOffset(const QPoint &offset)
-{
- if (d_ptr->offset != offset) {
- d_ptr->offset = offset;
- emit offsetChanged(offset);
- }
-}
-
-/*!
-\fn void QGeoMapCustomObject::offsetChanged(const QPoint &offset)
-
- This signal is emitted when the on-screen offset from the coordinate
- at which this custom object should be drawn has changed.
-
- The new value will be \a offset.
-*/
-
-/*!
- Sets the origin of the object to \a origin.
-*/
-void QGeoMapCustomObject::setOrigin(const QGeoCoordinate &origin)
-{
- QGeoMapObject::setOrigin(origin);
-}
-
-/*!
- Sets the coordinate units of the object to \a unit.
-
- Note that setting this property will reset the transformType property to
- the default for the units given. For PixelUnit, this is ExactTransform,
- and for all others, BilinearTransform.
-*/
-void QGeoMapCustomObject::setUnits(const CoordinateUnit &unit)
-{
- QGeoMapObject::setUnits(unit);
-}
-
-/*!
- Sets the transform type of the object to \a type.
-*/
-void QGeoMapCustomObject::setTransformType(const TransformType &type)
-{
- QGeoMapObject::setTransformType(type);
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapCustomObjectPrivate::QGeoMapCustomObjectPrivate()
- : graphicsItem(0) {}
-
-QGeoMapCustomObjectPrivate::~QGeoMapCustomObjectPrivate()
-{
-}
-
-#include "moc_qgeomapcustomobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomapcustomobject_p.h b/src/location/maps/qgeomapcustomobject_p.h
deleted file mode 100644
index 5387f193..00000000
--- a/src/location/maps/qgeomapcustomobject_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPCUSTOMOBJECT_P_H
-#define QGEOMAPCUSTOMOBJECT_P_H
-
-#include "qgeocoordinate.h"
-
-#include <QPoint>
-
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsItem;
-class QGeoMapCustomObjectPrivate
-{
-public:
- QGeoMapCustomObjectPrivate();
- ~QGeoMapCustomObjectPrivate();
-
- QGraphicsItem *graphicsItem;
- QPoint offset;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomapdata.cpp b/src/location/maps/qgeomapdata.cpp
deleted file mode 100644
index 6f7a2be3..00000000
--- a/src/location/maps/qgeomapdata.cpp
+++ /dev/null
@@ -1,836 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapdata.h"
-#include "qgeomapdata_p.h"
-
-#include <QGraphicsScene>
-#include <QGraphicsItem>
-#include <QGraphicsPolygonItem>
-#include <QGraphicsLineItem>
-#include <QGraphicsEllipseItem>
-#include <QGraphicsPathItem>
-
-#include "qgeoboundingbox.h"
-#include "qgeocoordinate.h"
-#include "qgraphicsgeomap.h"
-#include "qgeomapobject.h"
-#include "qgeomappixmapobject.h"
-#include "qgeomapgroupobject.h"
-#include "qgeomaptextobject.h"
-#include "qgeomappingmanagerengine.h"
-#include "qgeomapoverlay.h"
-
-#include "qgeomapobjectengine_p.h"
-#include "qgeomapobject_p.h"
-#include <private/projwrapper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapData
-
- \brief The QGeoMapData class are used as a bridge between QGraphicsGeoMap and
- QGeoMappingManager.
-
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-impl
-
- Instances of QGeoMapData are created with
- QGeoMappingManager::createMapData(), and are used internally by
- QGraphicsGeoMap to manage the state of the map and the associated
- QGeoMapObject instances.
-
- Plugin implementers will need to provide implementations of
- coordinateToScreenPosition(const QGeoCoordinate &coordinate) and
- QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition).
-
- The other virtual functions can be overridden. If the screen position to
- coordinate tranformations are expensive then overriding these functions may
- allow optimizations based on caching parts of the geometry information.
-
- Subclasses should override createMapObjectInfo() so that QGeoMapObjectInfo
- instances will be created for each QGeoMapObject type in order to provide
- the QGeoMapData subclass specific behaviours for the map objects.
- */
-
-/*!
- Constructs a new map data object, which makes use of the functionality provided by \a engine.
-*/
-QGeoMapData::QGeoMapData(QGeoMappingManagerEngine *engine)
- : d_ptr(new QGeoMapDataPrivate(this, engine))
-{
- if (engine->supportedConnectivityModes().length() > 0)
- setConnectivityMode(engine->supportedConnectivityModes().at(0));
- else
- setConnectivityMode(QGraphicsGeoMap::NoConnectivity);
-}
-
-/*!
- \internal
-*/
-QGeoMapData::QGeoMapData(QGeoMapDataPrivate *dd) : d_ptr(dd) {}
-
-/*!
- Destroys this map data object.
-*/
-QGeoMapData::~QGeoMapData()
-{
- Q_D(QGeoMapData);
- delete d;
-}
-
-/*!
- This function is run after the QGeoMapData instance has been
- constructed.
-
- Any subclasses which override this function should make sure that
- QGeoMapData::init() is called within the body of the overriding function.
-*/
-void QGeoMapData::init()
-{
- d_ptr->containerObject = new QGeoMapGroupObject();
- d_ptr->containerObject->setMapData(this);
-}
-
-/*!
- Returns the mapping engine that this map data object is associated with.
-*/
-QGeoMappingManagerEngine* QGeoMapData::engine() const
-{
- return d_ptr->engine;
-}
-
-/*!
- Returns the QGeoMapObject which acts as the parent to all QGeoMapObject
- instances which are added to the map by the user.
-*/
-QGeoMapObject* QGeoMapData::containerObject()
-{
- return d_ptr->containerObject;
-}
-
-/*!
- Sets the size of the map viewport to \a size.
-
- The size will be adjusted by the associated QGraphicsGeoMap as it resizes.
-*/
-void QGeoMapData::setWindowSize(const QSizeF &size)
-{
- if (d_ptr->windowSize == size)
- return;
-
- d_ptr->windowSize = size;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit windowSizeChanged(d_ptr->windowSize);
-}
-
-/*!
- \property QGeoMapData::windowSize
- Returns the size of the map viewport.
-
- The size will be adjusted by the associated QGraphicsGeoMap as it resizes.
-*/
-QSizeF QGeoMapData::windowSize() const
-{
- return d_ptr->windowSize;
-}
-
-/*!
- Sets the zoom level of the map to \a zoomLevel.
-
- Larger values of the zoom level correspond to more detailed views of the
- map.
-
- If \a zoomLevel is less than minimumZoomLevel() then minimumZoomLevel()
- will be used, and if \a zoomLevel is larger than
- maximumZoomLevel() then maximumZoomLevel() will be used.
-*/
-void QGeoMapData::setZoomLevel(qreal zoomLevel)
-{
- zoomLevel = qMin(zoomLevel, d_ptr->engine->maximumZoomLevel());
- zoomLevel = qMax(zoomLevel, d_ptr->engine->minimumZoomLevel());
-
- if (d_ptr->zoomLevel == zoomLevel)
- return;
-
- d_ptr->zoomLevel = zoomLevel;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit zoomLevelChanged(d_ptr->zoomLevel);
-}
-
-/*!
- \property QGeoMapData::zoomLevel
-
- Returns the zoom level of the map.
-
- Larger values of the zoom level correspond to more detailed views of the
- map.
-*/
-qreal QGeoMapData::zoomLevel() const
-{
- return d_ptr->zoomLevel;
-}
-
-/*!
- \property QGeoMapData::supportsBearing
-
- Returns whether bearing is supported by this engine.
-*/
-bool QGeoMapData::supportsBearing() const
-{
- return d_ptr->engine->supportsBearing();
-}
-
-/*!
- Sets the bearing of the map to \a bearing.
-
- Value in degrees in the range of 0-360. 0 being equivalent to 0 degrees from
- north.
-*/
-void QGeoMapData::setBearing(qreal bearing)
-{
- if (!supportsBearing())
- return;
-
- bearing = qMin(bearing, qreal(360.0));
- bearing = qMax(bearing, qreal(0.0));
-
- if (d_ptr->bearing == bearing)
- return;
-
- d_ptr->bearing = bearing;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit bearingChanged(d_ptr->bearing);
-}
-
-/*!
- \property QGeoMapData::bearing
-
- Returns the current bearing of the map.
-
- Value in degrees in the range of 0-360. 0 being equivalent to 0 degrees from
- north.
-*/
-qreal QGeoMapData::bearing() const
-{
- return d_ptr->bearing;
-}
-
-/*!
- \property QGeoMapData::supportsTilting
-
- Returns whether tilting is supported by this engine.
-*/
-bool QGeoMapData::supportsTilting() const
-{
- return d_ptr->engine->supportsTilting();
-}
-
-/*!
- \property QGeoMapData::minimumTilt
-
- Returns minimum tilt supported by this engine.
-*/
-qreal QGeoMapData::minimumTilt() const
-{
- return d_ptr->engine->minimumTilt();
-}
-
-/*!
- \property QGeoMapData::maximumTilt
-
- Returns maximum tilt supported by this engine.
-*/
-qreal QGeoMapData::maximumTilt() const
-{
- return d_ptr->engine->maximumTilt();
-}
-
-/*!
- Sets the tilt of the map to \a tilt.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-
- If \a tilt is less than minimumTilt() then minimumTilt()
- will be used, and if \a tilt is larger than
- maximumTilt() then maximumTilt() will be used.
-*/
-void QGeoMapData::setTilt(qreal tilt)
-{
- if (!supportsTilting())
- return;
-
- tilt = qMin(tilt, d_ptr->engine->maximumTilt());
- tilt = qMax(tilt, d_ptr->engine->minimumTilt());
-
- if (d_ptr->tilt == tilt)
- return;
-
- d_ptr->tilt = tilt;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit tiltChanged(d_ptr->tilt);
-}
-
-/*!
- \property QGeoMapData::tilt
-
- Returns the current tilt of the map.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-*/
-qreal QGeoMapData::tilt() const
-{
- return d_ptr->tilt;
-}
-
-/*!
- Pans the map view \a dx pixels in the x direction and \a dy pixels
- in the y direction.
-
- The x and y axes are specified in Graphics View Framework coordinates.
- By default this will mean that positive values of \a dx move the
- viewed area to the right and that positive values of \a dy move the
- viewed area down.
-
- Subclasses should call QGeoMapData::setCenter() when the pan has completed.
-*/
-void QGeoMapData::pan(int dx, int dy)
-{
- QPointF pos = coordinateToScreenPosition(center());
- setCenter(screenPositionToCoordinate(QPointF(pos.x() + dx, pos.y() + dy)));
-}
-
-/*!
- Centers the map viewport on the coordinate \a center.
-*/
-void QGeoMapData::setCenter(const QGeoCoordinate &center)
-{
- if (d_ptr->center == center)
- return;
-
- d_ptr->center = center;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit centerChanged(d_ptr->center);
-}
-
-/*!
- \property QGeoMapData::center
-
- Returns the coordinate of the point in the center of the map viewport.
-*/
-QGeoCoordinate QGeoMapData::center() const
-{
- return d_ptr->center;
-}
-
-/*!
- Changes the type of map data to display to \a mapType.
-*/
-void QGeoMapData::setMapType(QGraphicsGeoMap::MapType mapType)
-{
- if (d_ptr->mapType == mapType)
- return;
-
- d_ptr->mapType = mapType;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit mapTypeChanged(mapType);
-}
-
-/*!
- \property QGeoMapData::mapType
-
- Returns the type of map data which is being displayed.
-*/
-QGraphicsGeoMap::MapType QGeoMapData::mapType() const
-{
- return d_ptr->mapType;
-}
-
-/*!
- Changes the connectivity mode of this map to \a connectivityMode
-*/
-void QGeoMapData::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
-{
- if (d_ptr->connectivityMode == connectivityMode)
- return;
-
- d_ptr->connectivityMode = connectivityMode;
-
- if (!d_ptr->blockPropertyChangeSignals)
- emit connectivityModeChanged(connectivityMode);
-}
-
-/*!
- \property QGeoMapData::connectivityMode
-
- Returns the connectivity mode for this map.
-*/
-QGraphicsGeoMap::ConnectivityMode QGeoMapData::connectivityMode() const
-{
- return d_ptr->connectivityMode;
-}
-
-/*!
- Returns the map objects associated with this map.
-*/
-QList<QGeoMapObject*> QGeoMapData::mapObjects() const
-{
- return d_ptr->containerObject->childObjects();
-}
-
-/*!
- Adds \a mapObject to the list of map objects managed by this map.
-
- The children objects are drawn in order of the QGeoMapObject::zValue()
- value. Children objects having the same z value will be drawn
- in the order they were added.
-
- The map will take ownership of the \a mapObject.
-*/
-void QGeoMapData::addMapObject(QGeoMapObject *mapObject)
-{
- d_ptr->addObject(mapObject);
-}
-
-/*!
- Removes \a mapObject from the list of map objects managed by this map.
- The map will release ownership of the \a mapObject.
-*/
-void QGeoMapData::removeMapObject(QGeoMapObject *mapObject)
-{
- d_ptr->removeObject(mapObject);
-}
-
-/*!
- Clears the map objects associated with this map.
-
- The map objects will be deleted.
-*/
-void QGeoMapData::clearMapObjects()
-{
- d_ptr->clearObjects();
-}
-
-/*!
- \fn QGeoBoundingBox QGeoMapData::viewport() const
- Returns a bounding box corresponding to the physical area displayed
- in the viewport of the map.
-
- The bounding box which is returned is defined by the upper left and
- lower right corners of the visible area of the map.
-*/
-
-/*!
- \fn void QGeoMapData::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
-
- Attempts to fit the bounding box \a bounds into the viewport of the map.
-
- This method will change the zoom level to the maximum zoom level such
- that all of \a bounds is visible within the resulting viewport.
-
- If \a preserveViewportCenter is false the map will be centered on the
- bounding box \a bounds before the zoom level is changed, otherwise the
- center of the map will not be changed.
-*/
-
-/*!
- Returns the list of visible map objects managed by this map which
- contain the point \a screenPosition within their boundaries.
-*/
-QList<QGeoMapObject*> QGeoMapData::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
-{
- QList<QGeoMapObject*> results;
-
- QGeoCoordinate coord = screenPositionToCoordinate(screenPosition);
- int childObjectCount = d_ptr->containerObject->childObjects().count();
- for (int i = 0; i < childObjectCount; ++i) {
- QGeoMapObject *object = d_ptr->containerObject->childObjects().at(i);
- if (object->contains(coord) && object->isVisible())
- results.append(object);
- }
-
- return results;
-}
-
-/*!
- Returns the list of visible map objects managed by this map which are displayed at
- least partially within the on screen rectangle \a screenRect.
-*/
-QList<QGeoMapObject*> QGeoMapData::mapObjectsInScreenRect(const QRectF &screenRect) const
-{
- QList<QGeoMapObject*> results;
-
- QGeoCoordinate topLeft = screenPositionToCoordinate(screenRect.topLeft());
- QGeoCoordinate bottomRight = screenPositionToCoordinate(screenRect.bottomRight());
-
- QGeoBoundingBox bounds(topLeft, bottomRight);
-
- int childObjectCount = d_ptr->containerObject->childObjects().count();
- for (int i = 0; i < childObjectCount; ++i) {
- QGeoMapObject *object = d_ptr->containerObject->childObjects().at(i);
- if (bounds.intersects(object->boundingBox()) && object->isVisible())
- results.append(object);
- }
-
- return results;
-}
-
-/*!
- Returns the list of visible map objects manager by this widget which
- are displayed at least partially within the viewport of the map.
-*/
-QList<QGeoMapObject*> QGeoMapData::mapObjectsInViewport() const
-{
- return this->mapObjectsInScreenRect(QRectF(0.0,
- 0.0,
- d_ptr->windowSize.width(),
- d_ptr->windowSize.height()));
-}
-
-/*!
-\fn QPointF QGeoMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
-
- Returns the position on the screen at which \a coordinate is displayed.
-
- An invalid QPointF will be returned if \a coordinate is invalid or is not
- within the current viewport.
-*/
-
-/*!
-\fn QGeoCoordinate QGeoMapData::screenPositionToCoordinate(const QPointF &screenPosition) const
-
- Returns the coordinate corresponding to the point in the viewport at \a
- screenPosition.
-
- An invalid QGeoCoordinate will be returned if \a screenPosition is invalid
- or is not within the current viewport.
-*/
-
-/*!
- Paints the map and everything associated with it on \a painter, using the
- options \a option.
-
- This will paint the map with paintMap(), then the map overlays with
- QGeoMapOverlay::paint(), then the map objects with paintObjects(), and
- finally paintProviderNotices().
-*/
-void QGeoMapData::paint(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- paintMap(painter, option);
-
- for (int i = 0; i < d_ptr->overlays.size(); ++i)
- d_ptr->overlays[i]->paint(painter, option);
-
- paintObjects(painter, option);
-
- paintProviderNotices(painter, option);
-}
-
-/*!
- Paints the map on \a painter, using the options \a option.
-
- The map overlays, map objects and the provider notices (such as copyright
- and powered by notices) are painted in separate methods, which are combined
- in the paint() method.
-
- The default implementation does not paint anything.
-*/
-void QGeoMapData::paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- Q_UNUSED(painter)
- Q_UNUSED(option)
-}
-
-/*!
- Paints the map objects on \a painter, using the options \a option.
-
- The default implementation makes use of the coordinateToScreenPosition
- implemented by the subclass to perform object positioning and rendering.
-
- This implementation should suffice for most common use cases, and supports
- the full range of coordinate systems and transforms available to a
- QGeoMapObject.
-*/
-void QGeoMapData::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- Q_UNUSED(painter)
- Q_UNUSED(option)
-}
-
-/*!
- Paints the provider notices on \a painter, using the options \a option.
-
- The provider notices are things like the copyright and powered by notices.
-
- The provider may not want the client developers to be able to move the
- notices from their standard positions and so we have not provided API
- support for specifying the position of the notices at this time.
-
- If support for hinting at the position of the notices is to be provided by
- plugin parameters, the suggested parameter keys are
- "mapping.notices.copyright.alignment" and
- "mapping.notices.poweredby.alignment", with type Qt::Alignment.
-
- The default implementation does not paint anything.
-*/
-void QGeoMapData::paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- Q_UNUSED(painter)
- Q_UNUSED(option)
-}
-
-/*!
- Creates a QGeoMapObjectInfo instance which implements the behaviours o
- the map object \a object which are specific to this QGeoMapData.
-
- The default implementation returns 0.
-*/
-QGeoMapObjectInfo *QGeoMapData::createMapObjectInfo(QGeoMapObject *object)
-{
- Q_UNUSED(object);
- return 0;
-}
-
-/*!
- Returns the map overlays associated with this map.
-*/
-QList<QGeoMapOverlay*> QGeoMapData::mapOverlays() const
-{
- return d_ptr->overlays;
-}
-
-/*!
- Adds \a overlay to the list of map overlays associated with this map.
-
- The overlays will be drawn in the order in which they were added.
-
- The map will take ownership of \a overlay.
-*/
-void QGeoMapData::addMapOverlay(QGeoMapOverlay *overlay)
-{
- if (!overlay)
- return;
-
- overlay->setMapData(this);
- d_ptr->overlays.append(overlay);
-}
-
-/*!
- Removes \a overlay from the list of map overlays associated with this map.
-
- The map will release ownership of \a overlay.
-*/
-void QGeoMapData::removeMapOverlay(QGeoMapOverlay *overlay)
-{
- if (!overlay)
- return;
-
- d_ptr->overlays.removeAll(overlay);
-}
-
-/*!
- Clears the map overlays associated with this map.
-
- The map overlays will be deleted.
-*/
-void QGeoMapData::clearMapOverlays()
-{
- qDeleteAll(d_ptr->overlays);
- d_ptr->overlays.clear();
-}
-
-
-/*!
- Sets whether changes to properties will trigger their corresponding signals to \a block.
-
- By default the QGeoMapData implementations of the property functions are used
- which cause the property notification signals to be emitted immediately.
-
- Calling this function with \a block set to true will prevent these
- signals from being called, which will allow a subclass to defer the
- emission of the signal until a later time.
-
- If this function needs to be called it should be used as soon as possible,
- preferably in the constructor of the QGeoMapData subclass.
-*/
-void QGeoMapData::setBlockPropertyChangeSignals(bool block)
-{
- d_ptr->blockPropertyChangeSignals = block;
-}
-
-/*!
-\fn void QGeoMapData::windowSizeChanged(const QSizeF &windowSize)
-
- This signal is emitted when the size of the window which contains
- the map has changed.
-
- The new value is \a windowSize.
-*/
-
-/*!
-\fn void QGeoMapData::zoomLevelChanged(qreal zoomLevel)
-
- This signal is emitted when the zoom level of the map has changed.
-
- The new value is \a zoomLevel.
-*/
-
-/*!
-\fn void QGeoMapData::bearingChanged(qreal bearing)
-
- This signal is emitted when the bearing of the map has changed.
-
- The new value is \a bearing.
-*/
-
-/*!
-\fn void QGeoMapData::tiltChanged(qreal tilt)
-
- This signal is emitted when the tilt of the map has changed.
-
- The new value is \a tilt.
-*/
-
-/*!
-\fn void QGeoMapData::centerChanged(const QGeoCoordinate &coordinate)
-
- This signal is emitted when the center of the map has changed.
-
- The new value is \a coordinate.
-*/
-
-/*!
-\fn void QGeoMapData::mapTypeChanged(QGraphicsGeoMap::MapType mapType)
-
- This signal is emitted when the type of the map has changes.
-
- The value is \a mapType.
-*/
-
-/*!
-\fn void QGeoMapData::connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode)
-
- This signal is emitted when the connectivity mode used to fetch the
- map data has changed.
-
- The new value is \a connectivityMode.
-*/
-
-/*!
-\fn void QGeoMapData::updateMapDisplay(const QRectF &target)
-
- This signal is emitted when the region \a target of the window which
- contains the map needs to be updated.
-
-
- If \a target is empty then the entire map will be updated.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapDataPrivate::QGeoMapDataPrivate(QGeoMapData *parent, QGeoMappingManagerEngine *engine)
- : QObject(0),
- engine(engine),
- containerObject(0),
- zoomLevel(-1.0),
- shiftSinceLastInval(0, 0),
- bearing(0.0),
- tilt(0.0),
- windowSize(0, 0),
- blockPropertyChangeSignals(false),
- q_ptr(parent)
-{}
-
-QGeoMapDataPrivate::~QGeoMapDataPrivate()
-{
- if (containerObject)
- delete containerObject;
- qDeleteAll(overlays);
-}
-
-void QGeoMapDataPrivate::addObject(QGeoMapObject *object)
-{
- containerObject->addChildObject(object);
- //emit q_ptr->updateMapDisplay();
-}
-
-void QGeoMapDataPrivate::removeObject(QGeoMapObject *object)
-{
- containerObject->removeChildObject(object);
-}
-
-void QGeoMapDataPrivate::clearObjects()
-{
- foreach (QGeoMapObject *obj, containerObject->childObjects()) {
- this->removeObject(obj);
- delete obj;
- }
-}
-
-QPointF QGeoMapDataPrivate::coordinateToScreenPosition(double lon, double lat) const
-{
- QGeoCoordinate c(lon, lat);
- return q_ptr->coordinateToScreenPosition(c);
-}
-
-void QGeoMapDataPrivate::emitUpdateMapDisplay(const QRectF &target)
-{
- emit q_ptr->updateMapDisplay(target);
-}
-
-
-#include "moc_qgeomapdata.cpp"
-#include "moc_qgeomapdata_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapdata.h b/src/location/maps/qgeomapdata.h
deleted file mode 100644
index 20a22a24..00000000
--- a/src/location/maps/qgeomapdata.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPDATA_H
-#define QGEOMAPDATA_H
-
-#include "qgraphicsgeomap.h"
-
-#include <QObject>
-#include <QSize>
-#include <QRectF>
-#include <QPainter>
-#include <QStyleOptionGraphicsItem>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoBoundingBox;
-class QGeoMappingManagerEngine;
-class QGeoMapObject;
-class QGeoMapGroupObject;
-class QGeoMapDataPrivate;
-class QGeoMapOverlay;
-class QGeoMapObjectInfo;
-
-class Q_LOCATION_EXPORT QGeoMapData : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QSizeF windowSize READ windowSize WRITE setWindowSize NOTIFY windowSizeChanged)
- Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
- Q_PROPERTY(QGraphicsGeoMap::MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
- Q_PROPERTY(QGraphicsGeoMap::ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
- Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
- Q_PROPERTY(qreal minimumTilt READ minimumTilt CONSTANT)
- Q_PROPERTY(qreal maximumTilt READ maximumTilt CONSTANT)
- Q_PROPERTY(bool supportsTilting READ supportsTilting CONSTANT)
- Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
- Q_PROPERTY(bool supportsBearing READ supportsBearing CONSTANT)
-
-public:
- QGeoMapData(QGeoMappingManagerEngine *engine);
- virtual ~QGeoMapData();
-
- virtual void init();
-
- virtual void setWindowSize(const QSizeF &size);
- virtual QSizeF windowSize() const;
-
- virtual void setZoomLevel(qreal zoomLevel);
- virtual qreal zoomLevel() const;
-
- bool supportsBearing() const;
- void setBearing(qreal bearing);
- qreal bearing() const;
-
- bool supportsTilting() const;
- void setTilt(qreal tilt);
- qreal tilt() const;
- qreal minimumTilt() const;
- qreal maximumTilt() const;
-
- virtual void pan(int dx, int dy);
-
- virtual void setCenter(const QGeoCoordinate &center);
- virtual QGeoCoordinate center() const;
-
- virtual void setMapType(QGraphicsGeoMap::MapType mapType);
- virtual QGraphicsGeoMap::MapType mapType() const;
-
- virtual void setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode);
- virtual QGraphicsGeoMap::ConnectivityMode connectivityMode() const;
-
- QList<QGeoMapObject*> mapObjects() const;
- void addMapObject(QGeoMapObject *mapObject);
- void removeMapObject(QGeoMapObject *mapObject);
- void clearMapObjects();
-
- virtual QGeoBoundingBox viewport() const = 0;
- virtual void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false) = 0;
-
- virtual QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
- virtual QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
- virtual QList<QGeoMapObject*> mapObjectsInViewport() const;
-
- QList<QGeoMapOverlay*> mapOverlays() const;
- void addMapOverlay(QGeoMapOverlay *overlay);
- void removeMapOverlay(QGeoMapOverlay *overlay);
- void clearMapOverlays();
-
- virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const = 0;
- virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition) const = 0;
-
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option);
-
-protected:
- QGeoMapData(QGeoMapDataPrivate *dd);
-
- QGeoMappingManagerEngine* engine() const;
- QGeoMapObject* containerObject();
-
- void setBlockPropertyChangeSignals(bool block);
-
- virtual void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
- virtual void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
- virtual void paintProviderNotices(QPainter *painter, const QStyleOptionGraphicsItem *option);
-
- virtual QGeoMapObjectInfo* createMapObjectInfo(QGeoMapObject *object);
-
- QGeoMapDataPrivate* d_ptr;
-
-Q_SIGNALS:
- void windowSizeChanged(const QSizeF &windowSize);
- void zoomLevelChanged(qreal zoomLevel);
- void centerChanged(const QGeoCoordinate &coordinate);
- void mapTypeChanged(QGraphicsGeoMap::MapType mapType);
- void connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode);
- void updateMapDisplay(const QRectF &target = QRectF());
- void bearingChanged(qreal bearing);
- void tiltChanged(qreal tilt);
-
-private:
- Q_DECLARE_PRIVATE(QGeoMapData)
- Q_DISABLE_COPY(QGeoMapData)
-
- friend class QGeoMapObject;
- friend class QGeoMapObjectInfo;
- friend class QGeoMapGroupObject;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomapgroupobject.cpp b/src/location/maps/qgeomapgroupobject.cpp
deleted file mode 100644
index 07b19441..00000000
--- a/src/location/maps/qgeomapgroupobject.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapgroupobject.h"
-#include "qgeomapgroupobject_p.h"
-
-#include "qgeomapobject_p.h"
-#include "qgeomapobjectengine_p.h"
-
-#include "qgeocoordinate.h"
-#include "qgeoboundingbox.h"
-
-#include "qgeomapdata.h"
-#include "qgeomapdata_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapGroupObject
- \brief The QGeoMapGroupObject class is a QGeoMapObject used to
- manager a group of other map objects.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The QGeoMapGroupObject class can be used to quickly add and remove
- groups of objects to a map.
-
- The map objects contained in the group will be ordered relative to
- one another in the usual manner, such that objects with higher z-values
- will be drawn over objects with lower z-values and objects with
- equal z-values will be drawn in insertion order.
-
- This ordering of the objects will be independent of the other
- objects that are added to the map, since the z-value and insertion
- order of the QGeoMapGroupObject is used to determine where the
- group is placed in the scene.
-*/
-
-/*!
- Constructs a new group object.
-*/
-QGeoMapGroupObject::QGeoMapGroupObject()
- : d_ptr(new QGeoMapGroupObjectPrivate(this)) {}
-
-/*!
- Destroys this group object.
-*/
-QGeoMapGroupObject::~QGeoMapGroupObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapGroupObject::type() const
-{
- return QGeoMapObject::GroupType;
-}
-
-/*!
- Returns a bounding box which contains this map object.
-
- If this map object has children, the bounding box will be large
- enough to contain both this map object and all of its children.
-*/
-QGeoBoundingBox QGeoMapGroupObject::boundingBox() const
-{
- QGeoBoundingBox bounds;
-
- if (d_ptr->children.size() == 0)
- return bounds;
-
- bounds = d_ptr->children.at(0)->boundingBox();
-
- for (int i = 1; i < d_ptr->children.size(); ++i)
- bounds = bounds.united(d_ptr->children.at(i)->boundingBox());
-
- return bounds;
-}
-
-/*!
- Returns whether \a coordinate is contained with the boundary of this
- map object.
-
- If this map object has children, this function will return whether
- \a coordinate is contained within the boundary of this map object or
- within the boundary of any of its children.
-*/
-bool QGeoMapGroupObject::contains(const QGeoCoordinate &coordinate) const
-{
- for (int i = 0; i < d_ptr->children.size(); ++i)
- if (d_ptr->children.at(i)->contains(coordinate))
- return true;
-
- return false;
-}
-
-bool mapObjectLessThan(const QGeoMapObject* op1, const QGeoMapObject* op2)
-{
- return op1->operator <(*op2);
-}
-
-/*!
- Adds \a childObject to the list of children of this map object.
-
- The children objects are drawn in order of the QGeoMapObject::zValue()
- value. Children objects having the same z value will be drawn
- in the order they were added.
-
- The map object will take ownership of \a childObject.
-*/
-void QGeoMapGroupObject::addChildObject(QGeoMapObject *childObject)
-{
- if (!childObject || d_ptr->children.contains(childObject))
- return;
-
- childObject->setMapData(mapData());
- childObject->d_func()->serial = d_func()->serial++;
-
- //binary search
- QList<QGeoMapObject*>::iterator i = qUpperBound(d_ptr->children.begin(),
- d_ptr->children.end(),
- childObject,
- mapObjectLessThan);
- d_ptr->children.insert(i, childObject);
-
- connect(childObject, SIGNAL(zValueChanged(int)),
- d_ptr, SLOT(childChangedZValue(int)));
-
- emit childAdded(childObject);
-}
-
-/*!
- Removes \a childObject from the list of children of this map object.
-
- The map object will release ownership of \a childObject.
-*/
-void QGeoMapGroupObject::removeChildObject(QGeoMapObject *childObject)
-{
- if (!childObject)
- return;
-
- if (d_ptr->children.removeAll(childObject) > 0) {
-
- disconnect(childObject, SIGNAL(zValueChanged(int)),
- d_ptr, SLOT(childChangedZValue(int)));
-
- emit childRemoved(childObject);
- childObject->setMapData(0);
-
-// if (this->mapData()) {
-// QGeoMapObjectEngine *oe = this->mapData()->d_ptr->oe;
-// if (oe)
-// oe->removeObject(childObject);
-// }
- }
-
-// update();
-}
-
-/*!
- Returns the children of this object.
-*/
-QList<QGeoMapObject*> QGeoMapGroupObject::childObjects() const
-{
- return d_ptr->children;
-}
-
-/*!
- Clears the children of this object.
-
- The child objects will be deleted.
-*/
-void QGeoMapGroupObject::clearChildObjects()
-{
- for (int i = d_ptr->children.size() - 1; i >=0; --i) {
- QGeoMapObject* child = d_ptr->children[i];
- removeChildObject(child);
- delete child;
- }
-
- d_ptr->children.clear();
-}
-
-/*!
- Sets whether this group of objects is visible to \a visible.
-*/
-void QGeoMapGroupObject::setVisible(bool visible)
-{
- for (int i = 0; i < d_ptr->children.size(); ++i)
- d_ptr->children[i]->setVisible(visible);
-
- QGeoMapObject::setVisible(visible);
-}
-
-/*!
- \reimp
-*/
-void QGeoMapGroupObject::setMapData(QGeoMapData *mapData)
-{
-
- for (int i = 0; i < d_ptr->children.size(); ++i) {
- d_ptr->children[i]->setMapData(mapData);
- if (mapData)
- emit childAdded(d_ptr->children[i]);
- }
-
- QGeoMapObject::setMapData(mapData);
-}
-
-/*!
-\fn void QGeoMapGroupObject::childAdded(QGeoMapObject *childObject)
-
- This signal will be emitted when the map object \a childObject
- is added to the group.
-*/
-
-/*!
-\fn void QGeoMapGroupObject::childUpdated(QGeoMapObject *childObject)
-
- This signal will be emitted if the map object \a childObject has
- changed such that the corresponding QGeoMapObjectInfo class that handles
- the map-specific behaviours of the object needs to be informed of
- the change.
-
- The map object \a childObject must belong to this group.
-
- At the moment this is only emitted when the z-value of the
- child-objects are changed.
-*/
-
-/*!
-\fn void QGeoMapGroupObject::childRemoved(QGeoMapObject *childObject)
-
- This signal will be emitted when the map object \a childObject
- is removed from the group.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapGroupObjectPrivate::QGeoMapGroupObjectPrivate(QGeoMapGroupObject *p) :
- QObject(p),
- serial(1),
- q_ptr(p)
-{}
-
-QGeoMapGroupObjectPrivate::~QGeoMapGroupObjectPrivate()
-{
- qDeleteAll(children);
-}
-
-void QGeoMapGroupObjectPrivate::childChangedZValue(int zValue)
-{
- Q_UNUSED(zValue);
- QGeoMapObject *child = qobject_cast<QGeoMapObject*>(sender());
- if (!child)
- return;
-
- if (children.removeAll(child) > 0) {
- QList<QGeoMapObject*>::iterator i = qUpperBound(children.begin(),
- children.end(),
- child,
- mapObjectLessThan);
- children.insert(i, child);
- emit q_ptr->childUpdated(child);
- }
-}
-
-#include "moc_qgeomapgroupobject.cpp"
-#include "moc_qgeomapgroupobject_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomapobject.cpp b/src/location/maps/qgeomapobject.cpp
deleted file mode 100644
index 3f0b3993..00000000
--- a/src/location/maps/qgeomapobject.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapobject.h"
-#include "qgeomapobject_p.h"
-#include "qgeomapobjectengine_p.h"
-#include "qgeomapobjectinfo.h"
-#include "qgeomapdata.h"
-#include "qgeomapdata_p.h"
-#include "qgeoboundingbox.h"
-#include "qgeocoordinate.h"
-#include <private/projwrapper_p.h>
-
-#include <QtAlgorithms>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapObject
- \brief The QGeoMapObject class is a graphical item to be displayed on a map.
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- QGeoMapObject is the base class used to display graphical items on a map.
-
- Subclasses of QGeoMapObject exist in order to simplify the task of
- creating and managing map objects of various kinds.
-
- QGeoMapCustomObject is the most generic of these objects in that it
- allows QGraphicsItems to be added to a map, however as not all mapping
- plugins use the Qt Graphics View framework so clients should use
- QGraphicsGeoMap::supportsCustomMapObjects() before using
- QGeoMapCustomObject.
-
- QGeoMapObject instances can also be grouped into heirarchies in order to
- simplify the process of creating compound objects and managing groups of
- objects (see QGeoMapGroupObject)
-*/
-
-/*!
- \enum QGeoMapObject::Type
-
- Describes the type of a map object.
-
- \value NullType
- An empty QGeoMapObject.
- \value GroupType
- A QGeoMapObject used to organize other map objects into groups.
- \value RectangleType
- A QGeoMapObject used to display a rectangular region.
- \value CircleType
- A QGeoMapObject used to display a circular region.
- \value PolylineType
- A QGeoMapObject used to display a multi-segment line.
- \value PolygonType
- A QGeoMapObject used to display a polygonal region.
- \value PixmapType
- A QGeoMapObject used to display a pixmap on a map.
- \value TextType
- A QGeoMapObject used to display text on a map
- \value RouteType
- A QGeoMapObject used to display a route.
- \value CustomType
- A QGeoMapObject displaying a custom GraphicsItem.
-*/
-
-/*!
- \enum QGeoMapObject::CoordinateUnit
-
- \since 1.2
-
- Describes the units of measurement used for a map object's
- graphics item.
-
- \value PixelUnit
- Units are in pixels on the screen. Pixel coordinate (0,0) is
- translated to the origin coordinate.
- \value MeterUnit
- Units are in meters on the ground -- a local Transverse Mercator
- coordinate system (on the WGS84 ellipsoid) is used for translation,
- centered on the origin coordinate.
- \value RelativeArcSecondUnit
- Units are in arc seconds relative to the origin coordinate (along the
- WGS84 ellipsoid).
- \value AbsoluteArcSecondUnit
- Units are in arc seconds on WGS84, origin ignored.
-*/
-
-/*!
- \enum QGeoMapObject::TransformType
-
- \since 1.2
-
- Describes the type of transformation applied to change this object's
- coordinate system into screen coordinates.
-
- \value BilinearTransform
- This object's bounding box is taken, and transformed at each of its
- corners into screen coordinates. A bilinear interpolation is then used
- to draw the rest of the object's GraphicsItem.
- \value ExactTransform
- Individual key points on the object are transformed and the GraphicsItem
- is constructed in direct pixel coordinates. This is only available for
- certain subclasses, depending on the implementation of QGeoMapData used.
-*/
-
-/*!
- Constructs a new map object associated with \a mapData.
-
- The object will be in pixel coordinates, with exact transform.
-*/
-QGeoMapObject::QGeoMapObject(QGeoMapData *mapData)
- : d_ptr(new QGeoMapObjectPrivate())
-{
- setMapData(mapData);
-}
-
-/*!
- Destroys this map object.
-*/
-QGeoMapObject::~QGeoMapObject()
-{
- setMapData(0);
- delete d_ptr;
-}
-
-/*!
- Returns the type of this map object.
-*/
-QGeoMapObject::Type QGeoMapObject::type() const
-{
-// if (d_ptr->graphicsItem)
-// return QGeoMapObject::CustomType;
-// else
- return QGeoMapObject::NullType;
-}
-
-/*!
- \property QGeoMapObject::zValue
- \brief This property holds the z-value of the map object.
-
- The z-value determines the order in which the objects are drawn on the
- screen. Objects with the same value will be drawn in the order that
- they were added to the map or map object.
-
- This is the same behaviour as QGraphicsItem.
-*/
-void QGeoMapObject::setZValue(int zValue)
-{
- if (d_ptr->zValue != zValue) {
- d_ptr->zValue = zValue;
- emit zValueChanged(d_ptr->zValue);
- }
-}
-
-int QGeoMapObject::zValue() const
-{
- return d_ptr->zValue;
-}
-
-/*!
- \property QGeoMapObject::visible
- \brief This property holds whether the map object is visible.
-*/
-void QGeoMapObject::setVisible(bool visible)
-{
- if (d_ptr->isVisible != visible) {
- d_ptr->isVisible = visible;
- emit visibleChanged(d_ptr->isVisible);
- }
-}
-
-bool QGeoMapObject::isVisible() const
-{
- return d_ptr->isVisible;
-}
-
-/*!
- \property QGeoMapObject::selected
- \brief This property holds whether the map object is selected.
-*/
-void QGeoMapObject::setSelected(bool selected)
-{
- if (d_ptr->isSelected != selected) {
- d_ptr->isSelected = selected;
- emit selectedChanged(d_ptr->isSelected);
- }
-}
-
-bool QGeoMapObject::isSelected() const
-{
- return d_ptr->isSelected;
-}
-
-/*!
- Returns a bounding box which contains this map object.
-
- The default implementation requires the object to be added to a map
- before this function returns a valid bounding box.
-*/
-QGeoBoundingBox QGeoMapObject::boundingBox() const
-{
- if (!d_ptr->info)
- return QGeoBoundingBox();
-
- return d_ptr->info->boundingBox();
-}
-
-/*!
- Returns whether \a coordinate is contained with the boundary of this
- map object.
-
- The default implementation requires the object to be added to a map
- before this function is able to return true.
-*/
-bool QGeoMapObject::contains(const QGeoCoordinate &coordinate) const
-{
- if (!d_ptr->info)
- return false;
-
- return d_ptr->info->contains(coordinate);
-}
-
-/*!
- \internal
-*/
-bool QGeoMapObject::operator<(const QGeoMapObject &other) const
-{
- return d_ptr->zValue < other.d_ptr->zValue ||
- (d_ptr->zValue == other.d_ptr->zValue && d_ptr->serial < other.d_ptr->serial);
-}
-
-/*!
- \internal
-*/
-bool QGeoMapObject::operator>(const QGeoMapObject &other) const
-{
- return d_ptr->zValue > other.d_ptr->zValue ||
- (d_ptr->zValue == other.d_ptr->zValue && d_ptr->serial > other.d_ptr->serial);
-}
-
-/*!
- Associates the QGeoMapData instance \a mapData with this map object.
-
- This will create an appropriate QGeoMapObjectInfo instance for
- this QGeoMapObject and will connect the appropriate signals to it
- so that it can be kept up to date.
-*/
-void QGeoMapObject::setMapData(QGeoMapData *mapData)
-{
- if (d_ptr->mapData == mapData)
- return;
-
- if (d_ptr->info) {
- delete d_ptr->info;
- d_ptr->info = 0;
- }
-
- d_ptr->mapData = mapData;
- if (!d_ptr->mapData)
- return;
-
- d_ptr->info = mapData->createMapObjectInfo(this);
-
- if (!d_ptr->info)
- return;
-
- connect(d_ptr->mapData,
- SIGNAL(windowSizeChanged(QSizeF)),
- d_ptr->info,
- SLOT(windowSizeChanged(QSizeF)));
- connect(d_ptr->mapData,
- SIGNAL(zoomLevelChanged(qreal)),
- d_ptr->info,
- SLOT(zoomLevelChanged(qreal)));
- connect(d_ptr->mapData,
- SIGNAL(centerChanged(QGeoCoordinate)),
- d_ptr->info,
- SLOT(centerChanged(QGeoCoordinate)));
-
- connect(this,
- SIGNAL(zValueChanged(int)),
- d_ptr->info,
- SLOT(zValueChanged(int)));
- connect(this,
- SIGNAL(visibleChanged(bool)),
- d_ptr->info,
- SLOT(visibleChanged(bool)));
- connect(this,
- SIGNAL(selectedChanged(bool)),
- d_ptr->info,
- SLOT(selectedChanged(bool)));
- connect(this,
- SIGNAL(originChanged(QGeoCoordinate)),
- d_ptr->info,
- SLOT(originChanged(QGeoCoordinate)));
- connect(this,
- SIGNAL(transformTypeChanged(QGeoMapObject::TransformType)),
- d_ptr->info,
- SLOT(transformTypeChanged(QGeoMapObject::TransformType)));
- connect(this,
- SIGNAL(unitsChanged(QGeoMapObject::CoordinateUnit)),
- d_ptr->info,
- SLOT(unitsChanged(QGeoMapObject::CoordinateUnit)));
-
- d_ptr->info->init();
-}
-
-/*!
- Returns the QGeoMapData instance associated with this object.
-
- Will return 0 if not QGeoMapData instance has been set.
-*/
-QGeoMapData* QGeoMapObject::mapData() const
-{
- return d_ptr->mapData;
-}
-
-/*!
- Returns the QGeoMapObjectInfo instance which implements the
- QGeoMapData specific behaviours of this map object.
-
- This will mostly be useful when implementing custom QGeoMapData
- subclasses.
-*/
-QGeoMapObjectInfo *QGeoMapObject::info() const
-{
- return d_ptr->info;
-}
-
-/*!
- \property QGeoMapObject::transformType
- \brief This property holds the transformation type used to draw the object.
-
- \since 1.2
-
- \sa QGeoMapObject::TransformType
-*/
-QGeoMapObject::TransformType QGeoMapObject::transformType() const
-{
- return d_ptr->transType;
-}
-
-/*!
- Sets the transform type of the object to \a type.
-*/
-void QGeoMapObject::setTransformType(const TransformType &type)
-{
- if (type == d_ptr->transType)
- return;
-
- d_ptr->transType = type;
-
- emit transformTypeChanged(type);
-}
-
-/*!
- \property QGeoMapObject::origin
- \brief This property holds the origin of the object's coordinate system.
-
- \since 1.2
-
- How the origin coordinate is used depends on the selected coordinate
- system, see QGeoMapObject::TransformType for more details.
-*/
-QGeoCoordinate QGeoMapObject::origin() const
-{
- return d_ptr->origin;
-}
-
-/*!
- Sets the origin of the object to \a origin.
-*/
-void QGeoMapObject::setOrigin(const QGeoCoordinate &origin)
-{
- if (origin == d_ptr->origin)
- return;
-
- d_ptr->origin = origin;
-
- emit originChanged(origin);
-}
-
-/*!
- \property QGeoMapObject::units
- \brief This property holds the units of measurement for the object.
-
- \since 1.2
-
- \sa QGeoMapObject::CoordinateUnit
-*/
-QGeoMapObject::CoordinateUnit QGeoMapObject::units() const
-{
- return d_ptr->units;
-}
-
-/*!
- Sets the coordinate units of the object to \a unit.
-
- Note that setting this property will reset the transformType property to
- the default for the units given. For PixelUnit, this is ExactTransform,
- and for all others, BilinearTransform.
-*/
-void QGeoMapObject::setUnits(const CoordinateUnit &unit)
-{
- if (unit == d_ptr->units)
- return;
-
- d_ptr->units = unit;
-
- if (unit == QGeoMapObject::PixelUnit)
- setTransformType(QGeoMapObject::ExactTransform);
- else
- setTransformType(QGeoMapObject::BilinearTransform);
-
- emit unitsChanged(unit);
-}
-
-/*!
-\fn void QGeoMapObject::zValueChanged(int zValue)
-
- This signal is emitted when the z value of the map object
- has changed.
-
- The new value is \a zValue.
-*/
-
-/*!
-\fn void QGeoMapObject::visibleChanged(bool visible)
-
- This signal is emitted when the visible state of the map object
- has changed.
-
- The new value is \a visible.
-*/
-
-/*!
-\fn void QGeoMapObject::selectedChanged(bool selected)
-
- This signal is emitted when the selected state of the map object
- has changed.
-
- The new vlaue is \a selected.
-*/
-
-/*!
-\fn void QGeoMapObject::originChanged(QGeoCoordinate origin)
-
- This signal is emitted when the origin of the map object has changed.
-
- The new value is \a origin.
-*/
-
-/*!
-\fn void QGeoMapObject::unitsChanged(QGeoMapObject::CoordinateUnit units)
-
- This signal is emitted when the coordinate units of the map object have changed.
-
- The new value is \a units.
-*/
-
-/*!
-\fn void QGeoMapObject::transformTypeChanged(QGeoMapObject::TransformType transformType)
-
- This signal is emitted when the transform type of the map object has changed.
-
- The new value is \a transformType.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapObjectPrivate::QGeoMapObjectPrivate()
- : zValue(0),
- serial(0),
- isVisible(true),
- isSelected(false),
- mapData(0),
- info(0),
- units(QGeoMapObject::PixelUnit),
- transType(QGeoMapObject::ExactTransform){}
-
-QGeoMapObjectPrivate::~QGeoMapObjectPrivate()
-{
- if (info)
- delete info;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-#include "moc_qgeomapobject.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapobject.h b/src/location/maps/qgeomapobject.h
deleted file mode 100644
index 11e40b25..00000000
--- a/src/location/maps/qgeomapobject.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPOBJECT_H
-#define QGEOMAPOBJECT_H
-
-#include "qmobilityglobal.h"
-
-#include <QList>
-#include <QObject>
-
-QT_BEGIN_NAMESPACE
-class QPainter;
-class QRectF;
-class QGraphicsItem;
-
-
-class QGeoCoordinate;
-class QGeoBoundingBox;
-class QGeoMapObjectPrivate;
-class QGeoMapContainer;
-class QGeoMapObjectInfo;
-
-class QGeoMapData;
-
-class Q_LOCATION_EXPORT QGeoMapObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int zValue READ zValue WRITE setZValue NOTIFY zValueChanged)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
- Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged)
- Q_PROPERTY(QGeoCoordinate origin READ origin NOTIFY originChanged)
- Q_PROPERTY(CoordinateUnit units READ units NOTIFY unitsChanged)
- Q_PROPERTY(TransformType transformType READ transformType NOTIFY transformTypeChanged)
-
-public:
- enum Type {
- NullType,
- GroupType,
- RectangleType,
- CircleType,
- PolylineType,
- PolygonType,
- PixmapType,
- TextType,
- RouteType,
- CustomType
- };
-
- enum CoordinateUnit {
- PixelUnit,
- MeterUnit,
- RelativeArcSecondUnit,
- AbsoluteArcSecondUnit
- };
-
- enum TransformType {
- BilinearTransform,
- ExactTransform
- };
-
- QGeoMapObject(QGeoMapData *mapData = 0);
- virtual ~QGeoMapObject();
-
- virtual Type type() const;
-
- void setZValue(int zValue);
- int zValue() const;
-
- void setVisible(bool visible);
- bool isVisible() const;
-
- void setSelected(bool selected);
- bool isSelected() const;
-
- virtual QGeoBoundingBox boundingBox() const;
- virtual bool contains(const QGeoCoordinate &coordinate) const;
-
- bool operator<(const QGeoMapObject &other) const;
- bool operator>(const QGeoMapObject &other) const;
-
- virtual void setMapData(QGeoMapData *mapData);
- virtual QGeoMapData* mapData() const;
-
- QGeoMapObjectInfo *info() const;
-
- QGeoCoordinate origin() const;
- CoordinateUnit units() const;
- TransformType transformType() const;
-
-protected:
- void setOrigin(const QGeoCoordinate &origin);
- void setUnits(const CoordinateUnit &unit);
- void setTransformType(const TransformType &type);
-
-Q_SIGNALS:
- void zValueChanged(int zValue);
- void visibleChanged(bool visible);
- void selectedChanged(bool selected);
-
- void originChanged(QGeoCoordinate origin);
- void unitsChanged(QGeoMapObject::CoordinateUnit units);
- void transformTypeChanged(QGeoMapObject::TransformType transformType);
-
-private:
- QGeoMapObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapObject)
- Q_DISABLE_COPY(QGeoMapObject)
-
- friend class QGeoMapDataPrivate;
- friend class QGeoMapGroupObject;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomapobjectengine_p.cpp b/src/location/maps/qgeomapobjectengine_p.cpp
deleted file mode 100644
index 7579b829..00000000
--- a/src/location/maps/qgeomapobjectengine_p.cpp
+++ /dev/null
@@ -1,1182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapobjectengine_p.h"
-#include "qgeomaprouteobject.h"
-#include "qgeomapcircleobject.h"
-#include <private/qgeocoordinate_p.h>
-#include "qgeoboundingbox.h"
-#include <private/projwrapper_p.h>
-#include "qgeotiledmapobjectinfo_p.h"
-
-#include <QTransform>
-#include <QGraphicsItem>
-#include <QGraphicsScene>
-#include <QGraphicsPolygonItem>
-#include <QGraphicsPathItem>
-#include <QGraphicsEllipseItem>
-
-#include <cmath>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*
- A quick note about how the transforms are set up:
-
- Each QGeoMapObject has its own "local" coordinate system, whether this
- a pixel system or meters or whatever.
-
- For local systems that are not in pixels, we do a two-stage transform --
- first we transform the object to arc-seconds, then we transform from
- arc-seconds to pixels on the screen. This is necessary as QGeoMapData
- subclasses only provide a mapping from lat/lon coordinates to screen pixels
- and no other source.
-
- For local systems that are in pixels, we simply translate to the screen
- coordinates. However, we still generate a transform to arc-seconds for these
- objects, to speed up the drawing process.
-
- QGeoMapDataPrivate has two sets of 3 fields that are used here:
- - xxxTrans
- - xxxScene
- - xxxItems
- (where xxx = [latLon, pixel])
-
- xxxTrans = a multi-hash of transforms associated with each QGeoMapObject
- (a given map object may appear at more than one coordinate if
- it wraps over the dateline)
- xxxScene = a QGraphicsScene filled with bounding boxes for each object, one
- for each entry in xxxTrans
- xxxItems = a hash taking the items in the xxxScene and giving back the original
- QGeoMapObject they were created for
-
- the "latLon" entries describe the transformations from local coordinates to
- arc-seconds, and the "pixel" entries describe the transformations from local
- coordinates to pixels on screen.
-
- Items within latLonScene have their coordinates in arc-seconds, and items
- within pixelScene have theirs in pixels.
-
-*/
-
-QGeoMapObjectEngine::QGeoMapObjectEngine(QGeoMapData *mapData, QGeoMapDataPrivate *mapDataP) :
- md(mapData),
- mdp(mapDataP),
- exactMappingTolerance(1.0),
- latLonScene(new QGraphicsScene),
- pixelScene(new QGraphicsScene)
-{
- pixelScene->setItemIndexMethod(QGraphicsScene::NoIndex);
-}
-
-QGeoMapObjectEngine::~QGeoMapObjectEngine()
-{
- delete pixelScene;
- delete latLonScene;
-
- latLonTrans.clear();
- latLonItems.clear();
- latLonItemsRev.clear();
- pixelTrans.clear();
- pixelItems.clear();
- pixelItemsRev.clear();
-
- foreach (QGraphicsItem *i, latLonExact.values())
- delete i;
- latLonExact.clear();
-
- foreach (QGraphicsItem *i, pixelExact.values())
- delete i;
- pixelExact.clear();
-}
-
-/*****************************************************************************
- Object management
- *****************************************************************************/
-
-void QGeoMapObjectEngine::addObject(QGeoMapObject *object)
-{
- objectsForLatLonUpdate << object;
- objectsForPixelUpdate << object;
- updateTransforms();
- rebuildScenes();
-}
-
-void QGeoMapObjectEngine::removeObject(QGeoMapObject *object)
-{
- QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(object);
- if (group) {
- foreach (QGeoMapObject *child, group->childObjects())
- removeObject(child);
- } else {
- QList<QRectF> rectsToUpdate;
- foreach (QGraphicsItem *item, pixelItemsRev.values(object))
- rectsToUpdate << item->boundingRect();
-
- latLonTrans.remove(object);
- foreach (QGraphicsItem *item, latLonItemsRev.values(object)) {
- latLonItems.remove(item);
- latLonScene->removeItem(item);
- delete item;
- }
- latLonItemsRev.remove(object);
-
- pixelTrans.remove(object);
- foreach (QGraphicsItem *item, pixelItemsRev.values(object)) {
- pixelItems.remove(item);
- pixelScene->removeItem(item);
- delete item;
- }
- pixelItemsRev.remove(object);
-
- foreach (QRectF rect, rectsToUpdate)
- mdp->emitUpdateMapDisplay(rect);
-
- objectsForLatLonUpdate.removeAll(object);
- objectsForPixelUpdate.removeAll(object);
- }
-}
-
-/*****************************************************************************
- Transform support functions
- *****************************************************************************/
-
-static QGraphicsPolygonItem *polyCopy(const QGraphicsPolygonItem *polyItem)
-{
- QGraphicsPolygonItem *pi = new QGraphicsPolygonItem;
- pi->setBrush(polyItem->brush());
- pi->setPen(polyItem->pen());
- pi->setVisible(polyItem->isVisible());
- pi->setFillRule(polyItem->fillRule());
- pi->setOpacity(polyItem->opacity());
- pi->setGraphicsEffect(polyItem->graphicsEffect());
- return pi;
-}
-
-static QGraphicsPolygonItem *polyCopy(const QGraphicsEllipseItem *elItem)
-{
- QGraphicsPolygonItem *pi = new QGraphicsPolygonItem;
- pi->setBrush(elItem->brush());
- pi->setPen(elItem->pen());
- pi->setVisible(elItem->isVisible());
- pi->setOpacity(elItem->opacity());
- pi->setGraphicsEffect(elItem->graphicsEffect());
- return pi;
-}
-
-static QGraphicsPathItem *pathCopy(const QGraphicsPathItem *pathItem)
-{
- QGraphicsPathItem *pi = new QGraphicsPathItem;
- pi->setBrush(pathItem->brush());
- pi->setPen(pathItem->pen());
- pi->setVisible(pathItem->isVisible());
- pi->setOpacity(pathItem->opacity());
- pi->setGraphicsEffect(pathItem->graphicsEffect());
- return pi;
-}
-
-static QPolygonF approximateCircle(QGraphicsEllipseItem *elItem,
- QGeoMapObject *object,
- const QGeoCoordinate &center,
- const ProjCoordinate &projCenter)
-{
- const QRectF rect = elItem->rect();
-
- const double a = rect.height() / 2.0;
- const double b = rect.width() / 2.0;
-
- const double asq = a*a;
- const double bsq = b*b;
-
- QPolygonF secPoly;
-
- quint32 detail = 150;
- QGeoMapCircleObject *circObj = dynamic_cast<QGeoMapCircleObject*>(object);
- if (circObj)
- detail = circObj->pointCount();
-
- const double Pi = 3.14159265358;
- const double twopi = 6.283185307179;
-
- const double dth = twopi / detail;
-
- // TODO: make the semantics here the same as in normal graphicsview
- double startAngle = elItem->startAngle();
- startAngle /= 16.0;
- startAngle *= twopi;
- startAngle /= 360.0;
-
- double stopAngle = elItem->startAngle() + elItem->spanAngle();
- stopAngle /= 16.0;
- stopAngle *= twopi;
- stopAngle /= 360.0;
-
- bool drawToCenter = (elItem->spanAngle() != 360 * 16);
-
- for (double theta = startAngle; theta < stopAngle; theta += dth) {
- const double top = b*sin(theta);
- const double bottom = a*cos(theta);
-
- double phi = atan(top / bottom);
- if (bottom < 0)
- phi = phi + Pi;
-
- const double phiDeg = (360.0 * phi) / twopi;
-
- const double costh = cos(theta);
- const double sinth = sin(theta);
-
- const double r = sqrt(asq*costh*costh + bsq*sinth*sinth);
-
- double x, y;
- QGeoCoordinatePrivate::atDistanceAndAzimuth(center, r, phiDeg,
- &x, &y);
- x *= 3600.0;
- y *= 3600.0;
-
- secPoly << QPointF(x,y);
- }
-
- if (drawToCenter)
- secPoly << QPointF(projCenter.x() * 3600.0, projCenter.y() * 3600.0);
-
- return secPoly;
-}
-
-bool QGeoMapObjectEngine::exactMetersToSeconds(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QGraphicsItem *item,
- QList<QPolygonF> &polys)
-{
- QString projStr = QLatin1String("+proj=tmerc +lat_0=%1 +lon_0=%2 +k=1.0 +x_0=0 +y_0=0 +ellps=WGS84");
- projStr = projStr.arg(origin.latitude(), 0, 'f', 12)
- .arg(origin.longitude(), 0, 'f', 12);
-
- ProjCoordinateSystem localSys(projStr, false);
- ProjCoordinateSystem wgs84(QLatin1String("+proj=latlon +ellps=WGS84"));
-
- QTransform west;
- west.translate(360.0 * 3600.0, 0.0);
-
- QTransform east;
- east.translate(-360.0 * 3600.0, 0.0);
-
- foreach (QGraphicsItem *i, latLonExact.values(object))
- delete i;
- latLonExact.remove(object);
-
- QGraphicsEllipseItem *elItem = dynamic_cast<QGraphicsEllipseItem*>(item);
- if (elItem) {
- QRectF rect = elItem->rect();
-
- const QPointF cen = rect.center();
- ProjCoordinate c(cen.x(), -1*cen.y(), 0.0, localSys);
- c.convert(wgs84);
- const QGeoCoordinate center = c.toGeoCoordinate();
-
- QPolygonF wgs = approximateCircle(elItem, object, center, c);
-
- QGraphicsPolygonItem *pi = polyCopy(elItem);
- pi->setPolygon(wgs);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF westPoly = wgs * west;
- pi = polyCopy(elItem);
- pi->setPolygon(westPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF eastPoly = wgs * east;
- pi = polyCopy(elItem);
- pi->setPolygon(eastPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- return true;
- }
-
- QGraphicsPolygonItem *polyItem = dynamic_cast<QGraphicsPolygonItem*>(item);
- if (polyItem) {
- QPolygonF poly = polyItem->polygon() * polyItem->transform();
-
- ProjPolygon p(poly, localSys);
- p.scalarMultiply(1, -1, 1);
- p.convert(wgs84);
- QPolygonF wgs = p.toPolygonF(3600.0);
-
- QGraphicsPolygonItem *pi = polyCopy(polyItem);
- pi->setPolygon(wgs);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF westPoly = wgs * west;
- pi = polyCopy(polyItem);
- pi->setPolygon(westPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF eastPoly = wgs * east;
- pi = polyCopy(polyItem);
- pi->setPolygon(eastPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- return true;
- }
-
- QGraphicsPathItem *pathItem = dynamic_cast<QGraphicsPathItem*>(item);
- if (pathItem) {
- QPainterPath path = pathItem->path() * pathItem->transform();
-
- for (int i = 0; i < path.elementCount(); ++i) {
- QPainterPath::Element e = path.elementAt(i);
-
- ProjCoordinate c(e.x, -1*e.y, 0.0, localSys);
- Q_ASSERT(c.convert(wgs84));
-
- path.setElementPositionAt(i, c.x() * 3600.0, c.y() * 3600.0);
- }
-
- QGraphicsPathItem *pi = pathCopy(pathItem);
- pi->setPath(path);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPainterPath westPath = path * west;
- pi = pathCopy(pathItem);
- pi->setPath(westPath);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPainterPath eastPath = path * east;
- pi = pathCopy(pathItem);
- pi->setPath(eastPath);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- return true;
- }
-
- qWarning("QGeoMapData: did not recognize type of exact-transformed"
- "object: type #%d (object not supported for exact transform)",
- item->type());
- return false;
-}
-
-bool QGeoMapObjectEngine::exactSecondsToSeconds(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QGraphicsItem *item,
- QList<QPolygonF> &polys)
-{
- QTransform west;
- west.translate(360.0 * 3600.0, 0.0);
-
- QTransform east;
- east.translate(-360.0 * 3600.0, 0.0);
-
- QTransform toAbs;
- if (object->units() == QGeoMapObject::RelativeArcSecondUnit) {
- double ox = origin.longitude() * 3600.0;
- double oy = origin.latitude() * 3600.0;
- toAbs.translate(ox, oy);
- }
-
- foreach (QGraphicsItem *i, latLonExact.values(object))
- delete i;
- latLonExact.remove(object);
-
- QGraphicsPolygonItem *polyItem = dynamic_cast<QGraphicsPolygonItem*>(item);
- if (polyItem) {
- if (polyItem->polygon().isEmpty() || polyItem->polygon().size() < 3)
- return false;
-
- QPolygonF poly = polyItem->polygon() * polyItem->transform();
- poly = poly * toAbs;
-
- QGraphicsPolygonItem *pi = polyCopy(polyItem);
- pi->setPolygon(poly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF westPoly = poly * west;
- pi = polyCopy(polyItem);
- pi->setPolygon(westPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- QPolygonF eastPoly = poly * east;
- pi = polyCopy(polyItem);
- pi->setPolygon(eastPoly);
- latLonExact.insertMulti(object, pi);
- polys << pi->boundingRect();
-
- return true;
- }
-
- QGraphicsPathItem *pathItem = dynamic_cast<QGraphicsPathItem*>(item);
- if (pathItem) {
- if (pathItem->path().isEmpty() || pathItem->path().elementCount() < 2)
- return false;
-
- QPainterPath path = pathItem->path() * pathItem->transform();
- path = path * toAbs;
-
- QGraphicsPathItem *pi = pathCopy(pathItem);
- pi->setPath(path);
- latLonExact.insertMulti(object, pi);
- const QPolygonF originalBounds = pi->boundingRect();
- polys << originalBounds;
-
- QPainterPath westPath = path * west;
- pi = pathCopy(pathItem);
- pi->setPath(westPath);
- latLonExact.insertMulti(object, pi);
- polys << originalBounds * west;
-
- QPainterPath eastPath = path * east;
- pi = pathCopy(pathItem);
- pi->setPath(eastPath);
- latLonExact.insertMulti(object, pi);
- polys << originalBounds * east;
-
- return true;
- }
-
- qWarning("QGeoMapData: did not recognize type of exact-transformed "
- "object: type #%d (object not supported for exact transform)",
- item->type());
- return false;
-}
-
-void QGeoMapObjectEngine::bilinearMetersToSeconds(const QGeoCoordinate &origin,
- QGraphicsItem *item,
- QPolygonF &local,
- QTransform &latLon)
-{
- QString projStr = QLatin1String("+proj=tmerc +lat_0=%1 +lon_0=%2 +k=1.0 +x_0=0 +y_0=0 +ellps=WGS84");
- projStr = projStr.arg(origin.latitude(), 0, 'f', 12)
- .arg(origin.longitude(), 0, 'f', 12);
-
- ProjCoordinateSystem localSys(projStr, false);
- ProjCoordinateSystem wgs84(QLatin1String("+proj=latlon +ellps=WGS84"));
-
- ProjPolygon p(local, localSys);
- if (!p.convert(wgs84)) {
- qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
- "failed: projection is singular");
- return;
- }
- QPolygonF wgs = p.toPolygonF(3600.0);
-
- // QTransform expects the last vertex (closing vertex) to be dropped
- local.remove(4);
- wgs.remove(4);
-
- // perform wrapping
- if (wgs.at(2).x() < wgs.at(3).x()) {
- QPointF topRight = wgs.at(1);
- topRight.setX(topRight.x() + 360.0 * 3600.0);
- wgs.replace(1, topRight);
-
- QPointF bottomRight = wgs.at(2);
- bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
- wgs.replace(2, bottomRight);
- }
-
- bool ok = QTransform::quadToQuad(local, wgs, latLon);
- if (!ok) {
- qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
- "failed: could not obtain a transformation matrix");
- return;
- }
-
- QTransform flip;
- flip.scale(1, -1);
-
- latLon = flip * item->transform() * latLon;
-}
-
-void QGeoMapObjectEngine::bilinearPixelsToSeconds(const QGeoCoordinate &origin,
- QGraphicsItem *item,
- QPolygonF &local,
- QTransform &latLon)
-{
- QPointF pixelOrigin = mdp->coordinateToScreenPosition(origin.longitude(),
- origin.latitude());
-
- QPolygonF wgs;
- foreach (const QPointF &pt, local) {
- const QGeoCoordinate coord =
- md->screenPositionToCoordinate(pt + pixelOrigin);
- const QPointF lpt(coord.longitude() * 3600.0, coord.latitude() * 3600.0);
- wgs.append(lpt);
- }
-
- // QTransform expects the last vertex (closing vertex) to be dropped
- local.remove(4);
- wgs.remove(4);
-
- // perform wrapping
- if (wgs.at(2).x() < wgs.at(3).x()) {
- QPointF topRight = wgs.at(1);
- topRight.setX(topRight.x() + 360.0 * 3600.0);
- wgs.replace(1, topRight);
-
- QPointF bottomRight = wgs.at(2);
- bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
- wgs.replace(2, bottomRight);
- }
-
- bool ok = QTransform::quadToQuad(local, wgs, latLon);
- if (!ok) {
- qWarning("QGeoMapData: bilinear transform from meters to arc-seconds "
- "failed: could not obtain a transformation matrix");
- return;
- }
-
- latLon = item->transform() * latLon;
-}
-
-void QGeoMapObjectEngine::bilinearSecondsToScreen(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys)
-{
- Q_UNUSED(origin)
-
- QList<QTransform> latLons = latLonTrans.values(object);
-
- QGraphicsItem *item = graphicsItemFromMapObject(object);
- if (!item)
- return;
-
- // compute the transform by linearising from the lat/lon space
- foreach (QTransform latLon, latLons) {
- QTransform pixel;
-
-
- QPolygonF local = (item->boundingRect() | item->childrenBoundingRect());
- QPolygonF latLonPoly = latLon.map(local);
-
- QPolygonF pixelPoly = polyToScreen(latLonPoly);
-
- // QTransform expects the last vertex (closing vertex) to be dropped
- local.remove(4);
- pixelPoly.remove(4);
-
- bool ok = QTransform::quadToQuad(local, pixelPoly, pixel);
- if (!ok) {
- qWarning("QGeoMapData: bilinear transform to screen from arc-seconds "
- "failed: could not compute transformation matrix");
- return;
- }
-
- pixelTrans.insertMulti(object, pixel);
-
- polys << pixelPoly;
- }
-}
-
-struct PathStep
-{
- bool tooClose;
- QPointF pixel;
- QPainterPath::Element e;
-};
-
-void QGeoMapObjectEngine::exactPixelMap(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys)
-{
- Q_UNUSED(origin)
-
- QList<QGraphicsItem*> latLonItems = latLonExact.values(object);
-
- foreach (QGraphicsItem *i, pixelExact.values(object))
- delete i;
- pixelExact.remove(object);
-
- double tolerance = exactMappingTolerance;
- QGeoMapRouteObject *robj = qobject_cast<QGeoMapRouteObject*>(object);
- if (robj)
- tolerance = robj->detailLevel();
- // square it
- tolerance = tolerance * tolerance;
-
- foreach (QGraphicsItem *latLonItem, latLonItems) {
- QGraphicsPolygonItem *polyItem = qgraphicsitem_cast<QGraphicsPolygonItem*>(latLonItem);
- if (polyItem) {
- QPolygonF poly = polyItem->polygon();
- QPolygonF pixelPoly = polyToScreen(poly);
-
- QGraphicsPolygonItem *pi = polyCopy(polyItem);
- pi->setPolygon(pixelPoly);
- pixelExact.insertMulti(object, pi);
- polys << pi->boundingRect();
- }
-
- QGraphicsPathItem *pathItem = qgraphicsitem_cast<QGraphicsPathItem*>(latLonItem);
- if (pathItem) {
- const QPainterPath path = pathItem->path();
- const int pathSize = path.elementCount();
- QPainterPath mpath;
-
- const QRectF screen = latLonViewport().boundingRect();
-
- QPointF lastPixelAdded;
- bool lastOutside = true;
-
- struct PathStep *steps = new struct PathStep[pathSize];
-
- for (int i = 0; i < pathSize; ++i) {
- const QPainterPath::Element e = path.elementAt(i);
- steps[i].e = e;
-
- double x = e.x; x /= 3600.0;
- double y = e.y; y /= 3600.0;
-
- const QPointF pixel = mdp->coordinateToScreenPosition(x, y);
- const QPointF deltaP = (pixel - lastPixelAdded);
- const double delta = deltaP.x() * deltaP.x() + deltaP.y() * deltaP.y();
-
- steps[i].pixel = pixel;
-
- if (!lastPixelAdded.isNull() && delta < tolerance) {
- steps[i].tooClose = true;
- } else {
- steps[i].tooClose = false;
- lastPixelAdded = pixel;
- }
- }
-
- QPainterPath::Element em = steps[0].e;
-
- for (int i = 0; i < pathSize; ++i) {
- const QPainterPath::Element &e = steps[i].e;
-
- if (steps[i].tooClose)
- continue;
-
- // guilty until proven innocent
- bool outside = true;
- if (screen.contains(e.x, e.y))
- outside = false;
- if (lastOutside) {
- if (em.x < screen.left() && e.x > screen.right())
- outside = false;
- if (em.x > screen.right() && e.x < screen.left())
- outside = false;
- if (em.y < screen.bottom() && e.y > screen.top())
- outside = false;
- if (em.y > screen.top() && e.y < screen.bottom())
- outside = false;
- }
-
- // skip points not inside the screen rect
- // or attached to points inside it
- if (outside && lastOutside)
- continue;
-
- // entering the screen rect
- if (!outside && lastOutside && i > 0) {
- const QPointF lastPixel = steps[i-1].pixel;
- mpath.moveTo(lastPixel);
- }
- lastOutside = outside;
-
- QPointF pixel = steps[i].pixel;
-
- if (e.isMoveTo())
- mpath.moveTo(pixel);
- else
- mpath.lineTo(pixel);
-
- em = e;
- }
-
- delete[] steps;
-
- QGraphicsPathItem *pi = pathCopy(pathItem);
- pi->setPath(mpath);
- pixelExact.insertMulti(object, pi);
- polys << QPolygonF(pi->boundingRect());
- }
- }
-}
-
-void QGeoMapObjectEngine::pixelShiftToScreen(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys)
-{
- QGraphicsItem *item = graphicsItemFromMapObject(object);
- if (!item)
- return;
-
- const QRectF localRect = item->boundingRect()
- | item->childrenBoundingRect();
-
- // compute the transform as an origin shift
- QList<QPointF> origins;
- origins << QPointF(origin.longitude(), origin.latitude());
- origins << QPointF(origin.longitude() + 360.0, origin.latitude());
- origins << QPointF(origin.longitude() - 360.0, origin.latitude());
-
- foreach (QPointF o, origins) {
- QTransform pixel = item->transform();
- QPointF pixelOrigin = mdp->coordinateToScreenPosition(o.x(), o.y());
- pixel.translate(pixelOrigin.x(), pixelOrigin.y());
- pixelTrans.insertMulti(object, pixel);
- polys << pixel.map(localRect);
- }
-}
-
-/*****************************************************************************
- Update utility functions
- *****************************************************************************/
-
-static void _zoomDepsRecurse(QGeoMapObjectEngine *eng, QGeoMapGroupObject *group)
-{
- foreach (QGeoMapObject *obj, group->childObjects()) {
- QGeoMapGroupObject *subgroup = qobject_cast<QGeoMapGroupObject*>(obj);
- if (subgroup) {
- _zoomDepsRecurse(eng, subgroup);
- } else {
- if (obj->units() == QGeoMapObject::PixelUnit) {
- eng->objectsForLatLonUpdate << obj;
- eng->objectsForPixelUpdate << obj;
- }
- }
- }
-}
-
-void QGeoMapObjectEngine::invalidateZoomDependents()
-{
- if (mdp->containerObject)
- _zoomDepsRecurse(this, mdp->containerObject);
-}
-
-void QGeoMapObjectEngine::invalidatePixelsForViewport(bool updateNow)
-{
- QPolygonF view = latLonViewport();
-
- QList<QGraphicsItem*> itemsInView;
- itemsInView = latLonScene->items(view, Qt::IntersectsItemShape,
- Qt::AscendingOrder);
-
- QSet<QGeoMapObject*> done = objectsForPixelUpdate.toSet();
-
- foreach (QGraphicsItem *latLonItem, itemsInView) {
- QGeoMapObject *object = latLonItems.value(latLonItem);
- Q_ASSERT(object);
- if (!done.contains(object)) {
- objectsForPixelUpdate << object;
- done.insert(object);
- }
- }
-
- if (updateNow)
- mdp->emitUpdateMapDisplay();
-}
-
-void QGeoMapObjectEngine::trimPixelTransforms()
-{
- QPolygonF view = latLonViewport();
-
- QList<QGraphicsItem*> itemsInView;
- itemsInView = latLonScene->items(view, Qt::IntersectsItemShape,
- Qt::AscendingOrder);
-
- QSet<QGeoMapObject*> shouldBe;
- foreach (QGraphicsItem *latLonItem, itemsInView) {
- QGeoMapObject *object = latLonItems.value(latLonItem);
- Q_ASSERT(object);
- shouldBe.insert(object);
- }
-
- QList<QGraphicsItem*> itemsInPixels;
- itemsInPixels = pixelScene->items();
-
- QSet<QGeoMapObject*> currentlyAre;
- foreach (QGraphicsItem *pixelItem, itemsInPixels) {
- QGeoMapObject *object = pixelItems.value(pixelItem);
- Q_ASSERT(object);
- currentlyAre.insert(object);
- }
-
- QSet<QGeoMapObject*> excess = currentlyAre.subtract(shouldBe);
- foreach (QGeoMapObject *object, excess) {
- foreach (QGraphicsItem *item, pixelItemsRev.values(object)) {
- pixelScene->removeItem(item);
- pixelItems.remove(item);
- delete item;
- }
- pixelTrans.remove(object);
- pixelItemsRev.remove(object);
- }
-
- mdp->emitUpdateMapDisplay();
-}
-
-void QGeoMapObjectEngine::invalidateObject(QGeoMapObject *obj)
-{
- // force the lat lon to update now
- // otherwise we can't tell if it's supposed to be on screen
- updateLatLonTransform(obj);
-
- const QRectF view = latLonViewport().boundingRect();
-
- bool needsPixelUpdate = false;
- foreach (QGraphicsItem *item, latLonItemsRev.values(obj)) {
- if (item->boundingRect().intersects(view)) {
- needsPixelUpdate = true;
- break;
- }
- }
-
- if (needsPixelUpdate) {
- objectsForPixelUpdate << obj;
- mdp->emitUpdateMapDisplay();
- }
-}
-
-// update the transform tables as necessary
-void QGeoMapObjectEngine::updateTransforms()
-{
- bool groupUpdated = false;
-
- foreach (QGeoMapObject *obj, objectsForLatLonUpdate) {
- QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
- if (group) {
- updateLatLonsForGroup(group);
- groupUpdated = true;
- } else {
- updateLatLonTransform(obj);
- }
- }
-
- objectsForLatLonUpdate.clear();
-
- foreach (QGeoMapObject *obj, objectsForPixelUpdate) {
- QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
- if (group) {
- updatePixelsForGroup(group);
- groupUpdated = true;
- } else {
- updatePixelTransform(obj);
- }
- }
-
- objectsForPixelUpdate.clear();
-
- if (groupUpdated)
- rebuildScenes();
-}
-
-void QGeoMapObjectEngine::updatePixelsForGroup(QGeoMapGroupObject *group)
-{
- foreach (QGeoMapObject *obj, group->childObjects()) {
- QGeoMapGroupObject *subgroup = qobject_cast<QGeoMapGroupObject*>(obj);
- if (subgroup) {
- updatePixelsForGroup(subgroup);
- } else {
- updatePixelTransform(obj);
- }
- }
-}
-
-void QGeoMapObjectEngine::updateLatLonsForGroup(QGeoMapGroupObject *group)
-{
- foreach (QGeoMapObject *object, group->childObjects()) {
- QGeoMapGroupObject *subGroup = qobject_cast<QGeoMapGroupObject*>(object);
- if (subGroup)
- updateLatLonsForGroup(subGroup);
- else
- updateLatLonTransform(object);
- }
-}
-
-static void addGroupToScene(QGeoMapObjectEngine *eng, QGeoMapGroupObject *group)
-{
- foreach (QGeoMapObject *object, group->childObjects()) {
- QGeoMapGroupObject *subGroup = qobject_cast<QGeoMapGroupObject*>(object);
- if (subGroup) {
- addGroupToScene(eng, subGroup);
- } else {
- foreach (QGraphicsItem *i, eng->latLonItemsRev.values(object))
- eng->latLonScene->addItem(i);
- foreach (QGraphicsItem *i, eng->pixelItemsRev.values(object))
- eng->pixelScene->addItem(i);
- }
- }
-}
-
-void QGeoMapObjectEngine::rebuildScenes()
-{
- foreach (QGraphicsItem *i, latLonScene->items())
- latLonScene->removeItem(i);
- foreach (QGraphicsItem *i, pixelScene->items())
- pixelScene->removeItem(i);
-
- delete latLonScene;
- delete pixelScene;
-
- latLonScene = new QGraphicsScene;
- pixelScene = new QGraphicsScene;
- pixelScene->setItemIndexMethod(QGraphicsScene::NoIndex);
-
- addGroupToScene(this, mdp->containerObject);
-}
-
-/*****************************************************************************
- Actual update functions
- *****************************************************************************/
-
-void QGeoMapObjectEngine::updateLatLonTransform(QGeoMapObject *object)
-{
- QGeoCoordinate origin = object->origin();
-
- QGraphicsItem *item = graphicsItemFromMapObject(object);
-
- // skip any objects without graphicsitems
- if (!item)
- return;
-
- QRectF localRect = (item->boundingRect() | item->childrenBoundingRect());
-
- // skip any objects with invalid bounds
- if (!localRect.isValid() || localRect.isEmpty() || localRect.isNull())
- return;
-
- QPolygonF local = localRect * item->transform();
- QList<QPolygonF> polys;
-
- latLonTrans.remove(object);
-
- if (object->transformType() == QGeoMapObject::BilinearTransform ||
- object->units() == QGeoMapObject::PixelUnit) {
- QTransform latLon;
-
- if (object->units() == QGeoMapObject::MeterUnit) {
- bilinearMetersToSeconds(origin, item, local, latLon);
- } else if (object->units() == QGeoMapObject::RelativeArcSecondUnit) {
- latLon.translate(origin.longitude() * 3600.0, origin.latitude() * 3600.0);
- } else if (object->units() == QGeoMapObject::PixelUnit) {
- bilinearPixelsToSeconds(origin, item, local, latLon);
- }
-
- polys << latLon.map(localRect);
- latLonTrans.insertMulti(object, latLon);
-
- QTransform latLonWest;
- latLonWest.translate(360.0 * 3600.0, 0.0);
- latLonWest = latLon * latLonWest;
-
- polys << latLonWest.map(localRect);
- latLonTrans.insertMulti(object, latLonWest);
-
- QTransform latLonEast;
- latLonEast.translate(-360.0 * 3600.0, 0.0);
- latLonEast = latLon * latLonEast;
-
- polys << latLonEast.map(localRect);
- latLonTrans.insertMulti(object, latLonEast);
-
- } else if (object->transformType() == QGeoMapObject::ExactTransform) {
- if (object->units() == QGeoMapObject::MeterUnit) {
- if (!exactMetersToSeconds(origin, object, item, polys))
- return;
- } else if (object->units() == QGeoMapObject::AbsoluteArcSecondUnit ||
- object->units() == QGeoMapObject::RelativeArcSecondUnit) {
- if (!exactSecondsToSeconds(origin, object, item, polys))
- return;
- } else {
- qWarning("QGeoMapData: unknown units for map object");
- return;
- }
- }
-
- QList<QGraphicsItem*> items = latLonItemsRev.values(object);
- if (items.size() != polys.size()) {
- foreach (QGraphicsItem *item, items) {
- latLonScene->removeItem(item);
- latLonItems.remove(item);
- delete item;
- }
- latLonItemsRev.remove(object);
-
- foreach (QPolygonF poly, polys) {
- QGraphicsItem *item = new QGraphicsPolygonItem(poly);
- //item->setZValue(object->zValue());
- item->setVisible(true);
- latLonItems.insert(item, object);
- latLonItemsRev.insertMulti(object, item);
- latLonScene->addItem(item);
- }
- } else {
- for (int i = 0; i < polys.size(); ++i) {
- QGraphicsItem *item = items.at(i);
-
- if (!item)
- continue;
-
- QGraphicsPolygonItem *pi = dynamic_cast<QGraphicsPolygonItem*>(item);
- Q_ASSERT(pi);
- pi->setPolygon(polys.at(i));
- // pi->setZValue(object->zValue());
- }
- }
-}
-
-void QGeoMapObjectEngine::updatePixelTransform(QGeoMapObject *object)
-{
- QGeoCoordinate origin = object->origin();
- QGraphicsItem *item = graphicsItemFromMapObject(object);
-
- // skip any objects without graphicsitems
- if (!item)
- return;
-
- QRectF localRect = (item->boundingRect() | item->childrenBoundingRect());
-
- // skip any objects with invalid bounds
- if (!localRect.isValid() || localRect.isEmpty() || localRect.isNull())
- return;
-
- QList<QPolygonF> polys;
-
- pixelTrans.remove(object);
- if (object->transformType() == QGeoMapObject::BilinearTransform) {
- bilinearSecondsToScreen(origin, object, polys);
- } else if (object->transformType() == QGeoMapObject::ExactTransform) {
- if (object->units() == QGeoMapObject::PixelUnit) {
- pixelShiftToScreen(origin, object, polys);
- } else {
- exactPixelMap(origin, object, polys);
- }
- }
-
- QList<QGraphicsItem*> items = pixelItemsRev.values(object);
-
- if (items.size() != polys.size()) {
- foreach (QGraphicsItem *item, items) {
- pixelItems.remove(item);
- pixelScene->removeItem(item);
- delete item;
- }
- pixelItemsRev.remove(object);
- foreach (QPolygonF poly, polys) {
- QGraphicsPolygonItem *item = new QGraphicsPolygonItem(poly);
- //item->setZValue(object->zValue());
- item->setVisible(true);
- pixelItems.insert(item, object);
- pixelItemsRev.insertMulti(object, item);
- pixelScene->addItem(item);
- }
- } else {
- for (int i = 0; i < polys.size(); ++i) {
- QGraphicsItem *item = items.at(i);
-
- if (!item)
- continue;
-
- QGraphicsPolygonItem *pi = dynamic_cast<QGraphicsPolygonItem*>(item);
- Q_ASSERT(pi);
- pi->setPolygon(polys.at(i));
- //pi->setZValue(object->zValue());
- }
- }
-}
-
-QPolygonF QGeoMapObjectEngine::latLonViewport()
-{
- QPolygonF view;
- QGeoBoundingBox viewport = md->viewport();
- QGeoCoordinate c, c2;
- double offset = 0.0;
-
- c = viewport.bottomLeft();
- view << QPointF(c.longitude() * 3600.0, c.latitude() * 3600.0);
- c2 = viewport.bottomRight();
- if (c2.longitude() <= c.longitude())
- offset = 360.0 * 3600.0;
- view << QPointF(c2.longitude() * 3600.0 + offset, c2.latitude() * 3600.0);
- c = viewport.topRight();
- view << QPointF(c.longitude() * 3600.0 + offset, c.latitude() * 3600.0);
- c = viewport.topLeft();
- view << QPointF(c.longitude() * 3600.0, c.latitude() * 3600.0);
-
- return view;
-}
-
-QPolygonF QGeoMapObjectEngine::polyToScreen(const QPolygonF &poly)
-{
- QPolygonF r;
-#if QT_VERSION >= 0x040700
- r.reserve(poly.size());
-#endif
- foreach (QPointF pt, poly) {
- const double x = pt.x() / 3600.0;
- const double y = pt.y() / 3600.0;
- const QPointF pixel = mdp->coordinateToScreenPosition(x, y);
- r.append(pixel);
- }
- return r;
-}
-
-QGraphicsItem* QGeoMapObjectEngine::graphicsItemFromMapObject(QGeoMapObject *object)
-{
- if (!object || !object->info())
- return 0;
-
- QGeoTiledMapObjectInfo *tiledInfo
- = static_cast<QGeoTiledMapObjectInfo*>(object->info());
-
- if (tiledInfo)
- return tiledInfo->graphicsItem;
-
- return 0;
-}
-
-#include "moc_qgeomapobjectengine_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapobjectengine_p.h b/src/location/maps/qgeomapobjectengine_p.h
deleted file mode 100644
index 91d0bc97..00000000
--- a/src/location/maps/qgeomapobjectengine_p.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPOBJECTENGINE_P_H
-#define QGEOMAPOBJECTENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qmobilityglobal.h"
-#include "qgeomapdata_p.h"
-#include "qgeomapdata.h"
-#include "qgeomapobject_p.h"
-#include "qgeomapobject.h"
-
-#include <QHash>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-class QTransform;
-class QGraphicsItem;
-class QGraphicsScene;
-
-
-class QGeoMapObjectEngine : public QObject
-{
- Q_OBJECT
-public:
- QGeoMapObjectEngine(QGeoMapData *mapData, QGeoMapDataPrivate *mapDataP);
- virtual ~QGeoMapObjectEngine();
-
- QGeoMapData *md;
- QGeoMapDataPrivate *mdp;
-
- double exactMappingTolerance;
-
- /*** Lookup hashes and scenes ***/
-
- QHash<const QGeoMapObject*, QGraphicsItem*> latLonExact;
- QHash<const QGeoMapObject*, QGraphicsItem*> pixelExact;
-
- QHash<const QGeoMapObject*, QTransform> latLonTrans;
- QGraphicsScene *latLonScene;
- QHash<QGraphicsItem*, QGeoMapObject*> latLonItems;
- QHash<QGeoMapObject*, QGraphicsItem*> latLonItemsRev;
-
- QHash<const QGeoMapObject*, QTransform> pixelTrans;
- QGraphicsScene *pixelScene;
- QHash<QGraphicsItem*, QGeoMapObject*> pixelItems;
- QHash<QGeoMapObject*, QGraphicsItem*> pixelItemsRev;
-
- /*** Object management ***/
-
- virtual void addObject(QGeoMapObject *object);
- virtual void removeObject(QGeoMapObject *object);
-
- /*** Updating and validity ***/
-
- virtual void updateTransforms();
-
- QList<QGeoMapObject*> objectsForPixelUpdate;
- QList<QGeoMapObject*> objectsForLatLonUpdate;
-
- virtual void updatePixelsForGroup(QGeoMapGroupObject *group);
- virtual void updateLatLonsForGroup(QGeoMapGroupObject *group);
-
- virtual void updateLatLonTransform(QGeoMapObject *object);
- virtual void updatePixelTransform(QGeoMapObject *object);
-
- virtual void rebuildScenes();
-
- virtual void invalidateObject(QGeoMapObject *obj);
- virtual void invalidateZoomDependents();
- virtual void invalidatePixelsForViewport(bool updateNow=true);
- virtual void trimPixelTransforms();
-
-public:
-
- /*** Exact transform functions ***/
-
- // these are virtual so subclasses can add new types
- // of exact transform
- virtual bool exactMetersToSeconds(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QGraphicsItem *item,
- QList<QPolygonF> &polys);
- virtual bool exactSecondsToSeconds(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QGraphicsItem *item,
- QList<QPolygonF> &polys);
-
- virtual void exactPixelMap(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys);
-
- /*** Bilinear transforms ***/
-
- void bilinearMetersToSeconds(const QGeoCoordinate &origin,
- QGraphicsItem *item,
- QPolygonF &local,
- QTransform &latLon);
- void bilinearPixelsToSeconds(const QGeoCoordinate &origin,
- QGraphicsItem *item,
- QPolygonF &local,
- QTransform &latLon);
- void bilinearSecondsToScreen(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys);
-
- /*** Pixel shift transforms ***/
-
- void pixelShiftToScreen(const QGeoCoordinate &origin,
- QGeoMapObject *object,
- QList<QPolygonF> &polys);
-
- /*** Misc ***/
- virtual QGraphicsItem* graphicsItemFromMapObject(QGeoMapObject *object);
-
-private:
- /*** Internal helpers ***/
- QPolygonF latLonViewport();
- QPolygonF polyToScreen(const QPolygonF &poly);
-
- Q_DISABLE_COPY(QGeoMapObjectEngine)
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOMAPOBJECTENGINE_P_H
diff --git a/src/location/maps/qgeomapobjectinfo.cpp b/src/location/maps/qgeomapobjectinfo.cpp
deleted file mode 100644
index eeefcb8a..00000000
--- a/src/location/maps/qgeomapobjectinfo.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapobjectinfo.h"
-#include "qgeomapobjectinfo_p.h"
-
-#include "qgeomapdata.h"
-#include "qgeomapdata_p.h"
-#include "qgeomapobject.h"
-#include "qgeomapobject_p.h"
-#include "qgeoboundingbox.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapObjectInfo
- \brief The QGeoMapObjectInfo class is the base class used to define the
- parts of QGeoMapObject and its subclasses that are specific to a
- particular QGeoMapData subclass.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-impl
-
- Most of the mapping functionality is provided by a QGeoMapData subclass,
- including the rendering of the map itself.
-
- This means that QGeoMapData subclasses need to be able to render each of
- the QGeoMapObject instances and instances of the QGeoMapObject subclasses.
-
- Furthermore, the need to be able to create and manipulate map objects
- independently from the QGeoMapData instance precludes the use of a set of
- factory methods for creating QGeoMapData specific map objects.
-
- The QGeoMapObjectInfo class is used to provide the QGeoMapData subclass
- specific behaviours for the map objects in a way which fulfils this need,
- as the QGeoMapObjectInfo instances are only created at the point when a
- map object becomes associated with a QGeoMapData subclass - which is most
- commonly when the object is added to a QGraphicsGeoMap.
-*/
-
-/*!
- Constructs a new object info instance which will provide the behaviours of
- \a mapObject which are specific to \a mapData.
-*/
-QGeoMapObjectInfo::QGeoMapObjectInfo(QGeoMapData *mapData, QGeoMapObject *mapObject)
- : QObject(mapObject),
- d_ptr(new QGeoMapObjectInfoPrivate(mapData, mapObject)) {}
-
-/*!
- Destroys this info object.
-*/
-QGeoMapObjectInfo::~QGeoMapObjectInfo()
-{
- delete d_ptr;
-}
-
-/*!
- This function is run after the constructor.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::init() {}
-
-/*!
- This function is called when the window size of the map changes to
- \a windowSize.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::windowSizeChanged(const QSizeF &windowSize)
-{
- Q_UNUSED(windowSize)
-}
-
-/*!
- This function is called when the zoom level of the map changes to
- \a zoomLevel.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::zoomLevelChanged(qreal zoomLevel)
-{
- Q_UNUSED(zoomLevel)
-}
-
-/*!
- This function is called when the center of the map changes to
- \a coordinate.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::centerChanged(const QGeoCoordinate &coordinate)
-{
- Q_UNUSED(coordinate)
-}
-
-/*!
- This function is run when the z value of the object changes to \a zValue.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::zValueChanged(int zValue)
-{
- Q_UNUSED(zValue)
-}
-
-/*!
- This function is run when the visible state of the object changes to
- \a visible.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::visibleChanged(bool visible)
-{
- Q_UNUSED(visible)
-}
-
-/*!
- This function is run when the selected state of the object changes to
- \a selected.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::selectedChanged(bool selected)
-{
- Q_UNUSED(selected)
-}
-
-/*!
- This function is run when the origin of the object changes to
- \a origin.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::originChanged(const QGeoCoordinate &origin)
-{
- Q_UNUSED(origin);
-}
-
-/*!
- This function is run when the coordinate units of the object changes to
- \a units.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::unitsChanged(QGeoMapObject::CoordinateUnit units)
-{
- Q_UNUSED(units);
-}
-
-/*!
- This function is run when the transform type of the object changes to
- \a transformType.
-
- The default implementation does nothing.
-*/
-void QGeoMapObjectInfo::transformTypeChanged(QGeoMapObject::TransformType transformType)
-{
- Q_UNUSED(transformType);
-}
-
-/*!
- Returns a bounding box which contains this map object.
-
- The default implementation returns an invalid bounding box.
-*/
-QGeoBoundingBox QGeoMapObjectInfo::boundingBox() const
-{
- return QGeoBoundingBox();
-}
-
-/*!
- Returns whether \a coordinate is contained with the boundary of this
- map object.
-
- The default implementation returns false.
-*/
-bool QGeoMapObjectInfo::contains(const QGeoCoordinate &coordinate) const
-{
- Q_UNUSED(coordinate)
- return false;
-}
-
-/*!
- Returns the QGeoMapData instance associated with this info object.
-*/
-QGeoMapData* QGeoMapObjectInfo::mapData()
-{
- return d_ptr->mapData;
-}
-
-// Need to keep this for BC, otherwise would probably replace with const
-// version
-/*!
- Returns the QGeoMapObject instance associated with this info object.
-*/
-QGeoMapObject* QGeoMapObjectInfo::mapObject()
-{
- return d_ptr->mapObject;
-}
-
-/*!
- Returns the QGeoMapObject instance associated with this info object.
-*/
-QGeoMapObject* QGeoMapObjectInfo::mapObject() const
-{
- return d_ptr->mapObject;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapObjectInfoPrivate::QGeoMapObjectInfoPrivate(QGeoMapData *mapData, QGeoMapObject *mapObject)
- : mapData(mapData),
- mapObject(mapObject) {}
-
-QGeoMapObjectInfoPrivate::~QGeoMapObjectInfoPrivate() {}
-
-/*******************************************************************************
-*******************************************************************************/
-
-#include "moc_qgeomapobjectinfo.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapoverlay.cpp b/src/location/maps/qgeomapoverlay.cpp
deleted file mode 100644
index 8ee2e80d..00000000
--- a/src/location/maps/qgeomapoverlay.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomapoverlay.h"
-#include "qgeomapoverlay_p.h"
-
-#include "qgeomapdata.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapOverlay
- \brief The QGeoMapOverlay class is used to draw overlays on the map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping
-
- This allows for general drawing to occur in overlays above the map.
-*/
-
-/*!
- Constructs a new map overlay object.
-*/
-QGeoMapOverlay::QGeoMapOverlay()
- : d_ptr(new QGeoMapOverlayPrivate()) {}
-
-/*!
- Destroys this map overlay object.
-*/
-QGeoMapOverlay::~QGeoMapOverlay()
-{
- delete d_ptr;
-}
-
-/*!
-\fn void QGeoMapOverlay::paint(QPainter *painter, const QStyleOptionGraphicsItem *option)
-
-Paints the overlay on \a painter, using the options \a option.
-*/
-
-/*!
- \internal
-*/
-void QGeoMapOverlay::setMapData(QGeoMapData * mapData)
-{
- d_ptr->mapData = mapData;
-}
-
-/*!
- Returns the QGeoMapData instance that this overlay is associated, or 0
- if there is not such instance.
-
- The QGeoMapData instance provides access to information such as the
- zoom level and viewport position as well as methods to convert
- screen positions to coordinates and vice-versa.
-*/
-QGeoMapData const * QGeoMapOverlay::mapData() const
-{
- return d_ptr->mapData;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapOverlayPrivate::QGeoMapOverlayPrivate()
- : mapData(0) {}
-
-
-QGeoMapOverlayPrivate::~QGeoMapOverlayPrivate() {}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomappingmanager.cpp b/src/location/maps/qgeomappingmanager.cpp
index 23027fa8..adc65691 100644
--- a/src/location/maps/qgeomappingmanager.cpp
+++ b/src/location/maps/qgeomappingmanager.cpp
@@ -42,7 +42,9 @@
#include "qgeomappingmanager.h"
#include "qgeomappingmanager_p.h"
#include "qgeomappingmanagerengine.h"
+#include "qgeotiledmapreply.h"
+#include <QTimer>
#include <QNetworkProxy>
#include <QLocale>
@@ -90,11 +92,36 @@ QGeoMappingManager::QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject
d_ptr(new QGeoMappingManagerPrivate)
{
d_ptr->engine = engine;
- if (d_ptr->engine) {
- d_ptr->engine->setParent(this);
- } else {
+ if (!d_ptr->engine) {
qFatal("The mapping manager engine that was set for this mapping manager was NULL.");
}
+
+ d_ptr->thread= new QThread;
+
+ connect(d_ptr->engine,
+ SIGNAL(tileFinished(TileSpec,QByteArray)),
+ this,
+ SIGNAL(tileFinished(TileSpec,QByteArray)),
+ Qt::QueuedConnection);
+ connect(d_ptr->engine,
+ SIGNAL(tileError(TileSpec,QString)),
+ this,
+ SIGNAL(tileError(TileSpec,QString)),
+ Qt::QueuedConnection);
+ connect(d_ptr->engine,
+ SIGNAL(queueFinished()),
+ this,
+ SIGNAL(queueFinished()),
+ Qt::QueuedConnection);
+
+ connect(d_ptr->thread,
+ SIGNAL(started()),
+ d_ptr->engine,
+ SLOT(threadStarted()),
+ Qt::QueuedConnection);
+
+ d_ptr->engine->moveToThread(d_ptr->thread);
+ QTimer::singleShot(0, d_ptr->thread, SLOT(start()));
}
/*!
@@ -129,29 +156,47 @@ int QGeoMappingManager::managerVersion() const
return d_ptr->engine->managerVersion();
}
-/*!
- Returns a new QGeoMapData instance which will be managed by this manager.
-*/
-QGeoMapData* QGeoMappingManager::createMapData()
+void QGeoMappingManager::requestTiles(const QList<TileSpec> &tiles)
{
- return d_ptr->engine->createMapData();
+ QMetaObject::invokeMethod(d_ptr->engine, "requestTiles",
+ Qt::QueuedConnection,
+ Q_ARG(QList<TileSpec>, tiles));
}
-/*!
- Returns a list of the map types supported by this manager.
-*/
-QList<QGraphicsGeoMap::MapType> QGeoMappingManager::supportedMapTypes() const
-{
- return d_ptr->engine->supportedMapTypes();
-}
-
-/*!
- Returns a list of the connectivity modes supported by this manager.
-*/
-QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManager::supportedConnectivityModes() const
-{
- return d_ptr->engine->supportedConnectivityModes();
-}
+//QGeoTiledMapReply* QGeoMappingManager::getTileImage(const TileSpec &spec)
+//{
+// qWarning() << d_ptr->engine->minimumZoomLevel() << d_ptr->engine->maximumZoomLevel();
+// QGeoTiledMapReply* reply = d_ptr->engine->getTileImage(spec);
+
+// connect(reply, SIGNAL(finished()), this, SLOT(tileFinished()));
+
+// return reply;
+//}
+
+//void QGeoMappingManager::tileFinished()
+//{
+// QGeoTiledMapReply *reply = qobject_cast<QGeoTiledMapReply*>(sender());
+// if (!reply)
+// return;
+
+// emit finished(reply);
+//}
+
+///*!
+// Returns a list of the map types supported by this manager.
+//*/
+//QList<QGraphicsGeoMap::MapType> QGeoMappingManager::supportedMapTypes() const
+//{
+// return d_ptr->engine->supportedMapTypes();
+//}
+
+///*!
+// Returns a list of the connectivity modes supported by this manager.
+//*/
+//QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManager::supportedConnectivityModes() const
+//{
+// return d_ptr->engine->supportedConnectivityModes();
+//}
/*!
Returns the minimum zoom level supported by this manager.
@@ -214,18 +259,6 @@ qreal QGeoMappingManager::maximumTilt() const
}
/*!
- Returns whether custom map objects are supported by this engine.
-
- Custom map objects are map objects based on QGraphicsItem instances, which
- are hard to support in cases where the map rendering is not being
- performed by the Qt Graphics View framwork.
-*/
-bool QGeoMappingManager::supportsCustomMapObjects() const
-{
- return d_ptr->engine->supportsCustomMapObjects();
-}
-
-/*!
Sets the locale to be used by the this manager to \a locale.
If this mapping manager supports returning map labels
@@ -257,6 +290,7 @@ QGeoMappingManagerPrivate::~QGeoMappingManagerPrivate()
{
if (engine)
delete engine;
+ delete thread;
}
#include "moc_qgeomappingmanager.cpp"
diff --git a/src/location/maps/qgeomappingmanager.h b/src/location/maps/qgeomappingmanager.h
index d2e51b32..59c9b57d 100644
--- a/src/location/maps/qgeomappingmanager.h
+++ b/src/location/maps/qgeomappingmanager.h
@@ -42,7 +42,9 @@
#ifndef QGEOMAPPINGMANAGER_H
#define QGEOMAPPINGMANAGER_H
-#include "qgraphicsgeomap.h"
+//#include "qgraphicsgeomap.h"
+
+#include "qmobilityglobal.h"
#include <QObject>
#include <QSize>
@@ -54,12 +56,14 @@ class QLocale;
class QGeoBoundingBox;
class QGeoCoordinate;
-class QGeoMapData;
class QGeoMappingManagerPrivate;
class QGeoMapRequestOptions;
class QGeoMappingManagerEngine;
+class QGeoTiledMapReply;
+class TileSpec;
+
class Q_LOCATION_EXPORT QGeoMappingManager : public QObject
{
Q_OBJECT
@@ -70,10 +74,20 @@ public:
QString managerName() const;
int managerVersion() const;
- QGeoMapData* createMapData();
-
- QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
- QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
+ void requestTiles(const QList<TileSpec> &tiles);
+
+ /*
+ Possibly replace the MapType enum with some kind of struct / class
+ MapLayer {
+ enum? type
+ QString key;
+ QString description;
+ }
+ where enum includes things like street, satellite (day), satellite (night), traffic
+ but _really_ needs to include custom so people can go wild with layers
+ */
+// QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
+// QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
qreal minimumZoomLevel() const;
qreal maximumZoomLevel() const;
@@ -84,11 +98,14 @@ public:
qreal minimumTilt() const;
qreal maximumTilt() const;
- bool supportsCustomMapObjects() const;
-
void setLocale(const QLocale &locale);
QLocale locale() const;
+signals:
+ void tileFinished(const TileSpec &spec, const QByteArray &bytes);
+ void tileError(const TileSpec &spec, const QString &errorString);
+ void queueFinished();
+
private:
QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject *parent = 0);
diff --git a/src/location/maps/qgeomappingmanager_p.h b/src/location/maps/qgeomappingmanager_p.h
index fa0cbbca..73688384 100644
--- a/src/location/maps/qgeomappingmanager_p.h
+++ b/src/location/maps/qgeomappingmanager_p.h
@@ -53,10 +53,11 @@
// We mean it.
//
-#include "qgraphicsgeomap.h"
+#include "qmobilityglobal.h"
#include <QSize>
#include <QList>
+#include <QThread>
QT_BEGIN_NAMESPACE
@@ -68,6 +69,7 @@ public:
QGeoMappingManagerPrivate();
~QGeoMappingManagerPrivate();
+ QThread *thread;
QGeoMappingManagerEngine *engine;
private:
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
index 362ec23f..df1f464f 100644
--- a/src/location/maps/qgeomappingmanagerengine.cpp
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -41,6 +41,8 @@
#include "qgeomappingmanagerengine.h"
#include "qgeomappingmanagerengine_p.h"
+#include "qgeotiledmapreply.h"
+#include "tilespec.h"
#include <QNetworkProxy>
@@ -76,7 +78,7 @@ QGeoMappingManagerEngine::QGeoMappingManagerEngine(const QMap<QString, QVariant>
: QObject(parent),
d_ptr(new QGeoMappingManagerEnginePrivate())
{
- Q_UNUSED(parameters)
+ d_ptr->parameters = parameters;
}
/*!
@@ -95,6 +97,124 @@ QGeoMappingManagerEngine::~QGeoMappingManagerEngine()
delete d;
}
+QMap<QString, QVariant> QGeoMappingManagerEngine::parameters() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->parameters;
+}
+
+void QGeoMappingManagerEngine::init()
+{
+}
+
+void QGeoMappingManagerEngine::threadStarted()
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ init();
+
+ d->timer_ = new QTimer(this);
+
+ d->timer_->setInterval(0);
+
+ connect(d->timer_,
+ SIGNAL(timeout()),
+ this,
+ SLOT(requestNextTile()));
+
+ d->started_ = true;
+ if (!d->queue_.isEmpty())
+ d->timer_->start();
+}
+
+
+void QGeoMappingManagerEngine::requestTiles(const QList<TileSpec> &tiles)
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ if (!d->started_) {
+ d->queue_ = tiles;
+ return;
+ }
+
+ for (int i = 0; i < d->queue_.size(); ++i) {
+ QGeoTiledMapReply* reply = d->invmap_.value(d->queue_.at(i), 0);
+ if (reply) {
+ reply->abort();
+ d->map_.remove(reply);
+ d->invmap_.remove(d->queue_.at(i));
+ reply->deleteLater();
+ }
+ }
+
+ d->queue_ = tiles;
+
+ if (!d->queue_.empty())
+ d->timer_->start();
+}
+
+void QGeoMappingManagerEngine::requestNextTile()
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ TileSpec ts = d->queue_.takeFirst();
+
+ QGeoTiledMapReply *reply = getTileImage(ts);
+
+ if (reply->isFinished()) {
+ handleReply(reply, ts);
+ } else {
+ connect(reply,
+ SIGNAL(finished()),
+ this,
+ SLOT(finished()));
+
+ d->map_.insert(reply, ts);
+ d->invmap_.insert(ts, reply);
+ }
+
+ if (d->queue_.isEmpty())
+ d->timer_->stop();
+}
+
+void QGeoMappingManagerEngine::finished()
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ QGeoTiledMapReply *reply = qobject_cast<QGeoTiledMapReply*>(sender());
+ if (!reply)
+ return;
+
+ if (!d->map_.contains(reply)) {
+ reply->deleteLater();
+ return;
+ }
+
+ TileSpec spec = d->map_.value(reply);
+
+ d->map_.remove(reply);
+ d->invmap_.remove(spec);
+
+ handleReply(reply, spec);
+}
+
+void QGeoMappingManagerEngine::handleReply(QGeoTiledMapReply *reply, const TileSpec &spec)
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ if (reply->error() == QGeoTiledMapReply::NoError) {
+ QByteArray bytes = reply->mapImageData();
+ emit tileFinished(spec, bytes);
+ } else {
+ emit tileError(spec, reply->errorString());
+ }
+
+ if (d->queue_.isEmpty())
+ emit queueFinished();
+
+ reply->deleteLater();
+}
+
/*!
Sets the name which this engine implementation uses to distinguish itself
from the implementations provided by other plugins to \a managerName.
@@ -141,42 +261,23 @@ int QGeoMappingManagerEngine::managerVersion() const
return d_ptr->managerVersion;
}
-/*!
-\fn QGeoMapData* QGeoMappingManagerEngine::createMapData()
-
- Returns a new QGeoMapData instance which will be managed by
- this manager.
-
- A QGeoMapData instance contains and manages the information about
- what a QGraphicsGeoMap is looking at. A single manager can be used by several
- QGraphicsGeoMap instances since each instance has an associated QGeoMapData instance.
-
- The QGeoMapData instance can be treated as a kind of session object, or
- as a model in a model-view-controller architecture, with QGraphicsGeoMap
- as the view and QGeoMappingManagerEngine as the controller.
-
- Subclasses of QGeoMappingManagerEngine are free to override this function
- to return subclasses of QGeoMapData in order to customize the
- map.
-*/
-
-/*!
- Returns a list of the map types supported by this engine.
-*/
-QList<QGraphicsGeoMap::MapType> QGeoMappingManagerEngine::supportedMapTypes() const
-{
- Q_D(const QGeoMappingManagerEngine);
- return d->supportedMapTypes;
-}
-
-/*!
- Returns a list of the connectivity modes supported by this engine.
-*/
-QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManagerEngine::supportedConnectivityModes() const
-{
- Q_D(const QGeoMappingManagerEngine);
- return d->supportedConnectivityModes;
-}
+///*!
+// Returns a list of the map types supported by this engine.
+//*/
+//QList<QGraphicsGeoMap::MapType> QGeoMappingManagerEngine::supportedMapTypes() const
+//{
+// Q_D(const QGeoMappingManagerEngine);
+// return d->supportedMapTypes;
+//}
+
+///*!
+// Returns a list of the connectivity modes supported by this engine.
+//*/
+//QList<QGraphicsGeoMap::ConnectivityMode> QGeoMappingManagerEngine::supportedConnectivityModes() const
+//{
+// Q_D(const QGeoMappingManagerEngine);
+// return d->supportedConnectivityModes;
+//}
/*!
Returns the minimum zoom level supported by this engine.
@@ -203,32 +304,44 @@ qreal QGeoMappingManagerEngine::maximumZoomLevel() const
return d->maximumZoomLevel;
}
-/*!
- Sets the list of map types supported by this engine to \a mapTypes.
-
- Subclasses of QGeoMappingManagerEngine should use this function to ensure
- that supportedMapTypes() provides accurate information.
-*/
-void QGeoMappingManagerEngine::setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes)
+///*!
+// Sets the list of map types supported by this engine to \a mapTypes.
+
+// Subclasses of QGeoMappingManagerEngine should use this function to ensure
+// that supportedMapTypes() provides accurate information.
+//*/
+//void QGeoMappingManagerEngine::setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes)
+//{
+// Q_D(QGeoMappingManagerEngine);
+// d->supportedMapTypes = mapTypes;
+//}
+
+///*!
+// Sets the list of connectivity modes supported by this engine to \a connectivityModes.
+
+// Subclasses of QGeoMappingManagerEngine should use this function to ensure
+// that supportedConnectivityModes() provides accurate information.
+
+// If createMapData does not specify a connectivity mode the first mode from
+// \a connectivityModes will be used, or QGraphicsGeoMap::NoConnectivity will
+// be used if \a connectivityModes is empty.
+//*/
+//void QGeoMappingManagerEngine::setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes)
+//{
+// Q_D(QGeoMappingManagerEngine);
+// d->supportedConnectivityModes = connectivityModes;
+//}
+
+void QGeoMappingManagerEngine::setTileSize(const QSize &tileSize)
{
Q_D(QGeoMappingManagerEngine);
- d->supportedMapTypes = mapTypes;
+ d->tileSize = tileSize;
}
-/*!
- Sets the list of connectivity modes supported by this engine to \a connectivityModes.
-
- Subclasses of QGeoMappingManagerEngine should use this function to ensure
- that supportedConnectivityModes() provides accurate information.
-
- If createMapData does not specify a connectivity mode the first mode from
- \a connectivityModes will be used, or QGraphicsGeoMap::NoConnectivity will
- be used if \a connectivityModes is empty.
-*/
-void QGeoMappingManagerEngine::setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes)
+QSize QGeoMappingManagerEngine::tileSize() const
{
- Q_D(QGeoMappingManagerEngine);
- d->supportedConnectivityModes = connectivityModes;
+ Q_D(const QGeoMappingManagerEngine);
+ return d->tileSize;
}
/*!
@@ -364,32 +477,6 @@ void QGeoMappingManagerEngine::setSupportsTilting(bool supportsTilting)
}
/*!
- Returns whether custom map objects are supported by this engine.
-
- Custom map objects are map objects based on QGraphicsItem instances, which
- are hard to support in cases where the map rendering is not being
- performed by the Qt Graphics View framwork.
-*/
-bool QGeoMappingManagerEngine::supportsCustomMapObjects() const
-{
- Q_D(const QGeoMappingManagerEngine);
- return d->supportsCustomMapObjects;
-}
-
-/*!
- Sets whether custom map objects are supported by this engine to \a supportsCustomMapObjects.
-
- Custom map objects are map objects based on QGraphicsItem instances, which
- are hard to support in cases where the map rendering is not being
- performed by the Qt Graphics View framwork.
-*/
-void QGeoMappingManagerEngine::setSupportsCustomMapObjects(bool supportsCustomMapObjects)
-{
- Q_D(QGeoMappingManagerEngine);
- d->supportsCustomMapObjects = supportsCustomMapObjects;
-}
-
-/*!
Sets the locale to be used by the this manager to \a locale.
If this mapping manager supports returning map labels
@@ -422,7 +509,7 @@ QGeoMappingManagerEnginePrivate::QGeoMappingManagerEnginePrivate()
supportsTilting(false),
minimumTilt(0.0),
maximumTilt(0.0),
- supportsCustomMapObjects(false) {}
+ started_(false) {}
QGeoMappingManagerEnginePrivate::~QGeoMappingManagerEnginePrivate() {}
diff --git a/src/location/maps/qgeomappingmanagerengine.h b/src/location/maps/qgeomappingmanagerengine.h
index f8dd9872..be15438c 100644
--- a/src/location/maps/qgeomappingmanagerengine.h
+++ b/src/location/maps/qgeomappingmanagerengine.h
@@ -42,7 +42,9 @@
#ifndef QGEOMAPPINGMANAGERENGINE_H
#define QGEOMAPPINGMANAGERENGINE_H
-#include "qgraphicsgeomap.h"
+//#include "qgraphicsgeomap.h"
+
+#include "qmobilityglobal.h"
#include <QObject>
#include <QSize>
@@ -60,6 +62,9 @@ class QGeoMapRequestOptions;
class QGeoMappingManagerEnginePrivate;
+class QGeoTiledMapReply;
+class TileSpec;
+
class Q_LOCATION_EXPORT QGeoMappingManagerEngine : public QObject
{
Q_OBJECT
@@ -68,13 +73,15 @@ public:
QGeoMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
virtual ~QGeoMappingManagerEngine();
+ QMap<QString, QVariant> parameters() const;
+
QString managerName() const;
int managerVersion() const;
- virtual QGeoMapData* createMapData() = 0;
+// QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
+// QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
- QList<QGraphicsGeoMap::MapType> supportedMapTypes() const;
- QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes() const;
+ QSize tileSize() const;
qreal minimumZoomLevel() const;
qreal maximumZoomLevel() const;
@@ -85,16 +92,31 @@ public:
qreal minimumTilt() const;
qreal maximumTilt() const;
- bool supportsCustomMapObjects() const;
-
void setLocale(const QLocale &locale);
QLocale locale() const;
+ virtual void init();
+
+public slots:
+ void threadStarted();
+ void requestTiles(const QList<TileSpec> &tiles);
+
+private slots:
+ void requestNextTile();
+ void finished();
+
+signals:
+ void tileFinished(const TileSpec &spec, const QByteArray &bytes);
+ void tileError(const TileSpec &spec, const QString &errorString);
+ void queueFinished();
+
protected:
QGeoMappingManagerEngine(QGeoMappingManagerEnginePrivate *dd, QObject *parent = 0);
- void setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes);
- void setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes);
+// void setSupportedMapTypes(const QList<QGraphicsGeoMap::MapType> &mapTypes);
+// void setSupportedConnectivityModes(const QList<QGraphicsGeoMap::ConnectivityMode> &connectivityModes);
+
+ void setTileSize(const QSize &tileSize);
void setMinimumZoomLevel(qreal minimumZoom);
void setMaximumZoomLevel(qreal maximumZoom);
@@ -105,11 +127,13 @@ protected:
void setSupportsBearing(bool supportsBearing);
void setSupportsTilting(bool supportsTilting);
- void setSupportsCustomMapObjects(bool supportsCustomMapObjects);
-
QGeoMappingManagerEnginePrivate* d_ptr;
private:
+ virtual QGeoTiledMapReply* getTileImage(const TileSpec &spec) = 0;
+
+ void handleReply(QGeoTiledMapReply *reply, const TileSpec &spec);
+
void setManagerName(const QString &managerName);
void setManagerVersion(int managerVersion);
diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h
index 95decae5..f244c639 100644
--- a/src/location/maps/qgeomappingmanagerengine_p.h
+++ b/src/location/maps/qgeomappingmanagerengine_p.h
@@ -53,11 +53,16 @@
// We mean it.
//
-#include "qgraphicsgeomap.h"
+//#include "qgraphicsgeomap.h"
#include <QSize>
#include <QList>
+#include <QMap>
#include <QLocale>
+#include <QTimer>
+
+class TileSpec;
+class QGeoTiledMapReply;
QT_BEGIN_NAMESPACE
@@ -67,21 +72,29 @@ public:
QGeoMappingManagerEnginePrivate();
virtual ~QGeoMappingManagerEnginePrivate();
+ QMap<QString, QVariant> parameters;
+
QString managerName;
int managerVersion;
- QList<QGraphicsGeoMap::MapType> supportedMapTypes;
- QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes;
+// QList<QGraphicsGeoMap::MapType> supportedMapTypes;
+// QList<QGraphicsGeoMap::ConnectivityMode> supportedConnectivityModes;
+ QSize tileSize;
qreal minimumZoomLevel;
qreal maximumZoomLevel;
bool supportsBearing;
bool supportsTilting;
qreal minimumTilt;
qreal maximumTilt;
- bool supportsCustomMapObjects;
QLocale locale;
+ bool started_;
+ QTimer *timer_;
+ QList<TileSpec> queue_;
+ QHash<QGeoTiledMapReply*, TileSpec> map_;
+ QHash<TileSpec, QGeoTiledMapReply*> invmap_;
+
private:
Q_DISABLE_COPY(QGeoMappingManagerEnginePrivate)
};
diff --git a/src/location/maps/qgeomappixmapobject.cpp b/src/location/maps/qgeomappixmapobject.cpp
deleted file mode 100644
index 3b5a6a74..00000000
--- a/src/location/maps/qgeomappixmapobject.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomappixmapobject.h"
-#include "qgeomappixmapobject_p.h"
-#include "qgeoboundingbox.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapPixmapObject
- \brief The QGeoMapPixmapObject class is a QGeoMapObject used to draw
- a pixmap on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The pixmap object is rendered such that the upper left corner of
- QGeoMapPixmapObject::pixmap will be drawn QGeoMapPixmapObject::offset
- pixels away from the position of QGeoMapPixmapObject::coordinate on the
- map.
-*/
-
-/*!
- Constructs a new pixmap object.
-*/
-QGeoMapPixmapObject::QGeoMapPixmapObject()
- : d_ptr(new QGeoMapPixmapObjectPrivate())
-{
-}
-
-/*!
- Constructs a new pixmap object which will draw the pixmap \a pixmap at an
- offset of \a offset pixels from the coordinate \a coordinate.
-*/
-QGeoMapPixmapObject::QGeoMapPixmapObject(const QGeoCoordinate &coordinate, const QPoint &offset, const QPixmap &pixmap)
- : d_ptr(new QGeoMapPixmapObjectPrivate())
-{
- setOrigin(coordinate);
- d_ptr->pixmap = pixmap;
- d_ptr->offset = offset;
-}
-
-/*!
- Destroys this pixmap object.
-*/
-QGeoMapPixmapObject::~QGeoMapPixmapObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapPixmapObject::type() const
-{
- return QGeoMapObject::PixmapType;
-}
-
-/*!
- \property QGeoMapPixmapObject::coordinate
- \brief This property holds the coordinate that specifies where the pixmap
- will be drawn by this pixmap object.
-
- The default value of this property is an invalid coordinate. While the
- value of this property is invalid the pixmap object will not be displayed.
-*/
-QGeoCoordinate QGeoMapPixmapObject::coordinate() const
-{
- return origin();
-}
-
-void QGeoMapPixmapObject::setCoordinate(const QGeoCoordinate &coordinate)
-{
- if (origin() != coordinate) {
- setOrigin(coordinate);
- emit coordinateChanged(coordinate);
- }
-}
-
-/*!
- \property QGeoMapPixmapObject::pixmap
- \brief This property holds the pixmap that will be drawn by this pixmap
- object.
-
- The default value of this property is a null pixmap. While the value of
- this property is the null pixmap the pixmap object will not be displayed.
-
- The pixmap will be drawn such that the upper left corner of the pixmap
- will be drawn QGeoMapPixmapObject::offset pixels away from the position of
- QGeoMapPixmapObject::coordinate on the map.
-*/
-QPixmap QGeoMapPixmapObject::pixmap() const
-{
- return d_ptr->pixmap;
-}
-
-void QGeoMapPixmapObject::setPixmap(const QPixmap &pixmap)
-{
- QPixmap curPixmap = d_ptr->pixmap;
- if (curPixmap.isNull() && pixmap.isNull())
- return;
-
- if ((curPixmap.isNull() && !pixmap.isNull())
- || (!curPixmap.isNull() && pixmap.isNull())
- || (curPixmap.toImage() != pixmap.toImage())) {
- d_ptr->pixmap = pixmap;
- emit pixmapChanged(pixmap);
- }
-}
-
-/*!
- \property QGeoMapPixmapObject::offset
- \brief This property holds the offset in pixels at which the pixmap will be
- drawn by this pixmap object.
-
- The default value of this property is QPoint(0, 0). If this value is not
- changed the upper left coordinate of the pixmap will be drawn at the
- coordinate specified by QGeoMapPixmapObject::coordinate.
-
- The offset is in pixels and is independent of the zoom level of the map.
- The offset property is provided so that pixmaps such as arrows can be drawn
- with the point of the arrow placed exactly on the associated coordinate.
-*/
-QPoint QGeoMapPixmapObject::offset() const
-{
- return d_ptr->offset;
-// QPointF pt = d_ptr->offset;
-//
-// QPoint rounded;
-// rounded.setX(int(pt.x() > 0 ? pt.x() + 0.5 : pt.x() - 0.5));
-// rounded.setY(int(pt.y() > 0 ? pt.y() + 0.5 : pt.y() - 0.5));
-//
-// return rounded;
-}
-
-void QGeoMapPixmapObject::setOffset(const QPoint &offset)
-{
- if (d_ptr->offset != offset) {
- d_ptr->offset = offset;
- emit offsetChanged(offset);
- }
-}
-
-/*!
-\fn void QGeoMapPixmapObject::coordinateChanged(const QGeoCoordinate &coordinate)
-
- This signal is emitted when the coordinate at which the pixmap
- should be drawn has changed.
-
- The new value will be \a coordinate.
-*/
-
-/*!
-\fn void QGeoMapPixmapObject::pixmapChanged(const QPixmap &pixmap)
-
- This signal is emitted when the pixmap associated with this
- pixmap object has changed.
-
- The new value will be \a pixmap.
-*/
-
-/*!
-\fn void QGeoMapPixmapObject::offsetChanged(const QPoint &offset)
-
- This signal is emitted when the on-screen offset from the coordinate
- at which this pixmap object should be drawn has changed.
-
- The new value will be \a offset.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapPixmapObjectPrivate::QGeoMapPixmapObjectPrivate() {}
-
-QGeoMapPixmapObjectPrivate::~QGeoMapPixmapObjectPrivate() {}
-
-#include "moc_qgeomappixmapobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomappixmapobject.h b/src/location/maps/qgeomappixmapobject.h
deleted file mode 100644
index 6a3ac825..00000000
--- a/src/location/maps/qgeomappixmapobject.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPPIXMAPOBJECT_H
-#define QGEOMAPPIXMAPOBJECT_H
-
-#include "qgeomapobject.h"
-#include "qgeocoordinate.h"
-
-#include <QPixmap>
-#include <QPoint>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapPixmapObjectPrivate;
-
-class Q_LOCATION_EXPORT QGeoMapPixmapObject : public QGeoMapObject
-{
- Q_OBJECT
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
- Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged)
- Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
-
-public:
- QGeoMapPixmapObject();
- QGeoMapPixmapObject(const QGeoCoordinate &coordinate, const QPoint &offset = QPoint(0, 0), const QPixmap &pixmap = QPixmap());
- ~QGeoMapPixmapObject();
-
- QGeoMapObject::Type type() const;
-
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate &coordinate);
-
- QPixmap pixmap() const;
- void setPixmap(const QPixmap &pixmap);
-
- QPoint offset() const;
- void setOffset(const QPoint &offset);
-
-Q_SIGNALS:
- void coordinateChanged(const QGeoCoordinate &coordinate);
- void pixmapChanged(const QPixmap &pixmap);
- void offsetChanged(const QPoint &offset);
-
-private:
- QGeoMapPixmapObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapPixmapObject)
- Q_DISABLE_COPY(QGeoMapPixmapObject)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomappixmapobject_p.h b/src/location/maps/qgeomappixmapobject_p.h
deleted file mode 100644
index 9f6166fd..00000000
--- a/src/location/maps/qgeomappixmapobject_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPPIXMAPOBJECT_P_H
-#define QGEOMAPPIXMAPOBJECT_P_H
-
-#include "qgeocoordinate.h"
-
-#include <QPixmap>
-#include <QPoint>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapPixmapObjectPrivate
-{
-public:
- QGeoMapPixmapObjectPrivate();
- ~QGeoMapPixmapObjectPrivate();
-
- QPixmap pixmap;
- QPoint offset;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomappolygonobject.cpp b/src/location/maps/qgeomappolygonobject.cpp
deleted file mode 100644
index d82aba18..00000000
--- a/src/location/maps/qgeomappolygonobject.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomappolygonobject.h"
-#include "qgeomappolygonobject_p.h"
-
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapPolygonObject
- \brief The QGeoMapPolygonObject class is a QGeoMapObject used to draw
- a polygon on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The polygon is specified by a set of at least 3 valid QGeoCoordinate
- instances listed in the same order in which the coordinates would be
- traversed when traveling around the border of the polygon.
-*/
-
-/*!
- Constructs a new polygon object.
-*/
-QGeoMapPolygonObject::QGeoMapPolygonObject()
- : d_ptr(new QGeoMapPolygonObjectPrivate())
-{
- setUnits(QGeoMapObject::RelativeArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Destroys this polygon object.
-*/
-QGeoMapPolygonObject::~QGeoMapPolygonObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapPolygonObject::type() const
-{
- return QGeoMapObject::PolygonType;
-}
-
-/*!
- \property QGeoMapPolygonObject::path
- \brief This property holds the ordered list of coordinates which define the
- polygon to be drawn by this polygon object.
-
- The default value of this property is an empty list of coordinates.
-
- The coordinates should be listed in the order in which they would be
- traversed when traveling around the border of the polygon.
-
- Invalid coordinates in the list will be ignored, and if the list of
- coordinates contains less than 3 valid coordinates then the polygon object
- will not be displayed.
-
-*/
-void QGeoMapPolygonObject::setPath(const QList<QGeoCoordinate> &path)
-{
- if (d_ptr->path != path) {
- d_ptr->path = path;
- if (path.size() != 0)
- setOrigin(path.at(0));
- else
- setOrigin(QGeoCoordinate());
- emit pathChanged(emit d_ptr->path);
- }
-}
-
-QList<QGeoCoordinate> QGeoMapPolygonObject::path() const
-{
- return d_ptr->path;
-}
-
-/*!
- \property QGeoMapPolygonObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw an outline around the polygon. The polygon is
- filled using the QGeoMapPolygonObject::brush property.
-
- The pen will be treated as a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-void QGeoMapPolygonObject::setPen(const QPen &pen)
-{
-
- QPen newPen = pen;
- newPen.setCosmetic(true);
-
- if (d_ptr->pen == newPen)
- return;
-
- d_ptr->pen = pen;
- emit penChanged(pen);
-}
-
-QPen QGeoMapPolygonObject::pen() const
-{
- return d_ptr->pen;
-}
-
-/*!
- \property QGeoMapPolygonObject::brush
- \brief This property holds the brush that will be used to draw this object.
-
- The brush is used to fill in polygon.
-
- The outline around the perimeter of the polygon is drawn using the
- QGeoMapPolygonObject::pen property.
-*/
-void QGeoMapPolygonObject::setBrush(const QBrush &brush)
-{
- if (d_ptr->brush != brush) {
- d_ptr->brush = brush;
- emit brushChanged(brush);
- }
-}
-
-QBrush QGeoMapPolygonObject::brush() const
-{
- return d_ptr->brush;
-}
-
-/*!
-\fn void QGeoMapPolygonObject::pathChanged(const QList<QGeoCoordinate> &path)
-
- This signal is emitted when the ordered list of coordinates that define
- the polygon to be drawn by this polygon object has changed.
-
- The new value is \a path.
-*/
-
-/*!
-\fn void QGeoMapPolygonObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw the edge of this
- polygon object has changed.
-
- The new value is \a pen.
-*/
-
-/*!
-\fn void QGeoMapPolygonObject::brushChanged(const QBrush &brush)
-
- This signal is emitted when the brush used to fill in the interior of
- this polygon object has changed.
-
- The new value is \a brush.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapPolygonObjectPrivate::QGeoMapPolygonObjectPrivate()
-{
- pen.setCosmetic(true);
-}
-
-QGeoMapPolygonObjectPrivate::~QGeoMapPolygonObjectPrivate() {}
-
-#include "moc_qgeomappolygonobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomappolygonobject.h b/src/location/maps/qgeomappolygonobject.h
deleted file mode 100644
index a293f0af..00000000
--- a/src/location/maps/qgeomappolygonobject.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPPOLYGONOBJECT_H
-#define QGEOMAPPOLYGONOBJECT_H
-
-#include "qgeomapobject.h"
-
-#include <QList>
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapPolygonObjectPrivate;
-
-class Q_LOCATION_EXPORT QGeoMapPolygonObject : public QGeoMapObject
-{
- Q_OBJECT
- Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
- Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
-
-public:
- QGeoMapPolygonObject();
- ~QGeoMapPolygonObject();
-
- QGeoMapObject::Type type() const;
-
- void setPath(const QList<QGeoCoordinate> &path);
- QList<QGeoCoordinate> path() const;
-
- void setPen(const QPen &pen);
- QPen pen() const;
-
- void setBrush(const QBrush &brush);
- QBrush brush() const;
-
-Q_SIGNALS:
- void pathChanged(const QList<QGeoCoordinate> &path);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
-
-private:
- QGeoMapPolygonObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapPolygonObject)
- Q_DISABLE_COPY(QGeoMapPolygonObject)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomappolygonobject_p.h b/src/location/maps/qgeomappolygonobject_p.h
deleted file mode 100644
index c8bf4509..00000000
--- a/src/location/maps/qgeomappolygonobject_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPPOLYGONOBJECT_P_H
-#define QGEOMAPPOLYGONOBJECT_P_H
-
-#include "qgeocoordinate.h"
-
-#include <QList>
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapPolygonObjectPrivate
-{
-public:
- QGeoMapPolygonObjectPrivate();
- ~QGeoMapPolygonObjectPrivate();
-
- QList<QGeoCoordinate> path;
- QPen pen;
- QBrush brush;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomappolylineobject.cpp b/src/location/maps/qgeomappolylineobject.cpp
deleted file mode 100644
index bb3c501c..00000000
--- a/src/location/maps/qgeomappolylineobject.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomappolylineobject.h"
-#include "qgeomappolylineobject_p.h"
-
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapPolylineObject
- \brief The QGeoMapPolylineObject class is a QGeoMapObject used to draw
- a segmented line on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The polyline is specified by a list of at least 2 valid QGeoCoordinate
- instances and a line will be drawn between every adjacent pairs of
- coordinates in the list.
-*/
-
-/*!
- Constructs a new polyline object.
-*/
-QGeoMapPolylineObject::QGeoMapPolylineObject()
- : d_ptr(new QGeoMapPolylineObjectPrivate())
-{
- setUnits(QGeoMapObject::RelativeArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Destroys this polyline object.
-*/
-QGeoMapPolylineObject::~QGeoMapPolylineObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapPolylineObject::type() const
-{
- return QGeoMapObject::PolylineType;
-}
-
-/*!
- \property QGeoMapPolylineObject::path
- \brief This property holds the ordered list of coordinates which define the
- segmented line to be drawn by this polyline object.
-
- The default value of this property is an empty list of coordinates.
-
- A line will be drawn between every pair of coordinates which are adjacent in
- the list.
-
- Invalid coordinates in the list will be ignored, and if the list of
- coordinates contains less than 2 valid coordinates then the polyline object
- will not be displayed.
-*/
-void QGeoMapPolylineObject::setPath(const QList<QGeoCoordinate> &path)
-{
- if (d_ptr->path != path) {
- d_ptr->path = path;
- if (path.size() != 0)
- setOrigin(path.at(0));
- else
- setOrigin(QGeoCoordinate());
- emit pathChanged(d_ptr->path);
- }
-}
-
-QList<QGeoCoordinate> QGeoMapPolylineObject::path() const
-{
- return d_ptr->path;
-}
-
-/*!
- \property QGeoMapPolylineObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw the polyline.
-
- The pen will be treated as a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-void QGeoMapPolylineObject::setPen(const QPen &pen)
-{
- QPen newPen = pen;
- newPen.setCosmetic(false);
-
- if (d_ptr->pen == newPen)
- return;
-
- d_ptr->pen = pen;
- emit penChanged(pen);
-}
-
-QPen QGeoMapPolylineObject::pen() const
-{
- return d_ptr->pen;
-}
-
-/*!
-\fn void QGeoMapPolylineObject::pathChanged(const QList<QGeoCoordinate> &path)
-
- This signal is emitted when the ordered list of coordinates that define
- the polyline to be drawn by this polyline object has changed.
-
- The new value is \a path.
-*/
-
-/*!
-\fn void QGeoMapPolylineObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw the edge of this
- polyline object has changed.
-
- The new value is \a pen.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapPolylineObjectPrivate::QGeoMapPolylineObjectPrivate()
-{
- pen.setCosmetic(true);
-}
-
-QGeoMapPolylineObjectPrivate::~QGeoMapPolylineObjectPrivate() {}
-
-#include "moc_qgeomappolylineobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomappolylineobject_p.h b/src/location/maps/qgeomappolylineobject_p.h
deleted file mode 100644
index 845b7953..00000000
--- a/src/location/maps/qgeomappolylineobject_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPPOLYLINEOBJECT_P_H
-#define QGEOMAPPOLYLINEOBJECT_P_H
-
-#include "qgeocoordinate.h"
-
-#include <QList>
-#include <QPen>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapPolylineObjectPrivate
-{
-public:
- QGeoMapPolylineObjectPrivate();
- ~QGeoMapPolylineObjectPrivate();
-
- QList<QGeoCoordinate> path;
- QPen pen;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomaprectangleobject.cpp b/src/location/maps/qgeomaprectangleobject.cpp
deleted file mode 100644
index 4712ce8b..00000000
--- a/src/location/maps/qgeomaprectangleobject.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomaprectangleobject.h"
-#include "qgeomaprectangleobject_p.h"
-
-#include "qgeocoordinate.h"
-#include "qgeoboundingbox.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapRectangleObject
- \brief The QGeoMapRectangleObject class is a QGeoMapObject used to draw
- a rectangular region on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The rectangle is specified by either a valid QGeoBoundingBox instance or
- a pair of valid QGeoCoordinate instances which represent the top left and
- bottom right coordinates of the rectangle respectively.
-*/
-
-/*!
- Constructs a new rectangle object.
-*/
-QGeoMapRectangleObject::QGeoMapRectangleObject()
- : d_ptr(new QGeoMapRectangleObjectPrivate())
-{
- setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Constructs a new rectangle object based on the bounding box \a boundingBox.
-*/
-QGeoMapRectangleObject::QGeoMapRectangleObject(const QGeoBoundingBox &boundingBox)
- : d_ptr(new QGeoMapRectangleObjectPrivate())
-{
- d_ptr->bounds = boundingBox;
- setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Constructs a new rectangle object with the top left coordinate at \a
- topLeft and the bottom right coordinate at \a bottomRight.
-*/
-QGeoMapRectangleObject::QGeoMapRectangleObject(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
- : d_ptr(new QGeoMapRectangleObjectPrivate())
-{
- d_ptr->bounds = QGeoBoundingBox(topLeft, bottomRight);
- setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Destroys this rectangle object.
-*/
-QGeoMapRectangleObject::~QGeoMapRectangleObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapRectangleObject::type() const
-{
- return QGeoMapObject::RectangleType;
-}
-
-/*!
- Returns a QGeoBoundingBox instance which corresponds to the rectangle that
- will be drawn by this object.
-
- This is equivalent to
- \code
- QGeoMapRectangleObject *object;
- // setup object
- QGeoBoundingBox(object->topLeft(), object->bottomRight());
- \endcode
-*/
-QGeoBoundingBox QGeoMapRectangleObject::bounds() const
-{
- return d_ptr->bounds;
-}
-
-/*!
- Sets the rectangle that will be drawn by this object to \a bounds.
-
- This is equivalent to
- \code
- QGeoMapRectangleObject *object;
- // setup object
- object->setTopLeft(bounds.topLeft());
- object->setBottomRight(bounds.bottomRight());
- \endcode
-*/
-void QGeoMapRectangleObject::setBounds(const QGeoBoundingBox &bounds)
-{
- QGeoBoundingBox oldBounds = d_ptr->bounds;
-
- if (oldBounds == bounds)
- return;
-
- d_ptr->bounds = bounds;
-
- if (d_ptr->bounds.topLeft() != oldBounds.topLeft())
- emit topLeftChanged(d_ptr->bounds.topLeft());
-
- if (d_ptr->bounds.bottomRight() != oldBounds.bottomRight())
- emit bottomRightChanged(d_ptr->bounds.bottomRight());
-}
-
-/*!
- \property QGeoMapRectangleObject::topLeft
- \brief This property holds the top left coordinate of the rectangle to be
- drawn by this rectangle object.
-
- The default value of this property is an invalid coordinate. While
- the value of this property is invalid the rectangle object will not be
- displayed.
-*/
-QGeoCoordinate QGeoMapRectangleObject::topLeft() const
-{
- return d_ptr->bounds.topLeft();
-}
-
-void QGeoMapRectangleObject::setTopLeft(const QGeoCoordinate &topLeft)
-{
- if (d_ptr->bounds.topLeft() != topLeft) {
- d_ptr->bounds.setTopLeft(topLeft);
- emit topLeftChanged(d_ptr->bounds.topLeft());
- }
-}
-
-/*!
- \property QGeoMapRectangleObject::bottomRight
- \brief This property holds the bottom right coordinate of the rectangle to
- be drawn by this rectangle object.
-
- The default value of this property is an invalid coordinate. While
- the value of this property is invalid the rectangle object will not be
- displayed.
-*/
-QGeoCoordinate QGeoMapRectangleObject::bottomRight() const
-{
- return d_ptr->bounds.bottomRight();
-}
-
-void QGeoMapRectangleObject::setBottomRight(const QGeoCoordinate &bottomRight)
-{
- if (d_ptr->bounds.bottomRight() != bottomRight) {
- d_ptr->bounds.setBottomRight(bottomRight);
- emit bottomRightChanged(d_ptr->bounds.bottomRight());
- }
-}
-
-/*!
- \property QGeoMapRectangleObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw an outline around the rectangle. The rectangle is
- filled using the QGeoMapRectangleObject::brush property.
-
- The pen will be treated as a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-QPen QGeoMapRectangleObject::pen() const
-{
- return d_ptr->pen;
-}
-
-void QGeoMapRectangleObject::setPen(const QPen &pen)
-{
- QPen newPen = pen;
- newPen.setCosmetic(true);
-
- if (d_ptr->pen == newPen)
- return;
-
- d_ptr->pen = newPen;
- emit penChanged(newPen);
-}
-
-/*!
- \property QGeoMapRectangleObject::brush
- \brief This property holds the brush that will be used to draw this object.
-
- The brush is used to fill in rectangle.
-
- The outline around the perimeter of the rectangle is drawn using the
- QGeoMapRectangleObject::pen property.
-*/
-QBrush QGeoMapRectangleObject::brush() const
-{
- return d_ptr->brush;
-}
-
-void QGeoMapRectangleObject::setBrush(const QBrush &brush)
-{
- if (d_ptr->brush != brush) {
- d_ptr->brush = brush;
- emit brushChanged(d_ptr->brush);
- }
-}
-
-/*!
-\fn void QGeoMapRectangleObject::topLeftChanged(const QGeoCoordinate &topLeft)
-
- This signal is emitted when the top left coordinate of this rectangle
- object has changed.
-
- The new value is \a topLeft.
-*/
-
-/*!
-\fn void QGeoMapRectangleObject::bottomRightChanged(const QGeoCoordinate &bottomRight)
-
- This signal is emitted when the bottom right coordinate of this rectangle
- object has changed.
-
- The new value is \a bottomRight.
-*/
-
-/*!
-\fn void QGeoMapRectangleObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw the perimeter of this
- rectangle object has changed.
-
- The new value is \a pen.
-*/
-
-/*!
-\fn void QGeoMapRectangleObject::brushChanged(const QBrush &brush)
-
- This signal is emitted when the brush used to fill in the interior of
- this rectangle object has changed.
-
- The new value is \a brush.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapRectangleObjectPrivate::QGeoMapRectangleObjectPrivate()
-{
- pen.setCosmetic(true);
-}
-
-QGeoMapRectangleObjectPrivate::~QGeoMapRectangleObjectPrivate() {}
-
-#include "moc_qgeomaprectangleobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomaprectangleobject.h b/src/location/maps/qgeomaprectangleobject.h
deleted file mode 100644
index 6f24450f..00000000
--- a/src/location/maps/qgeomaprectangleobject.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPRECTANGLEOBJECT_H
-#define QGEOMAPRECTANGLEOBJECT_H
-
-#include "qgeomapobject.h"
-
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapRectangleObjectPrivate;
-class QGeoBoundingBox;
-class QGeoCoordinate;
-
-class Q_LOCATION_EXPORT QGeoMapRectangleObject : public QGeoMapObject
-{
- Q_OBJECT
- Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft NOTIFY topLeftChanged)
- Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight NOTIFY bottomRightChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
- Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
-
-public:
- QGeoMapRectangleObject();
- QGeoMapRectangleObject(const QGeoBoundingBox &boundingBox);
- QGeoMapRectangleObject(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
- ~QGeoMapRectangleObject();
-
- QGeoMapObject::Type type() const;
-
- QGeoBoundingBox bounds() const;
- void setBounds(const QGeoBoundingBox &bounds);
-
- QGeoCoordinate topLeft() const;
- void setTopLeft(const QGeoCoordinate &topLeft);
-
- QGeoCoordinate bottomRight() const;
- void setBottomRight(const QGeoCoordinate &bottomRight);
-
- QPen pen() const;
- void setPen(const QPen &pen);
-
- QBrush brush() const;
- void setBrush(const QBrush &brush);
-
-Q_SIGNALS:
- void topLeftChanged(const QGeoCoordinate &topLeft);
- void bottomRightChanged(const QGeoCoordinate &bottomRight);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
-
-private:
- QGeoMapRectangleObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapRectangleObject)
- Q_DISABLE_COPY(QGeoMapRectangleObject)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomaprectangleobject_p.h b/src/location/maps/qgeomaprectangleobject_p.h
deleted file mode 100644
index 814dc2fb..00000000
--- a/src/location/maps/qgeomaprectangleobject_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPRECTANGLEOBJECT_P_H
-#define QGEOMAPRECTANGLEOBJECT_P_H
-
-#include "qgeoboundingbox.h"
-
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapRectangleObjectPrivate
-{
-public:
- QGeoMapRectangleObjectPrivate();
- ~QGeoMapRectangleObjectPrivate();
-
- QGeoBoundingBox bounds;
- QPen pen;
- QBrush brush;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomaprouteobject.cpp b/src/location/maps/qgeomaprouteobject.cpp
deleted file mode 100644
index 462d98f0..00000000
--- a/src/location/maps/qgeomaprouteobject.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomaprouteobject.h"
-#include "qgeomaprouteobject_p.h"
-#include "qgeocoordinate.h"
-#include "qgeoroutesegment.h"
-
-#define DEFAULT_ROUTE_DETAIL_LEVEL 6
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapRouteObject
- \brief The QGeoMapRouteObject class is a QGeoMapObject used to draw
- a route on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The route is specified by a QGeoRoute object.
-
- The route might be quite detailed, and so to improve performance the
- detail level can be set with QGeoMapRouteObject::detailLevel.
-
- The route object draws the route as a series of lines with a minimum
- on-screen harmattan length equal to the detail level. This is done so that
- the small changes in direction of a road will be visible at high zoom
- levels but will not slow down the rendering at the lower zoom levels.
-*/
-
-/*!
- Constructs a new route object.
-*/
-QGeoMapRouteObject::QGeoMapRouteObject()
- : d_ptr(new QGeoMapRouteObjectPrivate())
-{
- setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Constructs a new route object for the route \a route.
-*/
-QGeoMapRouteObject::QGeoMapRouteObject(const QGeoRoute &route)
- : d_ptr(new QGeoMapRouteObjectPrivate())
-{
- d_ptr->route = route;
- setUnits(QGeoMapObject::AbsoluteArcSecondUnit);
- setTransformType(QGeoMapObject::ExactTransform);
-}
-
-/*!
- Destroys this route object
-*/
-QGeoMapRouteObject::~QGeoMapRouteObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapRouteObject::type() const
-{
- return QGeoMapObject::RouteType;
-}
-
-/*!
- \property QGeoMapRouteObject::route
- \brief This property holds the which will be displayed.
-
- The default value of this property is an empty route.
-
- If QGeoRoute::path() returns a list of less than 2 valid QGeoCoordinates
- then the route object will not be displayed.
-*/
-QGeoRoute QGeoMapRouteObject::route() const
-{
- return d_ptr->route;
-}
-
-void QGeoMapRouteObject::setRoute(const QGeoRoute &route)
-{
- d_ptr->route = route;
- emit routeChanged(d_ptr->route);
-}
-
-/*!
- \property QGeoMapRouteObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw the route.
-
- The pen will be treated like a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-QPen QGeoMapRouteObject::pen() const
-{
- return d_ptr->pen;
-}
-
-void QGeoMapRouteObject::setPen(const QPen &pen)
-{
- QPen newPen = pen;
- newPen.setCosmetic(false);
-
- if (d_ptr->pen == newPen)
- return;
-
- d_ptr->pen = newPen;
- emit penChanged(newPen);
-}
-
-/*!
- \property QGeoMapRouteObject::detailLevel
- \brief This property holds the level of detail used to draw this object.
-
- A QGeoRoute instance can contain a large amount of information about the
- path taken by the route. This property is used as a hint to help reduce the
- amount of information that needs to be drawn on the map.
-
- The path taken by the route is represented as a list of QGeoCoordinate
- instances. This route object will draw lines between these coordinates, but
- will skip members of the list until the manhattan distance between the
- start point and the end point of the line is at least \a detailLevel.
-
- The default value of this property is 6.
-*/
-quint32 QGeoMapRouteObject::detailLevel() const
-{
- return d_ptr->detailLevel;
-}
-
-void QGeoMapRouteObject::setDetailLevel(quint32 detailLevel)
-{
- if (d_ptr->detailLevel != detailLevel) {
- d_ptr->detailLevel = detailLevel;
- emit detailLevelChanged(d_ptr->detailLevel);
- }
-}
-
-/*!
-\fn void QGeoMapRouteObject::routeChanged(const QGeoRoute &route)
-
- This signal is emitted when the route drawn by this route object
- has changed.
-
- The new value is \a route.
-*/
-
-/*!
-\fn void QGeoMapRouteObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw this route object has
- changed.
-
- The new value is \a pen.
-*/
-
-/*!
-\fn void QGeoMapRouteObject::detailLevelChanged(quint32 detailLevel)
-
- This signal is emitted when the level of detail used to draw this
- route object has changed.
-
- The new value is \a detailLevel.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapRouteObjectPrivate::QGeoMapRouteObjectPrivate()
-{
- detailLevel = DEFAULT_ROUTE_DETAIL_LEVEL;
- pen.setCosmetic(true);
-}
-
-QGeoMapRouteObjectPrivate::~QGeoMapRouteObjectPrivate() {}
-
-#include "moc_qgeomaprouteobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomaprouteobject_p.h b/src/location/maps/qgeomaprouteobject_p.h
deleted file mode 100644
index 4d5fca57..00000000
--- a/src/location/maps/qgeomaprouteobject_p.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPROUTEOBJECT_P_H
-#define QGEOMAPROUTEOBJECT_P_H
-
-#include "qgeoroute.h"
-
-#include <QPen>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapRouteObjectPrivate
-{
-public:
- QGeoMapRouteObjectPrivate();
- ~QGeoMapRouteObjectPrivate();
-
- QGeoRoute route;
- QPen pen;
- quint32 detailLevel;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomaptextobject.cpp b/src/location/maps/qgeomaptextobject.cpp
deleted file mode 100644
index 2b9ee8cd..00000000
--- a/src/location/maps/qgeomaptextobject.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeomaptextobject.h"
-#include "qgeomaptextobject_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoMapTextObject
- \brief The QGeoMapTextObject class is a QGeoMapObject used to draw
- text on a map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping-objects
-
- The text is drawn at a given coordinate on the map.
-
- The text object is drawn such that the rendered size of the text object is
- independent of the zoom level of the map.
-*/
-
-/*!
- Constructs a new text object.
-*/
-QGeoMapTextObject::QGeoMapTextObject()
- : d_ptr(new QGeoMapTextObjectPrivate())
-{
- setUnits(QGeoMapObject::PixelUnit);
-}
-
-/*!
- Constructs a new text object which will display the text \a text with font
- \a font at the coordinate \a coordinate on the map.
-
- The text will be displayed at an on-screen offset from the coordinate of \a
- offset pixels, and will be aligned according to \a alignment.
-*/
-QGeoMapTextObject::QGeoMapTextObject(const QGeoCoordinate &coordinate,
- const QString &text,
- const QFont &font,
- const QPoint &offset,
- Qt::Alignment alignment)
- : d_ptr(new QGeoMapTextObjectPrivate())
-{
- setOrigin(coordinate);
- d_ptr->text = text;
- d_ptr->font = font;
- d_ptr->offset = offset;
- d_ptr->alignment = alignment;
- setUnits(QGeoMapObject::PixelUnit);
-}
-
-/*!
- Destroys this text object.
-*/
-QGeoMapTextObject::~QGeoMapTextObject()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-QGeoMapObject::Type QGeoMapTextObject::type() const
-{
- return QGeoMapObject::TextType;
-}
-
-/*!
- \property QGeoMapTextObject::coordinate
- \brief This property holds the coordinate at which this text object
- will be rendered.
-
- The default value of this property is an invalid coordinate. While the
- value of this property is invalid the text object will not be displayed.
-
- If QGeoMapTextObject::offset and QGeoMapTextObject::alignment are not set
- the text will be drawn so that it is centered both horizontally and
- vertically around the position of QGeoMapTextObject::coordinate on the
- screen.
-*/
-QGeoCoordinate QGeoMapTextObject::coordinate() const
-{
- return origin();
-}
-
-void QGeoMapTextObject::setCoordinate(const QGeoCoordinate &coordinate)
-{
- if (origin() != coordinate) {
- setOrigin(coordinate);
- emit coordinateChanged(coordinate);
- }
-}
-
-/*!
- \property QGeoMapTextObject::text
- \brief This property holds the text that will be displayed by this text
- object.
-
- The default value of this property is an empty string.
-*/
-QString QGeoMapTextObject::text() const
-{
- return d_ptr->text;
-}
-
-void QGeoMapTextObject::setText(const QString &text)
-{
- if (d_ptr->text != text) {
- d_ptr->text = text;
- emit textChanged(text);
- }
-}
-
-/*!
- \property QGeoMapTextObject::font
- \brief This property holds the font that will be used to render the text
- for this text object.
-
- The default value of this property is the application's default font.
-
- It is not necessary to account for the zoom level of the map, since text
- objects are scaled such that they appear to be independent of the zoom
- level.
-*/
-QFont QGeoMapTextObject::font() const
-{
- return d_ptr->font;
-}
-
-void QGeoMapTextObject::setFont(const QFont &font)
-{
- if (d_ptr->font != font) {
- d_ptr->font = font;
- emit fontChanged(font);
- }
-}
-
-/*!
- \property QGeoMapTextObject::pen
- \brief This property holds the pen that will be used to draw this object.
-
- The pen is used to draw an outline around the text. The text itself is
- filled using the QGeoMapTextObject::brush property.
-
- The pen will be treated as a cosmetic pen, which means that the width
- of the pen will be independent of the zoom level of the map.
-*/
-QPen QGeoMapTextObject::pen() const
-{
- return d_ptr->pen;
-}
-
-void QGeoMapTextObject::setPen(const QPen &pen)
-{
- QPen newPen = pen;
- newPen.setCosmetic(true);
-
- if (d_ptr->pen == newPen)
- return;
-
- d_ptr->pen = newPen;
- emit penChanged(pen);
-}
-
-/*!
- \property QGeoMapTextObject::brush
- \brief This property holds the brush that will be used to draw this object.
-
- The brush is used to fill in the glyphs of the text.
-
- The outline around the perimeter of the glyphs is drawn using the
- QGeoMapTextObject::pen property.
-*/
-QBrush QGeoMapTextObject::brush() const
-{
- return d_ptr->brush;
-}
-
-void QGeoMapTextObject::setBrush(const QBrush &brush)
-{
- if (d_ptr->brush != brush) {
- d_ptr->brush = brush;
- emit brushChanged(brush);
- }
-}
-
-/*!
- \property QGeoMapTextObject::offset
- \brief This property holds the offset in pixels from the screen position of
- QGeoMapTextObject::coordinate at which the text will be rendered when
- drawing this text object.
-
- The default value of this property is QPoint(0,0).
-*/
-QPoint QGeoMapTextObject::offset() const
-{
- return QPoint(d_ptr->offset.x(), d_ptr->offset.y());
-}
-
-void QGeoMapTextObject::setOffset(const QPoint &off)
-{
- if (d_ptr->offset != off) {
- d_ptr->offset = off;
- emit offsetChanged(off);
- }
-}
-
-/*!
- \property QGeoMapTextObject::alignment
- \brief This property holds the alignment options used to align the
- text when drawing this text object.
-
- The default value of this property will align the text so that it is
- centered both horizontally and vertically around the point that is
- QGeoMapTextObject::offset pixels away from the position of
- QGeoMapTextObject::coordinate on the screen.
-
- Using
- \code
- textObject->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
- \endcode
- will place the text so that the point halway up the left edge of
- the text is at the anchor point defined by
- QGeoMapTextObject::offset and QGeoMapTextObject::coordinate.
-
- The alignment property is a flag, so using
- \code
- textObject->setAlignment(Qt::AlignLeft);
- \endcode
- may alter the vertical alignment as well.
-
- The Qt::AlignVertical_Mask and Qt::AlignHorizontal_Mask enum
- values can be used to alter one component of the alignment
- independent of the other.
- \code
- textObject->setAlignment(Qt::AlignLeft | (textObject->alignment() & Qt::AlignVertical_Mask));
- \endcode
-
- The alignment does not take the width of QGeoMapTextObject::pen into
- consideration.
-*/
-Qt::Alignment QGeoMapTextObject::alignment() const
-{
- return d_ptr->alignment;
-}
-
-void QGeoMapTextObject::setAlignment(Qt::Alignment alignment)
-{
- if (d_ptr->alignment != alignment) {
- d_ptr->alignment = alignment;
- emit alignmentChanged(d_ptr->alignment);
- }
-}
-
-/*!
-\fn void QGeoMapTextObject::coordinateChanged(const QGeoCoordinate &coordinate)
-
- This signal is emitted when the coordinate at which this text
- object will be drawn has changed.
-
- The new value is \a coordinate.
-*/
-
-/*!
-\fn void QGeoMapTextObject::textChanged(const QString &text)
-
- This signal is emitted when the text to be drawn by this text object
- has changed.
-
- The new value is \a text.
-*/
-
-/*!
-\fn void QGeoMapTextObject::fontChanged(const QFont &font)
-
- This signal is emitted when the font use to draw this text object
- has changed.
-
- The new value is \a font.
-*/
-
-/*!
-\fn void QGeoMapTextObject::penChanged(const QPen &pen)
-
- This signal is emitted when the pen used to draw the outline of the
- letters for this text object has changed.
-
- The new value is \a pen.
-*/
-
-/*!
-\fn void QGeoMapTextObject::brushChanged(const QBrush &brush)
-
- This signal is emitted when the brush used to fill the inside of the
- letters for this text object has changed.
-
- The new value is \a brush.
-*/
-
-/*!
-\fn void QGeoMapTextObject::offsetChanged(const QPoint &offset)
-
- This signal is emitted when the on screen offset from the coordinate at
- which this text object will be drawn has changed.
-
- The new value is \a offset.
-*/
-
-/*!
-\fn void QGeoMapTextObject::alignmentChanged(Qt::Alignment alignment)
-
- This signal is emitted when the alignment of this text object has changed.
-
- The new value is \a alignment.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoMapTextObjectPrivate::QGeoMapTextObjectPrivate() :
- offset(0, 0)
-{
- pen.setCosmetic(true);
- alignment = Qt::AlignCenter;
-}
-
-QGeoMapTextObjectPrivate::~QGeoMapTextObjectPrivate() {}
-
-#include "moc_qgeomaptextobject.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/qgeomaptextobject.h b/src/location/maps/qgeomaptextobject.h
deleted file mode 100644
index 0447aea4..00000000
--- a/src/location/maps/qgeomaptextobject.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPTEXTOBJECT_H
-#define QGEOMAPTEXTOBJECT_H
-
-#include "qgeomapobject.h"
-#include "qgeocoordinate.h"
-
-#include <QFont>
-#include <QPoint>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapTextObjectPrivate;
-
-class Q_LOCATION_EXPORT QGeoMapTextObject : public QGeoMapObject
-{
- Q_OBJECT
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
- Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
- Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
-
-public:
- QGeoMapTextObject();
- QGeoMapTextObject(const QGeoCoordinate &coordinate,
- const QString &text = QString(),
- const QFont &font = QFont(),
- const QPoint &offset = QPoint(),
- Qt::Alignment alignment = Qt::AlignCenter);
- ~QGeoMapTextObject();
-
- QGeoMapObject::Type type() const;
-
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate &coordinate);
-
- QString text() const;
- void setText(const QString &text);
-
- QFont font() const;
- void setFont(const QFont &font);
-
- QPen pen() const;
- void setPen(const QPen &pen);
-
- QBrush brush() const;
- void setBrush(const QBrush &brush);
-
- QPoint offset() const;
- void setOffset(const QPoint &offset);
-
- Qt::Alignment alignment() const;
- void setAlignment(Qt::Alignment alignment);
-
-Q_SIGNALS:
- void coordinateChanged(const QGeoCoordinate &coordinate);
- void textChanged(const QString &text);
- void fontChanged(const QFont &font);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
- void offsetChanged(const QPoint &offset);
- void alignmentChanged(Qt::Alignment alignment);
-
-private:
- QGeoMapTextObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapTextObject)
- Q_DISABLE_COPY(QGeoMapTextObject)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/qgeomaptextobject_p.h b/src/location/maps/qgeomaptextobject_p.h
deleted file mode 100644
index 4c1a7101..00000000
--- a/src/location/maps/qgeomaptextobject_p.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOMAPTEXTOBJECT_P_H
-#define QGEOMAPTEXTOBJECT_P_H
-
-#include "qgeocoordinate.h"
-
-#include <QFont>
-#include <QString>
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapTextObjectPrivate
-{
-public:
- QGeoMapTextObjectPrivate();
- ~QGeoMapTextObjectPrivate();
-
- QString text;
- QFont font;
- QPen pen;
- QBrush brush;
- QPoint offset;
- Qt::Alignment alignment;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmapreply.cpp b/src/location/maps/qgeotiledmapreply.cpp
index 622db385..6908325b 100644
--- a/src/location/maps/tiled/qgeotiledmapreply.cpp
+++ b/src/location/maps/qgeotiledmapreply.cpp
@@ -42,8 +42,6 @@
#include "qgeotiledmapreply.h"
#include "qgeotiledmapreply_p.h"
-#include "qgeotiledmaprequest.h"
-
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -98,9 +96,9 @@ QT_BEGIN_NAMESPACE
/*!
Constructs a tiled map reply object based on \a request, with parent \a parent.
*/
-QGeoTiledMapReply::QGeoTiledMapReply(const QGeoTiledMapRequest &request, QObject *parent)
+QGeoTiledMapReply::QGeoTiledMapReply(const TileSpec &spec, QObject *parent)
: QObject(parent),
- d_ptr(new QGeoTiledMapReplyPrivate(request))
+ d_ptr(new QGeoTiledMapReplyPrivate(spec))
{
}
@@ -206,9 +204,9 @@ void QGeoTiledMapReply::setCached(bool cached)
/*!
Returns the request which corresponds to this reply.
*/
-QGeoTiledMapRequest QGeoTiledMapReply::request() const
+TileSpec QGeoTiledMapReply::tileSpec() const
{
- return d_ptr->request;
+ return d_ptr->spec;
}
/*!
@@ -309,12 +307,12 @@ void QGeoTiledMapReply::abort()
/*******************************************************************************
*******************************************************************************/
-QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(const QGeoTiledMapRequest &request)
+QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(const TileSpec &spec)
: error(QGeoTiledMapReply::NoError),
errorString(QLatin1String("")),
isFinished(false),
isCached(false),
- request(request) {}
+ spec(spec) {}
QGeoTiledMapReplyPrivate::QGeoTiledMapReplyPrivate(QGeoTiledMapReply::Error error, const QString &errorString)
: error(error),
diff --git a/src/location/maps/tiled/qgeotiledmapreply.h b/src/location/maps/qgeotiledmapreply.h
index 9b3bea4f..8258b22a 100644
--- a/src/location/maps/tiled/qgeotiledmapreply.h
+++ b/src/location/maps/qgeotiledmapreply.h
@@ -42,13 +42,13 @@
#ifndef QGEOTILEDMAPREPLY_H
#define QGEOTILEDMAPREPLY_H
-#include "qmobilityglobal.h"
+#include "qglobal.h"
#include <QObject>
QT_BEGIN_NAMESPACE
-class QGeoTiledMapRequest;
+class TileSpec;
class QGeoTiledMapReplyPrivate;
class Q_LOCATION_EXPORT QGeoTiledMapReply : public QObject
@@ -63,7 +63,7 @@ public:
UnknownError
};
- QGeoTiledMapReply(const QGeoTiledMapRequest &request, QObject *parent = 0);
+ QGeoTiledMapReply(const TileSpec &spec, QObject *parent = 0);
QGeoTiledMapReply(Error error, const QString &errorString, QObject *parent = 0);
virtual ~QGeoTiledMapReply();
@@ -73,7 +73,7 @@ public:
bool isCached() const;
- QGeoTiledMapRequest request() const;
+ TileSpec tileSpec() const;
QByteArray mapImageData() const;
QString mapImageFormat() const;
diff --git a/src/location/maps/tiled/qgeotiledmapreply_p.h b/src/location/maps/qgeotiledmapreply_p.h
index 537a23b7..e5e02235 100644
--- a/src/location/maps/tiled/qgeotiledmapreply_p.h
+++ b/src/location/maps/qgeotiledmapreply_p.h
@@ -54,14 +54,14 @@
//
#include "qgeotiledmapreply.h"
-#include "qgeotiledmaprequest.h"
+#include "tilespec.h"
QT_BEGIN_NAMESPACE
class QGeoTiledMapReplyPrivate
{
public:
- QGeoTiledMapReplyPrivate(const QGeoTiledMapRequest &request);
+ QGeoTiledMapReplyPrivate(const TileSpec &spec);
QGeoTiledMapReplyPrivate(QGeoTiledMapReply::Error error, const QString& errorString);
~QGeoTiledMapReplyPrivate();
@@ -70,7 +70,7 @@ public:
bool isFinished;
bool isCached;
- QGeoTiledMapRequest request;
+ TileSpec spec;
QByteArray mapImageData;
QString mapImageFormat;
};
diff --git a/src/location/maps/qgraphicsgeomap.cpp b/src/location/maps/qgraphicsgeomap.cpp
deleted file mode 100644
index 5ccad8a6..00000000
--- a/src/location/maps/qgraphicsgeomap.cpp
+++ /dev/null
@@ -1,821 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicsgeomap.h"
-#include "qgraphicsgeomap_p.h"
-
-#include "qgeocoordinate.h"
-#include "qgeoboundingbox.h"
-#include "qgeomapobject.h"
-#include "qgeomapoverlay.h"
-
-#include "qgeoserviceprovider.h"
-#include "qgeomappingmanager.h"
-#include "qgeomapdata.h"
-
-#include <QGraphicsSceneResizeEvent>
-#include <QTimer>
-
-#include <QNetworkProxyFactory>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsGeoMap
- \brief The QGraphicsGeoMap class is used to display a map and manager the
- interactions between the user and the map.
-
- \inmodule QtLocation
- \since 1.1
-
- \ingroup maps-mapping
-
- Most of the functionality is provided by QGeoMappingManager, which
- handles most aspects of the display.
-
- The map viewport can be panned, the zoom level can be changed and the
- center coordinate of the viewport can be set explicitly.
-
- The screenPositionToCoordinate() and coordinateToScreenPoisition()
- functions can be used to convert between positions on the screen and
- global coordinates.
-
- Mouse and keyboard events should be handled by subclassing QGraphicsGeoMap
- and providing implementations of the event handling functions present in
- QGraphicsWidget.
-*/
-
-/*!
-\enum QGraphicsGeoMap::MapType
-
-Describes a type of map data.
-
-\value NoMap
-Indicates a lack of map valid data.
-
-\value StreetMap
-The map data is a graphical representation of streets and building boundaries.
-
-\value SatelliteMapDay
-The map data is composed of images collected by satellites during the daytime.
-
-\value SatelliteMapNight
-The map data is composed of images collected by satellites during the nighttime.
-
-\value TerrainMap
-The map data is a graphical representation of terrain features. This may also
-include some of the information provided by QGraphicsGeoMap::StreetMap.
-*/
-
-/*!
-\enum QGraphicsGeoMap::ConnectivityMode
-
-Describes the method of obtaining the mapping data.
-
-\value NoConnectivity
-There is no map data.
-
-\value OfflineMode
-The map data will come from an offline source.
-
-\value OnlineMode
-The map data will come from an online source.
-
-\value HybridMode
-The map data will come from a combination of offline and online sources.
-*/
-
-/*!
- Creates a new mapping widget, with the mapping operations managed by
- \a manager, and the specified \a parent.
-
- Note that the \a manager will typically be accessed from an instance of
- QGeoServiceProvider:
- \code
- QGeoServiceProvider serviceProvider("nokia");
- QGeoMappingManager *manager = serviceProvider.mappingManager();
- QGraphicsGeoMap *widget = new QGraphicsGeoMap(manager);
- \endcode
-*/
-QGraphicsGeoMap::QGraphicsGeoMap(QGeoMappingManager *manager, QGraphicsItem *parent)
- : QGraphicsWidget(parent),
- d_ptr(new QGraphicsGeoMapPrivate())
-{
- Q_ASSERT(manager != 0);
- d_ptr->manager = manager;
-
- d_ptr->mapData = d_ptr->manager->createMapData();
- d_ptr->mapData->init();
-
- connect(d_ptr->mapData,
- SIGNAL(updateMapDisplay(QRectF)),
- this,
- SLOT(updateMapDisplay(QRectF)));
-
- setMapType(QGraphicsGeoMap::StreetMap);
- d_ptr->mapData->setWindowSize(size());
-
- connect(d_ptr->mapData,
- SIGNAL(zoomLevelChanged(qreal)),
- this,
- SIGNAL(zoomLevelChanged(qreal)));
- connect(d_ptr->mapData,
- SIGNAL(bearingChanged(qreal)),
- this,
- SIGNAL(bearingChanged(qreal)));
- connect(d_ptr->mapData,
- SIGNAL(tiltChanged(qreal)),
- this,
- SIGNAL(tiltChanged(qreal)));
- connect(d_ptr->mapData,
- SIGNAL(mapTypeChanged(QGraphicsGeoMap::MapType)),
- this,
- SIGNAL(mapTypeChanged(QGraphicsGeoMap::MapType)));
- connect(d_ptr->mapData,
- SIGNAL(centerChanged(QGeoCoordinate)),
- this,
- SIGNAL(centerChanged(QGeoCoordinate)));
- connect(d_ptr->mapData,
- SIGNAL(connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode)),
- this,
- SIGNAL(connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode)));
-
- setFlag(QGraphicsItem::ItemIsFocusable);
- setFocus();
-
- setMinimumSize(QSizeF(0, 0));
- setPreferredSize(QSizeF(500, 500));
-}
-
-/*!
- Destroys this map widget.
-*/
-QGraphicsGeoMap::~QGraphicsGeoMap()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsGeoMap::resizeEvent(QGraphicsSceneResizeEvent *event)
-{
- if (d_ptr->mapData) {
- d_ptr->mapData->setWindowSize(event->newSize());
- }
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsGeoMap::shape() const
-{
- QPainterPath path;
- path.addRect(boundingRect());
- return path;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsGeoMap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
-{
- if (d_ptr->mapData)
- d_ptr->mapData->paint(painter, option);
-}
-
-void QGraphicsGeoMap::updateMapDisplay(const QRectF &target)
-{
- update(target);
-}
-
-/*!
- \property QGraphicsGeoMap::minimumZoomLevel
- \brief This property holds the minimum zoom level supported by the
- QGeoMappingManager associated with this widget.
-
- Larger values of the zoom level correspond to more detailed views of the
- map.
-*/
-qreal QGraphicsGeoMap::minimumZoomLevel() const
-{
- if (d_ptr->manager)
- return d_ptr->manager->minimumZoomLevel();
-
- return -1;
-}
-
-/*!
- \property QGraphicsGeoMap::maximumZoomLevel
- \brief This property holds the maximum zoom level supported by the
- QGeoMappingManager associated with this widget.
-
- Larger values of the zoom level correspond to more detailed views of the
- map.
-*/
-qreal QGraphicsGeoMap::maximumZoomLevel() const
-{
- if (d_ptr->manager)
- return d_ptr->manager->maximumZoomLevel();
-
- return -1;
-}
-
-/*!
- \property QGraphicsGeoMap::zoomLevel
- \brief This property holds the zoom level of the map.
-
- Larger values of the zoom level correspond to more detailed views of the
- map.
-
- If zoomLevel is less than minimumZoomLevel then minimumZoomLevel
- will be used, and if zoomLevel is larger than
- maximumZoomLevel then maximumZoomLevel will be used.
-*/
-void QGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
-{
- if (d_ptr->mapData)
- d_ptr->mapData->setZoomLevel(zoomLevel);
-}
-
-qreal QGraphicsGeoMap::zoomLevel() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->zoomLevel();
-
- return -1;
-}
-/*!
- \property QGraphicsGeoMap::supportsBearing
- \brief This property holds whether bearing is supported by the
- QGeoMappingManager associated with this widget.
-*/
-bool QGraphicsGeoMap::supportsBearing() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->supportsBearing();
-
- return false;
-}
-
-/*!
- \property QGraphicsGeoMap::bearing
- \brief This property holds the bearing of the map.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-
- Changes to this property will be ignored if supportsBearing()
- returns false.
-*/
-void QGraphicsGeoMap::setBearing(qreal bearing)
-{
- if (d_ptr->mapData)
- d_ptr->mapData->setBearing(bearing);
-}
-
-qreal QGraphicsGeoMap::bearing() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->bearing();
-
- return 0;
-}
-
-/*!
- \property QGraphicsGeoMap::supportsTilting
- \brief This property holds whether tilting is supported by the
- QGeoMappingManager associated with this widget.
-*/
-bool QGraphicsGeoMap::supportsTilting() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->supportsTilting();
-
- return false;
-}
-
-/*!
- \property QGraphicsGeoMap::minimumTilt
- \brief This property holds the minimum tilt supported by the
- QGeoMappingManager associated with this widget.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-*/
-qreal QGraphicsGeoMap::minimumTilt() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->minimumTilt();
-
- return 0;
-}
-
-/*!
- \property QGraphicsGeoMap::maximumTilt
- \brief This property holds the maximum tilt supported by the
- QGeoMappingManager associated with this widget.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-*/
-qreal QGraphicsGeoMap::maximumTilt() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->maximumTilt();
-
- return 0;
-}
-
-/*!
- \property QGraphicsGeoMap::tilt
- \brief This property holds the tilt of the map.
-
- Value in degrees where 0 is equivalent to 90 degrees between view and earth's
- surface i.e. looking straight down to earth.
-
- If \a tilt is less than minimumTilt() then minimumTilt()
- will be used, and if \a tilt is larger than
- maximumTilt() then maximumTilt() will be used.
-
- Changes to this property will be ignored if supportsTilting()
- returns false.
-*/
-void QGraphicsGeoMap::setTilt(qreal tilt)
-{
- if (d_ptr->mapData)
- d_ptr->mapData->setTilt(tilt);
-}
-
-qreal QGraphicsGeoMap::tilt() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->tilt();
-
- return 0;
-}
-
-/*!
- Pans the map view \a dx pixels in the x direction and \a dy pixels
- in the y direction.
-
- The x and y axes are specified in Graphics View Framework coordinates.
- By default this will mean that positive values of \a dx move the
- viewed area to the right and that positive values of \a dy move the
- viewed area down.
-
- After the panning has occurred the centerChanged() signal will be emitted.
-*/
-void QGraphicsGeoMap::pan(int dx, int dy)
-{
- if (d_ptr->mapData) {
- d_ptr->mapData->pan(dx, dy);
- update();
- }
-}
-
-/*!
- \property QGraphicsGeoMap::center
- \brief This property holds the coordinate at the center of the map viewport.
-
- Panning the map can be more efficient than changing the center by small
- increments.
-*/
-void QGraphicsGeoMap::setCenter(const QGeoCoordinate &center)
-{
- if (d_ptr->mapData)
- d_ptr->mapData->setCenter(center);
-}
-
-QGeoCoordinate QGraphicsGeoMap::center() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->center();
-
- return QGeoCoordinate();
-}
-
-/*!
- Returns the map types supported by the QGeoMappingManager associated with
- this widget.
-*/
-QList<QGraphicsGeoMap::MapType> QGraphicsGeoMap::supportedMapTypes() const
-{
- if (d_ptr->manager)
- return d_ptr->manager->supportedMapTypes();
-
- return QList<QGraphicsGeoMap::MapType>();
-}
-
-/*!
- \property QGraphicsGeoMap::mapType
- \brief This property holds the type of map data displayed by the map.
-
- Setting mapType to a type not present in supportedMapTypes() will do
- nothing.
-*/
-void QGraphicsGeoMap::setMapType(QGraphicsGeoMap::MapType mapType)
-{
- if (d_ptr->mapData && d_ptr->manager) {
- if (!d_ptr->manager->supportedMapTypes().contains(mapType))
- return;
-
- d_ptr->mapData->setMapType(mapType);
- }
-}
-
-QGraphicsGeoMap::MapType QGraphicsGeoMap::mapType() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->mapType();
-
- return QGraphicsGeoMap::NoMap;
-}
-
-/*!
- Returns the connectivity modes supported by the QGeoMappingManager associated with
- this widget.
-*/
-QList<QGraphicsGeoMap::ConnectivityMode> QGraphicsGeoMap::supportedConnectivityModes() const
-{
- if (d_ptr->manager)
- return d_ptr->manager->supportedConnectivityModes();
-
- return QList<QGraphicsGeoMap::ConnectivityMode>();
-}
-
-/*!
- \property QGraphicsGeoMap::connectivityMode
- \brief This property holds the connectivity mode used to obtain the map data.
-
- Setting connectivityMode to a mode not present in supportedConnectivityModes() will do
- nothing.
-*/
-void QGraphicsGeoMap::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
-{
- if (d_ptr->mapData && d_ptr->manager) {
- if (!d_ptr->manager->supportedConnectivityModes().contains(connectivityMode))
- return;
-
- d_ptr->mapData->setConnectivityMode(connectivityMode);
- }
-}
-
-QGraphicsGeoMap::ConnectivityMode QGraphicsGeoMap::connectivityMode() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->connectivityMode();
-
- return QGraphicsGeoMap::NoConnectivity;
-}
-
-/*!
- Returns whether custom map objects are supported by this engine.
-
- Custom map objects are map objects based on QGraphicsItem instances, which
- are hard to support in cases where the map rendering is not being
- performed by the Qt Graphics View framwork.
-*/
-bool QGraphicsGeoMap::supportsCustomMapObjects() const
-{
- if (d_ptr->manager)
- return d_ptr->manager->supportsCustomMapObjects();
-
- return false;
-}
-
-/*!
- Returns the map objects associated with this map.
-*/
-QList<QGeoMapObject*> QGraphicsGeoMap::mapObjects() const
-{
- if (!d_ptr->mapData)
- return QList<QGeoMapObject*>();
-
- return d_ptr->mapData->mapObjects();
-}
-
-/*!
- Adds \a mapObject to the list of map objects managed by this widget.
-
- If \a mapObject is within the viewport of the map and
- QGeoMapObject::isVisible() returns true then the map will display the map
- object immediately.
-
- The map will take ownership of the \a mapObject.
-
- If supportsCustomMapObject() returns false and \a mapObject is a custom map
- object then \a mapObject will not be added to the map.
-*/
-void QGraphicsGeoMap::addMapObject(QGeoMapObject *mapObject)
-{
- if (!mapObject || !d_ptr->mapData)
- return;
-
- if ((mapObject->type() == QGeoMapObject::CustomType) && !supportsCustomMapObjects())
- return;
-
- d_ptr->mapData->addMapObject(mapObject);
-
- this->update();
-}
-
-/*!
- Removes \a mapObject from the list of map objects managed by this widget.
-
- If \a mapObject is within the viewport of the map and
- QGeoMapObject::isVisible() returns true then the map will stop displaying
- the map object immediately.
-
- The map will release ownership of the \a mapObject.
-*/
-void QGraphicsGeoMap::removeMapObject(QGeoMapObject *mapObject)
-{
- if (!mapObject || !d_ptr->mapData)
- return;
-
- d_ptr->mapData->removeMapObject(mapObject);
-
- this->update();
-}
-
-/*!
- Clears the map objects associated with this map.
-
- The map objects will be deleted.
-*/
-void QGraphicsGeoMap::clearMapObjects()
-{
- if (!d_ptr->mapData)
- return;
-
- d_ptr->mapData->clearMapObjects();
-}
-
-/*!
- Returns the map overlays associated with this map.
-*/
-QList<QGeoMapOverlay*> QGraphicsGeoMap::mapOverlays() const
-{
- if (!d_ptr->mapData)
- return QList<QGeoMapOverlay*>();
-
- return d_ptr->mapData->mapOverlays();
-}
-
-/*!
- Adds \a overlay to the list of map overlays associated with this map.
-
- The overlays will be drawn in the order in which they were added.
-
- The map will take ownership of \a overlay.
-*/
-void QGraphicsGeoMap::addMapOverlay(QGeoMapOverlay *overlay)
-{
- if (!overlay || !d_ptr->mapData)
- return;
-
- d_ptr->mapData->addMapOverlay(overlay);
-
- this->update();
-}
-
-/*!
- Removes \a overlay from the list of map overlays associated with this map.
-
- The map will release ownership of \a overlay.
-*/
-void QGraphicsGeoMap::removeMapOverlay(QGeoMapOverlay *overlay)
-{
- if (!overlay || !d_ptr->mapData)
- return;
-
- d_ptr->mapData->removeMapOverlay(overlay);
-
- this->update();
-}
-
-/*!
- Clears the map overlays associated with this map.
-
- The map overlays will be deleted.
-*/
-void QGraphicsGeoMap::clearMapOverlays()
-{
- if (!d_ptr->mapData)
- return;
-
- d_ptr->mapData->clearMapOverlays();
-}
-
-/*!
- Returns a bounding box corresponding to the physical area displayed
- in the viewport of the map.
-
- The bounding box which is returned is defined by the upper left and
- lower right corners of the visible area of the map.
-*/
-QGeoBoundingBox QGraphicsGeoMap::viewport() const
-{
- if (!d_ptr->mapData)
- return QGeoBoundingBox();
-
- return d_ptr->mapData->viewport();
-}
-
-/*!
- Attempts to fit the bounding box \a bounds into the viewport of the map.
-
- This method will change the zoom level to the maximum zoom level such
- that all of \a bounds is visible within the resulting viewport.
-
- If \a preserveViewportCenter is false the map will be centered on the
- bounding box \a bounds before the zoom level is changed, otherwise the
- center of the map will not be changed.
-*/
-void QGraphicsGeoMap::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
-{
- if (!d_ptr->mapData)
- return;
-
- d_ptr->mapData->fitInViewport(bounds, preserveViewportCenter);
-}
-
-/*!
- Returns the list of visible map objects managed by this widget which
- contain the point \a screenPosition within their boundaries.
-*/
-QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->mapObjectsAtScreenPosition(screenPosition);
-
- return QList<QGeoMapObject*>();
-}
-
-/*!
- Returns the list of visible map objects managed by this widget which are
- displayed at least partially within the on screen rectangle
- \a screenRect.
-*/
-QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsInScreenRect(const QRectF &screenRect) const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->mapObjectsInScreenRect(screenRect);
-
- return QList<QGeoMapObject*>();
-}
-
-/*!
- Returns the list of visible map objects manager by this widget which
- are displayed at least partially within the viewport of the map.
-*/
-QList<QGeoMapObject*> QGraphicsGeoMap::mapObjectsInViewport() const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->mapObjectsInViewport();
-
- return QList<QGeoMapObject*>();
-}
-
-/*!
- Returns the position on the screen at which \a coordinate is displayed.
-
- An invalid QPointF will be returned if \a coordinate is invalid or is not
- within the current viewport.
-*/
-QPointF QGraphicsGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->coordinateToScreenPosition(coordinate);
-
- return QPointF();
-}
-
-/*!
- Returns the coordinate corresponding to the point in the viewport at \a
- screenPosition.
-
- An invalid QGeoCoordinate will be returned if \a screenPosition is invalid
- or is not within the current viewport.
-*/
-QGeoCoordinate QGraphicsGeoMap::screenPositionToCoordinate(QPointF screenPosition) const
-{
- if (d_ptr->mapData)
- return d_ptr->mapData->screenPositionToCoordinate(screenPosition);
-
- return QGeoCoordinate();
-}
-
-/*!
-\fn void QGraphicsGeoMap::zoomLevelChanged(qreal zoomLevel)
-
- This signal is emitted when the zoom level of the map changes.
-
- The new value is \a zoomLevel.
-*/
-
-/*!
-\fn void QGraphicsGeoMap::bearingChanged(qreal bearing)
-
- This signal is emitted when the bearing of the map changes.
-
- The new value is \a bearing.
-
- This signal will not be emitted if supportsBearing()
- returns false.
-*/
-
-/*!
-\fn void QGraphicsGeoMap::tiltChanged(qreal tilt)
-
- This signal is emitted when the tilt of the map changes.
-
- The new value is \a tilt.
-
- This signal will not be emitted if supportsTilting()
- returns false.
-*/
-
-/*!
-\fn void QGraphicsGeoMap::centerChanged(const QGeoCoordinate &coordinate)
-
- This signal is emitted when the center of the map changes.
-
- The new value is \a coordinate.
-*/
-
-/*!
-\fn void QGraphicsGeoMap::mapTypeChanged(QGraphicsGeoMap::MapType mapType)
-
- This signal is emitted when the map type changes.
-
- The new value is \a mapType.
-*/
-
-/*!
-\fn void QGraphicsGeoMap::connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode)
-
- This signal is emitted when the connectivity mode used to fetch the
- map data changes.
-
- The new value is \a connectivityMode.
-*/
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGraphicsGeoMapPrivate::QGraphicsGeoMapPrivate()
- : manager(0),
- mapData(0),
- panActive(false) {}
-
-QGraphicsGeoMapPrivate::~QGraphicsGeoMapPrivate()
-{
- if (mapData)
- delete mapData;
-}
-
-#include "moc_qgraphicsgeomap.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/qgraphicsgeomap.h b/src/location/maps/qgraphicsgeomap.h
deleted file mode 100644
index 00a47d8c..00000000
--- a/src/location/maps/qgraphicsgeomap.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSGEOMAP_H
-#define QGRAPHICSGEOMAP_H
-
-#include "qmobilityglobal.h"
-
-#include <QGraphicsWidget>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoMappingManager;
-class QGeoBoundingBox;
-class QGeoMapObject;
-class QGeoMapOverlay;
-class QGraphicsGeoMapPrivate;
-
-class Q_LOCATION_EXPORT QGraphicsGeoMap : public QGraphicsWidget
-{
- Q_OBJECT
- Q_ENUMS(MapType)
- Q_ENUMS(ConnectivityMode)
-
- Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel CONSTANT)
- Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel CONSTANT)
- Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
- Q_PROPERTY(MapType mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
- Q_PROPERTY(ConnectivityMode connectivityMode READ connectivityMode WRITE setConnectivityMode NOTIFY connectivityModeChanged)
- Q_PROPERTY(qreal minimumTilt READ minimumTilt CONSTANT)
- Q_PROPERTY(qreal maximumTilt READ maximumTilt CONSTANT)
- Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged)
- Q_PROPERTY(bool supportsTilting READ supportsTilting CONSTANT)
- Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged)
- Q_PROPERTY(bool supportsBearing READ supportsBearing CONSTANT)
-
-public:
- enum MapType {
- NoMap,
- StreetMap,
- SatelliteMapDay,
- SatelliteMapNight,
- TerrainMap
- };
-
- enum ConnectivityMode {
- NoConnectivity,
- OfflineMode,
- OnlineMode,
- HybridMode
- };
-
- QGraphicsGeoMap(QGeoMappingManager *manager, QGraphicsItem *parent = 0);
- virtual ~QGraphicsGeoMap();
-
- QPainterPath shape() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *parent);
-
- qreal minimumZoomLevel() const;
- qreal maximumZoomLevel() const;
-
- void setZoomLevel(qreal zoomLevel);
- qreal zoomLevel() const;
-
- bool supportsBearing() const;
- void setBearing(qreal bearing);
- qreal bearing() const;
-
- bool supportsTilting() const;
- void setTilt(qreal tilt);
- qreal tilt() const;
- qreal minimumTilt() const;
- qreal maximumTilt() const;
-
- void setCenter(const QGeoCoordinate &center);
- QGeoCoordinate center() const;
-
- QList<MapType> supportedMapTypes() const;
- void setMapType(MapType mapType);
- MapType mapType() const;
-
- QList<ConnectivityMode> supportedConnectivityModes() const;
- void setConnectivityMode(ConnectivityMode connectivityMode);
- ConnectivityMode connectivityMode() const;
-
- bool supportsCustomMapObjects() const;
-
- QList<QGeoMapObject*> mapObjects() const;
- void addMapObject(QGeoMapObject *mapObject);
- void removeMapObject(QGeoMapObject *mapObject);
- void clearMapObjects();
-
- QList<QGeoMapOverlay*> mapOverlays() const;
- void addMapOverlay(QGeoMapOverlay *overlay);
- void removeMapOverlay(QGeoMapOverlay *overlay);
- void clearMapOverlays();
-
- QGeoBoundingBox viewport() const;
- void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false);
-
- QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
- QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
- QList<QGeoMapObject*> mapObjectsInViewport() const;
-
- QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
- QGeoCoordinate screenPositionToCoordinate(QPointF screenPosition) const;
-
-public Q_SLOTS:
- void pan(int dx, int dy);
-
-protected:
- void resizeEvent(QGraphicsSceneResizeEvent *event);
-
-Q_SIGNALS:
- void zoomLevelChanged(qreal zoomLevel);
- void centerChanged(const QGeoCoordinate &coordinate);
- void mapTypeChanged(QGraphicsGeoMap::MapType mapType);
- void connectivityModeChanged(QGraphicsGeoMap::ConnectivityMode connectivityMode);
- void bearingChanged(qreal bearing);
- void tiltChanged(qreal tilt);
-
-private Q_SLOTS:
- void updateMapDisplay(const QRectF& target);
-
-private:
- QGraphicsGeoMapPrivate *d_ptr;
- Q_DISABLE_COPY(QGraphicsGeoMap)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/makepoly_p.h b/src/location/maps/tiled/makepoly_p.h
deleted file mode 100644
index d8b3a852..00000000
--- a/src/location/maps/tiled/makepoly_p.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAKEPOLY_P_H
-#define MAKEPOLY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-#include "qgeocoordinate.h"
-
-#include <QList>
-#include <QPolygonF>
-#include <QGraphicsPolygonItem>
-
-QT_BEGIN_NAMESPACE
-
-// TODO: replace boolean parameter by enum
-static inline void makepoly(QPolygonF &points, const QList<QGeoCoordinate> & path, const QGeoTiledMapDataPrivate * mapData, bool closedPath, qreal ypole = -100)
-{
- points.clear();
-
- QGeoCoordinate lastCoord = closedPath ? path.last() : path.first();
- QPointF lastPoint = mapData->q_ptr->coordinateToWorldPixel(lastCoord);
-
- int width = mapData->maxZoomSize.width();
-
- for (int i = 0; i < path.size(); ++i) {
- const QGeoCoordinate &coord = path.at(i);
-
- if (!coord.isValid())
- continue;
-
- const qreal lng = coord.longitude();
- const qreal lastLng = lastCoord.longitude();
-
- // is the dateline crossed = different sign AND gap is large enough
- const bool crossesDateline = lastLng * lng < 0 && abs(lastLng - lng) > 180;
-
- // calculate base point
- QPointF point = mapData->q_ptr->coordinateToWorldPixel(coord);
-
- // if the dateline is crossed, draw "around" the map over the chosen pole
- if (crossesDateline) {
- // is the shortest route east = dateline crossed XOR longitude is east by simple comparison
- const bool goesEast = crossesDateline != (lng > lastLng);
- // direction = positive if east, negative otherwise
- const qreal dir = goesEast ? 1 : -1;
-
- // lastPoint on this side
- const QPointF & L = lastPoint;
-
- // point on the other side
- const QPointF & P = point;
-
- // lastPoint on the other side
- QPointF L_ = L - QPointF(width * dir, 0);
-
- // point on this side
- QPointF P_ = P + QPointF(width * dir, 0);
-
- // TODO: make a better algorithm to make sure the off-screen points P' and L' are far enough from the dateline so the lines to the poles don't flicker through.
- // this works for now :)
- L_ += (L_ - P) * 7;
- P_ += (P_ - L) * 7;
-
- // pole point on this side
- QPointF O1 = QPointF(P_.x(), ypole);
- // pole point on the other side
- QPointF O2 = QPointF(L_.x(), ypole);
-
- //points.append(L); // implicit
- points.append(P_); // P'
- points.append(O1);
- points.append(O2);
- points.append(L_); // L'
- points.append(P);
- } else {
- // add point to polygon
- points.append(point);
- }
-
- lastCoord = coord;
- lastPoint = point;
- }
-}
-
-QT_END_NAMESPACE
-
-#endif //MAKEPOLY_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp
deleted file mode 100644
index 2d726b2b..00000000
--- a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmapcircleobjectinfo_p.h"
-
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomapcircleobject.h"
-
-#include <QGraphicsItem>
-#include <QGraphicsEllipseItem>
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapCircleObjectInfo::QGeoTiledMapCircleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- circle = static_cast<QGeoMapCircleObject*>(mapObject);
-
- connect(circle,
- SIGNAL(radiusChanged(qreal)),
- this,
- SLOT(radiusChanged(qreal)));
- connect(circle,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
- connect(circle,
- SIGNAL(brushChanged(QBrush)),
- this,
- SLOT(brushChanged(QBrush)));
-
- ellipseItem = new QGraphicsEllipseItem;
- ellipseItem->setPos(0, 0);
-
- graphicsItem = ellipseItem;
-
- radiusChanged(circle->radius());
- brushChanged(circle->brush());
- penChanged(circle->pen());
-}
-
-QGeoTiledMapCircleObjectInfo::~QGeoTiledMapCircleObjectInfo() {}
-
-void QGeoTiledMapCircleObjectInfo::radiusChanged(qreal /*radius*/)
-{
- qreal radius = circle->radius();
- ellipseItem->setRect(-1*radius, -1*radius, 2*radius, 2*radius);
- updateItem();
-}
-
-void QGeoTiledMapCircleObjectInfo::penChanged(const QPen &pen)
-{
- ellipseItem->setPen(pen);
- updateItem();
-}
-
-void QGeoTiledMapCircleObjectInfo::brushChanged(const QBrush &brush)
-{
- ellipseItem->setBrush(brush);
- updateItem();
-}
-
-#include "moc_qgeotiledmapcircleobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h
deleted file mode 100644
index c6f07383..00000000
--- a/src/location/maps/tiled/qgeotiledmapcircleobjectinfo_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
-#define QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeotiledmapobjectinfo_p.h"
-
-#include <QPolygonF>
-#include <QPen>
-#include <QBrush>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsEllipseItem;
-class QGeoMapCircleObject;
-
-class QGeoTiledMapCircleObjectInfo : public QGeoTiledMapObjectInfo
-{
- Q_OBJECT
-public:
- QGeoTiledMapCircleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapCircleObjectInfo();
-
- QGeoMapCircleObject* circle;
- QGraphicsEllipseItem *ellipseItem;
-
-public slots:
- void radiusChanged(qreal radius);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
-};
-
-QT_END_NAMESPACE
-
-#endif //QGEOTILEDMAPCIRCLEOBJECT_INFO_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h
deleted file mode 100644
index cdf2c81c..00000000
--- a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
-#define QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeoboundingbox.h"
-
-#include <QPixmap>
-
-class QGraphicsPixmapItem;
-
-QT_BEGIN_NAMESPACE
-
-class QGeoMapCustomObject;
-
-class QGeoTiledMapCustomObjectInfo : public QGeoTiledMapObjectInfo
-{
- Q_OBJECT
-public:
- QGeoTiledMapCustomObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapCustomObjectInfo();
-
- QGeoMapCustomObject* custom;
-
-public slots:
- void updateTriggered();
- void graphicsItemChanged(QGraphicsItem *graphicsItem);
- void offsetChanged(const QPoint &offset);
-};
-
-QT_END_NAMESPACE
-
-#endif //QGEOTILEDMAPCUSTOMOBJECT_INFO_P_H
-
diff --git a/src/location/maps/tiled/qgeotiledmapdata.cpp b/src/location/maps/tiled/qgeotiledmapdata.cpp
deleted file mode 100644
index 207242f1..00000000
--- a/src/location/maps/tiled/qgeotiledmapdata.cpp
+++ /dev/null
@@ -1,1431 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeotiledmappingmanagerengine.h"
-#include "qgeotiledmappingmanagerengine_p.h"
-#include "qgeotiledmaprequest.h"
-#include "qgeocoordinate.h"
-#include "qgeoboundingbox.h"
-#include "qgeomapoverlay.h"
-#include <private/projwrapper_p.h>
-#include "qgeomapobjectengine_p.h"
-
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeotiledmapcircleobjectinfo_p.h"
-#include "qgeotiledmapgroupobjectinfo_p.h"
-#include "qgeotiledmappixmapobjectinfo_p.h"
-#include "qgeotiledmappolygonobjectinfo_p.h"
-#include "qgeotiledmappolylineobjectinfo_p.h"
-#include "qgeotiledmaprectangleobjectinfo_p.h"
-#include "qgeotiledmaprouteobjectinfo_p.h"
-#include "qgeotiledmaptextobjectinfo_p.h"
-#include "qgeotiledmapcustomobjectinfo_p.h"
-
-#include "qgeomaptextobject.h"
-
-#include <QTimer>
-#include <QImage>
-#include <QGraphicsScene>
-
-#include <QDebug>
-
-//#define DEFAULT_ZOOMLEVEL 8
-#define PI 3.14159265
-//#define HIT_DETECTION_COLOR qRgba(0, 0, 255, 127) //semi-transparent blue
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-uint qHash(const QRectF& key)
-{
- uint result = qHash(qRound(key.x()));
- result += qHash(qRound(key.y()));
- result += qHash(qRound(key.width()));
- result += qHash(qRound(key.height()));
- return result;
-}
-
-
-/*!
- \class QGeoTiledMapData
- \brief The QGeoTiledMapData class is a subclass of QGeoMapData provided
- to make working with tile based mapping services more convenient.
-
- \inmodule QtLocation
-
- \ingroup maps-impl-tiled
-
- \since 1.2
-
- This class assumes that at a zoom level of z the world is represented as a
- 2^z by 2^z grid of tiles, and that the Mercator projection is used to map
- back and forth between coordinate and positions on the map.
-
- Different projections can be provided by reimplementing
- coordinateToWorldReferencePosition() and worldReferencePositionToCoordinate().
-
- Many of the internal calculations deal with positions as though they are
- pixel positions on the map at the maximum zoom level. Several functions are
- provided which expose information about the map and the viewport onto the
- map in these terms for use with custom QGeoMapObjectInfo subclasses.
-
- These functions include worldReferenceViewportCenter(), worldReferenceSize() and
- worldReferenceViewportRect().
-
- NOTE: QGeoTiledMapData blocks property change signals from QGeoMapData by calling
- QGeoMapData::setBlockPropertyChangeSignals() with true. Changing this in
- QGeoTiledMapData subclasses will cause the signals being emitted at wrong time.
-*/
-
-/*!
- Constructs a new tiled map data object, which makes use of the functionality provided by \a engine.
-*/
-QGeoTiledMapData::QGeoTiledMapData(QGeoMappingManagerEngine *engine)
- : QGeoMapData(new QGeoTiledMapDataPrivate(this, engine))
-{
- Q_D(QGeoTiledMapData);
-
- QGeoTiledMappingManagerEngine *tileEngine = static_cast<QGeoTiledMappingManagerEngine *>(d->engine);
-
- setBlockPropertyChangeSignals(true);
-
- setZoomLevel(8.0);
-
- d->worldReferenceSize = (1 << qRound(tileEngine->maximumZoomLevel())) * tileEngine->tileSize();
-
- // TODO get this from the engine, which should give different values depending on if this is running on a device or not
-#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
- d->cache.setMaxCost(5 * 1024 * 1024);
- d->zoomCache.setMaxCost(5 * 1024 * 1024);
-#else
- d->cache.setMaxCost(10 * 1024 * 1024);
- d->zoomCache.setMaxCost(10 * 1024 * 1024);
-#endif
-}
-
-/*!
- Destroys this tiled map data object.
-*/
-QGeoTiledMapData::~QGeoTiledMapData()
-{
-}
-
-
-QPointF QGeoTiledMapDataPrivate::coordinateToScreenPosition(double lon, double lat) const
-{
- QPointF offset = windowOffset();
-
- QPoint pos(coordinateToWorldReferencePosition(lon, lat));
-
- const int x = pos.x() - worldReferenceViewportRect.left();
-// if (x < 0)
-// x += worldReferenceSize.width();
-
- const int y = pos.y() - worldReferenceViewportRect.top();
-
- QPointF posF(offset.x() + qreal(x) / zoomFactor, offset.y() + qreal(y) / zoomFactor);
-
- return posF;
-}
-
-/*!
- \reimp
-*/
-QPointF QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordwgs) const
-{
- Q_D(const QGeoTiledMapData);
- return d->coordinateToScreenPosition(coordwgs.longitude(), coordwgs.latitude());
-}
-
-/*!
- \reimp
-*/
-QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QPointF &screenPosition) const
-{
- Q_D(const QGeoTiledMapData);
-
- QPoint worldRef = d->screenPositionToWorldReferencePosition(screenPosition);
-
- if (worldRef.isNull())
- return QGeoCoordinate();
-
- const QGeoCoordinate insph = worldReferencePositionToCoordinate(worldRef);
-
- //ProjCoordinate c(insph.longitude(), insph.latitude(), 0.0, d->spherical);
- //c.convert(d->wgs84);
- return insph;
-}
-
-// this belongs to QGeoTiledMapDataPrivate in order to avoid
-// breaking B.C.
-QPoint QGeoTiledMapDataPrivate::screenPositionToWorldReferencePosition(const QPointF &screenPosition) const
-{
- QPointF offset = windowOffset();
-
- QPointF pos(screenPosition.x() - offset.x(), screenPosition.y() - offset.y());
-
- const int worldX = int(worldReferenceViewportRect.left() + pos.x() * zoomFactor + 0.5) % worldReferenceSize.width();
- const int worldY = int(worldReferenceViewportRect.top() + pos.y() * zoomFactor + 0.5) % worldReferenceSize.height();
-
- return QPoint(worldX, worldY);
-}
-
-QPoint QGeoTiledMapDataPrivate::coordinateToWorldReferencePosition(double lng, double lat) const
-{
- lng = lng / 360.0 + 0.5;
-
- lat = 0.5 - (log(tan((PI / 4.0) + (PI / 2.0) * lat / 180.0)) / PI) / 2.0;
- lat = qMax(0.0, lat);
- lat = qMin(1.0, lat);
-
- const double x = lng * worldReferenceSize.width();
- const double y = lat * worldReferenceSize.height();
-
- const QPoint r(int(x > 0 ? x + 0.5 : x - 0.5),
- int(y > 0 ? y + 0.5 : y - 0.5));
- return r;
-}
-
-/*!
- Converts the coordinate \a coordinate to a pixel position on the entire
- map at the maximum zoom level.
-
- The default implementation is based on the Mercator projection.
-*/
-QPoint QGeoTiledMapData::coordinateToWorldReferencePosition(const QGeoCoordinate &coordinate) const
-{
- Q_D(const QGeoTiledMapData);
- return d->coordinateToWorldReferencePosition(coordinate.longitude(),
- coordinate.latitude());
-}
-
-qreal rmod(const qreal a, const qreal b)
-{
- quint64 div = static_cast<quint64>(a / b);
- return a - static_cast<qreal>(div) * b;
-}
-
-/*!
- Converts the pixel position \a pixel on the map to a coordinate.
-
- The pixel position is relative the entire map at the maximum zoom level.
-
- The default implementation is based on the Mercator projection.
-*/
-QGeoCoordinate QGeoTiledMapData::worldReferencePositionToCoordinate(const QPoint &pixel) const
-{
- Q_D(const QGeoTiledMapData);
-
- qreal fx = qreal(pixel.x()) / d->worldReferenceSize.width();
- qreal fy = qreal(pixel.y()) / d->worldReferenceSize.height();
-
- if (fy < 0.0f)
- fy = 0.0f;
- else if (fy > 1.0f)
- fy = 1.0f;
-
- qreal lat;
-
- if (fy == 0.0f)
- lat = 90.0f;
- else if (fy == 1.0f)
- lat = -90.0f;
- else
- lat = (180.0f / PI) * (2.0f * atan(exp(PI * (1.0f - 2.0f * fy))) - (PI / 2.0f));
-
- qreal lng;
- if (fx >= 0) {
- lng = rmod(fx, 1.0f);
- } else {
- lng = rmod(1.0f - rmod(-1.0f * fx, 1.0f), 1.0f);
- }
-
- lng = lng * 360.0f - 180.0f;
-
- return QGeoCoordinate(lat, lng, 0.0);
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::setCenter(const QGeoCoordinate &center)
-{
- Q_D(QGeoTiledMapData);
-
- bool changed = (d->center != center);
-
- if (!changed)
- return;
-
- d->worldReferenceViewportCenter = coordinateToWorldReferencePosition(center);
- d->updateScreenRect();
- emit updateMapDisplay();
-
- emit centerChanged(center);
-
- d->updateMapImage();
-
- QGeoMapData::setCenter(center);
- d->oe->invalidatePixelsForViewport();
- d->oe->trimPixelTransforms();
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::setMapType(QGraphicsGeoMap::MapType mapType)
-{
- Q_D(QGeoTiledMapData);
-
- bool changed = (d->mapType != mapType);
-
- if (!changed)
- return;
-
- QGeoMapData::setMapType(mapType);
-
- d->clearRequests();
- d->cache.clear();
- d->zoomCache.clear();
- emit updateMapDisplay();
-
- emit mapTypeChanged(d->mapType);
-
- d->updateMapImage();
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode)
-{
- QGraphicsGeoMap::ConnectivityMode oldMode = QGeoMapData::connectivityMode();
-
- if (oldMode == connectivityMode)
- return;
-
- QGeoMapData::setConnectivityMode(connectivityMode);
-
- if (oldMode == QGeoMapData::connectivityMode())
- return;
-
- emit connectivityModeChanged(connectivityMode);
-}
-
-/*!
- \reimp
-*/
-QGeoCoordinate QGeoTiledMapData::center() const
-{
- Q_D(const QGeoTiledMapData);
- return worldReferencePositionToCoordinate(d->worldReferenceViewportCenter);
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::setZoomLevel(qreal zoomLevelf)
-{
- Q_D(QGeoTiledMapData);
-
- QPixmap oldImage(windowSize().toSize());
- if (!oldImage.isNull()) {
- // grab the old image
- QPainter painter1(&oldImage);
- d->paintMap(&painter1, 0);
- painter1.end();
- }
-
- qreal oldZoomLevel = d->zoomLevel;
- int zoomLevel = qRound(zoomLevelf);
-
- QGeoMapData::setZoomLevel(zoomLevel);
-
- d->oe->invalidateZoomDependents();
- d->oe->invalidatePixelsForViewport();
- d->oe->trimPixelTransforms();
-
- // QGeoMapData::setZoomLevel clips the zoom level to be
- // in between the minimum and maximum zoom levels
- zoomLevel = QGeoMapData::zoomLevel();
-
- int zoomDiff = qRound(zoomLevel - oldZoomLevel);
-
- if (zoomDiff == 0)
- return;
-
- d->zoomFactor = 1 << qRound(d->engine->maximumZoomLevel() - d->zoomLevel);
-
- QGeoTiledMappingManagerEngine *tileEngine = static_cast<QGeoTiledMappingManagerEngine *>(d->engine);
- QSize tileSize = tileEngine->tileSize();
-
- d->updateScreenRect();
-
- if (oldImage.isNull()) {
- d->updateMapImage();
- emit zoomLevelChanged(d->zoomLevel);
- return;
- }
-
- //scale old image
- QRectF target = oldImage.rect();
- qreal width = target.width() / (1 << qAbs(zoomDiff));
- qreal height = target.height() / (1 << qAbs(zoomDiff));
- qreal x = target.x() + ((target.width() - width) / 2.0);
- qreal y = target.y() + ((target.height() - height) / 2.0);
- QRectF source = QRectF(x, y, width, height);
-
- QPixmap newImage(oldImage.size());
- newImage.fill(Qt::lightGray);
- QPainter painter2(&newImage);
-#if !(defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6))
- painter2.setRenderHint(QPainter::SmoothPixmapTransform, true);
-#endif
- if (zoomDiff < 0) {
- painter2.drawPixmap(source, oldImage, target);
- } else {
- painter2.drawPixmap(target, oldImage, source);
- }
- painter2.end();
-
- d->zoomCache.clear();
-
- QGeoTileIterator it(d);
-
- QPointF offset = d->windowOffset();
-
- while (it.hasNext()) {
- QGeoTiledMapRequest req = it.next();
- QRect tileRect = req.tileRect();
-
- if (d->cache.contains(req))
- continue;
-
- if (!d->intersectsScreen(tileRect))
- continue;
-
- QList<QPair<QRect, QRect> > overlaps = d->intersectedScreen(tileRect);
- for (int i = 0; i < overlaps.size(); ++i) {
- QRect s = overlaps.at(i).first;
- QRect t = overlaps.at(i).second;
-
- QRectF source = QRectF(offset.x() + int(t.left()) / d->zoomFactor,
- offset.y() + int(t.top()) / d->zoomFactor,
- int(t.width()) / d->zoomFactor,
- int(t.height()) / d->zoomFactor);
-
- QPixmap *tile = new QPixmap(tileSize);
- tile->fill(Qt::lightGray); // TODO: this looks useless
-
- QRectF target = QRectF(int(s.left()) / d->zoomFactor,
- int(s.top()) / d->zoomFactor,
- int(s.width()) / d->zoomFactor,
- int(s.height()) / d->zoomFactor);
-
- QPainter painter3(tile);
- painter3.drawPixmap(target, newImage, source);
- painter3.end();
-
- d->zoomCache.insert(req, tile, (tile->depth() * tile->width() * tile->height()) / 8);
- }
- }
-
- emit updateMapDisplay();
-
- d->clearRequests();
- d->updateMapImage();
-
- emit zoomLevelChanged(d->zoomLevel);
-
- // call again
- QGeoMapData::setZoomLevel(zoomLevel);
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::setWindowSize(const QSizeF &size)
-{
- Q_D(QGeoTiledMapData);
-
- bool changed = (d->windowSize != size);
-
- if (!changed)
- return;
-
- QGeoMapData::setWindowSize(size);
-
- d->oe->invalidatePixelsForViewport();
- d->oe->trimPixelTransforms();
-
- d->updateScreenRect();
-
- emit windowSizeChanged(d->windowSize);
-
- d->updateMapImage();
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::pan(int dx, int dy)
-{
- Q_D(QGeoTiledMapData);
-
- int x = d->worldReferenceViewportCenter.x();
- int y = d->worldReferenceViewportCenter.y();
-
- x = (x + dx * d->zoomFactor) % d->worldReferenceSize.width();
- if (x < 0)
- x += d->worldReferenceSize.width();
-
- y = (y + dy * d->zoomFactor);
- int height = int(d->worldReferenceViewportRect.height() / 2.0);
- if (y < height)
- y = height;
- if (y > d->worldReferenceSize.height() - height)
- y = d->worldReferenceSize.height() - height;
-
- d->worldReferenceViewportCenter.setX(x);
- d->worldReferenceViewportCenter.setY(y);
-
- QGeoCoordinate centerCoord = center();
-
- QGeoMapData::setCenter(centerCoord);
- d->oe->invalidatePixelsForViewport();
- d->oe->trimPixelTransforms();
-
- d->updateScreenRect();
-
- emit centerChanged(centerCoord);
-
- d->updateMapImage();
-}
-
-/*!
- \reimp
-*/
-QGeoBoundingBox QGeoTiledMapData::viewport() const
-{
- Q_D(const QGeoTiledMapData);
- if (d->worldReferenceViewportRectRight.isValid()) {
- return QGeoBoundingBox(worldReferencePositionToCoordinate(d->worldReferenceViewportRectLeft.topLeft()),
- worldReferencePositionToCoordinate(d->worldReferenceViewportRectRight.bottomRight()));
- } else {
- return QGeoBoundingBox(worldReferencePositionToCoordinate(d->worldReferenceViewportRect.topLeft()),
- worldReferencePositionToCoordinate(d->worldReferenceViewportRect.bottomRight()));
- }
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter)
-{
- Q_D(QGeoTiledMapData);
-
- if (!preserveViewportCenter)
- setCenter(bounds.center());
-
- int minZoomLevel = engine()->minimumZoomLevel();
- int maxZoomLevel = engine()->maximumZoomLevel();
-
- int zoomFactor = 1 << maxZoomLevel;
-
- for (int i = minZoomLevel; i <= maxZoomLevel; ++i) {
- QRect rect = d->screenRectForZoomFactor(zoomFactor);
- QGeoBoundingBox viewport = QGeoBoundingBox(worldReferencePositionToCoordinate(rect.topLeft()),
- worldReferencePositionToCoordinate(rect.bottomRight()));
-
-// qWarning() << i << zoomFactor
-// << viewport.topLeft()
-// << viewport.bottomRight();
-
- if (!viewport.contains(bounds)) {
- setZoomLevel(qMax(minZoomLevel, i - 1));
- return;
- }
-
- zoomFactor /= 2;
- }
-
- setZoomLevel(maxZoomLevel);
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- Q_D(QGeoTiledMapData);
- d->paintMap(painter, option);
-}
-
-/*!
- \reimp
-*/
-void QGeoTiledMapData::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- Q_D(QGeoTiledMapData);
- d->paintObjects(painter, option);
-}
-
-/*!
- \reimp
-*/
-QGeoMapObjectInfo *QGeoTiledMapData::createMapObjectInfo(QGeoMapObject *mapObject)
-{
- switch (mapObject->type()) {
- case QGeoMapObject::GroupType:
- return new QGeoTiledMapGroupObjectInfo(this, mapObject);
- case QGeoMapObject::RectangleType:
- return new QGeoTiledMapRectangleObjectInfo(this, mapObject);
- case QGeoMapObject::CircleType:
- return new QGeoTiledMapCircleObjectInfo(this, mapObject);
- case QGeoMapObject::PolylineType:
- return new QGeoTiledMapPolylineObjectInfo(this, mapObject);
- case QGeoMapObject::PolygonType:
- return new QGeoTiledMapPolygonObjectInfo(this, mapObject);
- case QGeoMapObject::PixmapType:
- return new QGeoTiledMapPixmapObjectInfo(this, mapObject);
- case QGeoMapObject::TextType:
- return new QGeoTiledMapTextObjectInfo(this, mapObject);
- case QGeoMapObject::RouteType:
- return new QGeoTiledMapRouteObjectInfo(this, mapObject);
- case QGeoMapObject::CustomType:
- return new QGeoTiledMapCustomObjectInfo(this, mapObject);
- default:
- return 0;
- }
-}
-
-void QGeoTiledMapData::processRequests()
-{
- Q_D(QGeoTiledMapData);
-
- QMutableSetIterator<QGeoTiledMapReply*> replyIter(d->replies);
- // Abort off-screen replies
- while (replyIter.hasNext()) {
- QGeoTiledMapReply *reply = replyIter.next();
- if (!d->intersectsScreen(reply->request().tileRect())
- || (zoomLevel() != reply->request().zoomLevel())
- || (mapType() != reply->request().mapType())
- || (connectivityMode() != reply->request().connectivityMode())) {
- d->replyRects.remove(reply->request().tileRect());
- d->zoomCache.remove(reply->request());
- replyIter.remove();
- reply->abort();
- }
- }
-
- QGeoTiledMappingManagerEngine *tiledEngine
- = static_cast<QGeoTiledMappingManagerEngine*>(engine());
-
- QMutableListIterator<QGeoTiledMapRequest> requestIter(d->requests);
- while (requestIter.hasNext()) {
- QGeoTiledMapRequest req = requestIter.next();
-
- d->requestRects.remove(req.tileRect());
- requestIter.remove();
-
- // Do not use the requests which have pending replies or are off screen
- if (d->replyRects.contains(req.tileRect()) || !d->intersectsScreen(req.tileRect())) {
- continue;
- }
-
- QGeoTiledMapReply *reply = tiledEngine->getTileImage(req);
-
- if (!reply) {
- continue;
- }
-
- if (reply->error() != QGeoTiledMapReply::NoError) {
- tileError(reply->error(), reply->errorString());
- reply->deleteLater();
- d->zoomCache.remove(reply->request());
- continue;
- }
-
- connect(reply,
- SIGNAL(finished()),
- this,
- SLOT(tileFinished()));
-
- connect(reply,
- SIGNAL(error(QGeoTiledMapReply::Error, QString)),
- this,
- SLOT(tileError(QGeoTiledMapReply::Error, QString)));
-
- d->replies.insert(reply);
- d->replyRects.insert(reply->request().tileRect());
-
- if (reply->isFinished())
- replyFinished(reply);
- }
-}
-
-void QGeoTiledMapData::tileFinished()
-{
- Q_D(QGeoTiledMapData);
-
- QGeoTiledMapReply *reply = qobject_cast<QGeoTiledMapReply*>(sender());
-
- if (!reply) {
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
- return;
- } else {
- replyFinished(reply);
- }
-}
-
-void QGeoTiledMapData::replyFinished(QGeoTiledMapReply *reply)
-{
- Q_D(QGeoTiledMapData);
-
- d->replyRects.remove(reply->request().tileRect());
- d->replies.remove(reply);
- d->zoomCache.remove(reply->request());
-
- if (reply->error() != QGeoTiledMapReply::NoError) {
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
- reply->deleteLater();
- return;
- }
-
- if ((zoomLevel() != reply->request().zoomLevel())
- || (mapType() != reply->request().mapType())
- || (connectivityMode() != reply->request().connectivityMode())) {
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
- reply->deleteLater();
- return;
- }
-
- //QPixmap *tile = new QPixmap();
- QImage *tile = new QImage();
-
- if (!tile->loadFromData(reply->mapImageData(), reply->mapImageFormat().toAscii())) {
- delete tile;
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
- reply->deleteLater();
- return;
- //setError(QGeoTiledMapReply::ParseError, "The response from the service was not in a recognisable format.");
- }
-
- if (tile->isNull() || tile->size().isEmpty()) {
- delete tile;
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
- reply->deleteLater();
- return;
- //setError(QGeoTiledMapReply::ParseError, "The map image is empty.");
- }
-
- d->cache.insert(reply->request(), tile, (tile->depth() * tile->width() * tile->height()) / 8);
-
- d->cleanupCaches();
-
- QRect tileRect = reply->request().tileRect();
-
- QPointF offset = d->windowOffset();
-
- QList<QPair<QRect, QRect> > overlaps = d->intersectedScreen(tileRect);
- for (int i = 0; i < overlaps.size(); ++i) {
- QRect t = overlaps.at(i).second;
- QRectF target = QRectF(offset.x() + int(t.left()) / d->zoomFactor,
- offset.y() + int(t.top()) / d->zoomFactor,
- int(t.width()) / d->zoomFactor,
- int(t.height()) / d->zoomFactor);
-
- emit updateMapDisplay(target);
- }
-
- if (d->requests.size() > 0)
- QTimer::singleShot(0, this, SLOT(processRequests()));
-
- reply->deleteLater();
-}
-
-void QGeoTiledMapData::tileError(QGeoTiledMapReply::Error error, QString errorString)
-{
- Q_UNUSED(error)
- qWarning() << errorString;
-}
-
-/*!
- \reimp
-*/
-QList<QGeoMapObject*> QGeoTiledMapData::mapObjectsAtScreenPosition(const QPointF &screenPosition) const
-{
- return mapObjectsInScreenRect(QRectF(screenPosition - QPointF(1,1),
- screenPosition + QPointF(1,1)));
-// if (screenPosition.isNull())
-// return QList<QGeoMapObject*>();
-
-// Q_D(const QGeoTiledMapData);
-
-// QList<QGeoMapObject*> results;
-// QSet<QGeoMapObject*> considered;
-
-// d->oe->updateTransforms();
-
-// QList<QGraphicsItem*> pixelItems;
-// pixelItems = d->oe->pixelScene->items(QRectF(screenPosition - QPointF(1,1),
-// screenPosition + QPointF(1,1)),
-// Qt::IntersectsItemShape,
-// Qt::AscendingOrder);
-
-// foreach (QGraphicsItem *item, pixelItems) {
-// QGeoMapObject *object = d->oe->pixelItems.value(item);
-// Q_ASSERT(object);
-
-// if (object->isVisible() && !considered.contains(object)) {
-// bool contains = false;
-
-// if (d->oe->pixelExact.contains(object)) {
-// foreach (QGraphicsItem *item, d->oe->pixelExact.values(object)) {
-// if (item->shape().contains(screenPosition)) {
-// contains = true;
-// break;
-// }
-// }
-// } else {
-// QGraphicsItem *item
-// = d->oe->graphicsItemFromMapObject(object);
-
-// if (item) {
-// QList<QTransform> trans = d->oe->pixelTrans.values(object);
-
-// foreach (QTransform t, trans) {
-// bool ok;
-// QTransform inv = t.inverted(&ok);
-// if (ok) {
-// QPointF testPt = screenPosition * inv;
-
-// // we have to special case text objects here
-// // in order to maintain their old (1.1) behaviour
-// QGeoMapTextObject *tobj = qobject_cast<QGeoMapTextObject*>(object);
-// if (tobj) {
-// if (item->boundingRect().contains(testPt)) {
-// contains = true;
-// break;
-// }
-// } else {
-// if (item->shape().contains(testPt)) {
-// contains = true;
-// break;
-// }
-// }
-// }
-// }
-// }
-// }
-
-// if (contains)
-// results << object;
-
-// considered.insert(object);
-// }
-// }
-
-// return results;
-}
-
-/*!
- \reimp
-*/
-QList<QGeoMapObject*> QGeoTiledMapData::mapObjectsInScreenRect(const QRectF &screenRect) const
-{
- QList<QGeoMapObject*> results;
- QSet<QGeoMapObject*> considered;
-
- Q_D(const QGeoTiledMapData);
-
- d->oe->updateTransforms();
-
- QList<QGraphicsItem*> pixelItems = d->oe->pixelScene->items(screenRect,
- Qt::IntersectsItemShape,
- Qt::AscendingOrder);
-
- foreach (QGraphicsItem *item, pixelItems) {
- QGeoMapObject *object = d->oe->pixelItems.value(item);
- Q_ASSERT(object);
-
- if (object->isVisible() && !considered.contains(object)) {
- bool contains = false;
-
- if (d->oe->pixelExact.contains(object)) {
- foreach (QGraphicsItem *item, d->oe->pixelExact.values(object))
- if (item->shape().intersects(screenRect))
- contains = true;
- } else {
- QGraphicsItem *item
- = d->oe->graphicsItemFromMapObject(object);
-
- if (item) {
- QList<QTransform> trans = d->oe->pixelTrans.values(object);
-
- foreach (QTransform t, trans) {
- bool ok;
- QTransform inv = t.inverted(&ok);
- if (ok) {
- QPolygonF testPoly = screenRect * inv;
-
- QPainterPath testPath;
- testPath.moveTo(testPoly[0]);
- testPath.lineTo(testPoly[1]);
- testPath.lineTo(testPoly[2]);
- testPath.lineTo(testPoly[3]);
- testPath.closeSubpath();
-
- if (item->shape().intersects(testPath))
- contains = true;
- }
- }
- }
- }
-
- if (contains)
- results << object;
-
- considered.insert(object);
- }
- }
-
- return results;
-}
-
-/*!
- Returns the center of the viewport, in pixels on the entire
- map as a pixmap at the maximum zoom level.
-*/
-QPoint QGeoTiledMapData::worldReferenceViewportCenter() const
-{
- Q_D(const QGeoTiledMapData);
- return d->worldReferenceViewportCenter;
-}
-
-/*!
- Returns the size, in pixels, of the entire map as a pixmap at the maximum
- zoom level.
-*/
-QSize QGeoTiledMapData::worldReferenceSize() const
-{
- Q_D(const QGeoTiledMapData);
- return d->worldReferenceSize;
-}
-
-/*!
- Returns the visible screen rectangle, in pixels on the entire map
- as a pixmap at the maximum zoom level.
-*/
-QRect QGeoTiledMapData::worldReferenceViewportRect() const
-{
- Q_D(const QGeoTiledMapData);
- return d->worldReferenceViewportRect;
-}
-
-/*!
- Returns the ratio between a single pixel on the screen and a pixel on
- the entire map as a pixmap at the maximum zoom level.
-*/
-int QGeoTiledMapData::zoomFactor() const
-{
- Q_D(const QGeoTiledMapData);
- return d->zoomFactor;
-}
-
-/*!
- Forces the map display to update in the region specified by \a target.
-
- If \a target is empty the entire map display will be updated.
-*/
-void QGeoTiledMapData::triggerUpdateMapDisplay(const QRectF &target)
-{
- emit updateMapDisplay(target);
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoTiledMapDataPrivate::QGeoTiledMapDataPrivate(QGeoTiledMapData *parent, QGeoMappingManagerEngine *engine)
- : QGeoMapDataPrivate(parent, engine),
- oe(new QGeoMapObjectEngine(parent, this)),
- zoomFactor(0),
- spherical(QLatin1String("+proj=latlon +ellps=sphere")),
- wgs84(QLatin1String("+proj=latlon +ellps=WGS84")) {}
-
-QGeoTiledMapDataPrivate::~QGeoTiledMapDataPrivate()
-{
- foreach(QGeoTiledMapReply * reply, replies) {
- reply->abort();
- reply->deleteLater();
- }
-
- if (oe)
- delete oe;
-}
-
-QPointF QGeoTiledMapDataPrivate::windowOffset() const
-{
- qreal offsetX = ((windowSize.width() * zoomFactor) - worldReferenceViewportRect.width()) / 2.0;
- if (offsetX < 0.0)
- offsetX = 0.0;
- offsetX /= zoomFactor;
-
- qreal offsetY = ((windowSize.height() * zoomFactor) - worldReferenceViewportRect.height()) / 2.0;
- if (offsetY < 0.0)
- offsetY = 0.0;
- offsetY /= zoomFactor;
-
- return QPointF(offsetX, offsetY);
-}
-
-void QGeoTiledMapDataPrivate::updateMapImage()
-{
- Q_Q(QGeoTiledMapData);
-
- if ((zoomLevel == -1.0) || !windowSize.isValid())
- return;
-
- bool wasEmpty = (requests.size() == 0);
- QGeoTileIterator it(this);
-
- while (it.hasNext()) {
- QGeoTiledMapRequest req = it.next();
- QRect tileRect = req.tileRect();
-
- if (!cache.contains(req)) {
- if (!requestRects.contains(tileRect) && !replyRects.contains(tileRect)) {
- requests.append(req);
- requestRects.insert(tileRect);
- }
- }
- }
-
-// qWarning()
-// << d->requests.size()
-// << d->cache.size()
-// << d->cache.totalCost()
-// << d->zoomCache.size()
-// << d->zoomCache.totalCost();
-
- if (wasEmpty && requests.size() > 0) {
- QTimer::singleShot(0, q, SLOT(processRequests()));
- }
-}
-
-void QGeoTiledMapDataPrivate::clearRequests()
-{
- requests.clear();
- requestRects.clear();
-}
-
-void QGeoTiledMapDataPrivate::paintMap(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/)
-{
- QPointF offset = windowOffset();
-
- QGeoTileIterator it(this);
-
- while (it.hasNext()) {
- QGeoTiledMapRequest req = it.next();
- QRect tileRect = req.tileRect();
-
- QList<QPair<QRect, QRect> > overlaps = intersectedScreen(tileRect);
- for (int i = 0; i < overlaps.size(); ++i) {
- QRect s = overlaps.at(i).first;
- QRect t = overlaps.at(i).second;
-
- QRectF source = QRectF(int(s.left()) / zoomFactor,
- int(s.top()) / zoomFactor,
- int(s.width()) / zoomFactor,
- int(s.height()) / zoomFactor);
- QRectF target = QRectF(offset.x() + int(t.left()) / zoomFactor,
- offset.y() + int(t.top()) / zoomFactor,
- int(t.width()) / zoomFactor,
- int(t.height()) / zoomFactor);
-
- if (cache.contains(req)) {
- //painter->drawPixmap(target, *cache.object(req), source);
- painter->drawImage(target, *cache.object(req), source);
- } else {
- if (zoomCache.contains(req)) {
- painter->drawPixmap(target, *zoomCache.object(req), source);
- } else {
- painter->fillRect(target, Qt::lightGray);
- }
- }
- }
- }
-}
-
-void QGeoTiledMapDataPrivate::paintObjects(QPainter *painter, const QStyleOptionGraphicsItem * option)
-{
- painter->save();
- painter->setRenderHint(QPainter::Antialiasing);
-
- QRectF target = option ? option->rect : QRectF(QPointF(0,0), windowSize);
-
- QPointF offset = windowOffset();
-
- target.adjust(offset.x(), offset.y(), -1.0 * offset.x(), -1.0 * offset.y());
-
- painter->setClipRect(target);
-
- oe->updateTransforms();
-
- QList<QGraphicsItem*> items = oe->pixelScene->items(target,
- Qt::IntersectsItemShape,
- Qt::AscendingOrder);
- QSet<QGeoMapObject*> objsDone;
-
- QTransform baseTrans = painter->transform();
-
- QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
-
- foreach (QGraphicsItem *item, items) {
- QGeoMapObject *object = oe->pixelItems.value(item);
- Q_ASSERT(object);
- if (object->isVisible() && !objsDone.contains(object)) {
- if (oe->pixelExact.contains(object)) {
- foreach (QGraphicsItem *it, oe->pixelExact.values(object)) {
- painter->setTransform(baseTrans);
-
-// QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
- it->paint(painter, style);
-// delete style;
- }
- } else {
- QGraphicsItem *item = oe->graphicsItemFromMapObject(object);
- if (item) {
- foreach (QTransform trans, oe->pixelTrans.values(object)) {
- painter->setTransform(trans * baseTrans);
-
-// QStyleOptionGraphicsItem *style = new QStyleOptionGraphicsItem;
- item->paint(painter, style);
- foreach (QGraphicsItem *child, item->children()) {
- painter->setTransform(child->transform() * trans * baseTrans);
- painter->translate(child->pos());
- child->paint(painter, style);
- }
-
-// delete style;
- }
- }
- }
- objsDone.insert(object);
- }
- }
-
- painter->restore();
-
- delete style;
-}
-
-void QGeoTiledMapDataPrivate::cleanupCaches()
-{
- int boundaryTiles = 3;
-
- QGeoTiledMappingManagerEngine *tiledEngine = static_cast<QGeoTiledMappingManagerEngine*>(engine);
-
- QSize tileSize = tiledEngine->tileSize();
-
- QRectF cacheRect1;
- QRectF cacheRect2;
-
- cacheRect1 = worldReferenceViewportRect.adjusted(-boundaryTiles * tileSize.width(),
- -boundaryTiles * tileSize.height(),
- boundaryTiles * tileSize.width(),
- boundaryTiles * tileSize.height());
-
- if (cacheRect1.width() > worldReferenceSize.width()) {
- cacheRect1.setX(0);
- cacheRect1.setWidth(worldReferenceSize.width());
- } else {
- if (cacheRect1.x() + cacheRect1.width() > worldReferenceSize.width()) {
- int oldWidth = cacheRect1.width();
- cacheRect1.setWidth(worldReferenceSize.width() - cacheRect1.x());
- cacheRect2 = QRectF(0,
- cacheRect1.y(),
- oldWidth - cacheRect1.width(),
- cacheRect1.height());
- }
- }
-
- QList<QGeoTiledMapRequest> keys = cache.keys();
- for (int i = 0; i < keys.size(); ++i) {
- QRectF tileRect = keys.at(i).tileRect();
- if (!cacheRect1.intersects(tileRect)) {
- if (cacheRect2.isNull() || !cacheRect2.intersects(tileRect)) {
- cache.remove(keys.at(i));
- }
- }
- }
-}
-
-QRect QGeoTiledMapDataPrivate::screenRectForZoomFactor(int factor)
-{
- qreal viewportWidth = q_ptr->windowSize().width();
- qreal viewportHeight = q_ptr->windowSize().height();
-
- int width = int(viewportWidth * factor);
- int height = int(viewportHeight * factor);
-
- if (width > worldReferenceSize.width())
- width = worldReferenceSize.width();
-
- if (height > worldReferenceSize.height())
- height = worldReferenceSize.height();
-
- int x = (worldReferenceViewportCenter.x() - (width / 2)) % worldReferenceSize.width();
- if (x < 0)
- x += worldReferenceSize.width();
-
- int y = worldReferenceViewportCenter.y() - (height / 2);
-
- if (y < 0)
- y = 0;
-
- if ((y + height) >= worldReferenceSize.height())
- y = worldReferenceSize.height() - height;
-
- return QRect(x, y, width, height);
-}
-
-void QGeoTiledMapDataPrivate::updateScreenRect()
-{
- worldReferenceViewportRect = screenRectForZoomFactor(zoomFactor);
-
- int x = worldReferenceViewportRect.x();
- int y = worldReferenceViewportRect.y();
- int width = worldReferenceViewportRect.width();
- int height = worldReferenceViewportRect.height();
-
- if (x + width < worldReferenceSize.width()) {
- worldReferenceViewportRectLeft = worldReferenceViewportRect;
- worldReferenceViewportRectRight = QRect();
- } else {
- int widthLeft = worldReferenceSize.width() - x;
- int widthRight = width - widthLeft;
- worldReferenceViewportRectLeft = QRect(x, y, widthLeft, height);
- worldReferenceViewportRectRight = QRect(0, y, widthRight, height);
- }
-}
-
-bool QGeoTiledMapDataPrivate::containedInScreen(const QPoint &point) const
-{
- return (worldReferenceViewportRectLeft.contains(point)
- || (worldReferenceViewportRectRight.isValid()
- && worldReferenceViewportRectRight.contains(point)));
-}
-
-bool QGeoTiledMapDataPrivate::intersectsScreen(const QRect &rect) const
-{
- return (worldReferenceViewportRectLeft.intersects(rect)
- || (worldReferenceViewportRectRight.isValid()
- && worldReferenceViewportRectRight.intersects(rect)));
-}
-
-QList<QPair<QRect, QRect> > QGeoTiledMapDataPrivate::intersectedScreen(const QRect &rect, bool translateToScreen) const
-{
- QList<QPair<QRect, QRect> > result;
-
- QRect rectL = rect.intersected(worldReferenceViewportRectLeft);
- if (!rectL.isEmpty()) {
- QRect source = QRect(rectL.topLeft() - rect.topLeft(), rectL.size());
- QRect target = QRect(rectL.topLeft() - worldReferenceViewportRectLeft.topLeft(), rectL.size());
- result << QPair<QRect, QRect>(source, target);
- }
-
- if (worldReferenceViewportRectRight.isValid()) {
- QRect rectR = rect.intersected(worldReferenceViewportRectRight);
- if (!rectR.isEmpty()) {
- QRect source = QRect(rectR.topLeft() - rect.topLeft(), rectR.size());
- QRect target = QRect(rectR.topLeft() - worldReferenceViewportRectRight.topLeft(), rectR.size());
- if (translateToScreen)
- target.translate(worldReferenceViewportRectLeft.width(), 0);
- result << QPair<QRect, QRect>(source, target);
- }
- }
-
- return result;
-}
-
-// Old version, for reference
-
-//void QGeoMapDataPrivate::addObject(QGeoMapObject *object)
-//{
-// containerObject->addChildObject(object);
-// oe->addObject(object);
-// emit q_ptr->updateMapDisplay();
-//}
-
-//void QGeoMapDataPrivate::removeObject(QGeoMapObject *object)
-//{
-// containerObject->removeChildObject(object);
-// oe->removeObject(object);
-//}
-
-void QGeoTiledMapDataPrivate::addObject(QGeoMapObject *object)
-{
-// containerObject->addChildObject(object);
-// oe->addObject(object);
-// emit q_ptr->updateMapDisplay();
-
- QGeoMapDataPrivate::addObject(object);
- oe->addObject(object);
-}
-
-void QGeoTiledMapDataPrivate::removeObject(QGeoMapObject *object)
-{
- QGeoMapDataPrivate::removeObject(object);
- oe->removeObject(object);
-}
-
-void QGeoTiledMapDataPrivate::update(QObject *object)
-{
- QGeoMapObject *obj = qobject_cast<QGeoMapObject*>(object);
- if (obj) {
- QGeoMapGroupObject *group = qobject_cast<QGeoMapGroupObject*>(obj);
- if (group) {
- oe->objectsForLatLonUpdate << group;
- oe->objectsForPixelUpdate << group;
- static_cast<QGeoTiledMapData*>(q_ptr)->triggerUpdateMapDisplay();
- } else {
- oe->invalidateObject(obj);
- }
- } else {
- static_cast<QGeoTiledMapData*>(q_ptr)->triggerUpdateMapDisplay();
- }
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoTileIterator::QGeoTileIterator(const QGeoTiledMapDataPrivate *mapDataPrivate)
- : atEnd(false),
- row(-1),
- col(-1),
- screenRect(mapDataPrivate->worldReferenceViewportRect),
- mapType(mapDataPrivate->mapType),
- connectivityMode(mapDataPrivate->connectivityMode),
- zoomLevel(mapDataPrivate->zoomLevel)
-{
- QGeoTiledMappingManagerEngine *tiledEngine
- = static_cast<QGeoTiledMappingManagerEngine*>(mapDataPrivate->engine);
- tileSize = tiledEngine->tileSize() * mapDataPrivate->zoomFactor;
- tileRect = QRect(QPoint(0, 0), tileSize);
-
- qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
- qulonglong y = static_cast<qulonglong>(screenRect.topLeft().y() / tileSize.height());
-
- width = tileSize.width() * (1 << zoomLevel);
-
- currTopLeft.setX(x * tileSize.width());
- currTopLeft.setY(y * tileSize.height());
-}
-
-QGeoTileIterator::QGeoTileIterator(QGraphicsGeoMap::ConnectivityMode connectivityMode,
- QGraphicsGeoMap::MapType mapType,
- const QRect &screenRect,
- const QSize &tileSize,
- int zoomLevel)
- : atEnd(false),
- row(-1),
- col(-1),
- screenRect(screenRect),
- tileSize(tileSize),
- mapType(mapType),
- connectivityMode(connectivityMode),
- zoomLevel(zoomLevel),
- tileRect(QPoint(0, 0), tileSize)
-{
- qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
- qulonglong y = static_cast<qulonglong>(screenRect.topLeft().y() / tileSize.height());
-
- width = tileSize.width() * (1 << zoomLevel);
-
- currTopLeft.setX(x * tileSize.width());
- currTopLeft.setY(y * tileSize.height());
-}
-
-bool QGeoTileIterator::hasNext()
-{
- return !atEnd;
-}
-
-QGeoTiledMapRequest QGeoTileIterator::next()
-{
- int numCols = 1 << zoomLevel;
- col = static_cast<int>(currTopLeft.x() / tileSize.width()) % numCols;
- row = static_cast<int>(currTopLeft.y() / tileSize.height()) % numCols;
- tileRect.moveTopLeft(currTopLeft);
- if (tileRect.left() >= width)
- tileRect.translate(-width, 0);
-
- currTopLeft.rx() += tileSize.width();
-
- if (currTopLeft.x() > screenRect.right()) { //next row
- qulonglong x = static_cast<qulonglong>(screenRect.topLeft().x() / tileSize.width());
- currTopLeft.setX(x * tileSize.width());
- currTopLeft.ry() += tileSize.height();
- }
-
- if (currTopLeft.y() > screenRect.bottom()) //done
- atEnd = true;
-
- return QGeoTiledMapRequest(connectivityMode, mapType, zoomLevel, row, col, tileRect);
-}
-
-#include "moc_qgeotiledmapdata.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapdata.h b/src/location/maps/tiled/qgeotiledmapdata.h
deleted file mode 100644
index 5926f085..00000000
--- a/src/location/maps/tiled/qgeotiledmapdata.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPDATA_H
-#define QGEOTILEDMAPDATA_H
-
-#include "qgeomapdata.h"
-#include "qgeotiledmapreply.h"
-
-#include <QRectF>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoTiledMapDataPrivate;
-
-class Q_LOCATION_EXPORT QGeoTiledMapData : public QGeoMapData
-{
- Q_OBJECT
-
-public:
- QGeoTiledMapData(QGeoMappingManagerEngine *engine);
- virtual ~QGeoTiledMapData();
-
- void setWindowSize(const QSizeF &size);
-
- void setZoomLevel(qreal zoomLevel);
-
- void pan(int dx, int dy);
-
- void setCenter(const QGeoCoordinate &center);
- QGeoCoordinate center() const;
-
- void setMapType(QGraphicsGeoMap::MapType mapType);
-
- void setConnectivityMode(QGraphicsGeoMap::ConnectivityMode connectivityMode);
-
- virtual QGeoBoundingBox viewport() const;
- virtual void fitInViewport(const QGeoBoundingBox &bounds, bool preserveViewportCenter = false);
-
- QList<QGeoMapObject*> mapObjectsAtScreenPosition(const QPointF &screenPosition) const;
- QList<QGeoMapObject*> mapObjectsInScreenRect(const QRectF &screenRect) const;
-
- QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
- QGeoCoordinate screenPositionToCoordinate(const QPointF &screenPosition) const;
-
- virtual QPoint coordinateToWorldReferencePosition(const QGeoCoordinate &coordinate) const;
- virtual QGeoCoordinate worldReferencePositionToCoordinate(const QPoint &pixel) const;
-
- QPoint worldReferenceViewportCenter() const;
- QSize worldReferenceSize() const;
- QRect worldReferenceViewportRect() const;
- int zoomFactor() const;
-
- void triggerUpdateMapDisplay(const QRectF &target = QRectF());
-
-protected:
- void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
- void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
-
- QGeoMapObjectInfo* createMapObjectInfo(QGeoMapObject *mapObject);
-
-private Q_SLOTS:
- void processRequests();
- void tileFinished();
- void replyFinished(QGeoTiledMapReply *reply);
- void tileError(QGeoTiledMapReply::Error error, QString errorString);
-
-private:
- Q_DECLARE_PRIVATE(QGeoTiledMapData)
- Q_DISABLE_COPY(QGeoTiledMapData)
- friend class QGeoTiledMappingManagerEngine;
- friend class QGeoTiledMapObjectInfo;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmapdata_p.h b/src/location/maps/tiled/qgeotiledmapdata_p.h
deleted file mode 100644
index 5df38012..00000000
--- a/src/location/maps/tiled/qgeotiledmapdata_p.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPDATA_P_H
-#define QGEOTILEDMAPDATA_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeomapdata_p.h"
-#include "qgeomapobject.h"
-#include "qgeomapobject_p.h"
-#include <private/projwrapper_p.h>
-
-#include <QRectF>
-#include <QHash>
-#include <QCache>
-#include <QPair>
-#include <QList>
-
-class QGraphicsScene;
-
-QT_BEGIN_NAMESPACE
-
-class QGeoTiledMapData;
-class QGeoTiledMapRequest;
-class QGeoTiledMapReply;
-class QGeoTiledMapObjectInfo;
-class QGeoMapObjectEngine;
-
-class QGeoTiledMapDataPrivate : public QGeoMapDataPrivate
-{
-public:
- QGeoTiledMapDataPrivate(QGeoTiledMapData *parent, QGeoMappingManagerEngine *engine);
- ~QGeoTiledMapDataPrivate();
-
- void updateMapImage();
- void clearRequests();
-
- QPointF windowOffset() const;
-
- void paintMap(QPainter *painter, const QStyleOptionGraphicsItem *option);
- void paintObjects(QPainter *painter, const QStyleOptionGraphicsItem *option);
-
- void cleanupCaches();
-
- bool intersects(QGeoMapObject *mapObject, const QRectF &rect);
-
- QRect screenRectForZoomFactor(int zoomFactor);
- void updateScreenRect();
-
- bool containedInScreen(const QPoint &point) const;
- bool intersectsScreen(const QRect &rect) const;
- QList<QPair<QRect, QRect> > intersectedScreen(const QRect &rect, bool translateToScreen = true) const;
-
- virtual QPoint screenPositionToWorldReferencePosition(const QPointF &screenPosition) const;
- virtual QPoint coordinateToWorldReferencePosition(double lon, double lat) const;
- virtual QPointF coordinateToScreenPosition(double lon, double lat) const;
-
- virtual void addObject(QGeoMapObject *object);
- virtual void removeObject(QGeoMapObject *object);
-
- virtual void update(QObject *object);
-
- QGeoMapObjectEngine *oe;
-
- int zoomFactor;
-
- QPoint worldReferenceViewportCenter;
- QSize worldReferenceSize;
- QRect worldReferenceViewportRect;
-
- QRect worldReferenceViewportRectLeft;
- QRect worldReferenceViewportRectRight;
-
- QSet<QRect> requestRects;
- QSet<QRect> replyRects;
-
- QList<QGeoTiledMapRequest> requests;
- QSet<QGeoTiledMapReply*> replies;
-
- QCache<QGeoTiledMapRequest, QImage> cache;
- QCache<QGeoTiledMapRequest, QPixmap> zoomCache;
-
- ProjCoordinateSystem spherical;
- ProjCoordinateSystem wgs84;
-
- Q_DECLARE_PUBLIC(QGeoTiledMapData)
-private:
- Q_DISABLE_COPY(QGeoTiledMapDataPrivate)
-};
-
-class QGeoTileIterator
-{
-public:
- QGeoTileIterator(const QGeoTiledMapDataPrivate *mapData);
- QGeoTileIterator(QGraphicsGeoMap::ConnectivityMode connectivityMode,
- QGraphicsGeoMap::MapType mapType,
- const QRect &screenRect,
- const QSize &tileSize,
- int zoomLevel);
-
- bool hasNext();
- QGeoTiledMapRequest next();
-
-private:
- bool atEnd;
- int row;
- int col;
- int width;
- QRect screenRect;
- QSize tileSize;
- QGraphicsGeoMap::MapType mapType;
- QGraphicsGeoMap::ConnectivityMode connectivityMode;
- int zoomLevel;
- QPoint currTopLeft;
- QRect tileRect;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp
deleted file mode 100644
index 0bac17f8..00000000
--- a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmapgroupobjectinfo_p.h"
-
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomapobject.h"
-#include "qgeomapgroupobject.h"
-
-#include "qgeomapobjectengine_p.h"
-
-#include <QGraphicsItem>
-#include <QGraphicsScene>
-#include <QGraphicsPathItem>
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapGroupObjectInfo::QGeoTiledMapGroupObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
-
- group = static_cast<QGeoMapGroupObject*>(mapObject);
-
- connect(group,
- SIGNAL(childAdded(QGeoMapObject*)),
- this,
- SLOT(childAdded(QGeoMapObject*)));
- connect(group,
- SIGNAL(childUpdated(QGeoMapObject*)),
- this,
- SLOT(childUpdated(QGeoMapObject*)));
- connect(group,
- SIGNAL(childRemoved(QGeoMapObject*)),
- this,
- SLOT(childRemoved(QGeoMapObject*)));
-
- pathItem = new QGraphicsPathItem();
- graphicsItem = pathItem;
- pathItem->setPos(0.0, 0.0);
-
- QList<QGeoMapObject*> objects = group->childObjects();
-
- foreach(QGeoMapObject * object, objects) {
- QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(object->info());
-
- if (info)
- info->graphicsItem->setParentItem(graphicsItem);
- }
-
- updateItem();
-}
-
-QGeoTiledMapGroupObjectInfo::~QGeoTiledMapGroupObjectInfo()
-{
-}
-
-void QGeoTiledMapGroupObjectInfo::childAdded(QGeoMapObject *childObject)
-{
- if (!childObject)
- return;
-
- QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(childObject->info());
- if (info && info->graphicsItem) {
- // the child's z value will get updated in QGeoTiledMapGroupObjectInfo::childUpdated
- // we do this in order to keep the same order of operations that we had previously
- childObject->disconnect(childObject, SIGNAL(zValueChanged(int)), info, SLOT(zValueChanged(int)));
- info->graphicsItem->setParentItem(graphicsItem);
- tiledMapDataPrivate->update(mapObject());
- //tiledMapDataPrivate->update(childObject);
- }
-}
-
-void QGeoTiledMapGroupObjectInfo::childUpdated(QGeoMapObject *childObject)
-{
- if (!childObject)
- return;
-
- QGeoTiledMapObjectInfo* info = static_cast<QGeoTiledMapObjectInfo*>(childObject->info());
- if (info && info->graphicsItem) {
- //info->graphicsItem->setParentItem(graphicsItem);
- tiledMapDataPrivate->update(mapObject());
- info->zValueChanged(childObject->zValue());
- }
-}
-
-void QGeoTiledMapGroupObjectInfo::childRemoved(QGeoMapObject *childObject)
-{
- if (childObject && tiledMapDataPrivate->oe) {
- tiledMapDataPrivate->oe->removeObject(childObject);
- updateItem();
- }
-}
-
-#include "moc_qgeotiledmapgroupobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h
deleted file mode 100644
index 7ea3de33..00000000
--- a/src/location/maps/tiled/qgeotiledmapgroupobjectinfo_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPGROUPOBJECT_INFO_P_H
-#define QGEOTILEDMAPGROUPOBJECT_INFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeotiledmapobjectinfo_p.h"
-
-QT_BEGIN_NAMESPACE
-class QGraphicsPathItem;
-
-class QGeoMapGroupObject;
-
-class QGeoTiledMapGroupObjectInfo : public QGeoTiledMapObjectInfo
-{
- Q_OBJECT
-public:
- QGeoTiledMapGroupObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapGroupObjectInfo();
-
- QGeoMapGroupObject *group;
- QGraphicsPathItem *pathItem;
-
-public slots:
- void childAdded(QGeoMapObject *childObject);
- void childUpdated(QGeoMapObject *childObject);
- void childRemoved(QGeoMapObject *childObject);
-};
-
-QT_END_NAMESPACE
-
-#endif //QGEOTILEDMAPGROUPOBJECT_INFO_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp
deleted file mode 100644
index 6b19d571..00000000
--- a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmapobjectinfo_p.h"
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-#include "qgeoboundingbox.h"
-#include "qgeomapobjectengine_p.h"
-
-#include <QGraphicsScene>
-
-#include <QPolygonF>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapObjectInfo::QGeoTiledMapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoMapObjectInfo(mapData, mapObject),
- inited(false),
- updateAfterInit(false),
- graphicsItem(0)
-{
- tiledMapData = mapData;
- tiledMapDataPrivate = static_cast<QGeoTiledMapDataPrivate*>(mapData->d_ptr);
-}
-
-QGeoTiledMapObjectInfo::~QGeoTiledMapObjectInfo()
-{
- if (graphicsItem) {
- delete graphicsItem;
- graphicsItem = 0;
- }
-}
-
-void QGeoTiledMapObjectInfo::init()
-{
- if (graphicsItem) {
- graphicsItem->setZValue(mapObject()->zValue());
- graphicsItem->setVisible(mapObject()->isVisible());
- //graphicsItem->setFlag(QGraphicsItem::ItemIsSelectable);
- }
- inited = true;
- if (updateAfterInit) {
- tiledMapData->updateMapDisplay();
- updateAfterInit = false;
- }
-}
-
-QGeoMapObject* QGeoTiledMapObjectInfo::mapObject() const
-{
- return QGeoMapObjectInfo::mapObject();
-}
-
-void QGeoTiledMapObjectInfo::zValueChanged(int zValue)
-{
- if (graphicsItem) {
- graphicsItem->setZValue(zValue);
- updateItem();
- if (tiledMapDataPrivate && tiledMapDataPrivate->oe)
- tiledMapDataPrivate->oe->rebuildScenes();
- }
-}
-
-void QGeoTiledMapObjectInfo::visibleChanged(bool visible)
-{
- if (graphicsItem) {
- graphicsItem->setVisible(visible);
- updateItem();
- }
-}
-
-void QGeoTiledMapObjectInfo::selectedChanged(bool /*selected*/)
-{
- // don't want to draw the selection box
-// if (graphicsItem) {
-// graphicsItem->setSelected(selected);
-// updateItem();
-// }
-}
-
-void QGeoTiledMapObjectInfo::originChanged(const QGeoCoordinate &/*origin*/)
-{
- if (graphicsItem)
- updateItem();
-}
-
-void QGeoTiledMapObjectInfo::unitsChanged(QGeoMapObject::CoordinateUnit /*units*/)
-{
- if (graphicsItem)
- updateItem();
-}
-
-void QGeoTiledMapObjectInfo::transformTypeChanged(QGeoMapObject::TransformType /*transformType*/)
-{
- if (graphicsItem)
- updateItem();
-}
-
-QGeoBoundingBox QGeoTiledMapObjectInfo::boundingBox() const
-{
- if (!graphicsItem || !tiledMapData)
- return QGeoBoundingBox();
-
- QGeoMapObjectEngine *e = tiledMapDataPrivate->oe;
-
- QGeoMapObject *object = mapObject();
-
- e->updateTransforms();
-
- if (e->latLonExact.contains(object)) {
- QList<QGraphicsItem*> items = e->latLonExact.values(object);
- QGeoBoundingBox box;
- foreach (QGraphicsItem *item, items) {
- QRectF latLonBounds = item->boundingRect();
- QPointF topLeft = latLonBounds.bottomLeft();
- if (topLeft.x() >= 180.0 * 3600.0)
- topLeft.setX(topLeft.x() - 360.0 * 3600.0);
- if (topLeft.x() < -180.0 * 3600.0)
- topLeft.setX(topLeft.x() + 360.0 * 3600.0);
-
- QPointF bottomRight = latLonBounds.topRight();
- if (bottomRight.x() >= 180.0 * 3600.0)
- bottomRight.setX(bottomRight.x() - 360.0 * 3600.0);
- if (bottomRight.x() < -180.0 * 3600.0)
- bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
-
- QGeoCoordinate tlc(topLeft.y() / 3600.0, topLeft.x() / 3600.0);
- QGeoCoordinate brc(bottomRight.y() / 3600.0, bottomRight.x() / 3600.0);
-
- return QGeoBoundingBox(tlc, brc);
-
- // it looks like the following is overkill
-// if (box.isValid()) {
-// box |= QGeoBoundingBox(tlc, brc);
-// } else {
-// box = QGeoBoundingBox(tlc, brc);
-// }
- }
- return box;
- } else {
- QTransform trans = e->latLonTrans.value(object);
-
- QRectF bounds = graphicsItem->boundingRect();
- QPolygonF poly = bounds * trans;
-
- QRectF latLonBounds = poly.boundingRect();
- QPointF topLeft = latLonBounds.bottomLeft();
- if (topLeft.x() >= 180.0 * 3600.0)
- topLeft.setX(topLeft.x() - 360.0 * 3600.0);
- if (topLeft.x() < -180.0 * 3600.0)
- topLeft.setX(topLeft.x() + 360.0 * 3600.0);
-
- QPointF bottomRight = latLonBounds.topRight();
- if (bottomRight.x() >= 180.0 * 3600.0)
- bottomRight.setX(bottomRight.x() - 360.0 * 3600.0);
- if (bottomRight.x() < -180.0 * 3600.0)
- bottomRight.setX(bottomRight.x() + 360.0 * 3600.0);
-
- QGeoCoordinate tlc(topLeft.y() / 3600.0, topLeft.x() / 3600.0);
- QGeoCoordinate brc(bottomRight.y() / 3600.0, bottomRight.x() / 3600.0);
-
- return QGeoBoundingBox(tlc, brc);
- }
-}
-
-bool QGeoTiledMapObjectInfo::contains(const QGeoCoordinate &coordinate) const
-{
- if (!graphicsItem || !tiledMapData)
- return false;
-
- QGeoMapObjectEngine *e = tiledMapDataPrivate->oe;
-
- e->updateTransforms();
- QPointF latLonPoint(coordinate.longitude()*3600.0, coordinate.latitude()*3600.0);
-
- QGeoMapObject *object = mapObject();
-
- if (e->latLonExact.contains(object)) {
- QList<QGraphicsItem*> items = e->latLonExact.values(object);
- foreach (QGraphicsItem *item, items) {
- if (item->contains(latLonPoint))
- return true;
- }
- } else {
- QList<QTransform> transList = e->latLonTrans.values(object);
- foreach (QTransform trans, transList) {
- bool ok;
- QTransform inv = trans.inverted(&ok);
- if (!ok)
- continue;
-
- QPointF localPoint = latLonPoint * inv;
-
- if (graphicsItem->contains(localPoint))
- return true;
- }
- }
-
- return false;
-}
-
-void QGeoTiledMapObjectInfo::updateItem(const QRectF& target)
-{
- if (!inited) {
- updateAfterInit = true;
- return;
- }
-
- QGeoMapObject *object = mapObject();
- if (object)
- tiledMapDataPrivate->update(object);
- if (graphicsItem)
- tiledMapData->triggerUpdateMapDisplay(target);
-}
-
-#include "moc_qgeotiledmapobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h
deleted file mode 100644
index ea1fb559..00000000
--- a/src/location/maps/tiled/qgeotiledmapobjectinfo_p.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPOBJECT_INFO_P_H
-#define QGEOTILEDMAPOBJECT_INFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeomapobject_p.h"
-
-#include <QRectF>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsItem;
-class QRect;
-class QPolygonF;
-
-class QGeoTiledMapData;
-class QGeoBoundingBox;
-class QGeoCoordinate;
-class QGeoTiledMapDataPrivate;
-
-class QGeoTiledMapObjectInfo : public QGeoMapObjectInfo
-{
- Q_OBJECT
-public:
- QGeoTiledMapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapObjectInfo();
-
- virtual void init();
-
- QGeoMapObject* mapObject() const;
-
- QGeoBoundingBox boundingBox() const;
- bool contains(const QGeoCoordinate &coordinate) const;
-
- void updateItem(const QRectF &target = QRectF());
-
- bool inited;
- bool updateAfterInit;
-
- QGraphicsItem *graphicsItem;
- QGeoTiledMapData *tiledMapData;
-
-public slots:
- virtual void zValueChanged(int zValue);
- virtual void visibleChanged(bool visible);
- virtual void selectedChanged(bool selected);
-
- virtual void originChanged(const QGeoCoordinate &origin);
- virtual void unitsChanged(QGeoMapObject::CoordinateUnit units);
- virtual void transformTypeChanged(QGeoMapObject::TransformType transformType);
-
-protected:
- QGeoTiledMapDataPrivate *tiledMapDataPrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif //QGEOTILEDMAPOBJECT_INFO_P_H
-
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp b/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp
deleted file mode 100644
index aedff2b6..00000000
--- a/src/location/maps/tiled/qgeotiledmappingmanagerengine.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmappingmanagerengine.h"
-#include "qgeotiledmappingmanagerengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoTiledMappingManagerEngine
-
- \brief The QGeoTiledMappingManagerEngine class is provided to make writing
- Qt Maps and Navigation API plugins for tiled based mapping services easier.
-
- \inmodule QtLocation
-
- \ingroup maps-impl-tiled
-
- \since 1.2
-
- Subclasses of QGeoTiledMappingManagerEngine need to provide an implementation
- of getTileImage().
-
- It is important that the function setTileSize() is called before
- getTileImage() to ensure that the tile is dealt with correctly after it is
- fetched. If setTileSize() is not calle dfirst the behaviour is undefined.
-
- A subclass of QGeoTiledMappingManagerEngine will often make use of a subclass
- fo QGeoTiledMapReply internally, in order to add any engine-specific
- data (such as a QNetworkReply object for network-based services) to the
- QGeoTiledMapReply instances used by the engine.
-
- QGeoTiledMappingManagerEngine will report that custom map objects are supported
- by default.
-*/
-
-/*!
- Constructs a new tiled mapping manager using the parameters \a parameters
- and the parent \a parent.
-*/
-QGeoTiledMappingManagerEngine::QGeoTiledMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent)
- : QGeoMappingManagerEngine(new QGeoTiledMappingManagerEnginePrivate(), parent)
-{
- Q_UNUSED(parameters)
- setSupportsCustomMapObjects(true);
-}
-
-/*!
- Destroys this tiled mapping manager.
-*/
-QGeoTiledMappingManagerEngine::~QGeoTiledMappingManagerEngine()
-{
- // deleted in superclass destructor
-}
-
-/*
- Requests the map tiled specified by \a request.
-
- A QGeoTiledMapReply object will be returned, which can be used to manage the
- fetching of the tile and to return the tile data.
-
- This manager and the returned QGeoTiledMapReply object will emit signals
- indicating if the operation completes or if errors occur.
-
- Once the operation has completed, QGeoTiledMapReply::mapImageData() and
- QGeoTiledMapReply::mapImageFormat() can be used to generate the tile image.
-
- The user is responsible for deleting the returned reply object, although
- this can be done in the slot connected to QGeoTiledMappingManagerEngine::finished(),
- QGeoTiledMappingManagerEngine::error(), QGeoTiledMapReply::finished() or
- QGeoTiledMapReply::error() with deleteLater().
-*/
-
-/*!
-\fn virtual QGeoTiledMapReply* QGeoTiledMappingManagerEngine::getTileImage(const QGeoTiledMapRequest &request)
- Requests the map tiled specified by \a request.
-
- A QGeoTiledMapReply object will be returned, which can be used to manage the
- fetching of the tile and to return the tile data.
-
- The returned QGeoTiledMapReply object will emit signals
- indicating if the operation completes or if errors occur.
-
- Once the operation has completed, QGeoTiledMapReply::mapImageData() and
- QGeoTiledMapReply::mapImageFormat() can be used to generate the tile image.
-
- The user is responsible for deleting the returned reply object, although
- this can be done in the slot connected to QGeoTiledMapReply::finished() or
- QGeoTiledMapReply::error() with deleteLater().
-
-*/
-
-/*!
- Returns a new QGeoMapData instance which will be managed by
- this manager.
-
- A QGeoMapData instance contains and manages the information about
- what a map widget is looking at. A single manager can be used by several
- QGraphcisGeoMap instances since each instance has an associated QGeoMapData instance.
-
- The QGeoMapData instance can be treated as a kind of session object, or
- as a model in a model-view-controller architecture, with QGraphicsGeoMap
- as the view and QGeoMappingManagerEngine as the controller.
-
- The instance returned by the default implementation will be a
- QGeoTiledMapData instance. Subclasses of QGeoTiledMappingManagerEngine are
- free to override this function to return subclasses of QGeoTiledMapData in
- order to customize the map.
-*/
-QGeoMapData* QGeoTiledMappingManagerEngine::createMapData()
-{
- return new QGeoTiledMapData(this);
-}
-
-/*!
- Returns the size of the tiles returned by this tiled mapping manager.
-*/
-QSize QGeoTiledMappingManagerEngine::tileSize() const
-{
- Q_D(const QGeoTiledMappingManagerEngine);
- return d->tileSize;
-}
-
-/*!
- Sets the size of the tiles returned by this tiled mapping manager to \a
- tileSize.
-
- Subclasses of QGeoTiledMappingManagerEngine should use this function to
- ensure tileSize() provides accurate information.
-*/
-void QGeoTiledMappingManagerEngine::setTileSize(const QSize &tileSize)
-{
- Q_D(QGeoTiledMappingManagerEngine);
- d->tileSize = tileSize;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoTiledMappingManagerEnginePrivate::QGeoTiledMappingManagerEnginePrivate()
- : QGeoMappingManagerEnginePrivate() {}
-
-QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate() {}
-
-/*******************************************************************************
-*******************************************************************************/
-
-#include "moc_qgeotiledmappingmanagerengine.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine.h b/src/location/maps/tiled/qgeotiledmappingmanagerengine.h
deleted file mode 100644
index 975fd02a..00000000
--- a/src/location/maps/tiled/qgeotiledmappingmanagerengine.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPPINGMANAGERENGINE_H
-#define QGEOTILEDMAPPINGMANAGERENGINE_H
-
-#include "qgeomappingmanagerengine.h"
-
-#include "qgeotiledmapreply.h"
-#include "qgeotiledmaprequest.h"
-#include "qgeotiledmapdata.h"
-
-#include <QMap>
-#include <QVariant>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoTiledMappingManagerEnginePrivate;
-
-class Q_LOCATION_EXPORT QGeoTiledMappingManagerEngine : public QGeoMappingManagerEngine
-{
- Q_OBJECT
-public:
- virtual ~QGeoTiledMappingManagerEngine();
-
- virtual QGeoTiledMapReply* getTileImage(const QGeoTiledMapRequest &request) = 0;
-
- virtual QGeoMapData* createMapData();
-
- QSize tileSize() const;
-
-protected:
- QGeoTiledMappingManagerEngine(const QMap<QString, QVariant> &parameters, QObject *parent = 0);
- void setTileSize(const QSize &tileSize);
-
-private:
- Q_DECLARE_PRIVATE(QGeoTiledMappingManagerEngine)
- Q_DISABLE_COPY(QGeoTiledMappingManagerEngine)
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QGeoTiledMapReply::Error))
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h b/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h
deleted file mode 100644
index 580346f9..00000000
--- a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
-#define QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeoboundingbox.h"
-
-#include <QPixmap>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsPixmapItem;
-class QGeoMapPixmapObject;
-
-class QGeoTiledMapPixmapObjectInfo : public QGeoTiledMapObjectInfo
-{
- Q_OBJECT
-public:
- QGeoTiledMapPixmapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapPixmapObjectInfo();
-
- QGeoMapPixmapObject* pixmap;
- QGraphicsPixmapItem *pixmapItem;
-
-public slots:
- void pixmapChanged(const QPixmap &pixmap);
- void offsetChanged(const QPoint &offset);
-};
-
-QT_END_NAMESPACE
-
-#endif //QGEOTILEDMAPPIXMAPOBJECT_INFO_P_H
-
diff --git a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp
deleted file mode 100644
index 9e5928bd..00000000
--- a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmappolygonobjectinfo_p.h"
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomappolygonobject.h"
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapPolygonObjectInfo::QGeoTiledMapPolygonObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- polygon = static_cast<QGeoMapPolygonObject*>(mapObject);
-
- connect(polygon,
- SIGNAL(pathChanged(QList<QGeoCoordinate>)),
- this,
- SLOT(pathChanged(QList<QGeoCoordinate>)));
- connect(polygon,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
- connect(polygon,
- SIGNAL(brushChanged(QBrush)),
- this,
- SLOT(brushChanged(QBrush)));
-
- polygonItem = new QGraphicsPolygonItem();
- graphicsItem = polygonItem;
-
- penChanged(polygon->pen());
- brushChanged(polygon->brush());
- pathChanged(polygon->path());
-}
-
-QGeoTiledMapPolygonObjectInfo::~QGeoTiledMapPolygonObjectInfo() {}
-
-void QGeoTiledMapPolygonObjectInfo::pathChanged(const QList<QGeoCoordinate> &/*path*/)
-{
- genPoly();
- updateItem();
-}
-
-void QGeoTiledMapPolygonObjectInfo::penChanged(const QPen &/*pen*/)
-{
- polygonItem->setPen(polygon->pen());
- updateItem();
-}
-
-void QGeoTiledMapPolygonObjectInfo::brushChanged(const QBrush &/*brush*/)
-{
- polygonItem->setBrush(polygon->brush());
- updateItem();
-}
-
-void QGeoTiledMapPolygonObjectInfo::genPoly()
-{
- QPolygonF poly;
-
- QList<QGeoCoordinate> path = polygon->path();
-
- if (path.size() > 0) {
- QGeoCoordinate origin = path.at(0);
- double ox = origin.longitude() * 3600.0;
- double oy = origin.latitude() * 3600.0;
-
- double oldx = ox;
-
- poly << QPointF(0,0);
- for (int i = 0; i < path.size(); ++i) {
- QGeoCoordinate pt = path.at(i);
- double x = pt.longitude() * 3600.0;
- double y = pt.latitude() * 3600.0;
-
- if (qAbs(x - oldx) > 180.0 * 3600.0) {
- if (x > oldx) {
- x -= 360.0 * 3600.0;
- } else if (x < oldx) {
- x += 360.0 * 3600.0;
- }
- }
-
- poly << QPointF(x - ox, y - oy);
-
- oldx = x;
- }
- }
-
- polygonItem->setPolygon(poly);
-}
-
-#include "moc_qgeotiledmappolygonobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp
deleted file mode 100644
index 472d032b..00000000
--- a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmappolylineobjectinfo_p.h"
-//#include "makepoly_p.h"
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomappolylineobject.h"
-
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapPolylineObjectInfo::QGeoTiledMapPolylineObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- polyline = static_cast<QGeoMapPolylineObject*>(mapObject);
-
- connect(polyline,
- SIGNAL(pathChanged(QList<QGeoCoordinate>)),
- this,
- SLOT(pathChanged(QList<QGeoCoordinate>)));
- connect(polyline,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
-
- pathItem = new QGraphicsPathItem();
- graphicsItem = pathItem;
-
- penChanged(polyline->pen());
- pathChanged(polyline->path());
-}
-
-QGeoTiledMapPolylineObjectInfo::~QGeoTiledMapPolylineObjectInfo() {}
-
-void QGeoTiledMapPolylineObjectInfo::pathChanged(const QList<QGeoCoordinate> &/*path*/)
-{
- genPath();
- updateItem();
-}
-
-void QGeoTiledMapPolylineObjectInfo::penChanged(const QPen &/*pen*/)
-{
- pathItem->setPen(polyline->pen());
- updateItem();
-}
-
-void QGeoTiledMapPolylineObjectInfo::genPath()
-{
- QPainterPath p;
-
- QList<QGeoCoordinate> path = polyline->path();
-
- if (path.size() > 0) {
- QGeoCoordinate origin = path.at(0);
- double ox = origin.longitude() * 3600.0;
- double oy = origin.latitude() * 3600.0;
-
- double oldx = ox;
-
- p.moveTo(0, 0);
- for (int i = 1; i < path.size(); ++i) {
- QGeoCoordinate pt = path.at(i);
- double x = pt.longitude() * 3600.0;
- double y = pt.latitude() * 3600.0;
-
- if (qAbs(x - oldx) > 180.0 * 3600.0) {
- if (x > oldx) {
- x -= 360.0 * 3600.0;
- } else if (x < oldx) {
- x += 360.0 * 3600.0;
- }
- }
-
- p.lineTo(x - ox, y - oy);
-
- oldx = x;
- }
- }
-
- pathItem->setPath(p);
-}
-
-#include "moc_qgeotiledmappolylineobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp
deleted file mode 100644
index 7f20bab4..00000000
--- a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmaprectangleobjectinfo_p.h"
-
-#include <QGraphicsPolygonItem>
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeoboundingbox.h"
-
-#include "qgeomaprectangleobject.h"
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapRectangleObjectInfo::QGeoTiledMapRectangleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- rectangle = static_cast<QGeoMapRectangleObject*>(mapObject);
-
- connect(rectangle,
- SIGNAL(topLeftChanged(QGeoCoordinate)),
- this,
- SLOT(topLeftChanged(QGeoCoordinate)));
- connect(rectangle,
- SIGNAL(bottomRightChanged(QGeoCoordinate)),
- this,
- SLOT(bottomRightChanged(QGeoCoordinate)));
- connect(rectangle,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
- connect(rectangle,
- SIGNAL(brushChanged(QBrush)),
- this,
- SLOT(brushChanged(QBrush)));
-
- polygonItem = new QGraphicsPolygonItem();
- graphicsItem = polygonItem;
-
- topLeftChanged(rectangle->topLeft());
- bottomRightChanged(rectangle->bottomRight());
- penChanged(rectangle->pen());
- brushChanged(rectangle->brush());
-}
-
-QGeoTiledMapRectangleObjectInfo::~QGeoTiledMapRectangleObjectInfo() {}
-
-void QGeoTiledMapRectangleObjectInfo::topLeftChanged(const QGeoCoordinate &/*topLeft*/)
-{
- regenPolygon();
- updateItem();
-}
-
-void QGeoTiledMapRectangleObjectInfo::bottomRightChanged(const QGeoCoordinate &/*bottomRight*/)
-{
- regenPolygon();
- updateItem();
-}
-
-void QGeoTiledMapRectangleObjectInfo::penChanged(const QPen &/*pen*/)
-{
- polygonItem->setPen(rectangle->pen());
- updateItem();
-}
-
-void QGeoTiledMapRectangleObjectInfo::brushChanged(const QBrush &/*brush*/)
-{
- polygonItem->setBrush(rectangle->brush());
- updateItem();
-}
-
-void QGeoTiledMapRectangleObjectInfo::regenPolygon()
-{
- QPolygonF poly;
-
- if (!rectangle->bounds().isValid())
- return;
-
- const QGeoCoordinate tl = rectangle->bounds().topLeft();
- if (!tl.isValid())
- return;
-
- const QGeoCoordinate br = rectangle->bounds().bottomRight();
- if (!br.isValid())
- return;
-
- double left = tl.longitude() * 3600.0;
- double right = br.longitude() * 3600.0;
- double top = tl.latitude() * 3600.0;
- double bottom = br.latitude() * 3600.0;
-
- if (left > right)
- right += 360.0 * 3600.0;
-
- poly << QPointF(left, top);
- poly << QPointF(right, top);
- poly << QPointF(right, bottom);
- poly << QPointF(left, bottom);
-
- polygonItem->setPolygon(poly);
-}
-
-#include "moc_qgeotiledmaprectangleobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
-
diff --git a/src/location/maps/tiled/qgeotiledmaprequest.cpp b/src/location/maps/tiled/qgeotiledmaprequest.cpp
deleted file mode 100644
index cad5a7f2..00000000
--- a/src/location/maps/tiled/qgeotiledmaprequest.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmaprequest.h"
-#include "qgeotiledmaprequest_p.h"
-
-#include "qgeotiledmapdata.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoTiledMapRequest
- \brief The QGeoTiledMapRequest class represents a request for a map tile
- from a tile-based mapping service.
-
- \inmodule QtLocation
-
- \ingroup maps-impl-tiled
-
- \since 1.2
-
- The tile is specified by a map type, a zoom level, a row and a column.
-
- At a zoom level of z the world is represented as a 2^z by 2^z grid
- of tiles, and the row and column are relative to the grid of tiles
- for the zoom level of the request.
-*/
-
-/*!
- Constructs a new tiled map request.
-*/
-QGeoTiledMapRequest::QGeoTiledMapRequest()
- : d_ptr(new QGeoTiledMapRequestPrivate()) {}
-
-/*!
- Constructs a new tiled map request.
-
- At a zoom level of z the world is represented as a 2^z by 2^z grid
- of tiles.
-
- This tiled map request represents a request for the tile at row \a row and
- column \a column at zoom level \a zoomLevel and type
- \a mapType.
-
- The request will use connectivity mode \a connectivityMode when
- accessing the map data.
-
- The rectangle that the tile occupies on the map at the maximum zoom level
- is also given as \a tileRect.
-*/
-QGeoTiledMapRequest::QGeoTiledMapRequest(QGraphicsGeoMap::ConnectivityMode connectivityMode,
- QGraphicsGeoMap::MapType mapType,
- qreal zoomLevel,
- int row,
- int column,
- const QRect &tileRect)
- : d_ptr(new QGeoTiledMapRequestPrivate())
-{
- //d_ptr->mapData = mapData;
- d_ptr->row = row;
- d_ptr->column = column;
- d_ptr->tileRect = tileRect;
-
- d_ptr->zoomLevel = zoomLevel;
- d_ptr->mapType = mapType;
- d_ptr->connectivityMode = connectivityMode;
-}
-
-/*!
- Constructs a tiled map request from the contents of \a other.
-*/
-QGeoTiledMapRequest::QGeoTiledMapRequest(const QGeoTiledMapRequest &other)
- : d_ptr(other.d_ptr) {}
-
-/*!
- Destroys this tiled map request.
-*/
-QGeoTiledMapRequest::~QGeoTiledMapRequest() {}
-
-/*!
- Assigns \a other to this tiled map request and then returns a reference to
- this tiled map request.
-*/
-QGeoTiledMapRequest& QGeoTiledMapRequest::operator= (const QGeoTiledMapRequest & other)
-{
- d_ptr = other.d_ptr;
-
- return *this;
-}
-
-/*!
- Returns with this tiled map request is equal to \a other.
-*/
-bool QGeoTiledMapRequest::operator== (const QGeoTiledMapRequest &other) const
-{
- return (d_ptr->row == other.d_ptr->row) &&
- (d_ptr->column == other.d_ptr->column) &&
- (d_ptr->zoomLevel == other.d_ptr->zoomLevel) &&
- (d_ptr->mapType == other.d_ptr->mapType) &&
- (d_ptr->connectivityMode == other.d_ptr->connectivityMode);
-}
-
-/*
- Returns the QGeoMapData instance associated with this request.
-*/
-//QGeoTiledMapData* QGeoTiledMapRequest::mapData() const
-//{
-// return d_ptr->mapData;
-//}
-
-/*!
- Returns the connectivity mode of the tile request.
-*/
-QGraphicsGeoMap::ConnectivityMode QGeoTiledMapRequest::connectivityMode() const
-{
- return d_ptr->connectivityMode;
-}
-
-/*!
- Returns the map type of the requested tile.
-*/
-QGraphicsGeoMap::MapType QGeoTiledMapRequest::mapType() const
-{
- return d_ptr->mapType;
-}
-
-/*!
- Returns the zoom level of the requested tile.
-
- The lower and upper bounds of the zoom level are set by
- the QGeoMappingManager that created this request.
-*/
-int QGeoTiledMapRequest::zoomLevel() const
-{
- return d_ptr->zoomLevel;
-}
-
-/*!
- Returns the row of the requested tile.
-
- At a zoom level of z the world is represented as a 2^z by 2^z grid
- of tiles, and so the row will be between 0 and 2^z - 1.
-*/
-int QGeoTiledMapRequest::row() const
-{
- return d_ptr->row;
-}
-
-/*!
- Returns the column of the requested tile.
-
- At a zoom level of z the world is represented as a 2^z by 2^z grid
- of tiles, and so the column will be between 0 and 2^z - 1.
-*/
-int QGeoTiledMapRequest::column() const
-{
- return d_ptr->column;
-}
-
-/*!
- Returns the rectangle that the tile covers on the map at the maximum zoon
- level.
-
- At a zoom level of z the world is represented as a 2^z by 2^z grid of
- tiles. If m is the maximum zoom level and the tiles are t by t pixel
- squares, then the entire world could be viewed as a 2^m * t by 2^m * t
- pixel image.
-
- The rectangle returned is specified relative to the pixel coordinates of
- the map at the maximum zoom level.
-*/
-QRect QGeoTiledMapRequest::tileRect() const
-{
- return d_ptr->tileRect;
-}
-
-/*!
- Returns a hash of the tiled map request \a key.
-*/
-uint qHash(const QGeoTiledMapRequest &key)
-{
- uint result = QT_PREPEND_NAMESPACE(qHash)(key.row() * 13);
- result += QT_PREPEND_NAMESPACE(qHash)(key.column() * 17);
- result += QT_PREPEND_NAMESPACE(qHash)(key.zoomLevel() * 19);
- result += QT_PREPEND_NAMESPACE(qHash)(static_cast<int>(key.mapType()));
- return result;
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate()
- : QSharedData(),
- connectivityMode(QGraphicsGeoMap::NoConnectivity),
- mapType(QGraphicsGeoMap::NoMap),
- zoomLevel(0),
- row(0),
- column(0),
- tileRect(QRect()) {}
-//mapData(0) {}
-
-QGeoTiledMapRequestPrivate::QGeoTiledMapRequestPrivate(const QGeoTiledMapRequestPrivate &other)
- : QSharedData(other),
-// mapData(other.mapData),
- connectivityMode(other.connectivityMode),
- mapType(other.mapType),
- zoomLevel(other.zoomLevel),
- row(other.row),
- column(other.column),
- tileRect(other.tileRect) {}
-
-QGeoTiledMapRequestPrivate::~QGeoTiledMapRequestPrivate() {}
-
-QGeoTiledMapRequestPrivate& QGeoTiledMapRequestPrivate::operator= (const QGeoTiledMapRequestPrivate & other)
-{
-// mapData = other.mapData;
- connectivityMode = other.connectivityMode;
- mapType = other.mapType;
- zoomLevel = other.zoomLevel;
- row = other.row;
- column = other.column;
- tileRect = other.tileRect;
-
- return *this;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/qgeotiledmaprequest.h b/src/location/maps/tiled/qgeotiledmaprequest.h
deleted file mode 100644
index bf00f4fb..00000000
--- a/src/location/maps/tiled/qgeotiledmaprequest.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPREQUEST_H
-#define QGEOTILEDMAPREQUEST_H
-
-#include "qgraphicsgeomap.h"
-
-#include <QRect>
-#include <QExplicitlySharedDataPointer>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoTiledMapData;
-class QGeoTiledMapRequestPrivate;
-
-class Q_LOCATION_EXPORT QGeoTiledMapRequest
-{
-public:
- QGeoTiledMapRequest();
- QGeoTiledMapRequest(QGraphicsGeoMap::ConnectivityMode connectivityMode,
- QGraphicsGeoMap::MapType mapType,
- qreal zoomLevel,
- int row,
- int column,
- const QRect &tileRect);
- QGeoTiledMapRequest(const QGeoTiledMapRequest &other);
- ~QGeoTiledMapRequest();
-
- QGeoTiledMapRequest& operator= (const QGeoTiledMapRequest &other);
-
- bool operator== (const QGeoTiledMapRequest &other) const;
-
- //QGeoTiledMapData *mapData() const;
-
- QGraphicsGeoMap::ConnectivityMode connectivityMode() const;
- QGraphicsGeoMap::MapType mapType() const;
- int zoomLevel() const;
-
- int row() const;
- int column() const;
- QRect tileRect() const;
-
-private:
- QExplicitlySharedDataPointer<QGeoTiledMapRequestPrivate> d_ptr;
-};
-
-Q_LOCATION_EXPORT uint qHash(const QGeoTiledMapRequest &key);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmaprequest_p.h b/src/location/maps/tiled/qgeotiledmaprequest_p.h
deleted file mode 100644
index 5c0a474a..00000000
--- a/src/location/maps/tiled/qgeotiledmaprequest_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOTILEDMAPREQUEST_P_H
-#define QGEOTILEDMAPREQUEST_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicsgeomap.h"
-
-#include <QSharedData>
-
-QT_BEGIN_NAMESPACE
-
-//class QGeoTiledMapData;
-
-class QGeoTiledMapRequestPrivate : public QSharedData
-{
-public:
- QGeoTiledMapRequestPrivate();
- QGeoTiledMapRequestPrivate(const QGeoTiledMapRequestPrivate &other);
- ~QGeoTiledMapRequestPrivate();
-
- QGeoTiledMapRequestPrivate& operator= (const QGeoTiledMapRequestPrivate &other);
-
- //QGeoTiledMapData *mapData;
- QGraphicsGeoMap::ConnectivityMode connectivityMode;
- QGraphicsGeoMap::MapType mapType;
- int zoomLevel;
- int row;
- int column;
- QRect tileRect;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp
deleted file mode 100644
index 4b14647f..00000000
--- a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmaprouteobjectinfo_p.h"
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomaprouteobject.h"
-
-#include "qgeoroutesegment.h"
-
-#include <QPointF>
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapRouteObjectInfo::QGeoTiledMapRouteObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- route = static_cast<QGeoMapRouteObject*>(mapObject);
-
- connect(route,
- SIGNAL(routeChanged(QGeoRoute)),
- this,
- SLOT(routeChanged(QGeoRoute)));
- connect(route,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
- connect(route,
- SIGNAL(detailLevelChanged(quint32)),
- this,
- SLOT(detailLevelChanged(quint32)));
-
- pathItem = new QGraphicsPathItem();
- graphicsItem = pathItem;
-
- routeChanged(route->route());
- penChanged(route->pen());
- routeChanged(route->route());
-}
-
-QGeoTiledMapRouteObjectInfo::~QGeoTiledMapRouteObjectInfo() {}
-
-void QGeoTiledMapRouteObjectInfo::routeChanged(const QGeoRoute &/*route*/)
-{
- regenPath();
- updateItem();
-}
-
-void QGeoTiledMapRouteObjectInfo::penChanged(const QPen &/*pen*/)
-{
- pathItem->setPen(route->pen());
- updateItem();
-}
-
-void QGeoTiledMapRouteObjectInfo::detailLevelChanged(quint32 /*detailLevel*/)
-{
- updateItem();
-}
-
-void QGeoTiledMapRouteObjectInfo::regenPath()
-{
- QList<QGeoCoordinate> path;
-
- QGeoRouteSegment segment = route->route().firstRouteSegment();
- while (segment.isValid()) {
- path.append(segment.path());
- segment = segment.nextRouteSegment();
- }
-
- QPainterPath pth;
-
- if (path.size() > 0) {
- double oldx = 0.0;
-
- for (int i = 0; i < path.size(); ++i) {
- double x = path.at(i).longitude() * 3600.0;
- double y = path.at(i).latitude() * 3600.0;
- if (i == 0) {
- pth.moveTo(x, y);
- } else {
- if (qAbs(x - oldx) > 180.0 * 3600.0) {
- if (x > oldx) {
- x -= 360.0 * 3600.0;
- } else if (x < oldx) {
- x += 360.0 * 3600.0;
- }
- }
-
- pth.lineTo(x, y);
- }
-
- oldx = x;
- }
- }
-
- pathItem->setPath(pth);
-}
-
-#include "moc_qgeotiledmaprouteobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp b/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp
deleted file mode 100644
index 576eff82..00000000
--- a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeotiledmaptextobjectinfo_p.h"
-
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomaptextobject.h"
-
-#include <QFontMetrics>
-
-QT_BEGIN_NAMESPACE
-
-QGeoTiledMapTextObjectInfo::QGeoTiledMapTextObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- text = static_cast<QGeoMapTextObject*>(mapObject);
-
- connect(text,
- SIGNAL(textChanged(QString)),
- this,
- SLOT(textChanged(QString)));
- connect(text,
- SIGNAL(fontChanged(QFont)),
- this,
- SLOT(fontChanged(QFont)));
- connect(text,
- SIGNAL(penChanged(QPen)),
- this,
- SLOT(penChanged(QPen)));
- connect(text,
- SIGNAL(brushChanged(QBrush)),
- this,
- SLOT(brushChanged(QBrush)));
- connect(text,
- SIGNAL(offsetChanged(QPoint)),
- this,
- SLOT(offsetChanged(QPoint)));
- connect(text,
- SIGNAL(alignmentChanged(Qt::Alignment)),
- this,
- SLOT(alignmentChanged(Qt::Alignment)));
-
- textItem = new QGraphicsSimpleTextItem();
- graphicsItem = textItem;
-
- penChanged(text->pen());
- brushChanged(text->brush());
- originChanged(text->origin());
- fontChanged(text->font());
- textChanged(text->text());
-}
-
-QGeoTiledMapTextObjectInfo::~QGeoTiledMapTextObjectInfo() {}
-
-void QGeoTiledMapTextObjectInfo::textChanged(const QString &/*text*/)
-{
- textItem->setText(text->text());
- doAlignment();
- updateItem();
-}
-
-void QGeoTiledMapTextObjectInfo::fontChanged(const QFont &/*font*/)
-{
- textItem->setFont(text->font());
- doAlignment();
- updateItem();
-}
-
-void QGeoTiledMapTextObjectInfo::offsetChanged(const QPoint &/*offset*/)
-{
- doAlignment();
- updateItem();
-}
-
-void QGeoTiledMapTextObjectInfo::alignmentChanged(Qt::Alignment /*alignment*/)
-{
- doAlignment();
- updateItem();
-}
-
-void QGeoTiledMapTextObjectInfo::penChanged(const QPen &/*pen*/)
-{
- textItem->setPen(text->pen());
- doAlignment();
- updateItem();
-}
-
-void QGeoTiledMapTextObjectInfo::brushChanged(const QBrush &/*brush*/)
-{
- if (textItem) {
- textItem->setBrush(text->brush());
- doAlignment();
- updateItem();
- }
-}
-
-void QGeoTiledMapTextObjectInfo::doAlignment()
-{
- Qt::Alignment align = text->alignment();
- QTransform trans;
- textItem->setTransform(trans);
-
- QRectF rect = textItem->boundingRect();
- QPointF center = rect.center();
-
- if (align & Qt::AlignVCenter) {
- trans.translate(0, -1 * center.y());
- } else if (align & Qt::AlignTop) {
- trans.translate(0, -1 * rect.top());
- } else if (align & Qt::AlignBottom) {
- trans.translate(0, -1 * rect.bottom());
- }
- if (align & Qt::AlignHCenter) {
- trans.translate(-1 * center.x(), 0);
- } else if (align & Qt::AlignLeft) {
- trans.translate(-1 * rect.left(), 0);
- } else if (align & Qt::AlignRight) {
- trans.translate(-1 * rect.right(), 0);
- }
-
- QPoint offset = text->offset();
- trans.translate(offset.x(), offset.y());
- textItem->setTransform(trans);
-}
-
-#include "moc_qgeotiledmaptextobjectinfo_p.cpp"
-
-QT_END_NAMESPACE
-
diff --git a/src/location/maps/tiled/tiled.pri b/src/location/maps/tiled/tiled.pri
deleted file mode 100644
index c6a2c108..00000000
--- a/src/location/maps/tiled/tiled.pri
+++ /dev/null
@@ -1,40 +0,0 @@
-
-INCLUDEPATH += maps/tiled
-
-PUBLIC_HEADERS += \
- maps/tiled/qgeotiledmapdata.h \
- maps/tiled/qgeotiledmappingmanagerengine.h \
- maps/tiled/qgeotiledmapreply.h \
- maps/tiled/qgeotiledmaprequest.h
-
-PRIVATE_HEADERS += \
- maps/tiled/qgeotiledmapdata_p.h \
- maps/tiled/qgeotiledmapobjectinfo_p.h \
- maps/tiled/qgeotiledmapcircleobjectinfo_p.h \
- maps/tiled/qgeotiledmapcustomobjectinfo_p.h \
- maps/tiled/qgeotiledmapgroupobjectinfo_p.h \
- maps/tiled/qgeotiledmappixmapobjectinfo_p.h \
- maps/tiled/qgeotiledmappolygonobjectinfo_p.h \
- maps/tiled/qgeotiledmappolylineobjectinfo_p.h \
- maps/tiled/qgeotiledmaprectangleobjectinfo_p.h \
- maps/tiled/qgeotiledmaprouteobjectinfo_p.h \
- maps/tiled/qgeotiledmaptextobjectinfo_p.h \
- maps/tiled/qgeotiledmappingmanagerengine_p.h \
- maps/tiled/qgeotiledmapreply_p.h \
- maps/tiled/qgeotiledmaprequest_p.h
-
-SOURCES += \
- maps/tiled/qgeotiledmapdata.cpp \
- maps/tiled/qgeotiledmapobjectinfo_p.cpp \
- maps/tiled/qgeotiledmapcircleobjectinfo_p.cpp \
- maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp \
- maps/tiled/qgeotiledmapgroupobjectinfo_p.cpp \
- maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp \
- maps/tiled/qgeotiledmappolygonobjectinfo_p.cpp \
- maps/tiled/qgeotiledmappolylineobjectinfo_p.cpp \
- maps/tiled/qgeotiledmaprectangleobjectinfo_p.cpp \
- maps/tiled/qgeotiledmaprouteobjectinfo_p.cpp \
- maps/tiled/qgeotiledmaptextobjectinfo_p.cpp \
- maps/tiled/qgeotiledmappingmanagerengine.cpp \
- maps/tiled/qgeotiledmapreply.cpp \
- maps/tiled/qgeotiledmaprequest.cpp
diff --git a/src/location/mapsgl/cameradata.cpp b/src/location/mapsgl/cameradata.cpp
new file mode 100644
index 00000000..4d522b68
--- /dev/null
+++ b/src/location/mapsgl/cameradata.cpp
@@ -0,0 +1,290 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "cameradata.h"
+
+#include "projection_p.h"
+
+#include <QVariant>
+#include <QVariantAnimation>
+
+#include <QMetaType>
+
+#include <QWeakPointer>
+
+#include <cmath>
+
+
+class CameraDataPrivate : public QSharedData
+{
+public:
+ CameraDataPrivate();
+ CameraDataPrivate(const CameraDataPrivate &rhs);
+
+ CameraDataPrivate& operator = (const CameraDataPrivate &rhs);
+
+ bool operator == (const CameraDataPrivate &rhs) const;
+
+ QGeoCoordinate center_;
+ double distance_;
+ double bearing_;
+ double tilt_;
+ double roll_;
+ double aspectRatio_;
+ int zoomLevel_;
+ double zoomFactor_;
+
+ QWeakPointer<Projection> projection_;
+};
+
+CameraDataPrivate::CameraDataPrivate()
+ : QSharedData(),
+ center_(-27.5, 153),
+ distance_(0.02),
+ bearing_(0.0),
+ tilt_(0.0),
+ roll_(0.0),
+ aspectRatio_(1.0),
+ zoomLevel_(9) {}
+
+CameraDataPrivate::CameraDataPrivate(const CameraDataPrivate &rhs)
+ : QSharedData(rhs),
+ center_(rhs.center_),
+ distance_(rhs.distance_),
+ bearing_(rhs.bearing_),
+ tilt_(rhs.tilt_),
+ roll_(rhs.roll_),
+ aspectRatio_(rhs.aspectRatio_),
+ zoomLevel_(rhs.zoomLevel_),
+ zoomFactor_(rhs.zoomFactor_),
+ projection_(rhs.projection_) {}
+
+CameraDataPrivate& CameraDataPrivate::operator = (const CameraDataPrivate &rhs)
+{
+ center_ = rhs.center_;
+ distance_ = rhs.distance_;
+ bearing_ = rhs.bearing_;
+ tilt_ = rhs.tilt_;
+ roll_ = rhs.roll_;
+ aspectRatio_ = rhs.aspectRatio_;
+ zoomLevel_ = rhs.zoomLevel_;
+ zoomFactor_ = rhs.zoomFactor_;
+ QSharedPointer<Projection> p = rhs.projection_.toStrongRef();
+ if (p)
+ projection_ = p.toWeakRef();
+ else
+ projection_.clear();
+
+ return *this;
+}
+
+bool CameraDataPrivate::operator == (const CameraDataPrivate &rhs) const
+{
+ return ((center_ == rhs.center_)
+ && (distance_ == rhs.distance_)
+ && (bearing_ == rhs.bearing_)
+ && (tilt_ == rhs.tilt_)
+ && (roll_ == rhs.roll_)
+ && (aspectRatio_ == rhs.aspectRatio_)
+ && (zoomLevel_ == rhs.zoomLevel_)
+ && (zoomFactor_ == rhs.zoomFactor_));
+}
+
+QVariant cameraInterpolator(const CameraData &start,
+ const CameraData &end,
+ qreal progress)
+{
+ CameraData result = start;
+
+
+ QSharedPointer<Projection> p = start.projection();
+ if (!p)
+ p = end.projection();
+
+ if (!p)
+ result.setCenter(start.center());
+ else
+ result.setCenter(p->interpolate(start.center(), end.center(), progress));
+
+ double sf = 1.0 - progress;
+ double ef = progress;
+
+ result.setBearing(sf * start.bearing() + ef * end.bearing());
+ result.setTilt(sf * start.tilt() + ef * end.tilt());
+ result.setRoll(sf * start.roll() + ef * end.roll());
+ result.setZoomFactor(sf * start.zoomFactor() + ef * end.zoomFactor());
+
+ return QVariant::fromValue(result);
+}
+
+CameraData::CameraData()
+ : d(new CameraDataPrivate())
+{
+ qRegisterMetaType<CameraData>();
+ qRegisterAnimationInterpolator<CameraData>(cameraInterpolator);
+ setZoomFactor(4.0);
+}
+
+CameraData::CameraData(const CameraData &other)
+ : d(other.d) {}
+
+CameraData::~CameraData()
+{
+}
+
+CameraData& CameraData::operator = (const CameraData &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool CameraData::operator == (const CameraData &rhs) const
+{
+ return (*(d.constData()) == *(rhs.d.constData()));
+}
+
+bool CameraData::operator != (const CameraData &other) const
+{
+ return !(operator==(other));
+}
+
+void CameraData::setCenter(const QGeoCoordinate &center)
+{
+ d->center_ = center;
+}
+
+QGeoCoordinate CameraData::center() const
+{
+ return d->center_;
+}
+
+void CameraData::setBearing(double bearing)
+{
+ d->bearing_ = bearing;
+}
+
+double CameraData::bearing() const
+{
+ return d->bearing_;
+}
+
+void CameraData::setTilt(double tilt)
+{
+ d->tilt_ = tilt;
+}
+
+double CameraData::tilt() const
+{
+ return d->tilt_;
+}
+
+void CameraData::setRoll(double roll)
+{
+ d->roll_ = roll;
+}
+
+double CameraData::roll() const
+{
+ return d->roll_;
+}
+
+void CameraData::setAspectRatio(double aspectRatio)
+{
+ d->aspectRatio_ = aspectRatio;
+}
+
+double CameraData::aspectRatio() const
+{
+ return d->aspectRatio_;
+}
+
+/*
+ Distance and zoomLevel are only writeable for debugging purposes.
+ The setters will eventually go away and then zoomFactor will be
+ the way to set these.
+*/
+
+void CameraData::setDistance(double distance)
+{
+ d->zoomFactor_ = -1.0 * log(distance) / log(2.0);
+ d->distance_ = distance;
+}
+
+double CameraData::distance() const
+{
+ return d->distance_;
+}
+
+void CameraData::setZoomLevel(int zoomLevel)
+{
+ d->zoomLevel_ = zoomLevel;
+}
+
+int CameraData::zoomLevel() const
+{
+ return d->zoomLevel_;
+}
+
+void CameraData::setZoomFactor(double zoomFactor)
+{
+ d->zoomLevel_ = floor(zoomFactor);
+// qDebug() << __FUNCTION__ << zoomFactor << d->zoomLevel_;
+
+ // FIXME this will need some tuning
+
+ d->distance_ = 1.0 / pow(2.0, zoomFactor);
+
+ d->zoomFactor_ = zoomFactor;
+}
+
+double CameraData::zoomFactor() const
+{
+ return d->zoomFactor_;
+}
+
+void CameraData::setProjection(QSharedPointer<Projection> projection)
+{
+ d->projection_ = projection.toWeakRef();
+}
+
+QSharedPointer<Projection> CameraData::projection() const
+{
+ return d->projection_.toStrongRef();
+}
diff --git a/src/location/maps/qgeomapcustomobject.h b/src/location/mapsgl/cameradata.h
index a79e5b89..27bcd550 100644
--- a/src/location/maps/qgeomapcustomobject.h
+++ b/src/location/mapsgl/cameradata.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,57 +38,68 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef CAMERADATA_H
+#define CAMERADATA_H
-#ifndef QGEOMAPCUSTOMOBJECT_H
-#define QGEOMAPCUSTOMOBJECT_H
+#include "qmobilityglobal.h"
-#include "qgeomapobject.h"
#include "qgeocoordinate.h"
-#include <QPoint>
+#include <QMetaType>
-#include <QGraphicsItem>
+#include <QSharedPointer>
+#include <QSharedDataPointer>
QT_BEGIN_NAMESPACE
-class QGeoMapCustomObjectPrivate;
+class Projection;
+class CameraDataPrivate;
-class Q_LOCATION_EXPORT QGeoMapCustomObject : public QGeoMapObject
+class Q_LOCATION_EXPORT CameraData
{
- Q_OBJECT
- Q_PROPERTY(QGraphicsItem* graphicsItem READ graphicsItem WRITE setGraphicsItem NOTIFY graphicsItemChanged)
- Q_PROPERTY(QPoint offset READ offset WRITE setOffset NOTIFY offsetChanged)
-
public:
- QGeoMapCustomObject();
- QGeoMapCustomObject(const QGeoCoordinate &coordinate, const QPoint &offset = QPoint(0, 0));
- ~QGeoMapCustomObject();
+ CameraData();
+ CameraData(const CameraData &other);
+ ~CameraData();
+
+ CameraData& operator = (const CameraData &other);
+
+ bool operator == (const CameraData &other) const;
+ bool operator != (const CameraData &other) const;
+
+ void setCenter(const QGeoCoordinate &coordinate);
+ QGeoCoordinate center() const;
- QGeoMapObject::Type type() const;
+ void setBearing(double bearing);
+ double bearing() const;
- void update();
+ void setTilt(double tilt);
+ double tilt() const;
- QGraphicsItem* graphicsItem() const;
- void setGraphicsItem(QGraphicsItem *graphicsItem);
+ void setRoll(double roll);
+ double roll() const;
- QPoint offset() const;
- void setOffset(const QPoint &offset);
+ void setAspectRatio(double aspectRatio);
+ double aspectRatio() const;
- void setOrigin(const QGeoCoordinate &origin);
- void setUnits(const CoordinateUnit &unit);
- void setTransformType(const TransformType &type);
+ void setDistance(double distance);
+ double distance() const;
-Q_SIGNALS:
- void triggerUpdate();
- void graphicsItemChanged(QGraphicsItem *graphicsItem);
- void offsetChanged(const QPoint &offset);
+ void setZoomLevel(int zoomLevel);
+ int zoomLevel() const;
+
+ void setZoomFactor(double zoomFactor);
+ double zoomFactor() const;
+
+ void setProjection(QSharedPointer<Projection> projection);
+ QSharedPointer<Projection> projection() const;
private:
- QGeoMapCustomObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapCustomObject)
- Q_DISABLE_COPY(QGeoMapCustomObject)
+ QSharedDataPointer<CameraDataPrivate> d;
};
+Q_DECLARE_METATYPE(CameraData)
+
QT_END_NAMESPACE
-#endif
+#endif // CAMERADATA_H
diff --git a/src/location/mapsgl/frustum.cpp b/src/location/mapsgl/frustum.cpp
new file mode 100644
index 00000000..2b4bd27d
--- /dev/null
+++ b/src/location/mapsgl/frustum.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "frustum_p.h"
+
+#include "viewportcamera_p.h"
+
+#include <Qt3D/qglcamera.h>
+
+#include <cmath>
+
+Frustum::Frustum() {}
+
+void Frustum::update(const QGLCamera *camera, double aspectRatio, bool updatePlanes)
+{
+ if (aspectRatio > 1.0) {
+ double fov = atan2(camera->viewSize().height() , (2 * camera->nearPlane()));
+
+ hn_ = 2 * tan(fov) * camera->nearPlane();
+ wn_ = hn_ * aspectRatio;
+
+ hf_ = 2 * tan(fov) * camera->farPlane();
+ wf_ = hf_ * aspectRatio;
+ } else {
+ double fov = atan2(camera->viewSize().width() , (2 * camera->nearPlane()));
+
+ wn_ = 2 * tan(fov) * camera->nearPlane();
+ hn_ = wn_ / aspectRatio;
+
+ wf_ = 2 * tan(fov) * camera->farPlane();
+ hf_ = wf_ / aspectRatio;
+ }
+
+ QVector3D p = camera->eye();
+ QVector3D d = camera->center() - camera->eye();
+ d.normalize();
+
+ QVector3D up = camera->upVector();
+ up.normalize();
+
+ QVector3D right = QVector3D::normal(d, up);
+
+ cf_ = p + d * camera->farPlane();
+ tlf_ = cf_ + (up * hf_ / 2) - (right * wf_ / 2);
+ trf_ = cf_ + (up * hf_ / 2) + (right * wf_ / 2);
+ blf_ = cf_ - (up * hf_ / 2) - (right * wf_ / 2);
+ brf_ = cf_ - (up * hf_ / 2) + (right * wf_ / 2);
+
+ cn_ = p + d * camera->nearPlane();
+ tln_ = cn_ + (up * hn_ / 2) - (right * wn_ / 2);
+ trn_ = cn_ + (up * hn_ / 2) + (right * wn_ / 2);
+ bln_ = cn_ - (up * hn_ / 2) - (right * wn_ / 2);
+ brn_ = cn_ - (up * hn_ / 2) + (right * wn_ / 2);
+
+ if (!updatePlanes)
+ return;
+
+ QPlane3D pn = QPlane3D(bln_, tln_, brn_);
+ pn.setNormal(pn.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Near), pn);
+
+ QPlane3D pf = QPlane3D(blf_, brf_, tlf_);
+ pf.setNormal(pf.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Far), pf);
+
+ QPlane3D pl = QPlane3D(blf_, tlf_, bln_);
+ pl.setNormal(pl.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Left), pl);
+
+ QPlane3D pr = QPlane3D(brf_, brn_, trf_);
+ pr.setNormal(pr.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Right), pr);
+
+ QPlane3D pt = QPlane3D(tlf_, trf_, tln_);
+ pt.setNormal(pt.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Top), pt);
+
+ QPlane3D pb = QPlane3D(blf_, bln_, brf_);
+ pb.setNormal(pb.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Bottom), pb);
+}
+
+void Frustum::update(const ViewportCamera &camera)
+{
+ if (camera.aspectRatio() > 1.0) {
+ double fov = atan2(camera.viewSize().height() , (2 * camera.nearPlane()));
+
+ hn_ = 2 * tan(fov) * camera.nearPlane();
+ wn_ = hn_ * camera.aspectRatio();
+
+ hf_ = 2 * tan(fov) * camera.farPlane();
+ wf_ = hf_ * camera.aspectRatio();
+ } else {
+ double fov = atan2(camera.viewSize().width() , (2 * camera.nearPlane()));
+
+ wn_ = 2 * tan(fov) * camera.nearPlane();
+ hn_ = wn_ / camera.aspectRatio();
+
+ wf_ = 2 * tan(fov) * camera.farPlane();
+ hf_ = wf_ / camera.aspectRatio();
+ }
+
+ QVector3D p = camera.eye();
+ QVector3D d = camera.center() - camera.eye();
+ d.normalize();
+
+ QVector3D up = camera.up();
+ up.normalize();
+
+ QVector3D right = QVector3D::normal(d, up);
+
+ cf_ = p + d * camera.farPlane();
+ tlf_ = cf_ + (up * hf_ / 2) - (right * wf_ / 2);
+ trf_ = cf_ + (up * hf_ / 2) + (right * wf_ / 2);
+ blf_ = cf_ - (up * hf_ / 2) - (right * wf_ / 2);
+ brf_ = cf_ - (up * hf_ / 2) + (right * wf_ / 2);
+
+ cn_ = p + d * camera.nearPlane();
+ tln_ = cn_ + (up * hn_ / 2) - (right * wn_ / 2);
+ trn_ = cn_ + (up * hn_ / 2) + (right * wn_ / 2);
+ bln_ = cn_ - (up * hn_ / 2) - (right * wn_ / 2);
+ brn_ = cn_ - (up * hn_ / 2) + (right * wn_ / 2);
+
+ QPlane3D pn = QPlane3D(bln_, tln_, brn_);
+ pn.setNormal(pn.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Near), pn);
+
+ QPlane3D pf = QPlane3D(blf_, brf_, tlf_);
+ pf.setNormal(pf.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Far), pf);
+
+ QPlane3D pl = QPlane3D(blf_, tlf_, bln_);
+ pl.setNormal(pl.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Left), pl);
+
+ QPlane3D pr = QPlane3D(brf_, brn_, trf_);
+ pr.setNormal(pr.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Right), pr);
+
+ QPlane3D pt = QPlane3D(tlf_, trf_, tln_);
+ pt.setNormal(pt.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Top), pt);
+
+ QPlane3D pb = QPlane3D(blf_, bln_, brf_);
+ pb.setNormal(pb.normal().normalized());
+ planeHash_.insert(Frustum::Planes(Frustum::Bottom), pb);
+}
+
+bool Frustum::contains(const QVector3D &center, double radius) const
+{
+ if (planeHash_.isEmpty())
+ return false;
+
+ QHash<Frustum::Planes, QPlane3D>::const_iterator i = planeHash_.constBegin();
+ QHash<Frustum::Planes, QPlane3D>::const_iterator end = planeHash_.constEnd();
+
+ while (i != end) {
+ if (i.value().distanceTo(center) < -1.0 * radius)
+ return false;
+ ++i;
+ }
+
+ return true;
+}
+
+QPlane3D Frustum::plane(Planes planes) const
+{
+ return planeHash_.value(planes);
+}
diff --git a/src/location/mapsgl/frustum_p.h b/src/location/mapsgl/frustum_p.h
new file mode 100644
index 00000000..5341c360
--- /dev/null
+++ b/src/location/mapsgl/frustum_p.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TILEFRUSTUM_H
+#define TILEFRUSTUM_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmobilityglobal.h"
+
+#include <QVector3D>
+#include <QHash>
+
+#include <Qt3D/qplane3d.h>
+
+class ViewportCamera;
+
+class QGLCamera;
+
+class Q_AUTOTEST_EXPORT Frustum
+{
+public:
+ enum Plane {
+ Near = 0x001,
+ Far = 0x002,
+ Right = 0x004,
+ Left = 0x008,
+ Top = 0x010,
+ Bottom = 0x020,
+ TopLeftNear = Top | Left | Near,
+ TopLeftFar = Top | Left | Far,
+ TopRightNear = Top | Right | Near,
+ TopRightFar = Top | Right | Far,
+ BottomLeftNear = Bottom | Left | Near,
+ BottomLeftFar = Bottom | Left | Far,
+ BottomRightNear = Bottom | Right | Near,
+ BottomRightFar = Bottom | Right | Far
+ };
+
+ Q_DECLARE_FLAGS(Planes, Plane)
+
+ Frustum();
+
+ void update(const ViewportCamera &camera);
+
+ void update(const QGLCamera *camera, double aspectRatio, bool updatePlanes = false);
+
+ bool contains(const QVector3D &center, double radius) const;
+
+ QVector3D topLeftNear() const {
+ return tln_;
+ }
+ QVector3D topLeftFar() const {
+ return tlf_;
+ }
+ QVector3D bottomLeftNear() const {
+ return bln_;
+ }
+ QVector3D bottomLeftFar() const {
+ return blf_;
+ }
+ QVector3D topRightNear() const {
+ return trn_;
+ }
+ QVector3D topRightFar() const {
+ return trf_;
+ }
+ QVector3D bottomRightNear() const {
+ return brn_;
+ }
+ QVector3D bottomRightFar() const {
+ return brf_;
+ }
+
+ QPlane3D plane(Planes planes) const;
+
+private:
+ double hf_;
+ double wf_;
+ QVector3D cf_;
+ QVector3D tlf_;
+ QVector3D trf_;
+ QVector3D blf_;
+ QVector3D brf_;
+
+ double hn_;
+ double wn_;
+ QVector3D cn_;
+ QVector3D tln_;
+ QVector3D trn_;
+ QVector3D bln_;
+ QVector3D brn_;
+
+ QHash<Planes, QPlane3D> planeHash_;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(Frustum::Planes)
+
+#endif // TILEFRUSTUM_H
diff --git a/src/location/mapsgl/map.cpp b/src/location/mapsgl/map.cpp
new file mode 100644
index 00000000..a61bcead
--- /dev/null
+++ b/src/location/mapsgl/map.cpp
@@ -0,0 +1,402 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "map.h"
+#include "map_p.h"
+#include "map2d_p.h"
+#include "map3d_p.h"
+
+#include "tilecache.h"
+#include "mapsphere_p.h"
+#include "projection_p.h"
+#include "tile.h"
+#include "mapitem.h"
+
+#include <QMutex>
+#include <QMap>
+
+#include <qglscenenode.h>
+#include <qgeometrydata.h>
+#include <qglbuilder.h>
+#include <Qt3D/qglpainter.h>
+#include <Qt3D/qglcamera.h>
+
+#include <cmath>
+
+Map::Map(TileCache *cache, QObject *parent)
+ : QObject(parent),
+ autoUpdate_(true)
+{
+// d_ptr = new Map3DPrivate(this, cache, 20000.0);
+
+ // edge is 2^max zoom * 4
+ d_ptr = new Map2DPrivate(this, cache, 20, 256);
+}
+
+Map::~Map()
+{
+ delete d_ptr;
+}
+
+void Map::setMappingManager(QGeoMappingManager *manager)
+{
+ d_ptr->setMappingManager(manager);
+}
+
+void Map::paintGL(QGLPainter *painter)
+{
+ d_ptr->paintGL(painter);
+}
+
+QGLCamera* Map::glCamera() const
+{
+ return d_ptr->glCamera();
+}
+
+void Map::resize(int width, int height)
+{
+ d_ptr->resize(width, height);
+}
+
+void Map::setAutoUpdate(bool autoUpdate)
+{
+ autoUpdate_ = autoUpdate;
+}
+
+bool Map::autoUpdate() const
+{
+ return autoUpdate_;
+}
+
+void Map::clearCache()
+{
+// sphere_->clearCache();
+}
+
+void Map::setCameraData(const CameraData &cameraData)
+{
+ if (cameraData == d_ptr->cameraData())
+ return;
+
+ d_ptr->setCameraData(cameraData);
+
+ if (autoUpdate_)
+ update();
+
+ emit cameraDataChanged(d_ptr->cameraData());
+}
+
+CameraData Map::cameraData() const
+{
+ return d_ptr->cameraData();
+}
+
+void Map::update()
+{
+ d_ptr->update();
+ emit updateRequired();
+}
+
+int Map::numMapItems() const
+{
+ return d_ptr->numMapItems();
+}
+
+MapItem* Map::mapItem(int index) const
+{
+ return d_ptr->mapItem(index);
+}
+
+QList<MapItem*> Map::mapItems() const
+{
+ return d_ptr->mapItems();
+}
+
+void Map::addMapItem(MapItem *item)
+{
+ d_ptr->addMapItem(item);
+}
+
+void Map::removeMapItem(MapItem *item)
+{
+ d_ptr->removeMapItem(item);
+}
+
+void Map::clearMapItems()
+{
+ d_ptr->clearMapItems();
+}
+
+QGeoCoordinate Map::screenPositionToCoordinate(const QPointF &pos) const
+{
+ return d_ptr->screenPositionToCoordinate(pos);
+}
+
+QPointF Map::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+{
+ return d_ptr->coordinateToScreenPosition(coordinate);
+}
+
+//------------------------------------------------------------//
+
+MapPrivate::MapPrivate(Map *parent, TileCache *cache)
+ : manager_(0)
+{
+ sphere_ = new MapSphere(parent, this, cache);
+ mapSceneNode_ = new QGLSceneNode();
+ mapSceneNode_->addNode(sphere_->sphereSceneNode());
+ objectSceneNode_ = new QGLSceneNode();
+ glCamera_ = new QGLCamera();
+}
+
+MapPrivate::~MapPrivate()
+{
+ delete sphere_;
+ delete mapSceneNode_;
+ delete objectSceneNode_;
+ delete glCamera_;
+ // TODO map items are not deallocated!
+ // However: how to ensure this is done in rendering thread?
+}
+
+void MapPrivate::setMappingManager(QGeoMappingManager *manager)
+{
+ manager_ = manager;
+ sphere_->setMappingManager(manager_);
+}
+
+QGeoMappingManager* MapPrivate::manager() const
+{
+ return manager_;
+}
+
+QGLCamera* MapPrivate::glCamera() const
+{
+ return glCamera_;
+}
+
+void MapPrivate::setProjection(const QSharedPointer<Projection> &projection)
+{
+ projection_ = projection;
+}
+
+QSharedPointer<Projection> MapPrivate::projection() const
+{
+ return projection_;
+}
+
+void MapPrivate::setCameraData(const CameraData &cameraData)
+{
+ cameraData_ = cameraData;
+ cameraData_.setAspectRatio(aspectRatio_);
+ cameraData_.setProjection(projection_.toWeakRef());
+ updateGlCamera(glCamera_);
+ updateFrustum(frustum_);
+ visibleTiles_ = updateVisibleTiles();
+ sphere_->update(visibleTiles_);
+}
+
+CameraData MapPrivate::cameraData() const
+{
+ return cameraData_;
+}
+
+void MapPrivate::update()
+{
+ sphere_->update(visibleTiles_);
+}
+
+void MapPrivate::resize(int width, int height)
+{
+ width_ = width;
+ height_ = height;
+ aspectRatio_ = 1.0 * width_ / height_;
+ setCameraData(cameraData_);
+}
+
+Frustum MapPrivate::frustum() const
+{
+ return frustum_;
+}
+
+void MapPrivate::paintGL(QGLPainter *painter)
+{
+ if (!sphere_->updateMutex.tryLock()) {
+ qDebug() << "map will miss a frame, no mutex acquired!------";
+ return;
+ }
+
+ sphere_->GLContextAvailable();
+ GLContextAvailable();
+
+ mapSceneNode_->draw(painter);
+
+ glDisable(GL_DEPTH_TEST);
+ objectSceneNode_->draw(painter);
+ glEnable(GL_DEPTH_TEST);
+
+ sphere_->updateMutex.unlock();
+}
+
+int MapPrivate::numMapItems() const
+{
+ return mapItems_.length();
+}
+
+MapItem* MapPrivate::mapItem(int index) const
+{
+ return mapItems_.at(index);
+}
+
+QList<MapItem*> MapPrivate::mapItems() const
+{
+ return mapItems_;
+}
+
+void MapPrivate::addMapItem(MapItem *item)
+{
+ // TODO bit hard block - on declarative side the coordinate may well be invalid time to time
+ if (!item->coordinate().isValid())
+ return;
+ sphere_->updateMutex.lock();
+ updateMapItemSceneNode(item);
+ if (item->sceneNode()) {
+ objectSceneNode_->addNode(item->sceneNode());
+ }
+ mapItems_.append(item);
+ sphere_->updateMutex.unlock();
+}
+
+// Function is guaranteed to be only called when executing in
+// rendering thread with valid GL context. Furthermore it is
+// safe to update any geometry/structures - mutex is locked.
+void MapPrivate::GLContextAvailable()
+{
+ // remove obsolete items
+ QSet<MapItem *>::const_iterator i = obsoleteItems_.constBegin();
+ while (i != obsoleteItems_.constEnd()) {
+ QGLSceneNode *node = (*i)->sceneNode();
+ if (node) {
+ //sceneNode_->removeNode(node); must be removed in GUI thread, not in rendering thread
+ delete node;
+ }
+ mapItems_.removeAll(*i);
+ ++i;
+ }
+ if (!obsoleteItems_.isEmpty())
+ obsoleteItems_.clear();
+}
+
+// Must not be called from rendering thread
+void MapPrivate::removeMapItem(MapItem *item)
+{
+ sphere_->updateMutex.lock();
+ // nodes need to be removed from the scene node tree in GUI thread,
+ // but the deletion needs to occur in rendering thread
+ if (item->sceneNode())
+ objectSceneNode_->removeNode(item->sceneNode());
+ if (!obsoleteItems_.contains(item))
+ obsoleteItems_.insert(item);
+ sphere_->updateMutex.unlock();
+}
+
+void MapPrivate::clearMapItems()
+{
+ sphere_->updateMutex.lock();
+ for (int i = 0; i < mapItems_.size(); ++i) {
+ if (!obsoleteItems_.contains(mapItems_.at(i))) {
+ if (mapItems_.at(i)->sceneNode())
+ objectSceneNode_->removeNode(mapItems_.at(i)->sceneNode());
+ obsoleteItems_.insert(mapItems_.at(i));
+ }
+ }
+ sphere_->updateMutex.unlock();
+}
+
+QVector2D MapPrivate::pointToTile(const QVector3D &point, int zoom, bool roundUp) const
+{
+ QVector2D p = projection_->pointToMercator(point);
+
+ int z = 1 << zoom;
+ int x = 0;
+ int y = 0;
+
+ if (p.y() == 1.0)
+ y = z - 1;
+ else
+ y = static_cast<int>(z * p.y()) % z;
+
+ if ((qAbs(p.x()) < 1e-6) || (qAbs(p.x() - 1) < 1e-6))
+ if (roundUp)
+ x = z - 1;
+ else
+ x = 0;
+ else
+ x = static_cast<int>(z * p.x()) % z;
+
+ return QVector2D(x, y);
+}
+
+QVector3D MapPrivate::tileXIntersectToPoint(int zoomLevel, int x) const
+{
+ int zpow2 = 1 << zoomLevel;
+ return projection_->mercatorToPoint(QVector2D(x * 1.0 / zpow2, zpow2 / 2.0));
+}
+
+QVector3D MapPrivate::tileYIntersectToPoint(int zoomLevel, int y) const
+{
+ int zpow2 = 1 << zoomLevel;
+ return projection_->mercatorToPoint(QVector2D(zpow2 / 2.0, y * 1.0 / zpow2));
+}
+
+int MapPrivate::width() const
+{
+ return width_;
+}
+
+int MapPrivate::height() const
+{
+ return height_;
+}
+
+double MapPrivate::aspectRatio() const
+{
+ return aspectRatio_;
+}
diff --git a/src/location/maps/qgeomapobjectinfo.h b/src/location/mapsgl/map.h
index f9fafa7c..65ad9751 100644
--- a/src/location/maps/qgeomapobjectinfo.h
+++ b/src/location/mapsgl/map.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,60 +38,76 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOMAPOBJECTINFO_H
-#define QGEOMAPOBJECTINFO_H
-
-#include "qmobilityglobal.h"
-#include "qgeomapobject.h"
+#ifndef MAP_H
+#define MAP_H
#include <QObject>
-#include <QSizeF>
+
+#include "cameradata.h"
QT_BEGIN_NAMESPACE
class QGeoCoordinate;
-class QGeoBoundingBox;
-class QGeoMapData;
-class QGeoMapObject;
-class QGeoMapObjectInfoPrivate;
+class QGeoMappingManager;
+
+class TileCache;
+class MapPrivate;
+class MapItem;
-class Q_LOCATION_EXPORT QGeoMapObjectInfo : public QObject
+class QGLCamera;
+class QGLPainter;
+
+class QPointF;
+
+class Q_LOCATION_EXPORT Map : public QObject
{
Q_OBJECT
+
+ Q_PROPERTY(CameraData camera READ cameraData WRITE setCameraData NOTIFY cameraDataChanged)
+
public:
- QGeoMapObjectInfo(QGeoMapData *mapData, QGeoMapObject *mapObject);
- virtual ~QGeoMapObjectInfo();
+ Map(TileCache *cache, QObject *parent = 0);
+ virtual ~Map();
- virtual void init();
+ void setMappingManager(QGeoMappingManager *manager);
- virtual QGeoBoundingBox boundingBox() const;
- virtual bool contains(const QGeoCoordinate &coordinate) const;
+ QGLCamera* glCamera() const;
+ void paintGL(QGLPainter *painter);
-public slots:
- virtual void windowSizeChanged(const QSizeF &windowSize);
- virtual void zoomLevelChanged(qreal zoomLevel);
- virtual void centerChanged(const QGeoCoordinate &coordinate);
+ void resize(int width, int height);
- virtual void zValueChanged(int zValue);
- virtual void visibleChanged(bool visible);
- virtual void selectedChanged(bool selected);
+ void setAutoUpdate(bool autoUpdate);
+ bool autoUpdate() const;
- virtual void originChanged(const QGeoCoordinate &origin);
- virtual void unitsChanged(QGeoMapObject::CoordinateUnit units);
- virtual void transformTypeChanged(QGeoMapObject::TransformType transformType);
+ void setCameraData(const CameraData &cameraData);
+ CameraData cameraData() const;
-protected:
- QGeoMapData* mapData();
- QGeoMapObject* mapObject();
- QGeoMapObject* mapObject() const;
+ int numMapItems() const;
+ MapItem* mapItem(int index) const;
+ QList<MapItem*> mapItems() const;
+ void addMapItem(MapItem *item);
+ void removeMapItem(MapItem *item);
+ void clearMapItems();
+
+ QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
+ QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+
+public slots:
+ void clearCache();
+ void update();
+
+signals:
+ void updateRequired();
+ void updatesFinished();
+ void cameraDataChanged(const CameraData &cameraData);
private:
- QGeoMapObjectInfoPrivate *d_ptr;
- Q_DISABLE_COPY(QGeoMapObjectInfo)
+ MapPrivate *d_ptr;
+
+ bool autoUpdate_;
};
QT_END_NAMESPACE
-#endif
+#endif // MAP_H
diff --git a/src/location/mapsgl/map2d/map2d.pri b/src/location/mapsgl/map2d/map2d.pri
new file mode 100644
index 00000000..0adaaeb4
--- /dev/null
+++ b/src/location/mapsgl/map2d/map2d.pri
@@ -0,0 +1,11 @@
+
+INCLUDEPATH += mapsgl/map2d
+
+SOURCES += \
+ mapsgl/map2d/projection2d_p.cpp \
+ mapsgl/map2d/map2d_p.cpp
+
+PRIVATE_HEADERS += \
+ mapsgl/map2d/projection2d_p.h \
+ mapsgl/map2d/map2d_p.h
+
diff --git a/src/location/mapsgl/map2d/map2d_p.cpp b/src/location/mapsgl/map2d/map2d_p.cpp
new file mode 100644
index 00000000..98e7fe0d
--- /dev/null
+++ b/src/location/mapsgl/map2d/map2d_p.cpp
@@ -0,0 +1,660 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "map2d_p.h"
+#include "projection2d_p.h"
+
+#include "tile.h"
+#include "mapitem.h"
+
+#include <Qt3D/qgeometrydata.h>
+#include <Qt3D/qglbuilder.h>
+#include <Qt3D/qglcamera.h>
+
+#include <cmath>
+
+TileMap::TileMap(int minY, int maxY)
+ : size(0),
+ minY(minY),
+ maxY(maxY),
+ minX(maxY - minY + 1, -1),
+ maxX(maxY - minY + 1, -1)
+{}
+
+void TileMap::adjust(int tileX, int tileY)
+{
+ int index = tileY - minY;
+ int min = minX.at(index);
+ int max = maxX.at(index);
+
+ if (min == -1) {
+ min = tileX;
+ max = tileX;
+ minX[index] = min;
+ maxX[index] = max;
+ size += 1;
+ } else {
+ int oldSize = (max - min);
+ int min2 = qMin(min, tileX);
+ if (min2 != min)
+ minX[index] = min2;
+ int max2 = qMax(max, tileX);
+ if (max2 != max)
+ maxX[index] = max2;
+ int newSize = (max2 - min2);
+ size += (newSize - oldSize);
+ }
+}
+
+IntersectGenerator::IntersectGenerator(const MapPrivate *mp,
+ double p1,
+ double p2,
+ int t1,
+ int t2,
+ IntersectGenerator::Axis axis,
+ int zoomLevel)
+ : mp_(mp),
+ axis_(axis),
+ zoomLevel_(zoomLevel)
+{
+ if (t1 == t2) {
+ hasNext_ = false;
+ return;
+ }
+
+ bool inc = true;
+ if (axis_ == IntersectGenerator::XAxis) {
+ inc = (0 < (p2 - p1));
+ } else {
+ inc = (0 < (p1 - p2));
+ }
+
+ step_ = 1;
+ adjust_ = 0;
+ if (!inc) {
+ step_ = -1;
+ adjust_ = -1;
+ }
+
+ first_ = p1;
+ denom_ = p2 - p1;
+
+ current_ = t1;
+ end_ = t2 + step_;
+
+ hasNext_ = true;
+
+ generateValue();
+}
+
+bool IntersectGenerator::hasNext() const
+{
+ return hasNext_;
+}
+
+QPair<double, int> IntersectGenerator::value() const
+{
+ return value_;
+}
+
+void IntersectGenerator::next()
+{
+ generateValue();
+}
+
+void IntersectGenerator::generateValue()
+{
+ while (current_ != end_) {
+ double alpha = 0.0;
+
+ if (axis_ == IntersectGenerator::XAxis) {
+ double x = mp_->tileXIntersectToPoint(zoomLevel_, current_).x();
+ alpha = (x - first_) / denom_;
+ } else {
+ double y = mp_->tileYIntersectToPoint(zoomLevel_, current_).y();
+ alpha = (y - first_) / denom_;
+ }
+
+ if ((0.0 < alpha) && (alpha < 1.0)) {
+ value_ = QPair<double,int>(alpha, current_ + adjust_);
+ current_ += step_;
+ return;
+ }
+ current_ += step_;
+ }
+ hasNext_ = false;
+}
+
+Map2DPrivate::Map2DPrivate(Map *parent, TileCache *cache, int maxZoom, int tileSize)
+ : MapPrivate(parent, cache),
+ maxZoom_(maxZoom),
+ tileSize_(tileSize),
+ baseHeight_(100.0)
+{
+ sideLength_ = pow(2.0, 1.0 * maxZoom_);
+
+ setProjection(QSharedPointer<Projection>(new Projection2D(baseHeight_, sideLength_)));
+ screenPoly_.resize(4);
+ screenPoly_[0] = QPointF(0.0, 0.0);
+ screenPoly_[1] = QPointF(0.0, sideLength_);
+ screenPoly_[2] = QPointF(sideLength_, sideLength_);
+ screenPoly_[3] = QPointF(sideLength_, 0.0);
+
+ screenPolyLeft_.resize(4);
+ screenPolyLeft_[0] = QPointF(0.0, 0.0);
+ screenPolyLeft_[1] = QPointF(0.0, sideLength_);
+ screenPolyLeft_[2] = QPointF(sideLength_ / 2.0, sideLength_);
+ screenPolyLeft_[3] = QPointF(sideLength_ / 2.0, 0.0);
+
+ screenPolyRight_.resize(4);
+ screenPolyRight_[0] = QPointF(sideLength_ / 2.0, 0.0);
+ screenPolyRight_[1] = QPointF(sideLength_ / 2.0, sideLength_);
+ screenPolyRight_[2] = QPointF(sideLength_, sideLength_);
+ screenPolyRight_[3] = QPointF(sideLength_, 0.0);
+}
+
+Map2DPrivate::~Map2DPrivate() {}
+
+QGLSceneNode* Map2DPrivate::createTileNode(const Tile &tile)
+{
+ int geomZoom = tile.tileSpec().zoom();
+ int tileZoom = geomZoom;
+ int x = tile.tileSpec().x();
+ int y = tile.tileSpec().y();
+
+ QGLBuilder builder;
+
+ int z = 1 << geomZoom;
+
+ bool rightEdge = false;
+
+ double x1 = x * 1.0 / z;
+ double x2 = ((x + 1) % z) * 1.0 / z;
+ if (x2 == 0.0) {
+ x2 = 1.0;
+ rightEdge = true;
+ }
+ double y1 = y * 1.0 / z;
+ double y2 = (y + 1) * 1.0 / z;
+
+ QSharedPointer<Projection> p = projection();
+
+ QVector3D tl = p->mercatorToPoint(QVector2D(x1, y1));
+ QVector3D tr = p->mercatorToPoint(QVector2D(x2, y1));
+ QVector3D bl = p->mercatorToPoint(QVector2D(x1, y2));
+ QVector3D br = p->mercatorToPoint(QVector2D(x2, y2));
+
+ if (rightEdge) {
+ tr.setX(sideLength_);
+ br.setX(sideLength_);
+ }
+
+ int dz = 1 << (geomZoom - tileZoom);
+
+ int tx1 = x % dz;
+ int ty1 = y % dz;
+
+ ty1 = dz - ty1;
+
+ int tx2 = (x + 1) % dz;
+ if (tx2 == 0)
+ tx2 = dz;
+
+ int ty2 = (y + 1) % dz;
+ if (ty2 == 0)
+ ty2 = dz;
+
+ ty2 = dz - ty2;
+
+ QGeometryData g;
+
+ QVector3D n = QVector3D(0, 0, 1);
+
+ g.appendVertex(tl);
+ g.appendNormal(n);
+ g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty1 * 1.0 / dz));
+
+ g.appendVertex(bl);
+ g.appendNormal(n);
+ g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty2 * 1.0 / dz));
+
+ g.appendVertex(br);
+ g.appendNormal(n);
+ g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty2 * 1.0 / dz));
+
+ g.appendVertex(tr);
+ g.appendNormal(n);
+ g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty1 * 1.0 / dz));
+
+ builder.addQuads(g);
+
+ QGLSceneNode *node = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial(node);
+// tile.texture()->bind();
+ mat->setTexture(tile.texture());
+ node->setEffect(QGL::LitDecalTexture2D);
+
+ node->setMaterial(mat);
+
+ return node;
+}
+
+void Map2DPrivate::updateGlCamera(QGLCamera* glCamera)
+{
+ bool old = glCamera->blockSignals(true);
+
+ CameraData camera = cameraData();
+
+ double f = 1.0 * qMin(width(), height()) / tileSize_;
+
+ double altitude = sideLength_ * camera.distance() * f / 2.0;
+
+ QSharedPointer<Projection> p = projection();
+
+ QGeoCoordinate coord = camera.center();
+ coord.setAltitude(0.0);
+ QVector3D center = p->coordToPoint(coord);
+ coord.setAltitude(altitude);
+ QVector3D eye = p->coordToPoint(coord);
+
+ QVector3D view = eye - center;
+ QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ QVector3D up = QVector3D::normal(side, view);
+
+ QMatrix4x4 mBearing;
+ mBearing.rotate(-1.0 * camera.bearing(), view);
+ up = mBearing * up;
+
+ QVector3D side2 = QVector3D::normal(up, view);
+ QMatrix4x4 mTilt;
+ mTilt.rotate(camera.tilt(), side2);
+ eye = (mTilt * view) + center;
+
+ view = eye - center;
+ side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ up = QVector3D::normal(view, side2);
+
+ QMatrix4x4 mRoll;
+ mRoll.rotate(camera.roll(), view);
+ up = mRoll * up;
+
+ double nearPlane = 1.0;
+ double farPlane = 2.0 * altitude;
+
+ glCamera->setCenter(center);
+ glCamera->setEye(eye);
+ glCamera->setUpVector(up);
+ glCamera->setNearPlane(nearPlane);
+ glCamera->setFarPlane(farPlane);
+
+ glCamera->blockSignals(old);
+
+ // TODO fold into above code if this works for screen <-> coordinate conversions
+ viewSize_ = glCamera->viewSize();
+ eye_ = eye;
+ projectionMatrix_ = glCamera->projectionMatrix(aspectRatio()) * glCamera->modelViewMatrix();
+}
+
+void Map2DPrivate::updateFrustum(Frustum &frustum)
+{
+ frustum.update(glCamera(), cameraData().aspectRatio());
+}
+
+QList<TileSpec> Map2DPrivate::updateVisibleTiles()
+{
+ Frustum f = frustum();
+
+ QPolygonF poly(4);
+
+ QVector3D tln = f.topLeftNear();
+ QVector3D tlf = f.topLeftFar();
+ double tl = (tln.z() - baseHeight_) / (tln.z() - tlf.z());
+
+ poly[0] = ((1 - tl) * tln + tl * tlf).toPointF();
+
+ QVector3D bln = f.bottomLeftNear();
+ QVector3D blf = f.bottomLeftFar();
+ double bl = (bln.z() - baseHeight_) / (bln.z() - blf.z());
+
+ poly[1] = ((1 - bl) * bln + bl * blf).toPointF();
+
+ QVector3D brn = f.bottomRightNear();
+ QVector3D brf = f.bottomRightFar();
+ double br = (brn.z() - baseHeight_) / (brn.z() - brf.z());
+
+ poly[2] = ((1 - br) * brn + br * brf).toPointF();
+
+ QVector3D trn = f.topRightNear();
+ QVector3D trf = f.topRightFar();
+ double tr = (trn.z() - baseHeight_) / (trn.z() - trf.z());
+
+ poly[3] = ((1 - tr) * trn + tr * trf).toPointF();
+
+ bool widePoly = false;
+ bool clip = false;
+ for (int i = 0; i < poly.size(); ++i) {
+ QPointF p = poly.at(i);
+ if (p.x() >= sideLength_) {
+ widePoly = true;
+ break;
+ }
+ if ((p.x() < 0)
+ || (sideLength_ < p.x())
+ || (p.y() < 0)
+ || (sideLength_ < p.y())) {
+ clip = true;
+ }
+ }
+
+ if (!widePoly) {
+ if (!clip) {
+ QVector<QVector3D> points(poly.size());
+
+ for (int i = 0; i < poly.size(); ++i)
+ points[i] = QVector3D(poly.at(i));
+
+ return tilesFromPoints(points, false);
+ } else {
+ QPolygonF clipped = intersection(poly, screenPoly_);
+
+ QList<TileSpec> tiles;
+
+ if (!clipped.isEmpty()) {
+ QVector<QVector3D> points(clipped.size() - 1);
+
+ for (int i = 0; i < clipped.size() - 1; ++i)
+ points[i] = QVector3D(clipped.at(i));
+
+ return tilesFromPoints(points, false);
+ }
+
+ return tiles;
+ }
+
+ } else {
+ QPolygonF clippedLeft = intersection(poly, screenPolyLeft_);
+ QPolygonF clippedRight = intersection(poly, screenPolyRight_);
+
+ QList<TileSpec> tiles;
+
+ if (!clippedLeft.isEmpty()) {
+ QVector<QVector3D> pointsLeft(clippedLeft.size() - 1);
+
+ for (int i = 0; i < clippedLeft.size() - 1; ++i)
+ pointsLeft[i] = QVector3D(clippedLeft.at(i));
+
+ if (clippedRight.isEmpty())
+ return tilesFromPoints(pointsLeft, false);
+ else
+ tiles.append(tilesFromPoints(pointsLeft, false));
+ }
+
+ if (!clippedRight.isEmpty()) {
+ QVector<QVector3D> pointsRight(clippedRight.size() - 1);
+
+ for (int i = 0; i < clippedRight.size() - 1; ++i)
+ pointsRight[i] = QVector3D(clippedRight.at(i));
+
+ if (tiles.isEmpty())
+ return tilesFromPoints(pointsRight, true);
+ else
+ tiles.append(tilesFromPoints(pointsRight, true));
+ }
+
+ return tiles;
+ }
+}
+
+QPolygonF Map2DPrivate::intersection(const QPolygonF &p1, const QPolygonF &p2) const
+{
+ QVector<double> x(4);
+ QVector<double> y(4);
+
+ x[0] = p1.at(0).x();
+ x[1] = p1.at(2).x();
+ x[2] = p2.at(0).x();
+ x[3] = p2.at(2).x();
+
+ y[0] = p1.at(0).y();
+ y[1] = p1.at(2).y();
+ y[2] = p2.at(0).y();
+ y[3] = p2.at(2).y();
+
+ qSort(x);
+ qSort(y);
+
+ QPolygonF result(5);
+
+ result[0] = QPointF(x.at(1), y.at(1));
+ result[1] = QPointF(x.at(2), y.at(1));
+ result[2] = QPointF(x.at(2), y.at(2));
+ result[3] = QPointF(x.at(1), y.at(2));
+ result[4] = QPointF(x.at(1), y.at(1));
+
+ return result;
+}
+
+void Map2DPrivate::tilesFromLine(const QVector3D &p1,
+ const QVector3D &p2,
+ const QVector2D &t1,
+ const QVector2D &t2,
+ int zoomLevel,
+ TileMap &map) const
+{
+ IntersectGenerator xGen = IntersectGenerator(this, p1.x(), p2.x(), t1.x(), t2.x(),
+ IntersectGenerator::XAxis, zoomLevel);
+ IntersectGenerator yGen = IntersectGenerator(this, p1.y(), p2.y(), t1.y(), t2.y(),
+ IntersectGenerator::YAxis, zoomLevel);
+
+ int tileX = t1.x();
+ int tileY = t1.y();
+
+ map.adjust(tileX, tileY);
+
+ while (xGen.hasNext() && yGen.hasNext()) {
+ QPair<double, int> x = xGen.value();
+ QPair<double, int> y = yGen.value();
+ if (x.first < y.first) {
+ tileX = x.second;
+ map.adjust(tileX, tileY);
+ xGen.next();
+ } else if (x.first > y.first) {
+ tileY = y.second;
+ map.adjust(tileX, tileY);
+ yGen.next();
+ } else {
+ map.adjust(tileX, y.second);
+ map.adjust(x.second, tileY);
+ tileX = x.second;
+ tileY = y.second;
+ map.adjust(tileX, tileY);
+ xGen.next();
+ yGen.next();
+ }
+ }
+
+ while (xGen.hasNext()) {
+ tileX = xGen.value().second;
+ map.adjust(tileX, tileY);
+ xGen.next();
+ }
+
+ while (yGen.hasNext()) {
+ tileY = yGen.value().second;
+ map.adjust(tileX, tileY);
+ yGen.next();
+ }
+}
+
+QList<TileSpec> Map2DPrivate::tilesFromPoints(const QVector<QVector3D> &points, bool roundUp) const
+{
+ int numPoints = points.size();
+
+ if (numPoints == 0)
+ return QList<TileSpec>();
+
+ int zoomLevel = cameraData().zoomLevel();
+
+ int minY = -1;
+ int maxY = -1;
+
+ QVector<QVector2D> tiles(points.size());
+ for (int i = 0; i < numPoints; ++i) {
+ QVector2D t = pointToTile(points.at(i), zoomLevel, roundUp);
+ if (minY == -1) {
+ minY = t.y();
+ maxY = t.y();
+ } else {
+ minY = qMin(minY, static_cast<int>(t.y()));
+ maxY = qMax(maxY, static_cast<int>(t.y()));
+ }
+ tiles[i] = t;
+ }
+
+ TileMap map(minY, maxY);
+
+ for (int i1 = 0; i1 < numPoints; ++i1) {
+ int i2 = (i1 + 1) % numPoints;
+ tilesFromLine(points.at(i1), points.at(i2), tiles.at(i1), tiles.at(i2), zoomLevel, map);
+ }
+
+ QList<TileSpec> results;
+
+ results.reserve(map.size);
+
+ int size = map.minX.size();
+ for (int i = 0; i < size; ++i) {
+ int y = map.minY + i;
+ int minX = map.minX[i];
+ int maxX = map.maxX[i];
+ for (int x = minX; x <= maxX; ++x)
+ results << TileSpec(zoomLevel, x, y);
+ }
+
+ return results;
+}
+
+void Map2DPrivate::updateMapItemSceneNode(MapItem *item)
+{
+ double z = item->zoom();
+
+ if (z < 0) {
+ // TODO draw item on camera
+ return;
+ }
+
+ double scale = sideLength_ / (tileSize_ * pow(2, z));
+ QPointF anchor = item->anchor() * scale;
+ QSizeF size = item->size() * scale;
+ double alt = 0.0;
+ QVector3D point = projection()->coordToPoint(item->coordinate());
+ QVector3D tl = QVector3D(point.x() + anchor.x(), point.y() - anchor.y(), alt);
+ QVector3D tr = QVector3D(tl.x() + size.width(), tl.y(), alt);
+ QVector3D bl = QVector3D(tl.x(), tl.y() - size.height(), alt);
+ QVector3D br = QVector3D(tl.x() + size.width(), tl.y() - size.height(), alt);
+
+ QVector3D up(0.0, 0.0, 1.0);
+
+ QGeometryData g;
+
+ g.appendVertex(tl);
+ g.appendNormal(up);
+ g.appendTexCoord(QVector2D(0.0, 0.0));
+
+ g.appendVertex(bl);
+ g.appendNormal(up);
+ g.appendTexCoord(QVector2D(0.0, 1.0));
+
+ g.appendVertex(br);
+ g.appendNormal(up);
+ g.appendTexCoord(QVector2D(1.0, 1.0));
+
+ g.appendVertex(tr);
+ g.appendNormal(up);
+ g.appendTexCoord(QVector2D(1.0, 0.0));
+
+ QGLBuilder builder;
+ builder.addQuads(g);
+ QGLSceneNode *node = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial(node);
+ QColor defaultItemColor(128, 128, 128, 128);
+ mat->setColor(defaultItemColor);
+ mat->setSpecularColor(defaultItemColor);
+ mat->setDiffuseColor(defaultItemColor);
+ mat->setShininess(1.0);
+ node->setEffect(QGL::LitMaterial);
+
+ node->setMaterial(mat);
+ item->setSceneNode(node);
+}
+
+QGeoCoordinate Map2DPrivate::screenPositionToCoordinate(const QPointF &pos) const
+{
+ double w = width() * 1.0 / viewSize_.width();
+ double h = height() * 1.0 / viewSize_.height();
+ double x = (pos.x() - w) / w;
+ double y = (pos.y() - h) / h;
+
+ x = (x + 1.0) / 2.0;
+ y = (y + 1.0) / 2.0;
+
+ QVector3D tl = frustum().topLeftFar();
+ QVector3D tr = frustum().topRightFar();
+ QVector3D bl = frustum().bottomLeftFar();
+
+ QVector3D n = (1 - x - y) * tl + x * tr + y * bl;
+
+ if (eye_.z() == n.z())
+ return QGeoCoordinate();
+
+ double alpha = eye_.z() / (eye_.z() - n.z());
+ QVector3D c = (1 - alpha) * eye_ + alpha * n;
+
+ return projection()->pointToCoord(c);
+}
+
+QPointF Map2DPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+{
+ QVector3D c = projection()->coordToPoint(coordinate);
+ QVector3D d = projectionMatrix_.map(c);
+ return QPointF((d.x() + 1.0) * width() / 2.0, (-d.y() + 1.0) * height() / 2.0);
+}
diff --git a/src/location/mapsgl/map2d/map2d_p.h b/src/location/mapsgl/map2d/map2d_p.h
new file mode 100644
index 00000000..bd790e7a
--- /dev/null
+++ b/src/location/mapsgl/map2d/map2d_p.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MAP2D_P_H
+#define MAP2D_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "map_p.h"
+
+#include <QVector>
+#include <QPair>
+#include <QPolygonF>
+#include <QSizeF>
+#include <QVector3D>
+#include <QMatrix4x4>
+
+struct TileMap
+{
+ TileMap(int minY, int maxY);
+
+ int size;
+ int minY;
+ int maxY;
+ QVector<int> minX;
+ QVector<int> maxX;
+
+ void adjust(int tileX, int tileY);
+};
+
+class IntersectGenerator
+{
+public:
+ enum Axis {
+ XAxis,
+ YAxis
+ };
+ IntersectGenerator(const MapPrivate *mp,
+ double p1,
+ double p2,
+ int t1,
+ int t2,
+ Axis axis,
+ int zoomLevel);
+
+ bool hasNext() const;
+ QPair<double, int> value() const;
+ void next();
+
+private:
+ void generateValue();
+
+protected:
+ const MapPrivate *mp_;
+ Axis axis_;
+ int zoomLevel_;
+
+ bool hasNext_;
+ QPair<double, int> value_;
+
+ int current_;
+ int step_;
+ int end_;
+
+ int adjust_;
+ double first_;
+ double denom_;
+};
+
+class Map2DPrivate : public MapPrivate
+{
+public:
+ Map2DPrivate(Map *parent,
+ TileCache *cache,
+ int maxZoom,
+ int tileSize);
+ virtual ~Map2DPrivate();
+
+ virtual QGLSceneNode* createTileNode(const Tile &tile);
+
+ virtual void updateGlCamera(QGLCamera* glCamera);
+ virtual void updateFrustum(Frustum &frustum);
+ virtual QList<TileSpec> updateVisibleTiles();
+ virtual void updateMapItemSceneNode(MapItem *item);
+
+ virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
+ virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+
+private:
+ void tilesFromLine(const QVector3D &p1,
+ const QVector3D &p2,
+ const QVector2D &t1,
+ const QVector2D &t2,
+ int zoomLevel,
+ TileMap &map) const;
+
+ QPolygonF intersection(const QPolygonF &p1, const QPolygonF &p2) const;
+
+ QList<TileSpec> tilesFromPoints(const QVector<QVector3D> &points, bool roundUp) const;
+
+ int maxZoom_;
+ int tileSize_;
+
+ double baseHeight_;
+ double sideLength_;
+ QPolygonF screenPoly_;
+ QPolygonF screenPolyLeft_;
+ QPolygonF screenPolyRight_;
+
+ QSizeF viewSize_;
+ QVector3D eye_;
+ QMatrix4x4 projectionMatrix_;
+};
+
+#endif // MAP2D_P_H
diff --git a/src/location/mapsgl/map2d/projection2d_p.cpp b/src/location/mapsgl/map2d/projection2d_p.cpp
new file mode 100644
index 00000000..98299a7e
--- /dev/null
+++ b/src/location/mapsgl/map2d/projection2d_p.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "projection2d_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <QVector2D>
+#include <QVector3D>
+
+Projection2D::Projection2D(double baseHeight, double sideLength)
+ : baseHeight_(baseHeight), sideLength_(sideLength) {}
+
+Projection2D::~Projection2D() {}
+
+QVector3D Projection2D::coordToPoint(const QGeoCoordinate &coord) const
+{
+ QVector2D m = coordToMercator(coord);
+ return QVector3D(m.x() * sideLength_, (1.0 - m.y()) * sideLength_, coord.altitude() + baseHeight_);
+}
+
+QGeoCoordinate Projection2D::pointToCoord(const QVector3D &point) const
+{
+ QVector2D m = QVector2D(point.x() / sideLength_, 1.0 - point.y() / sideLength_);
+ QGeoCoordinate coord = mercatorToCoord(m);
+ coord.setAltitude(point.z() - baseHeight_);
+ return coord;
+}
+
+QVector3D Projection2D::mercatorToPoint(const QVector2D &mercator) const
+{
+ return QVector3D(mercator.x() * sideLength_, (1.0 - mercator.y()) * sideLength_, baseHeight_);
+}
+
+QVector2D Projection2D::pointToMercator(const QVector3D &point) const
+{
+ return QVector2D(point.x() / sideLength_, 1.0 - (point.y() / sideLength_));
+}
+
+QGeoCoordinate Projection2D::interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress)
+{
+ if (start == end) {
+ if (progress < 0.5) {
+ return start;
+ } else {
+ return end;
+ }
+ }
+
+ QGeoCoordinate s2 = start;
+ s2.setAltitude(0.0);
+ QGeoCoordinate e2 = end;
+ e2.setAltitude(0.0);
+ QVector3D s = coordToPoint(s2);
+ QVector3D e = coordToPoint(e2);
+
+ double x = s.x();
+
+ if (sideLength_ / 2.0 < qAbs(e.x() - s.x())) {
+ // handle dateline crossing
+ } else {
+ x = (1.0 - progress) * s.x() + progress * e.x();
+ }
+
+ double y = (1.0 - progress) * s.y() + progress * e.y();
+
+ QGeoCoordinate result = pointToCoord(QVector3D(x, y, 0.0));
+ result.setAltitude((1.0 - progress) * start.altitude() + progress * end.altitude());
+ return result;
+
+ return start;
+}
diff --git a/src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h b/src/location/mapsgl/map2d/projection2d_p.h
index fc0f89b3..c311e204 100644
--- a/src/location/maps/tiled/qgeotiledmappingmanagerengine_p.h
+++ b/src/location/mapsgl/map2d/projection2d_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPPINGMANAGERENGINE_P_H
-#define QGEOTILEDMAPPINGMANAGERENGINE_P_H
+#ifndef PROJECTION2D_P_H
+#define PROJECTION2D_P_H
//
// W A R N I N G
@@ -53,30 +52,29 @@
// We mean it.
//
-#include "qgeomappingmanagerengine_p.h"
-#include "qgeotiledmapreply.h"
-
-#include <QSize>
+#include "projection_p.h"
QT_BEGIN_NAMESPACE
-class QGeoTiledMappingManagerEngine;
-class QGeoTiledMapRequestHandler;
-class QGeoTiledMapData;
-class QGeoTiledMapRequest;
-
-class QGeoTiledMappingManagerEnginePrivate : public QGeoMappingManagerEnginePrivate
+class Q_AUTOTEST_EXPORT Projection2D : public Projection
{
public:
- QGeoTiledMappingManagerEnginePrivate();
- ~QGeoTiledMappingManagerEnginePrivate();
+ Projection2D(double baseHeight, double sideLength);
+ virtual ~Projection2D();
+
+ virtual QVector3D coordToPoint(const QGeoCoordinate &coord) const;
+ virtual QGeoCoordinate pointToCoord(const QVector3D &point) const;
+
+ virtual QVector3D mercatorToPoint(const QVector2D &mercator) const;
+ virtual QVector2D pointToMercator(const QVector3D &point) const;
- QSize tileSize;
+ virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress);
private:
- Q_DISABLE_COPY(QGeoTiledMappingManagerEnginePrivate)
+ double baseHeight_;
+ double sideLength_;
};
QT_END_NAMESPACE
-#endif
+#endif // PROJECTION2D_P_H
diff --git a/src/location/mapsgl/map3d/map3d.pri b/src/location/mapsgl/map3d/map3d.pri
new file mode 100644
index 00000000..dd53928e
--- /dev/null
+++ b/src/location/mapsgl/map3d/map3d.pri
@@ -0,0 +1,26 @@
+
+INCLUDEPATH += mapsgl/map3d
+
+SOURCES += \
+ mapsgl/map3d/projection3d_p.cpp \
+ mapsgl/map3d/map3d_p.cpp \
+ mapsgl/map3d/sphere.cpp \
+ mapsgl/map3d/spheregeometry.cpp \
+ mapsgl/map3d/viewport.cpp \
+ mapsgl/map3d/viewportcamera.cpp \
+ mapsgl/map3d/viewporttiles.cpp \
+ mapsgl/map3d/viewporttilesold.cpp \
+ mapsgl/map3d/viewporttilesnew.cpp
+
+PRIVATE_HEADERS += \
+ mapsgl/map3d/projection3d_p.h \
+ mapsgl/map3d/map3d_p.h \
+ mapsgl/map3d/sphere_p.h \
+ mapsgl/map3d/spheregeometry_p.h \
+ mapsgl/map3d/viewport_p.h \
+ mapsgl/map3d/viewportcamera_p.h \
+ mapsgl/map3d/viewporttiles_p.h \
+ mapsgl/map3d/viewporttiles_p_p.h \
+ mapsgl/map3d/viewporttilesold_p.h \
+ mapsgl/map3d/viewporttilesnew_p.h
+
diff --git a/src/location/mapsgl/map3d/map3d_p.cpp b/src/location/mapsgl/map3d/map3d_p.cpp
new file mode 100644
index 00000000..404b94ed
--- /dev/null
+++ b/src/location/mapsgl/map3d/map3d_p.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "map3d_p.h"
+#include "projection3d_p.h"
+
+#include "tile.h"
+
+#include <qgeometrydata.h>
+#include <qglbuilder.h>
+#include <Qt3D/qglcamera.h>
+
+#include <cmath>
+
+Map3DPrivate::Map3DPrivate(Map *parent, TileCache *cache, double radius)
+ : MapPrivate(parent, cache),
+ minZoom_(6),
+ radius_(radius)
+{
+ Projection3D* p = new Projection3D(radius_);
+ setProjection(QSharedPointer<Projection>(p));
+ viewport_.setProjection(p);
+}
+
+Map3DPrivate::~Map3DPrivate()
+{
+}
+
+QGeometryData Map3DPrivate::generateTileGeometryData(int x, int y, int tileZoom, int geomZoom) const
+{
+ int z = 1 << geomZoom;
+
+ double x1 = x * 1.0 / z;
+ double x2 = ((x + 1) % z) * 1.0 / z;
+ if (x2 == 0.0)
+ x2 = 1.0;
+ double y1 = y * 1.0 / z;
+ double y2 = (y + 1) * 1.0 / z;
+
+ QSharedPointer<Projection> p = projection();
+
+ QVector3D tl = p->mercatorToPoint(QVector2D(x1, y1));
+ QVector3D tr = p->mercatorToPoint(QVector2D(x2, y1));
+ QVector3D bl = p->mercatorToPoint(QVector2D(x1, y2));
+ QVector3D br = p->mercatorToPoint(QVector2D(x2, y2));
+
+ int dz = 1 << (geomZoom - tileZoom);
+
+ int tx1 = x % dz;
+ int ty1 = y % dz;
+
+ ty1 = dz - ty1;
+
+ int tx2 = (x + 1) % dz;
+ if (tx2 == 0)
+ tx2 = dz;
+
+ int ty2 = (y + 1) % dz;
+ if (ty2 == 0)
+ ty2 = dz;
+
+ ty2 = dz - ty2;
+
+ QGeometryData g;
+
+ g.appendVertex(tl);
+ g.appendNormal(tl / radius_);
+ g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty1 * 1.0 / dz));
+
+ g.appendVertex(bl);
+ g.appendNormal(bl / radius_);
+ g.appendTexCoord(QVector2D(tx1 * 1.0 / dz, ty2 * 1.0 / dz));
+
+ g.appendVertex(br);
+ g.appendNormal(br / radius_);
+ g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty2 * 1.0 / dz));
+
+ g.appendVertex(tr);
+ g.appendNormal(tr / radius_);
+ g.appendTexCoord(QVector2D(tx2 * 1.0 / dz, ty1 * 1.0 / dz));
+
+ return g;
+}
+
+QGLSceneNode* Map3DPrivate::createTileNode(const Tile &tile)
+{
+ int tileZoom = tile.tileSpec().zoom();
+ int geomZoom = qMax(minZoom_, tileZoom);
+
+ int dz = 1 << (geomZoom - tileZoom);
+
+ int x1 = tile.tileSpec().x() * dz;
+ int y1 = tile.tileSpec().y() * dz;
+
+ QGLBuilder builder;
+
+ for (int x = 0; x < dz; ++x) {
+ for (int y = 0; y < dz; ++y) {
+ builder.addQuads(generateTileGeometryData(x1 + x, y1 + y, tileZoom, geomZoom));
+ }
+ }
+
+ QGLSceneNode *node = builder.finalizedSceneNode();
+
+ QGLMaterial *mat = new QGLMaterial(node);
+ // tile.texture()->bind();
+ mat->setTexture(tile.texture());
+ node->setEffect(QGL::LitDecalTexture2D);
+
+ node->setMaterial(mat);
+
+ return node;
+}
+
+void Map3DPrivate::updateGlCamera(QGLCamera* glCamera)
+{
+ CameraData camera = cameraData();
+
+ double altitude = radius_ * camera.distance();
+
+ QSharedPointer<Projection> p = projection();
+
+ QGeoCoordinate coord = camera.center();
+ coord.setAltitude(0.0);
+ QVector3D center = p->coordToPoint(coord);
+ coord.setAltitude(altitude);
+ QVector3D eye = p->coordToPoint(coord);
+
+ QVector3D view = eye - center;
+ QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ QVector3D up = QVector3D::normal(side, view);
+
+ QMatrix4x4 mBearing;
+ mBearing.rotate(-1.0 * camera.bearing(), view);
+ up = mBearing * up;
+
+ QVector3D side2 = QVector3D::normal(up, view);
+ QMatrix4x4 mTilt;
+ mTilt.rotate(camera.tilt(), side2);
+ eye = (mTilt * view) + center;
+
+ view = eye - center;
+ side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ up = QVector3D::normal(view, side2);
+
+ QMatrix4x4 mRoll;
+ mRoll.rotate(camera.roll(), view);
+ up = mRoll * up;
+
+ double nearPlane = 1.0;
+ double farPlane = 2.0 * altitude;
+
+ glCamera->setCenter(center);
+ glCamera->setEye(eye);
+ glCamera->setUpVector(up);
+ glCamera->setNearPlane(nearPlane);
+ glCamera->setFarPlane(farPlane);
+}
+
+void Map3DPrivate::updateFrustum(Frustum &frustum)
+{
+ frustum.update(glCamera(), cameraData().aspectRatio());
+ viewport_.setCameraData(cameraData());
+}
+
+QList<TileSpec> Map3DPrivate::updateVisibleTiles()
+{
+ return viewport_.visibleTiles();
+}
+
+void Map3DPrivate::updateMapItemSceneNode(MapItem */*item*/)
+{
+}
+
+QGeoCoordinate Map3DPrivate::screenPositionToCoordinate(const QPointF &/*pos*/) const
+{
+ return QGeoCoordinate();
+}
+
+QPointF Map3DPrivate::coordinateToScreenPosition(const QGeoCoordinate &/*coordinate*/) const
+{
+ return QPointF();
+}
diff --git a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h b/src/location/mapsgl/map3d/map3d_p.h
index e275ab56..c5d875f6 100644
--- a/src/location/maps/tiled/qgeotiledmaprouteobjectinfo_p.h
+++ b/src/location/mapsgl/map3d/map3d_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPROUTEOBJECT_INFO_P_H
-#define QGEOTILEDMAPROUTEOBJECT_INFO_P_H
+#ifndef MAP3D_P_H
+#define MAP3D_P_H
//
// W A R N I N G
@@ -53,36 +52,37 @@
// We mean it.
//
-#include "qgeotiledmapobjectinfo_p.h"
-
-#include "qgeoroute.h"
-
-#include <QPen>
+#include "map_p.h"
+#include "viewport_p.h"
QT_BEGIN_NAMESPACE
-class QGraphicsPathItem;
-class QGeoMapRouteObject;
-class QGeoTiledMapRouteObjectInfo : public QGeoTiledMapObjectInfo
+class QGeometryData;
+
+class Map3DPrivate : public MapPrivate
{
- Q_OBJECT
public:
- QGeoTiledMapRouteObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapRouteObjectInfo();
+ Map3DPrivate(Map *parent, TileCache *cache, double radius);
+ virtual ~Map3DPrivate();
- QGeoMapRouteObject *route;
- QGraphicsPathItem *pathItem;
+ virtual QGLSceneNode* createTileNode(const Tile &tile);
-public slots:
- void routeChanged(const QGeoRoute &route);
- void penChanged(const QPen &pen);
- void detailLevelChanged(quint32 detailLevel);
+ virtual void updateGlCamera(QGLCamera* glCamera);
+ virtual void updateFrustum(Frustum &frustum);
+ virtual QList<TileSpec> updateVisibleTiles();
+ virtual void updateMapItemSceneNode(MapItem *item);
+
+ virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
+ virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
private:
- void regenPath();
+ QGeometryData generateTileGeometryData(int x, int y, int tileZoom, int geomZoom) const;
+
+ int minZoom_;
+ double radius_;
+ Viewport viewport_;
};
QT_END_NAMESPACE
-#endif //QGEOTILEDMAPROUTEOBJECT_INFO_P_H
-
+#endif // MAP3D_P_H
diff --git a/src/location/mapsgl/map3d/projection3d_p.cpp b/src/location/mapsgl/map3d/projection3d_p.cpp
new file mode 100644
index 00000000..8d131ea2
--- /dev/null
+++ b/src/location/mapsgl/map3d/projection3d_p.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "projection3d_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <QVector2D>
+#include <QVector3D>
+#include <QMatrix4x4>
+#include <qnumeric.h>
+
+#include <cmath>
+
+Projection3D::Projection3D(double radius)
+ : radius_(radius) {}
+
+Projection3D::~Projection3D() {}
+
+double Projection3D::radius() const
+{
+ return radius_;
+}
+
+QVector3D Projection3D::coordToPoint(const QGeoCoordinate &coord) const
+{
+ double r = radius_ + coord.altitude();
+
+ const double pi = M_PI;
+ double lonRad = pi * -1.0 * (coord.longitude() + 90.0) / 180.0;
+ double latRad = pi * (90.0 - coord.latitude()) / 180.0;
+
+ return QVector3D(r * cos(lonRad) * sin(latRad),
+ r * cos(latRad),
+ r * sin(lonRad) * sin(latRad));
+}
+
+QGeoCoordinate Projection3D::pointToCoord(const QVector3D &point) const
+{
+ const double pi = M_PI;
+
+ double alt = point.length();
+ double lat = 180.0 * acos(point.y() / alt) / pi;
+ double lon = 270.0 - (180.0 * atan2(point.z(), point.x()) / pi);
+
+ if (lon < -180.0)
+ lon += 360.0;
+ if (lon >= 180.0)
+ lon -= 360.0;
+
+ return QGeoCoordinate(90.0 - lat, lon, alt);
+}
+
+QGeoCoordinate Projection3D::interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress)
+{
+ if (start == end) {
+ if (progress < 0.5) {
+ return start;
+ } else {
+ return end;
+ }
+ }
+
+ QGeoCoordinate s2 = start;
+ s2.setAltitude(0.0);
+ QGeoCoordinate e2 = end;
+ e2.setAltitude(0.0);
+ QVector3D s = coordToPoint(s2).normalized();
+ QVector3D e = coordToPoint(e2).normalized();
+
+ double dot = QVector3D::dotProduct(s, e);
+ const double pi = M_PI;
+ double angle = 180.0 * acos(dot) / pi;
+ if (qFuzzyCompare(qAbs(dot), 1.0) || qIsNaN(angle)) { // qIsNan is extra check, fuzzy compare is sometimes too 'loose'
+ if (progress < 0.5) {
+ return start;
+ } else {
+ return end;
+ }
+ }
+
+ QVector3D axis = QVector3D::crossProduct(s, e);
+ QMatrix4x4 mRot;
+ mRot.rotate(angle * progress, axis);
+ QVector3D p = mRot * s;
+
+ QGeoCoordinate result = pointToCoord(p);
+ result.setAltitude((1.0 - progress) * start.altitude() + progress * end.altitude());
+ return result;
+}
+
diff --git a/src/location/maps/qgraphicsgeomap_p.h b/src/location/mapsgl/map3d/projection3d_p.h
index c3818c99..769ae437 100644
--- a/src/location/maps/qgraphicsgeomap_p.h
+++ b/src/location/mapsgl/map3d/projection3d_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGRAPHICSGEOMAP_P_H
-#define QGRAPHICSGEOMAP_P_H
+#ifndef PROJECTION3D_P_H
+#define PROJECTION3D_P_H
//
// W A R N I N G
@@ -53,28 +52,23 @@
// We mean it.
//
-#include "qmobilityglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoServiceProvider;
-class QGeoMappingManager;
-class QGeoMapData;
+#include "projection_p.h"
-class QGraphicsGeoMapPrivate
+class Q_AUTOTEST_EXPORT Projection3D : public Projection
{
public:
- QGraphicsGeoMapPrivate();
- ~QGraphicsGeoMapPrivate();
+ Projection3D(double radius);
+ virtual ~Projection3D();
- QGeoMappingManager *manager;
- QGeoMapData *mapData;
- bool panActive;
+ double radius() const;
+
+ virtual QVector3D coordToPoint(const QGeoCoordinate &coord) const;
+ virtual QGeoCoordinate pointToCoord(const QVector3D &point) const;
+
+ virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress);
private:
- Q_DISABLE_COPY(QGraphicsGeoMapPrivate)
+ double radius_;
};
-QT_END_NAMESPACE
-
-#endif
+#endif // PROJECTION3D_P_H
diff --git a/src/location/mapsgl/map3d/sphere.cpp b/src/location/mapsgl/map3d/sphere.cpp
new file mode 100644
index 00000000..7c2e75ae
--- /dev/null
+++ b/src/location/mapsgl/map3d/sphere.cpp
@@ -0,0 +1,1234 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "sphere_p.h"
+
+#include <cmath>
+
+Arc::Arc() {}
+
+Arc::Arc(const QPlane3D &plane, double sphereRadius, const QVector3D &start, const QVector3D &end)
+ : plane_(plane),
+ sphereRadius_(sphereRadius),
+ start_(start),
+ end_(end)
+{
+ QVector3D origin;
+ double dist = plane.distanceTo(origin);
+ center_ = -1.0 * dist * plane.normal().normalized();
+ radius_ = sqrt(sphereRadius_ * sphereRadius_ - dist * dist);
+}
+
+void Arc::setPlane(const QPlane3D &plane)
+{
+ plane_ = plane;
+ QVector3D origin;
+ double dist = plane.distanceTo(origin);
+ center_ = -1.0 * dist * plane.normal().normalized();
+ radius_ = sqrt(sphereRadius_ * sphereRadius_ - dist * dist);
+}
+
+bool Arc::operator ==(const Arc &rhs)
+{
+ return (qFuzzyCompare(sphereRadius_, rhs.sphereRadius_)
+ && qFuzzyCompare(radius_, rhs.radius_)
+ && qFuzzyCompare(plane_, rhs.plane_)
+ && qFuzzyCompare(center_, rhs.center_)
+ && qFuzzyCompare(start_, rhs.start_)
+ && qFuzzyCompare(end_, rhs.end_));
+}
+
+QPlane3D Arc::plane() const
+{
+ return plane_;
+}
+
+QVector3D Arc::center() const
+{
+ return center_;
+}
+
+double Arc::sphereRadius() const
+{
+ return sphereRadius_;
+}
+
+double Arc::radius() const
+{
+ return radius_;
+}
+
+void Arc::setStart(const QVector3D &start)
+{
+ start_ = start;
+}
+
+QVector3D Arc::start() const
+{
+ return start_;
+}
+
+void Arc::setEnd(const QVector3D &end)
+{
+ end_ = end;
+}
+
+QVector3D Arc::end() const
+{
+ return end_;
+}
+
+QVector3D Arc::interpolate(double n) const
+{
+ QVector3D a = start_ - center_;
+ QVector3D b = end_ - center_;
+
+ a *= (1 - n);
+ b *= n;
+
+ a += b;
+
+ a.normalize();
+ a *= radius_;
+ a += center_;
+
+ return a;
+}
+
+QPair<QVector3D, QVector3D> Arc::intersect2(const QPlane3D &plane) const
+{
+ QVector3D n1 = plane_.normal();
+ QVector3D n2 = plane.normal();
+ double h1 = QVector3D::dotProduct(n1, plane_.origin());
+ double h2 = QVector3D::dotProduct(n2, plane.origin());
+
+ double dot = QVector3D::dotProduct(n1, n2);
+
+ if (dot == 1.0)
+ return QPair<QVector3D, QVector3D>(start_, QVector3D());
+ if (dot == -1.0)
+ return QPair<QVector3D, QVector3D>(QVector3D(), QVector3D());
+
+ QVector3D b = QVector3D::crossProduct(n1, n2);
+
+ double c1 = h1 - h2 * dot;
+ double c2 = h2 - h1 * dot;
+ double den = 1 - dot * dot;
+
+ n1 *= c1;
+ n2 *= c2;
+
+ n1 += n2;
+ n1 /= den;
+
+ double r2 = sphereRadius_ * sphereRadius_;
+
+ QVector3D a = n1;
+
+// QPair<double, double> f = quadraticResults(b.lengthSquared(), 2 * QVector3D::dotProduct(a, b), a.lengthSquared() - r2, false);
+// qWarning() << "f " << f.first << f.second;
+
+ if (r2 >= a.lengthSquared()) {
+ double alpha = sqrt(r2 - a.lengthSquared()) / b.length();
+ QVector3D v1 = b;
+ v1 *= alpha;
+ v1 += a;
+ QVector3D v2 = b;
+ v2 *= -1.0 * alpha;
+ v2 += a;
+
+
+ // TODO
+ // need a more robust method to determine whether v1, v2 are between start and end
+ // needs to be computationally cheap
+ double se = QVector3D::dotProduct(start_, end_);
+ bool hasV1 = ((se <= QVector3D::dotProduct(start_, v1)) && (se <= QVector3D::dotProduct(v1, end_)));
+ bool hasV2 = ((se <= QVector3D::dotProduct(start_, v2)) && (se <= QVector3D::dotProduct(v2, end_)));
+
+ if (hasV1) {
+ if (hasV2 && !qFuzzyCompare(v1, v2)) {
+ if ((v1 - start_).lengthSquared() > (v2 - start_).lengthSquared())
+ qSwap(v1, v2);
+ return QPair<QVector3D, QVector3D>(v1, v2);
+ } else {
+ return QPair<QVector3D, QVector3D>(v1, QVector3D());
+ }
+ } else if (hasV2) {
+ return QPair<QVector3D, QVector3D>(v2, QVector3D());
+ }
+ }
+
+ return QPair<QVector3D, QVector3D>(QVector3D(), QVector3D());
+}
+
+QPair<QVector3D, QVector3D> Arc::intersects(const QPlane3D &plane) const
+{
+// return intersect2(plane);
+
+ QVector3D va = start_ - center_;
+ QVector3D vb = end_ - center_;
+
+ QVector3D n = plane.normal();
+
+ double na = QVector3D::dotProduct(n, va);
+ double nb = QVector3D::dotProduct(n, vb);
+ double nab = na - nb;
+ double no = QVector3D::dotProduct(n, plane.origin());
+ double nc = QVector3D::dotProduct(n, center_);
+ double ab = QVector3D::dotProduct(va, vb);
+ double r2 = radius_ * radius_;
+ double rab = 1 - (ab / r2);
+
+ double noc = no - nc;
+ noc *= noc;
+
+
+ double a = nab * nab - 2 * noc * rab;
+ double b = 2 * (noc * rab - na * nab);
+ double c = na * na - noc;
+
+ QPair<double, double> factors = quadraticResults(a, b, c);
+
+ double f1 = factors.first;
+ QVector3D v1;
+ bool hasV1 = false;
+
+ double f2 = factors.second;
+ QVector3D v2;
+ bool hasV2 = false;
+
+ if (f1 != -1.0) {
+ v1 = interpolate(f1);
+ if (qAbs(plane.distanceTo(v1) / sphereRadius_) < 1e-6) {
+ hasV1 = true;
+ } else {
+ v1 = QVector3D();
+ }
+ }
+
+ if (f2 != -1.0) {
+ v2 = interpolate(f2);
+ if (qAbs(plane.distanceTo(v2) / sphereRadius_) < 1e-6) {
+ hasV2 = true;
+ if (!hasV1) {
+ v1 = v2;
+ v2 = QVector3D();
+ }
+ } else {
+ v2 = QVector3D();
+ }
+ }
+
+ return QPair<QVector3D, QVector3D>(v1, v2);
+}
+
+QPair<double, double> Arc::xIntersectFactor(double x) const
+{
+ return intersects(start_.x(), end_.x(), center_.x(), x);
+}
+
+QPair<double, double> Arc::yIntersectFactor(double y) const
+{
+ return intersects(start_.y(), end_.y(), center_.y(), y);
+}
+
+QPair<double, double> Arc::tIntersectFactor(double x, double z) const
+{
+ double t;
+ double ax;
+ double az;
+ double bx;
+ double bz;
+ double cx;
+ double cz;
+
+ // TODO deal with x = y = 0
+
+ if (qAbs(x) <= qAbs(z)) {
+ t = x / z;
+ ax = start_.x() - center_.x();
+ az = start_.z() - center_.z();
+ bx = end_.x() - center_.x();
+ bz = end_.z() - center_.z();
+ cx = center_.x();
+ cz = center_.z();
+ } else {
+ t = z / x;
+ ax = start_.z() - center_.z();
+ az = start_.x() - center_.x();
+ bx = end_.z() - center_.z();
+ bz = end_.x() - center_.x();
+ cx = center_.z();
+ cz = center_.x();
+ }
+
+
+ double r2 = radius_ * radius_;
+ double dot = QVector3D::dotProduct(start_ - center_, end_ - center_);
+ double dc = (cx - t * cz);
+ dc *= dc;
+
+ double ta = t * az - ax;
+ double tb = t * bz - bx;
+ double tab = ta - tb;
+
+ double a = r2 * tab * tab + 2 * (dot - r2) * dc;
+ double b = 2 * (-1 * r2 * ta * tab + (r2 - dot) * dc);
+ double c = r2 * ta * ta - r2 * dc;
+
+ QPair<double, double> factors = quadraticResults(a, b, c);
+
+ // Need to check that the signs match
+
+ bool xNeg = (x < 0.0);
+ bool zNeg = (z < 0.0);
+
+ double f1 = factors.first;
+ bool f1Valid = false;
+ if (f1 != -1.0) {
+ QVector3D r = interpolate(f1);
+ bool rxNeg = (r.x() < 0.0);
+ bool rzNeg = (r.z() < 0.0);
+ if ((xNeg == rxNeg) && (zNeg == rzNeg)) {
+ f1Valid = true;
+ } else {
+ f1 = -1.0;
+ }
+ }
+
+ double f2 = factors.second;
+ if (f2 != -1.0) {
+ QVector3D r = interpolate(f2);
+ bool rxNeg = (r.x() < 0.0);
+ bool rzNeg = (r.z() < 0.0);
+ if ((xNeg == rxNeg) && (zNeg == rzNeg)) {
+ if (!f1Valid) {
+ f1 = f2;
+ f2 = -1.0;
+ }
+ } else {
+ f2 = -1.0;
+ }
+ }
+
+ return QPair<double, double>(f1, f2);
+}
+
+QPair<double, double> Arc::intersects(double startValue, double endValue, double centerValue, double target) const
+{
+ double r2 = radius_ * radius_;
+ double dc = (target - centerValue) * (target - centerValue);
+ double dot = QVector3D::dotProduct(start_ - center_, end_ - center_);
+
+ double a = 2 * (r2 - dot) * dc - r2 * (startValue - endValue) * (startValue - endValue);
+ double b = 2 * (dot - r2) * dc - 2 * r2 * (startValue - centerValue) * (endValue - startValue);
+ double c = r2 * (dc - (startValue - centerValue) * (startValue - centerValue));
+
+ return quadraticResults(a, b, c);
+}
+
+QPair<double, double> Arc::quadraticResults(double a, double b, double c, bool clip)
+{
+ if (a == 0.0)
+ return QPair<double, double>(-1.0, -1.0);
+
+ double s = b * b - 4 * a * c;
+
+ if (s < 0.0)
+ return QPair<double, double>(-1.0, -1.0);
+
+ double s2 = sqrt(s);
+
+ double n1 = (-b + s2) / (2 * a);
+ double n2 = (-b - s2) / (2 * a);
+
+ if (clip) {
+ if ((n1 < 0.0) || (n1 > 1.0))
+ n1 = -1.0;
+ if ((n2 < 0.0) || (n2 > 1.0))
+ n2 = -1.0;
+
+ if (n1 != -1.0) {
+ if ((n2 != -1.0) && (n1 != n2)) {
+ if (n2 < n1)
+ qSwap(n1, n2);
+ return QPair<double, double>(n1, n2);
+ } else {
+ return QPair<double, double>(n1, -1.0);
+ }
+ } else if (n2 != -1.0) {
+ return QPair<double, double>(n2, -1.0);
+ } else {
+ return QPair<double, double>(-1.0, -1.0);
+ }
+ } else {
+ if (n2 < n1)
+ qSwap(n1, n2);
+ return QPair<double, double>(n1, n2);
+ }
+}
+
+bool Arc::belowPlane(const QPlane3D &plane) const
+{
+ double ds = plane.distanceTo(start_) / sphereRadius_;
+ double de = plane.distanceTo(end_) / sphereRadius_;
+
+ if ((ds > 1e-6) || (de > 1e-6))
+ return false;
+
+ return ((ds < -1e-6) || (de < -1e-6));
+}
+
+bool PatchData::operator == (const PatchData &rhs)
+{
+ return (qFuzzyCompare(point,rhs.point) && qFuzzyCompare(plane, rhs.plane));
+}
+
+SpherePatch::SpherePatch(double radius, const QList<Arc> arcs, bool roundUp, bool planar)
+ : radius_(radius),
+ roundUp_(roundUp),
+ planar_(planar),
+ debug_(true)
+{
+ data_.reserve(arcs.size());
+ for (int i = 0; i < arcs.size(); ++i) {
+ PatchData d;
+ d.point = arcs.at(i).start();
+ d.plane = arcs.at(i).plane();
+ d.intersectIndex = -1;
+ d.done = false;
+ data_ << d;
+ }
+}
+
+SpherePatch::SpherePatch(double radius, const QList<PatchData> &data, bool roundUp, bool planar)
+ : data_(data),
+ radius_(radius),
+ roundUp_(roundUp),
+ planar_(planar),
+ debug_(true)
+{
+ int size = data_.size();
+
+ for (int i = 0; i < size; ++i) {
+ data_[i].intersectIndex = -1;
+ data_[i].done = false;
+ }
+}
+
+bool SpherePatch::operator ==(const SpherePatch &rhs)
+{
+ // TODO need to be able to handle rotations of the arc list
+ // TODO should also handle list in reverse order and with start/end
+ // in the opposite order
+ return (qFuzzyCompare(radius_, rhs.radius_)
+ && (data_ == rhs.data_)
+ && (roundUp_ == rhs.roundUp_));
+}
+
+bool SpherePatch::isomorphic(const SpherePatch &rhs)
+{
+ if (radius_ != rhs.radius_)
+ return false;
+ if (roundUp_ != rhs.roundUp_)
+ return false;
+ if (data_.size() != rhs.data_.size())
+ return false;
+ if (data_.size() == 0)
+ return true;
+
+ int index = -1;
+ int size = data_.size();
+ PatchData d1 = data_.at(0);
+ for (int i = 0; i < size; ++i) {
+ if (d1 == rhs.data_[i]) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index == -1)
+ return false;
+
+ for (int i1 = 0; i1 < size; ++i1) {
+ int i2 = (i1 + index) % size;
+ if (!(data_[i1] == rhs.data_[i2]))
+ return false;
+ }
+
+ return true;
+}
+
+int SpherePatch::arcCount() const
+{
+ return data_.size();
+}
+
+Arc SpherePatch::arc(int index) const
+{
+ if (index < 0 || index >= data_.size())
+ return Arc();
+
+ int size = data_.size();
+ int index2 = (index + 1) % size;
+
+ return Arc(data_.at(index).plane, radius_, data_.at(index).point, data_.at(index2).point);
+}
+
+void SpherePatch::setRoundUpTiles(bool roundUp)
+{
+ roundUp_ = roundUp;
+}
+
+bool SpherePatch::roundUpTiles() const
+{
+ return roundUp_;
+}
+
+bool SpherePatch::containsPoint(const QVector3D &point) const
+{
+ int size = data_.size();
+
+ for (int i = 0; i < size; ++i) {
+ if (data_.at(i).plane.distanceTo(point) < 0.0)
+ return false;
+ }
+
+ return true;
+}
+
+bool SpherePatch::inFrontOfPlane(const QPlane3D &plane) const
+{
+ int size = data_.size();
+
+ for (int i1 = 0; i1 < size; ++i1) {
+ if (plane.distanceTo(data_.at(i1).point) < 0)
+ return false;
+ }
+
+ return true;
+}
+
+bool SpherePatch::behindPlane(const QPlane3D &plane) const
+{
+ int size = data_.size();
+
+ for (int i1 = 0; i1 < size; ++i1) {
+ if (plane.distanceTo(data_.at(i1).point) > 0)
+ return false;
+ }
+
+ return true;
+}
+
+QList<SpherePatch> SpherePatch::intersect(const QPlane3D &plane)
+{
+ QList<SpherePatch> results;
+
+ /*
+ We need these tests to rule out several cases that would
+ otherwise leave us with two arcs defining the patch.
+
+ We want to save that case for when the plane / sphere
+ circle intersects one arc of this patch at two points.
+
+ If it's a small circle we end up with two arcs between
+ two points (but the arcs are on different planes.
+
+ If it's a bigger circle there may be some additional
+ points on the intersecting plane to make the interpolation
+ unambiguous
+ */
+
+ QVector3D origin;
+ double dist = plane.distanceTo(origin);
+ if (dist > radius_) {
+ if (debug_)
+ qWarning() << "keeping (outside radius)";
+ results << *this;
+ return results;
+ } else if (dist < -1 * radius_) {
+ if (debug_)
+ qWarning() << "removing (outside radius)";
+ return results;
+ }
+
+ // co-planar
+ QPlane3D negPlane = plane;
+ negPlane.setNormal(negPlane.normal() * -1.0);
+ int size = data_.size();
+ for (int i = 0; i < size; ++i) {
+ if (data_[i].plane == plane) {
+ if (debug_)
+ qWarning() << "keeping (co-planar)";
+ results << *this;
+ return results;
+ } else if (data_[i].plane == negPlane) {
+ if (debug_)
+ qWarning() << "removing (co-planar)";
+ return results;
+ }
+ }
+
+ Arc intersectArc(plane, radius_);
+ bool contains = containsPoint(intersectArc.center());
+// if (!contains) {
+// if (behindPlane(plane)) {
+// if (debug_)
+// qWarning() << "removing (intersection in different patch)";
+// return results;
+// } else if (inFrontOfPlane(plane)) {
+// if (debug_)
+// qWarning() << "keeping (intersection in different patch)";
+// results << *this;
+// return results;
+// }
+// }
+
+ /*
+ for each pair of points
+ add first point if above or on plane
+ add intersection points if not start or end point
+ */
+
+ SpherePatch newPatch(radius_, QList<PatchData>(), roundUp_);
+
+ int arcIntersectCount = 0;
+ int doubleIntersectCount = 0;
+
+ QList<int> intersections = split(newPatch, plane, arcIntersectCount, doubleIntersectCount);
+
+ if (debug_) {
+ qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
+ for (int i = 0; i < newPatch.data_.size(); ++i)
+ qWarning() << " " << newPatch.data_.at(i).point << newPatch.data_.at(i).plane << newPatch.data_.at(i).intersectIndex;
+ for (int i = 0; i < intersections.size(); ++i)
+ qWarning() << " " << intersections.at(i);
+ }
+
+
+ if ((arcIntersectCount == 0) || ((arcIntersectCount == 1) && (newPatch.data_.size() == 1))) {
+ if (contains)
+ return noIntersectPatches(plane);
+ if (debug_)
+ qWarning() << "keeping (center point in different patch)";
+// results << *this;
+
+ if (behindPlane(plane)) {
+ if (debug_)
+ qWarning() << "removing (intersection in different patch)";
+ return results;
+ } else if (inFrontOfPlane(plane)) {
+ if (debug_)
+ qWarning() << "keeping (intersection in different patch)";
+ results << *this;
+ return results;
+ }
+
+ return results;
+ }
+
+ //qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
+
+ if ((intersections.length() == 2) && (doubleIntersectCount == 1))
+ handleCircleEdgeIntersection(newPatch, plane, intersections);
+
+ arrangeIntersections(newPatch, plane, intersections);
+
+ if (debug_) {
+ qWarning() << newPatch.data_.size() << intersections.size() << arcIntersectCount << doubleIntersectCount << contains;
+ for (int i = 0; i < newPatch.data_.size(); ++i)
+ qWarning() << " " << newPatch.data_.at(i).point << newPatch.data_.at(i).plane << newPatch.data_.at(i).intersectIndex;
+ for (int i = 0; i < intersections.size(); ++i)
+ qWarning() << " " << intersections.at(i);
+ }
+
+ return divide(newPatch, plane, intersections);
+}
+
+QList<int> SpherePatch::split(SpherePatch &patch, const QPlane3D &plane, int &arcCount, int &doubleCount)
+{
+ QList<int> intersections;
+
+ arcCount = 0;
+ doubleCount = 0;
+
+ int size = data_.size();
+
+ for (int i1 = 0; i1 < size; ++i1) {
+ int i2 = (i1 + 1) % size;
+
+ PatchData d1 = data_.at(i1);
+ PatchData d2 = data_.at(i2);
+
+ QVector3D p1 = d1.point;
+ QVector3D p2 = d2.point;
+
+ Arc a = Arc(d1.plane, radius_, p1, p2);
+
+ QPair<QVector3D, QVector3D> intersectPoints = a.intersects(plane);
+ QVector3D origin;
+
+ if (intersectPoints.first != origin)
+ ++arcCount;
+
+ if (intersectPoints.second != origin)
+ ++doubleCount;
+
+ if (debug_)
+ qWarning() << "intersects "
+ << intersectPoints.first
+ << intersectPoints.second
+ << "(" << p1 << ", " << p2 << ")";
+
+ double dist = plane.distanceTo(p1);
+
+ if ((dist / radius_ > -1e-6) && (dist <= 2.0 * radius_)) {
+ patch.data_ << d1;
+
+ int lastIndex = patch.data_.size() - 1;
+
+ if (intersectPoints.first != origin) {
+ if (qFuzzyCompare(intersectPoints.first, p1) && (intersections.isEmpty() || !(intersections.last() == lastIndex))) {
+ intersections << lastIndex;
+ }
+ }
+
+ if (intersectPoints.second != origin) {
+ if (qFuzzyCompare(intersectPoints.second, p1) && (intersections.isEmpty() || !(intersections.last() == lastIndex))) {
+ intersections << lastIndex;
+ }
+ }
+
+ } else {
+ if (debug_)
+ qWarning() << "point " << p1 << " below plane";
+ }
+
+ if (intersectPoints.first != origin) {
+ if (!qFuzzyCompare(intersectPoints.first, p1) && !qFuzzyCompare(intersectPoints.first, p2)) {
+ PatchData d = d1;
+ d.point = intersectPoints.first;
+ patch.data_ << d;
+ intersections << patch.data_.size() - 1;
+ if (debug_)
+ qWarning() << "adding " << intersectPoints.first << " as intersect";
+ }
+ }
+
+ if (intersectPoints.second != origin) {
+ if (!qFuzzyCompare(intersectPoints.second, p1) && !qFuzzyCompare(intersectPoints.second, p2)) {
+ PatchData d = d1;
+ d.point = intersectPoints.second;
+ patch.data_ << d;
+ intersections << patch.data_.size() - 1;
+ if (debug_)
+ qWarning() << "adding " << intersectPoints.second << " as intersect";
+ }
+ }
+ }
+
+ return intersections;
+}
+
+void SpherePatch::handleCircleEdgeIntersection(SpherePatch &patch, const QPlane3D &plane, QList<int> &intersections)
+{
+ QList<QVector3D> newPoints;
+
+ Arc a(plane, radius_);
+
+ QVector3D p1 = patch.data_.at(intersections.at(0)).point;
+ QVector3D p2 = patch.data_.at(intersections.at(1)).point;
+
+ bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
+
+ if (rhplane)
+ intersections.removeFirst();
+ else
+ intersections.removeLast();
+
+ QVector3D up = p1 - p2;
+ up.normalize();
+ up *= a.radius();
+
+ QVector3D right = QVector3D::crossProduct(plane.normal(), up);
+ right.normalize();
+ right *= a.radius();
+
+ QVector3D down = -1 * up;
+
+ QVector3D left = -1 * right;
+
+ up += a.center();
+ right += a.center();
+ down += a.center();
+ left += a.center();
+
+ if (containsPoint(up) && !qFuzzyCompare(up, p1) && !qFuzzyCompare(up, p2))
+ newPoints << up;
+ if (containsPoint(right) && !qFuzzyCompare(right, p1) && !qFuzzyCompare(right, p2))
+ newPoints << right;
+ if (containsPoint(down) && !qFuzzyCompare(down, p1) && !qFuzzyCompare(down, p2))
+ newPoints << down;
+ if (containsPoint(left) && !qFuzzyCompare(left, p1) && !qFuzzyCompare(left, p2))
+ newPoints << left;
+
+ int index = intersections.at(0) + 1;
+
+ while (!newPoints.isEmpty()) {
+ int minIndex = 0;
+ QVector3D p = patch.data_.at(index - 1).point;
+ double minDist = (newPoints.at(0) - p).lengthSquared();
+ for (int j = 1; j < newPoints.size(); ++j) {
+ double d = (newPoints.at(j) - p).lengthSquared();
+ if (d < minDist) {
+ minIndex = j;
+ minDist = d;
+ }
+ }
+
+ PatchData d;
+ d.point = newPoints.takeAt(minIndex);
+ d.plane = plane;
+ d.intersectIndex = -1;
+ d.done = false;
+ patch.data_.insert(index, d);
+
+ intersections << index;
+ ++index;
+ }
+}
+
+void SpherePatch::arrangeIntersections(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections)
+{
+ bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
+
+ int modifier = 1;
+ if (!rhplane)
+ modifier = -1;
+
+ if (!rhplane) {
+ int intersectSize = intersections.size();
+ int dataSize = patch.data_.size();
+
+ for (int i1 = 0; i1 < intersectSize; ++i1) {
+ int i2 = (i1 + modifier) % intersectSize;
+ if (i2 < 0)
+ i2 += intersectSize;
+ int index1 = intersections.at(i1);
+ int index2 = intersections.at(i2);
+ if (index1 != index2) {
+ patch.data_[index1].intersectIndex = index2;
+
+ if (planar_) {
+ int i3 = (index1 + 1) % dataSize;
+ if (i3 < 0)
+ i3 += dataSize;
+ if (i3 == index2)
+ patch.data_[index1].plane = plane;
+ }
+ }
+ }
+ }
+}
+
+void SpherePatch::setupPlanes(QList<PatchData> &data, const QPlane3D &plane)
+{
+ int ndSize = data.size();
+
+ if (!planar_) {
+ for (int i1 = 0; i1 < ndSize; ++i1) {
+ int i2 = (i1 + 1) % ndSize;
+// if (!qFuzzyCompare(data.at(i1).plane, data.at(i2).plane)) {
+ if (qAbs(data.at(i1).plane.distanceTo(data.at(i2).point) / radius_) > 1e-6) {
+ data[i1].plane = plane;
+ }
+// }
+ }
+ }
+}
+
+QList<SpherePatch> SpherePatch::divide(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections)
+{
+ QList<SpherePatch> results;
+
+ int size = patch.data_.size();
+
+ bool rhplane = (plane.distanceTo(QVector3D()) < 0.0);
+
+ if ((patch.data_.size() > 1) && rhplane) {
+ setupPlanes(patch.data_, plane);
+ results << SpherePatch(radius_, patch.data_, roundUp_);
+ } else if (size != intersections.size()) {
+ int size = patch.data_.size();
+ for (int i = 0; i < size; ++i) {
+ PatchData d1 = patch.data_.at(i);
+ if ((d1.intersectIndex == -1) && !d1.done) {
+
+ bool followingIntersect = false;
+ QList<PatchData> newData;
+
+ newData << d1;
+
+ int j = (i + 1) % size;
+
+ int count = 0;
+ while ((j != i) && (count != size)) {
+ ++count;
+
+ PatchData d2 = patch.data_.at(j);
+ newData << d2;
+
+ int next = (j + 1) % size;
+
+ // if ([this point is not an intersection])
+ if (d2.intersectIndex == -1) {
+ patch.data_[j].done = true;
+ } else {
+ if (followingIntersect) {
+ // followingIntersect = [intersect exists and is adjacent]
+ followingIntersect = (d2.intersectIndex == next);
+ } else {
+ next = d2.intersectIndex;
+ followingIntersect = true;
+ }
+ }
+
+ j = next;
+ }
+
+ if (count == size + 1) {
+ qWarning() << "GAAAAH!!";
+ }
+
+ if (newData.size() > 1) {
+ setupPlanes(newData, plane);
+ SpherePatch sp = SpherePatch(radius_, newData, roundUp_);
+ results << sp;
+ }
+ }
+ }
+ }
+
+ return results;
+}
+
+QList<SpherePatch> SpherePatch::noIntersectPatches(const QPlane3D &plane) const
+{
+ QList<SpherePatch> results;
+
+ Arc a(plane, radius_);
+
+ bool allBigger = true;
+ bool allSmaller = true;
+
+ int size = data_.size();
+
+ for (int i = 0; i < size; ++i) {
+ double dist = (data_.at(i).point - a.center()).length();
+ double r = (dist - a.radius()) / radius_;
+
+ if (r < -1e-6)
+ allSmaller = false;
+ if (r > 1e-6)
+ allBigger = false;
+ }
+
+ if (allBigger) {
+ if (plane.distanceTo(data_.at(0).point) / radius_ > 0.0)
+ results << *this;
+ return results;
+ }
+
+ QList<QVector3D> points;
+
+ const double pi = 3.14159265358;
+ double angle = asin(a.radius() / radius_) * 180.0 / pi;
+ QVector3D center = a.center().normalized() * radius_;
+
+ for (int i = 0; i < size; ++i) {
+ QVector3D axis = QVector3D::crossProduct(center, data_.at(i).point);
+ QMatrix4x4 r;
+ r.rotate(angle, axis);
+ points << r * center;
+ }
+
+ double dist = plane.distanceTo(QVector3D());
+ if (dist > 0.0) {
+ // circle shaped hole
+
+ for (int i1 = 0; i1 < size; ++i1) {
+ int i2 = (i1 + 1) % size;
+
+ QVector3D start = data_.at(i1).point;
+ QVector3D end = data_.at(i2).point;
+
+ QList<PatchData> data;
+
+ PatchData d1;
+ d1.point = start;
+ d1.plane = data_.at(i1).plane;
+ data << d1;
+
+ PatchData d2;
+ d2.point = end;
+ d2.plane = QPlane3D(center, QVector3D::normal(center, end));
+ data << d2;
+
+ PatchData d3;
+ d3.point = points.at(i2);
+ d3.plane = plane;
+ data << d3;
+
+ PatchData d4;
+ d4.point = points.at(i1);
+ d4.plane = QPlane3D(center, QVector3D::normal(center, start));
+ data << d4;
+
+ results << SpherePatch(radius_, data, roundUp_);
+ }
+
+ } else if (dist < 0.0) {
+ // solo circle
+
+ QList<PatchData> data;
+ for (int i = 0; i < size; ++i) {
+ PatchData d;
+ d.point = points.at(i);
+ d.plane = plane;
+ data << d;
+ }
+
+ results << SpherePatch(radius_, data, roundUp_, true);
+ }
+
+ return results;
+}
+
+Sphere::Sphere(double radius, const QList<SpherePatch> &patches)
+ : radius_(radius),
+ patches_(patches) {}
+
+Sphere::Sphere(double radius)
+ : radius_(radius)
+{
+ QVector3D origin;
+
+ patches_.reserve(8);
+
+ QVector3D pxv = QVector3D(radius_, 0.0, 0.0);
+ QVector3D nxv = QVector3D(-1.0 * radius_, 0.0, 0.0);
+ QVector3D pyv = QVector3D(0.0, radius_, 0.0);
+ QVector3D nyv = QVector3D(0.0, -1.0 * radius_, 0.0);
+ QVector3D pzv = QVector3D(0.0, 0.0, radius_);
+ QVector3D nzv = QVector3D(0.0, 0.0, -1.0 * radius_);
+
+ QPlane3D pxp = QPlane3D(origin, QVector3D(1.0, 0.0, 0.0));
+ QPlane3D nxp = QPlane3D(origin, QVector3D(-1.0, 0.0, 0.0));
+ QPlane3D pyp = QPlane3D(origin, QVector3D(0.0, 1.0, 0.0));
+ QPlane3D nyp = QPlane3D(origin, QVector3D(0.0, -1.0, 0.0));
+ QPlane3D pzp = QPlane3D(origin, QVector3D(0.0, 0.0, 1.0));
+ QPlane3D nzp = QPlane3D(origin, QVector3D(0.0, 0.0, -1.0));
+
+ PatchData d;
+
+ QList<PatchData> data;
+ data.reserve(3);
+ data << d;
+ data << d;
+ data << d;
+
+ data[0].point = pxv;
+ data[0].plane = pzp;
+ data[1].point = pyv;
+ data[1].plane = pxp;
+ data[2].point = pzv;
+ data[2].plane = pyp;
+
+ SpherePatch patch000(radius, data, false);
+ patches_ << patch000;
+
+ data[0].point = pxv;
+ data[0].plane = pyp;
+ data[1].point = nzv;
+ data[1].plane = pxp;
+ data[2].point = pyv;
+ data[2].plane = nzp;
+
+ SpherePatch patch001(radius_, data, false);
+ patches_ << patch001;
+
+ data[0].point = pxv;
+ data[0].plane = nyp;
+ data[1].point = pzv;
+ data[1].plane = pxp;
+ data[2].point = nyv;
+ data[2].plane = pzp;
+
+ SpherePatch patch010(radius_, data, false);
+ patches_ << patch010;
+
+ data[0].point = pxv;
+ data[0].plane = nzp;
+ data[1].point = nyv;
+ data[1].plane = pxp;
+ data[2].point = nzv;
+ data[2].plane = nyp;
+
+ SpherePatch patch011(radius_, data, false);
+ patches_ << patch011;
+
+ data[0].point = nxv;
+ data[0].plane = pyp;
+ data[1].point = pzv;
+ data[1].plane = nxp;
+ data[2].point = pyv;
+ data[2].plane = nzp;
+
+ SpherePatch patch100(radius_, data, false);
+ patches_ << patch100;
+
+ data[0].point = nxv;
+ data[0].plane = nzp;
+ data[1].point = pyv;
+ data[1].plane = nxp;
+ data[2].point = nzv;
+ data[2].plane = pyp;
+
+ SpherePatch patch101(radius_, data, false);
+ patches_ << patch101;
+
+ data[0].point = nxv;
+ data[0].plane = pzp;
+ data[1].point = nyv;
+ data[1].plane = nxp;
+ data[2].point = pzv;
+ data[2].plane = nyp;
+
+ SpherePatch patch110(radius_, data, true);
+ patches_ << patch110;
+
+ data[0].point = nxv;
+ data[0].plane = nyp;
+ data[1].point = nyv;
+ data[1].plane = nxp;
+ data[2].point = nzv;
+ data[2].plane = nzp;
+
+ SpherePatch patch111(radius_, data, true);
+ patches_ << patch111;
+}
+
+bool Sphere::operator ==(const Sphere &rhs)
+{
+ // TODO either make canonical ordering for patches
+ // or do order-independent comparison of the patches
+ return (qFuzzyCompare(radius_, rhs.radius_)
+ && (patches_ == rhs.patches_));
+}
+
+bool Sphere::isomorphic (const Sphere &rhs)
+{
+ if (radius_ != rhs.radius_)
+ return false;
+ if (patches_.size() != rhs.patches_.size())
+ return false;
+
+ int size = patches_.size();
+
+ if (size == 0)
+ return true;
+
+ for (int i = 0; i < size; ++i)
+ if (!patches_[i].isomorphic(rhs.patches_.at(i)))
+ return false;
+
+ return true;
+}
+
+QList<SpherePatch> Sphere::patches() const
+{
+ return patches_;
+}
+
+void Sphere::intersect(const QPlane3D &plane)
+{
+ int size = patches_.size();
+
+ QList<SpherePatch> newPatches;
+
+ QPlane3D p = plane;
+ p.setNormal(p.normal().normalized());
+
+ for (int i = 0; i < size; ++i)
+ newPatches.append(patches_[i].intersect(p));
+
+ patches_ = newPatches;
+}
+
+QDebug operator << (QDebug dbg, const Arc &arc)
+{
+ dbg << " Arc [plane: " << arc.plane() << ", start: " << arc.start() << ", end: " << arc.end() << "]\n";
+ return dbg;
+}
+
+QDebug operator << (QDebug dbg, const SpherePatch &patch)
+{
+ dbg << " Patch [\n";
+
+ int arcCount = patch.arcCount();
+ for (int i = 0; i < arcCount; ++i)
+ dbg << patch.arc(i);
+
+ dbg << " ]\n";
+ return dbg;
+}
+
+QDebug operator << (QDebug dbg, const Sphere &sphere)
+{
+ dbg << "Sphere [\n";
+
+ QList<SpherePatch> patches = sphere.patches();
+ for (int i = 0; i < patches.size(); ++i)
+ dbg << patches.at(i);
+
+ dbg << "]\n";
+ return dbg;
+}
diff --git a/src/location/mapsgl/map3d/sphere_p.h b/src/location/mapsgl/map3d/sphere_p.h
new file mode 100644
index 00000000..f6ec0d65
--- /dev/null
+++ b/src/location/mapsgl/map3d/sphere_p.h
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef SPHERE_P_H
+#define SPHERE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QVector3D>
+#include <QPair>
+#include <qplane3d.h>
+#include <QDebug>
+
+class Q_AUTOTEST_EXPORT Arc {
+public:
+ Arc();
+ Arc(const QPlane3D &plane,
+ double sphereRadius,
+ const QVector3D &start = QVector3D(),
+ const QVector3D &end = QVector3D());
+
+ bool operator == (const Arc &rhs);
+
+ void setPlane(const QPlane3D &plane);
+ QPlane3D plane() const;
+
+ QVector3D center() const;
+ double radius() const;
+ double sphereRadius() const;
+
+ void setStart(const QVector3D &start);
+ QVector3D start() const;
+
+ void setEnd(const QVector3D &end);
+ QVector3D end() const;
+
+ QVector3D interpolate(double n) const;
+ QPair<QVector3D, QVector3D> intersects(const QPlane3D &plane) const;
+
+ QPair<double, double> xIntersectFactor(double x) const;
+ QPair<double, double> yIntersectFactor(double y) const;
+ QPair<double, double> tIntersectFactor(double x, double y) const;
+
+ bool belowPlane(const QPlane3D &plane) const;
+
+private:
+ QPair<double, double> intersects(double start, double end, double center, double target) const;
+ static QPair<double, double> quadraticResults(double a, double b, double c, bool clip = true);
+
+ QPair<QVector3D, QVector3D> intersect2(const QPlane3D &plane) const;
+
+ QPlane3D plane_;
+ double sphereRadius_;
+ QVector3D center_;
+ double radius_;
+ QVector3D start_;
+ QVector3D end_;
+};
+
+QDebug operator << (QDebug dbg, const Arc &arc);
+
+struct PatchData {
+ QVector3D point;
+ QPlane3D plane;
+ int intersectIndex;
+ bool done;
+
+ bool operator == (const PatchData &rhs);
+};
+
+class Q_AUTOTEST_EXPORT SpherePatch {
+public:
+ SpherePatch(double radius, const QList<Arc> arcs, bool roundUp = false, bool planar = false);
+ SpherePatch(double radius, const QList<PatchData> &data, bool roundUp, bool planar = false);
+
+ bool operator == (const SpherePatch &rhs);
+ bool isomorphic(const SpherePatch &rhs);
+
+ int arcCount() const;
+ Arc arc(int index) const;
+
+ void setRoundUpTiles(bool roundUp);
+ bool roundUpTiles() const;
+
+ QList<SpherePatch> intersect(const QPlane3D &plane);
+
+private:
+ bool inFrontOfPlane(const QPlane3D &plane) const;
+ bool behindPlane(const QPlane3D &plane) const;
+ bool containsPoint(const QVector3D &point) const;
+
+ QList<int> split(SpherePatch &patch, const QPlane3D &plane, int &arcCount, int &doubleCount);
+ void handleCircleEdgeIntersection(SpherePatch &patch, const QPlane3D &plane, QList<int> &intersections);
+ QList<SpherePatch> noIntersectPatches(const QPlane3D &plane) const;
+ void arrangeIntersections(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections);
+ void setupPlanes(QList<PatchData> &data, const QPlane3D &plane);
+ QList<SpherePatch> divide(SpherePatch &patch, const QPlane3D &plane, const QList<int> &intersections);
+
+ QList<PatchData> data_;
+// QList<int> intersections_;
+
+ double radius_;
+ //QList<Arc> arcs_;
+ bool roundUp_;
+ bool planar_;
+ bool debug_;
+};
+
+QDebug operator << (QDebug dbg, const SpherePatch &patch);
+
+class Q_AUTOTEST_EXPORT Sphere {
+public:
+ Sphere(double radius = 20000.0);
+ Sphere(double radius, const QList<SpherePatch> &patches);
+
+ bool operator == (const Sphere &rhs);
+ bool isomorphic (const Sphere &rhs);
+
+ QList<SpherePatch> patches() const;
+
+ void intersect(const QPlane3D &plane);
+
+private:
+ double radius_;
+ QList<SpherePatch> patches_;
+};
+
+Q_AUTOTEST_EXPORT QDebug operator << (QDebug dbg, const Sphere &sphere);
+
+
+#endif // SPHERE_P_H
diff --git a/src/location/mapsgl/map3d/spheregeometry.cpp b/src/location/mapsgl/map3d/spheregeometry.cpp
new file mode 100644
index 00000000..b8389d9a
--- /dev/null
+++ b/src/location/mapsgl/map3d/spheregeometry.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "spheregeometry_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <QVector2D>
+#include <QVector3D>
+#include <cmath>
+
+#include <QDebug>
+
+SphereGeometry::SphereGeometry()
+ : radius_(20000.0),
+ zoomLevel_(4) {}
+
+SphereGeometry::SphereGeometry(double radius, int zoomLevel)
+ : radius_(radius),
+ zoomLevel_(zoomLevel) {}
+
+void SphereGeometry::setRadius(double radius)
+{
+ radius_ = radius;
+}
+
+double SphereGeometry::radius() const
+{
+ return radius_;
+}
+
+//void SphereGeometry::setZoomLevel(int zoomLevel)
+//{
+// zoomLevel_ = zoomLevel;
+//}
+
+//int SphereGeometry::zoomLevel() const
+//{
+// return zoomLevel_;
+//}
+
+bool SphereGeometry::operator == (const SphereGeometry &rhs) const
+{
+ return ((radius_ == rhs.radius_) && (zoomLevel_ == rhs.zoomLevel_));
+}
+
+QVector3D SphereGeometry::coordToPoint(const QGeoCoordinate &coord) const
+{
+ double r = radius_ + coord.altitude();
+
+ const double pi = 3.14159265358;
+ double lonRad = pi * -1.0 * (coord.longitude() + 90.0) / 180.0;
+ double latRad = pi * (90.0 - coord.latitude()) / 180.0;
+
+ return QVector3D(r * cos(lonRad) * sin(latRad),
+ r * cos(latRad),
+ r * sin(lonRad) * sin(latRad));
+}
+
+QVector3D SphereGeometry::coordToPoint(double lat, double lon, double alt) const
+{
+ double r = radius_ + alt;
+
+ const double pi = 3.14159265358;
+ double lonRad = pi * -1.0 * (lon + 90.0) / 180.0;
+ double latRad = pi * (90.0 - lat) / 180.0;
+
+ return QVector3D(r * cos(lonRad) * sin(latRad),
+ r * cos(latRad),
+ r * sin(lonRad) * sin(latRad));
+}
+
+qreal realmod(const qreal a, const qreal b)
+{
+ quint64 div = static_cast<quint64>(a / b);
+ return a - static_cast<qreal>(div) * b;
+}
+
+QVector3D SphereGeometry::mercatorToPoint(double fx, double fy) const
+{
+ const double pi = 3.14159265358;
+
+ if (fy < 0.0)
+ fy = 0.0;
+ else if (fy > 1.0)
+ fy = 1.0;
+
+ double lat;
+
+ if (fy == 0.0)
+ lat = 90.0;
+ else if (fy == 1.0)
+ lat = -90.0;
+ else
+ lat = (180.0 / pi) * (2.0 * atan(exp(pi * (1.0 - 2.0 * fy))) - (pi / 2.0));
+
+ double lng;
+ if (fx >= 0) {
+ lng = realmod(fx, 1.0);
+ } else {
+ lng = realmod(1.0 - realmod(-1.0 * fx, 1.0), 1.0);
+ }
+
+ lng = lng * 360.0 - 180.0;
+
+ return coordToPoint(lat, lng);
+}
+
+QVector3D SphereGeometry::pointToCoord(const QVector3D &point) const
+{
+ const double pi = 3.14159265358;
+
+ double alt = point.length();
+ double lat = 180.0 * acos(point.y() / alt) / pi;
+ double lon = 270.0 - (180.0 * atan2(point.z(), point.x()) / pi);
+
+ if (lon < -180.0)
+ lon += 360.0;
+ if (lon >= 180.0)
+ lon -= 360.0;
+
+ return QVector3D(90.0 - lat, lon, alt);
+}
+
+QVector2D SphereGeometry::coordToMercator(const QVector2D &coord) const
+{
+ const double pi = 3.14159265358;
+
+ double lon = coord.y() / 360.0 + 0.5;
+
+ double lat = coord.x();
+ lat = 0.5 - (log(tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
+ lat = qMax(0.0, lat);
+ lat = qMin(1.0, lat);
+
+ return QVector2D(lon, lat);
+}
+
+QVector2D SphereGeometry::pointToMercator(const QVector3D &point) const
+{
+ return coordToMercator(pointToCoord(point).toVector2D());
+}
+
+QVector2D SphereGeometry::coordToTile(const QVector2D &coord, int zoom, bool roundUp) const
+{
+ QVector2D p = coordToMercator(coord);
+
+ int z = 1 << zoom;
+ int x = 0;
+ int y = 0;
+
+ if (p.y() == 1.0)
+ y = z - 1;
+ else
+ y = static_cast<int>(z * p.y()) % z;
+
+ if ((qAbs(p.x()) < 1e-6) || (qAbs(p.x() - 1) < 1e-6))
+ if (roundUp)
+ x = z - 1;
+ else
+ x = 0;
+ else
+ x = static_cast<int>(z * p.x()) % z;
+
+ return QVector2D(x, y);
+}
+
+QVector2D SphereGeometry::pointToTile(const QVector3D &point, int zoom, bool roundUp) const
+{
+ return coordToTile(pointToCoord(point).toVector2D(), zoom, roundUp);
+}
diff --git a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h b/src/location/mapsgl/map3d/spheregeometry_p.h
index 7e4ce9f8..c8e434e0 100644
--- a/src/location/maps/tiled/qgeotiledmaptextobjectinfo_p.h
+++ b/src/location/mapsgl/map3d/spheregeometry_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPTEXTOBJECT_INFO_P_H
-#define QGEOTILEDMAPTEXTOBJECT_INFO_P_H
+#ifndef SPHEREGEOMETRY_P_H
+#define SPHEREGEOMETRY_P_H
//
// W A R N I N G
@@ -53,42 +52,45 @@
// We mean it.
//
-#include "qgeotiledmapobjectinfo_p.h"
-#include "qgeoboundingbox.h"
-
-#include <QFont>
-#include <QPen>
-#include <QBrush>
+#include "qglobal.h"
QT_BEGIN_NAMESPACE
-class QGraphicsSimpleTextItem;
-
-class QGeoMapTextObject;
+class QGeoCoordinate;
+class QVector2D;
+class QVector3D;
-class QGeoTiledMapTextObjectInfo : public QGeoTiledMapObjectInfo
+class Q_LOCATION_EXPORT SphereGeometry
{
- Q_OBJECT
public:
- QGeoTiledMapTextObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapTextObjectInfo();
+ SphereGeometry();
+ SphereGeometry(double radius, int zoomLevel);
+
+ void setRadius(double radius);
+ double radius() const;
+
+// void setZoomLevel(int zoomLevel);
+// int zoomLevel() const;
- QGeoMapTextObject* text;
- QGraphicsSimpleTextItem *textItem;
+ bool operator == (const SphereGeometry &rhs) const;
-public slots:
- void textChanged(const QString &text);
- void fontChanged(const QFont &font);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
- void offsetChanged(const QPoint &offset);
- void alignmentChanged(Qt::Alignment alignment);
+ QVector3D coordToPoint(const QGeoCoordinate &coord) const;
+ QVector3D coordToPoint(double lat, double lon, double alt = 0.0) const;
+ QVector3D mercatorToPoint(double fx, double fy) const;
+
+ QVector3D pointToCoord(const QVector3D &point) const;
+
+ QVector2D coordToMercator(const QVector2D &coord) const;
+ QVector2D pointToMercator(const QVector3D &point) const;
+
+ QVector2D coordToTile(const QVector2D &coord, int zoom, bool roundUp = false) const;
+ QVector2D pointToTile(const QVector3D &point, int zoom, bool roundUp = false) const;
private:
- void doAlignment();
+ double radius_;
+ int zoomLevel_;
};
QT_END_NAMESPACE
-#endif //QGEOTILEDMAPTEXTOBJECT_INFO_P_H
-
+#endif // SPHEREGEOMETRY_P_H
diff --git a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp b/src/location/mapsgl/map3d/viewport.cpp
index 080df3e7..8acdad4c 100644
--- a/src/location/maps/tiled/qgeotiledmapcustomobjectinfo_p.cpp
+++ b/src/location/mapsgl/map3d/viewport.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,64 +38,89 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "viewport_p.h"
-#include "qgeotiledmapcustomobjectinfo_p.h"
+#include "sphere_p.h"
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
+#include <QLinkedList>
+#include <QPair>
+#include <QMutableLinkedListIterator>
-#include "qgeomapcustomobject.h"
+#include <qglscenenode.h>
+#include <qglbuilder.h>
+#include <qglmaterial.h>
+#include <qglsphere.h>
+
+#include <cmath>
QT_BEGIN_NAMESPACE
-QGeoTiledMapCustomObjectInfo::QGeoTiledMapCustomObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
+Viewport::Viewport()
+ : viewportTiles_(ViewportTiles(1))
{
- custom = static_cast<QGeoMapCustomObject*>(mapObject);
-
- connect(custom,
- SIGNAL(triggerUpdate()),
- this,
- SLOT(updateTriggered()));
- connect(custom,
- SIGNAL(graphicsItemChanged(QGraphicsItem*)),
- this,
- SLOT(graphicsItemChanged(QGraphicsItem*)));
- connect(custom,
- SIGNAL(offsetChanged(QPoint)),
- this,
- SLOT(offsetChanged(QPoint)));
-
- graphicsItem = 0;
-
- graphicsItemChanged(this->custom->graphicsItem());
- offsetChanged(this->custom->offset());
+// viewportTiles_.setSphere(sphere_);
}
-QGeoTiledMapCustomObjectInfo::~QGeoTiledMapCustomObjectInfo()
+Viewport::~Viewport()
{
- //custom->setGraphicsItem(0);
}
-void QGeoTiledMapCustomObjectInfo::updateTriggered()
+void Viewport::setProjection(Projection3D *projection)
{
- updateItem();
+ viewportCamera_.setProjection(projection);
}
-void QGeoTiledMapCustomObjectInfo::graphicsItemChanged(QGraphicsItem * /*graphicsItem*/)
+void Viewport::setZoomLevel(int zoomLevel)
{
- graphicsItem = this->custom->graphicsItem();
- updateItem();
+ viewportTiles_.setZoomLevel(zoomLevel);
}
-void QGeoTiledMapCustomObjectInfo::offsetChanged(const QPoint &/*offset*/)
+int Viewport::zoomLevel() const
{
- QPoint offset = custom->offset();
- graphicsItem->translate(offset.x(), offset.y());
- updateItem();
+ return viewportTiles_.zoomLevel();
}
-#include "moc_qgeotiledmapcustomobjectinfo_p.cpp"
+//void Viewport::setSphere(const SphereGeometry& sphere)
+//{
+// if (sphere_ == sphere)
+// return;
-QT_END_NAMESPACE
+// sphere_ = sphere;
+// viewportTiles_.setSphere(sphere_);
+
+// calculateVisibleTiles();
+//}
+
+//SphereGeometry Viewport::sphere() const
+//{
+// return sphere_;
+//}
+
+/*
+ Updates the internal QGLCamera, the frustum, and then updates the
+ list of visible tiles.
+*/
+void Viewport::setCameraData(const CameraData &cameraData)
+{
+ viewportTiles_.setZoomLevel(cameraData.zoomLevel());
+ viewportCamera_.setCameraData(cameraData);
+
+ calculateVisibleTiles();
+}
+
+QGLCamera* Viewport::camera() const
+{
+ return viewportCamera_.toGLCamera();
+}
+
+QList<TileSpec> Viewport::visibleTiles() const
+{
+ return visibleTiles_;
+}
+void Viewport::calculateVisibleTiles()
+{
+ visibleTiles_ = viewportTiles_.visibleTiles(viewportCamera_);
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h b/src/location/mapsgl/map3d/viewport_p.h
index b55b8479..882b2248 100644
--- a/src/location/maps/tiled/qgeotiledmaprectangleobjectinfo_p.h
+++ b/src/location/mapsgl/map3d/viewport_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
-#define QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
+#ifndef VIEWPORT_P_H
+#define VIEWPORT_P_H
//
// W A R N I N G
@@ -53,38 +52,55 @@
// We mean it.
//
-#include "qgeotiledmapobjectinfo_p.h"
+#include "spheregeometry_p.h"
+#include "cameradata.h"
+#include "tilespec.h"
+#include "frustum_p.h"
+
+#include "viewportcamera_p.h"
+#include "viewporttiles_p.h"
-#include <QPen>
-#include <QBrush>
+#include <QList>
+#include <QVector2D>
+#include <QVector3D>
+#include <Qt3D/qplane3d.h>
QT_BEGIN_NAMESPACE
-class QGraphicsPolygonItem;
+class QGLCamera;
+class QGLSceneNode;
-class QGeoMapRectangleObject;
+class Arc;
-class QGeoTiledMapRectangleObjectInfo : public QGeoTiledMapObjectInfo
+class Projection3D;
+
+class Q_LOCATION_EXPORT Viewport
{
- Q_OBJECT
public:
- QGeoTiledMapRectangleObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapRectangleObjectInfo();
+ Viewport();
+ ~Viewport();
+
+ void setProjection(Projection3D *projection);
- QGeoMapRectangleObject* rectangle;
- QGraphicsPolygonItem *polygonItem;
+ void setZoomLevel(int zoomLevel);
+ int zoomLevel() const;
-public slots:
- void topLeftChanged(const QGeoCoordinate &topLeft);
- void bottomRightChanged(const QGeoCoordinate &bottomRight);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
+ void setCameraData(const CameraData &cameraData);
+
+ QGLCamera* camera() const;
+
+ QList<TileSpec> visibleTiles() const;
private:
- void regenPolygon();
+ void calculateVisibleTiles();
+
+ ViewportCamera viewportCamera_;
+ ViewportTiles viewportTiles_;
+
+ QList<TileSpec> visibleTiles_;
};
QT_END_NAMESPACE
-#endif //QGEOTILEDMAPRECTANGLEOBJECT_INFO_P_H
+#endif // VIEWPORT_P_H
diff --git a/src/location/mapsgl/map3d/viewportcamera.cpp b/src/location/mapsgl/map3d/viewportcamera.cpp
new file mode 100644
index 00000000..6d8abc76
--- /dev/null
+++ b/src/location/mapsgl/map3d/viewportcamera.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "viewportcamera_p.h"
+
+#include "cameradata.h"
+
+#include "projection3d_p.h"
+
+#include <qglcamera.h>
+
+ViewportCamera::ViewportCamera()
+ : camera_(new QGLCamera()){}
+
+ViewportCamera::~ViewportCamera()
+{
+ delete camera_;
+}
+
+void ViewportCamera::setProjection(Projection3D *projection)
+{
+ projection_ = projection;
+}
+
+//void ViewportCamera::setSphere(const SphereGeometry &sphere)
+//{
+// sphere_ = sphere;
+//}
+
+void ViewportCamera::setCameraData(const CameraData &cameraData)
+{
+// sphere_.setZoomLevel(cameraData.zoomLevel());
+ double altitude = projection_->radius() * cameraData.distance();
+
+ QGeoCoordinate coord = cameraData.center();
+ coord.setAltitude(0.0);
+ center_ = projection_->coordToPoint(coord);
+ coord.setAltitude(altitude);
+ eye_ = projection_->coordToPoint(coord);
+
+ QVector3D view = eye_ - center_;
+ QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ up_ = QVector3D::normal(side, view);
+
+ QMatrix4x4 mBearing;
+ mBearing.rotate(-1.0 * cameraData.bearing(), view);
+ up_ = mBearing * up_;
+
+ QVector3D side2 = QVector3D::normal(up_, view);
+ QMatrix4x4 mTilt;
+ mTilt.rotate(cameraData.tilt(), side2);
+ eye_ = (mTilt * view) + center_;
+
+ view = eye_ - center_;
+ side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ up_ = QVector3D::normal(view, side2);
+
+ QMatrix4x4 mRoll;
+ mRoll.rotate(cameraData.roll(), view);
+ up_ = mRoll * up_;
+
+ nearPlane_ = 1.0;
+ farPlane_ = 2.0 * altitude;
+
+ viewSize_ = camera_->viewSize();
+ aspectRatio_ = cameraData.aspectRatio();
+
+ updateGLCamera();
+ updateFrustum();
+}
+
+void ViewportCamera::updateGLCamera()
+{
+ camera_->setCenter(center_);
+ camera_->setEye(eye_);
+ camera_->setUpVector(up_);
+ camera_->setNearPlane(nearPlane_);
+ camera_->setFarPlane(farPlane_);
+}
+
+void ViewportCamera::updateFrustum()
+{
+ frustum_.update(*this);
+}
+
+QVector3D ViewportCamera::center() const
+{
+ return center_;
+}
+
+QVector3D ViewportCamera::eye() const
+{
+ return eye_;
+}
+
+QVector3D ViewportCamera::up() const
+{
+ return up_;
+}
+
+QSizeF ViewportCamera::viewSize() const
+{
+ return viewSize_;
+}
+
+double ViewportCamera::aspectRatio() const
+{
+ return aspectRatio_;
+}
+
+double ViewportCamera::nearPlane() const
+{
+ return nearPlane_;
+}
+
+double ViewportCamera::farPlane() const
+{
+ return farPlane_;
+}
+
+QGLCamera* ViewportCamera::toGLCamera() const
+{
+ return camera_;
+}
+
+Frustum ViewportCamera::toFrustum() const
+{
+ return frustum_;
+}
diff --git a/src/location/mapsgl/map3d/viewportcamera_p.h b/src/location/mapsgl/map3d/viewportcamera_p.h
new file mode 100644
index 00000000..01f0f52a
--- /dev/null
+++ b/src/location/mapsgl/map3d/viewportcamera_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef VIEWPORTCAMERA_P_H
+#define VIEWPORTCAMERA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QSizeF>
+#include <QVector3D>
+
+#include "spheregeometry_p.h"
+#include "cameradata.h"
+#include "frustum_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Projection3D;
+
+class QGLCamera;
+
+class Q_AUTOTEST_EXPORT ViewportCamera {
+public:
+ ViewportCamera();
+ ~ViewportCamera();
+
+ void setProjection(Projection3D *projection);
+
+// void setSphere(const SphereGeometry &sphere);
+
+ void setCameraData(const CameraData &cameraData);
+
+ QVector3D center() const;
+ QVector3D eye() const;
+ QVector3D up() const;
+ QSizeF viewSize() const;
+ double aspectRatio() const;
+ double nearPlane() const;
+ double farPlane() const;
+
+ QGLCamera* toGLCamera() const;
+ Frustum toFrustum() const;
+
+private:
+ void updateGLCamera();
+ void updateFrustum();
+
+// SphereGeometry sphere_;
+ Projection3D *projection_;
+
+ QVector3D center_;
+ QVector3D eye_;
+ QVector3D up_;
+ QSizeF viewSize_;
+ double aspectRatio_;
+ double nearPlane_;
+ double farPlane_;
+
+ QGLCamera* camera_;
+ Frustum frustum_;
+};
+
+QT_END_NAMESPACE
+
+#endif // VIEWPORTCAMERA_P_H
diff --git a/src/location/mapsgl/map3d/viewporttiles.cpp b/src/location/mapsgl/map3d/viewporttiles.cpp
new file mode 100644
index 00000000..8dcc8774
--- /dev/null
+++ b/src/location/mapsgl/map3d/viewporttiles.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "viewporttiles_p.h"
+#include "viewporttiles_p_p.h"
+
+#include "viewporttilesold_p.h"
+#include "viewporttilesnew_p.h"
+
+#include "tilespec.h"
+#include "cameradata.h"
+#include "spheregeometry_p.h"
+#include "sphere_p.h"
+
+#include <QVector2D>
+#include <QVector>
+
+ViewportTiles::ViewportTiles(int codePath)
+{
+ if (codePath == 1) {
+ d_ptr = new ViewportTilesPrivateOld();
+ } else {
+ d_ptr = new ViewportTilesPrivateNew();
+ }
+}
+
+ViewportTiles::~ViewportTiles()
+{
+ delete d_ptr;
+}
+
+void ViewportTiles::setZoomLevel(int zoomLevel)
+{
+ d_ptr->setZoomLevel(zoomLevel);
+}
+
+int ViewportTiles::zoomLevel() const
+{
+ return d_ptr->zoomLevel();
+}
+
+void ViewportTiles::setSphere(const SphereGeometry &sphere)
+{
+ d_ptr->setSphere(sphere);
+}
+
+QList<TileSpec> ViewportTiles::visibleTiles(const ViewportCamera &viewportCamera) const
+{
+ return d_ptr->visibleTiles(viewportCamera);
+}
+
+ViewportTilesPrivate::ViewportTilesPrivate()
+{
+}
+
+ViewportTilesPrivate::~ViewportTilesPrivate()
+{
+}
+
+void ViewportTilesPrivate::setZoomLevel(int zoomLevel)
+{
+ zoomLevel_ = zoomLevel;
+}
+
+int ViewportTilesPrivate::zoomLevel() const
+{
+ return zoomLevel_;
+}
+
+void ViewportTilesPrivate::setSphere(const SphereGeometry &sphere)
+{
+ sphere_ = sphere;
+}
+
+SphereGeometry ViewportTilesPrivate::sphere() const
+{
+ return sphere_;
+}
+
+bool sorter(const QPair<double, int> &v1, const QPair<double, int> &v2)
+{
+ return v1.first < v2.first;
+}
+
+struct TileMap2
+{
+ int minY;
+ int maxY;
+ QHash<int, QPair<int, int> > range;
+
+ void adjust(int tileX, int tileY);
+};
+
+void TileMap2::adjust(int tileX, int tileY)
+{
+ if (minY == -1)
+ minY = tileY;
+ if (maxY == -1)
+ maxY = tileY;
+
+ minY = qMin(minY, tileY);
+ maxY = qMax(maxY, tileY);
+
+ if (range.contains(tileY)) {
+ QPair<int,int> r = range[tileY];
+ range[tileY] = QPair<int, int>(qMin(r.first, tileX), qMax(r.second, tileX));
+ } else {
+ range[tileY] = QPair<int, int>(tileX, tileX);
+ }
+}
+
+/*
+ This function returns the tiles that are touched by the line
+ running from start to end at zoom level zoom.
+
+ We first determine the tiles that the start and end points are in,
+ and from that we determine the minumum and maximum tile x and tile y values.
+
+ Between the minimum and maximum y values we calculate the points at which
+ the line intersects the tile boundaries.
+
+ The tile y value is entirely determined by the y value of the point, and
+ we do some algebra to find the the point of intersection for a give tile y value.
+
+ For each intersection we store the fraction of the way along the
+ line from start-end the intersection occurs and what the new tile y value
+ should be. These are stored in a QList<<QPair<double, int> >
+
+ There is a slight difference between the case of ascending and
+ descending y values and which tile value should be stored, which is accounted for.
+
+ We do something similar for the x values, although in this case the ratio of
+ the x and z values determines where the line of intersection is.
+
+ We have to treat x > z and x < z as special cases to avoid dividing by zero.
+
+ We sort both QList<<QPair<double, int> > by the double value and initialise tileX
+ and tileY to the tile values of the starting point.
+
+ We then look at the double values at the start of both lists. If one is smaller than
+ the other we take it from the list, update tileX or tileY appropriately, and add it to
+ the list of resulting tiles. If both values are equal we need to add (tileX, newTileY),
+ (newTileX, tileY) and (newTileX, newTileY) to the results.
+
+ If either of the lists is exhausted we can just add anything that remains in the other list.
+*/
+void ViewportTilesPrivate::tilesFromArc(const Arc &arc, bool roundUp, TileMap2 &map) const
+{
+ QVector3D start = arc.start();
+ QVector3D end = arc.end();
+
+ int zpow2 = 1 << zoomLevel_;
+
+ QVector2D t1 = sphere().pointToTile(start, zoomLevel_, roundUp);
+ QVector2D t2 = sphere().pointToTile(end, zoomLevel_, roundUp);
+
+ QVector<QPair<double, int> > yVals(qAbs(t1.y() - t2.y()) + 2);
+ int yIndex = -1;
+
+ yVals[++yIndex] = QPair<double, int>(0.0, t1.y());
+ yVals[++yIndex] = QPair<double, int>(1.0, t2.y());
+
+ int yStep = t2.y() - t1.y();
+
+ if (yStep != 0) {
+
+ yStep /= qAbs(yStep);
+
+ int yAdjust = 0;
+
+ int startY = t1.y();
+ int endY = t2.y();
+ if (yStep < 0) {
+ yAdjust = -1;
+ } else {
+ ++startY;
+ ++endY;
+ }
+
+ for (int y = startY; y != endY; y += yStep) {
+ QVector3D p = sphere().mercatorToPoint(zpow2 / 2.0, y * 1.0 / zpow2);
+ QPair<double, double> factors = arc.yIntersectFactor(p.y());
+
+ bool found = false;
+ double tf;
+
+ if (factors.first != -1.0) {
+ found = true;
+ tf = factors.first;
+
+ if (factors.second != -1.0) {
+ double e1 = qAbs(p.y() - arc.interpolate(factors.first).y());
+ double e2 = qAbs(p.y() - arc.interpolate(factors.second).y());
+ if (e2 < e1)
+ tf = factors.second;
+ }
+ }
+
+ if (found) {
+ yVals[++yIndex] = QPair<double, int>(tf, y + yAdjust);
+// qWarning() << "y " << y << " factor " << tf << te;
+// } else {
+// qWarning() << " no y solution for " << y;
+ }
+ }
+
+ }
+
+ yVals.resize(yIndex + 1);
+ qSort(yVals.begin(), yVals.end(), sorter);
+
+ QVector<QPair<double, int> > xVals(qAbs(t1.x() - t2.x()) + 2);
+ int xIndex = -1;
+
+ xVals[++xIndex] = QPair<double, int>(0.0, t1.x());
+ xVals[++xIndex] = QPair<double, int>(1.0, t2.x());
+
+ int xStep = t2.x() - t1.x();
+
+ if (xStep != 0) {
+
+ xStep /= qAbs(xStep);
+
+ int xAdjust = 0;
+
+ int startX = t1.x();
+ int endX = t2.x();
+ if (xStep < 0) {
+ xAdjust = -1;
+ } else {
+ ++startX;
+ ++endX;
+ }
+
+ for (int x = startX; x != endX; x += xStep) {
+ QVector3D p = sphere().mercatorToPoint(x * 1.0 / zpow2, zpow2 / 2.0);
+ QPair<double, double> factors = arc.tIntersectFactor(p.x(), p.z());
+
+ double t;
+ if (qAbs(p.x()) < qAbs(p.z()))
+ t = p.x() / p.z();
+ else
+ t = p.z() / p.x();
+
+ bool found = false;
+ double tf;
+
+ if (factors.first != -1.0) {
+ found = true;
+ tf = factors.first;
+
+ if (factors.second != -1.0) {
+ QVector3D v = arc.interpolate(factors.first);
+ double e1 = 0.0;
+ if (qAbs(v.x()) < qAbs(v.z()))
+ e1 = qAbs(t - v.x() / v.z());
+ else
+ e1 = qAbs(t - v.z() / v.x());
+
+ v = arc.interpolate(factors.second);
+
+ double e2 = 0.0;
+ if (qAbs(v.x()) < qAbs(v.z()))
+ e2 = qAbs(t - v.x() / v.z());
+ else
+ e2 = qAbs(t - v.z() / v.x());
+
+ if (e2 < e1)
+ tf = factors.second;
+ }
+ }
+
+ if (found) {
+ xVals[++xIndex] = QPair<double, int>(tf, x + xAdjust);
+// qWarning() << "x " << x << " factor " << tf << te;
+// } else {
+// qWarning() << " no x solution for " << x;
+ }
+ }
+ }
+
+ xVals.resize(xIndex + 1);
+ qSort(xVals.begin(), xVals.end(), sorter);
+
+ int tileX = t1.x();
+ int tileY = t1.y();
+
+ int ySize = yVals.size();
+ int xSize = xVals.size();
+ yIndex = 0;
+ xIndex = 0;
+
+ map.adjust(tileX, tileY);
+
+ while ((xIndex != xSize) && (yIndex != ySize)) {
+ QPair<double, int> x = xVals.at(xIndex);
+ QPair<double, int> y = yVals.at(yIndex);
+ if (x.first < y.first) {
+ tileX = xVals.at(xIndex++).second;
+ map.adjust(tileX, tileY);
+ } else if (x.first > y.first) {
+ tileY = yVals.at(yIndex++).second;
+ map.adjust(tileX, tileY);
+ } else {
+ int tileX2 = xVals.at(xIndex++).second;
+ int tileY2 = yVals.at(yIndex++).second;
+ map.adjust(tileX, tileY2);
+ map.adjust(tileX2, tileY);
+ tileX = tileX2;
+ tileY = tileY2;
+ map.adjust(tileX, tileY);
+ }
+ }
+
+ for (int x = xIndex; x < xSize; ++x) {
+ tileX = xVals.at(x).second;
+ map.adjust(tileX, tileY);
+ }
+
+ for (int y = yIndex; y < ySize; ++y) {
+ tileY = yVals.at(y).second;
+ map.adjust(tileX, tileY);
+ }
+}
+
+/*
+ This function takes a list of points at which the view frustum intersects the world sphere,
+ and returns the list of visible tiles that are bounded by that list of points.
+
+ It is assumed that the polygon described by the list of points doesn't cross the dateline
+ or contain a pole. The visibleTiles(int zoom) function takes care of that.
+
+ The tiles along the line for each of the points are gathered, and from that we can
+ determine which tiles are contained in the polygon.
+
+ The minumum and maximum tile y values are found by a linear scan, after which we
+ determine the minimum and maximum x values for each of the y values. We request all of the
+ tile with that y value which have an x value between the minimum and maximum x values (inclusive).
+*/
+QList<TileSpec> ViewportTilesPrivate::tilesFromSpherePatch(const SpherePatch &patch) const
+{
+ QList<TileSpec> results;
+
+ int numArcs = patch.arcCount();
+
+ if (numArcs == 0)
+ return results;
+
+ TileMap2 map;
+ map.minY = -1;
+ map.maxY = -1;
+
+ for (int i = 0; i < numArcs; ++i) {
+ tilesFromArc(patch.arc(i), patch.roundUpTiles(), map);
+ }
+
+ int minY = map.minY;
+ int maxY = map.maxY;
+
+
+ for (int y = minY; y <= maxY; ++y) {
+ if (!map.range.contains(y))
+ continue;
+ int minX = map.range[y].first;
+ int maxX = map.range[y].second;
+ for (int x = minX; x <= maxX; ++x) {
+ results << TileSpec(zoomLevel_, x, y);
+ }
+ }
+
+ return results;
+}
+
+QList<TileSpec> ViewportTilesPrivate::tilesFromSphere(const Sphere &sphere) const
+{
+ QList<TileSpec> tiles;
+
+// qWarning() << "sphere";
+// qWarning() << sphere;
+
+ int numPatches = sphere.patches().size();
+ for (int i = 0; i < numPatches; ++i) {
+ tiles.append(tilesFromSpherePatch(sphere.patches().at(i)));
+ }
+
+ return tiles;
+}
diff --git a/src/location/maps/qgeomapobjectinfo_p.h b/src/location/mapsgl/map3d/viewporttiles_p.h
index 646f6355..04b1da19 100644
--- a/src/location/maps/qgeomapobjectinfo_p.h
+++ b/src/location/mapsgl/map3d/viewporttiles_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOMAPOBJECTINFO_P_H
-#define QGEOMAPOBJECTINFO_P_H
+#ifndef VIEWPORTTILES_P_H
+#define VIEWPORTTILES_P_H
//
// W A R N I N G
@@ -53,26 +52,31 @@
// We mean it.
//
-#include "qmobilityglobal.h"
+#include <QList>
QT_BEGIN_NAMESPACE
-class QGeoMapObject;
-class QGeoMapData;
+class ViewportTilesPrivate;
+class SphereGeometry;
+class TileSpec;
+class ViewportCamera;
-class QGeoMapObjectInfoPrivate
-{
+class ViewportTiles {
public:
- QGeoMapObjectInfoPrivate(QGeoMapData *mapData, QGeoMapObject *mapObject);
- virtual ~QGeoMapObjectInfoPrivate();
+ ViewportTiles(int codePath = 1);
+ ~ViewportTiles();
+
+ void setZoomLevel(int zoomLevel);
+ int zoomLevel() const;
+
+ void setSphere(const SphereGeometry &sphere);
- QGeoMapData* mapData;
- QGeoMapObject* mapObject;
+ QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
private:
- Q_DISABLE_COPY(QGeoMapObjectInfoPrivate)
+ ViewportTilesPrivate *d_ptr;
};
QT_END_NAMESPACE
-#endif
+#endif // VIEWPORTTILES_P_H
diff --git a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h b/src/location/mapsgl/map3d/viewporttiles_p_p.h
index 23e33b76..64f6c3fd 100644
--- a/src/location/maps/tiled/qgeotiledmappolylineobjectinfo_p.h
+++ b/src/location/mapsgl/map3d/viewporttiles_p_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
-#define QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
+#ifndef VIEWPORTTILES_P_P_H
+#define VIEWPORTTILES_P_P_H
//
// W A R N I N G
@@ -53,36 +52,44 @@
// We mean it.
//
-#include "qgeotiledmapobjectinfo_p.h"
+#include <QList>
-#include <QPen>
-#include <QPolygonF>
+#include "spheregeometry_p.h"
+#include "tilespec.h"
QT_BEGIN_NAMESPACE
-class QGraphicsPathItem;
-class QPointF;
+class ViewportCamera;
+
+class Sphere;
+class SpherePatch;
+class Arc;
-class QGeoMapPolylineObject;
+struct TileMap2;
-class QGeoTiledMapPolylineObjectInfo : public QGeoTiledMapObjectInfo
-{
- Q_OBJECT
+class ViewportTilesPrivate {
public:
- QGeoTiledMapPolylineObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapPolylineObjectInfo();
+ ViewportTilesPrivate();
+ virtual ~ViewportTilesPrivate();
+
+ void setZoomLevel(int zoomLevel);
+ int zoomLevel() const;
- QGeoMapPolylineObject *polyline;
- QGraphicsPathItem *pathItem;
+ void setSphere(const SphereGeometry &sphere);
+ SphereGeometry sphere() const;
-public slots:
- void pathChanged(const QList<QGeoCoordinate> &path);
- void penChanged(const QPen &pen);
+ virtual QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const = 0;
+
+ QList<TileSpec> tilesFromSphere(const Sphere &sphere) const;
private:
- void genPath();
+ QList<TileSpec> tilesFromSpherePatch(const SpherePatch &patch) const;
+ void tilesFromArc(const Arc &arc, bool roundUp, TileMap2 &map) const;
+
+ int zoomLevel_;
+ SphereGeometry sphere_;
};
QT_END_NAMESPACE
-#endif //QGEOTILEDMAPPOLYLINEOBJECT_INFO_P_H
+#endif // VIEWPORTTILES_P_P_H
diff --git a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp b/src/location/mapsgl/map3d/viewporttilesnew.cpp
index 405af88e..e2df4680 100644
--- a/src/location/maps/tiled/qgeotiledmappixmapobjectinfo_p.cpp
+++ b/src/location/mapsgl/map3d/viewporttilesnew.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,59 +38,66 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "viewporttilesnew_p.h"
-#include "qgeotiledmappixmapobjectinfo_p.h"
+#include "viewportcamera_p.h"
-#include "qgeotiledmapdata.h"
-#include "qgeotiledmapdata_p.h"
-
-#include "qgeomappixmapobject.h"
+#include "sphere_p.h"
QT_BEGIN_NAMESPACE
-QGeoTiledMapPixmapObjectInfo::QGeoTiledMapPixmapObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject)
- : QGeoTiledMapObjectInfo(mapData, mapObject)
-{
- pixmap = static_cast<QGeoMapPixmapObject*>(mapObject);
-
- connect(pixmap,
- SIGNAL(pixmapChanged(QPixmap)),
- this,
- SLOT(pixmapChanged(QPixmap)));
- connect(pixmap,
- SIGNAL(offsetChanged(QPoint)),
- this,
- SLOT(offsetChanged(QPoint)));
-
- pixmapItem = new QGraphicsPixmapItem();
- graphicsItem = pixmapItem;
-
- originChanged(this->pixmap->origin());
- pixmapChanged(this->pixmap->pixmap());
- offsetChanged(this->pixmap->offset());
-}
+ViewportTilesPrivateNew::ViewportTilesPrivateNew()
+ : debug_(false) {}
-QGeoTiledMapPixmapObjectInfo::~QGeoTiledMapPixmapObjectInfo() {}
+ViewportTilesPrivateNew::~ViewportTilesPrivateNew() {}
-void QGeoTiledMapPixmapObjectInfo::pixmapChanged(const QPixmap &/*pixmap*/)
+QList<TileSpec> ViewportTilesPrivateNew::visibleTiles(const ViewportCamera &viewportCamera) const
{
- pixmapItem->setPixmap(this->pixmap->pixmap());
- pixmapItem->setScale(1.0);
- updateItem();
-}
+ Frustum frustum = viewportCamera.toFrustum();
-void QGeoTiledMapPixmapObjectInfo::offsetChanged(const QPoint &/*offset*/)
-{
- QPoint offset = pixmap->offset();
+ Sphere sphere = Sphere(this->sphere().radius());
- QTransform trans;
- trans.translate(offset.x(), offset.y());
- pixmapItem->setTransform(trans);
+ if (debug_)
+ qWarning() << "sphere " << sphere;
- updateItem();
-}
+ sphere.intersect(frustum.plane(Frustum::Far));
-#include "moc_qgeotiledmappixmapobjectinfo_p.cpp"
+ if (debug_)
+ qWarning() << "sphere (far)" << sphere;
-QT_END_NAMESPACE
+ sphere.intersect(frustum.plane(Frustum::Left));
+
+ if (debug_)
+ qWarning() << "sphere (left)" << sphere;
+
+ sphere.intersect(frustum.plane(Frustum::Top));
+
+ if (debug_)
+ qWarning() << "sphere (top)" << sphere;
+
+ sphere.intersect(frustum.plane(Frustum::Right));
+ if (debug_)
+ qWarning() << "sphere (right)" << sphere;
+
+ sphere.intersect(frustum.plane(Frustum::Bottom));
+
+ if (debug_)
+ qWarning() << "sphere (bottom)" << sphere;
+
+ sphere.intersect(frustum.plane(Frustum::Near));
+
+ if (debug_)
+ qWarning() << "sphere (near)" << sphere;
+
+ QList<TileSpec> tiles = tilesFromSphere(sphere);
+
+ if (debug_) {
+ for (int i = 0; i < tiles.size(); ++i)
+ qWarning() << " " << tiles.at(i).x() << tiles.at(i).y();
+ }
+
+ return tiles;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapoverlay_p.h b/src/location/mapsgl/map3d/viewporttilesnew_p.h
index 491006b1..33214ab4 100644
--- a/src/location/maps/qgeomapoverlay_p.h
+++ b/src/location/mapsgl/map3d/viewporttilesnew_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOMAPOVERLAY_P_H
-#define QGEOMAPOVERLAY_P_H
+#ifndef VIEWPORTTILESNEW_P_H
+#define VIEWPORTTILESNEW_P_H
//
// W A R N I N G
@@ -53,24 +52,17 @@
// We mean it.
//
-#include "qmobilityglobal.h"
-
-QT_BEGIN_NAMESPACE
+#include "viewporttiles_p_p.h"
-class QGeoMapData;
-
-class QGeoMapOverlayPrivate
-{
+class ViewportTilesPrivateNew : public ViewportTilesPrivate {
public:
- QGeoMapOverlayPrivate();
- virtual ~QGeoMapOverlayPrivate();
+ ViewportTilesPrivateNew();
+ ~ViewportTilesPrivateNew();
- QGeoMapData *mapData;
+ QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
private:
- Q_DISABLE_COPY(QGeoMapOverlayPrivate)
+ bool debug_;
};
-QT_END_NAMESPACE
-
-#endif
+#endif // VIEWPORTTILESNEW_P_H
diff --git a/src/location/mapsgl/map3d/viewporttilesold.cpp b/src/location/mapsgl/map3d/viewporttilesold.cpp
new file mode 100644
index 00000000..e1cb4943
--- /dev/null
+++ b/src/location/mapsgl/map3d/viewporttilesold.cpp
@@ -0,0 +1,690 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "viewporttilesold_p.h"
+
+#include "sphere_p.h"
+#include "tilespec.h"
+#include "viewportcamera_p.h"
+
+#include <QLinkedList>
+#include <QVector2D>
+
+#include <cmath>
+
+ViewportTilesPrivateOld::ViewportTilesPrivateOld() {}
+
+ViewportTilesPrivateOld::~ViewportTilesPrivateOld() {}
+
+QList<TileSpec> ViewportTilesPrivateOld::visibleTiles(const ViewportCamera &viewportCamera) const
+{
+ Frustum frustum = viewportCamera.toFrustum();
+
+ int lineIntersections = 0;
+
+ QList<Arc> points = pointIntersections(frustum, &lineIntersections);
+
+ if (lineIntersections < 3) {
+ return visibleTilesFromPlanes(viewportCamera);
+ }
+
+ return tilesFromSphere(sphereFromArcs(points));
+}
+
+Sphere ViewportTilesPrivateOld::sphereFromArcs(QList<Arc> &arcs) const
+{
+ QList<int> zeroIndices = addDatelineCrossings(arcs);
+
+ int zeroes = zeroIndices.size();
+
+ if (zeroes == 0) {
+ QList<SpherePatch> patches;
+ patches << SpherePatch(sphere().radius(), arcs, false);
+ return Sphere(sphere().radius(), patches);
+ } else if (zeroes == 1) {
+ return sphereForPole(arcs, zeroIndices.at(0));
+ } else if (zeroes == 2) {
+ return sphereForDateline(arcs, zeroIndices.at(0), zeroIndices.at(1));
+ } else {
+ qWarning() << "zeroes: " << zeroes;
+ return Sphere(sphere().radius());
+ }
+}
+
+/*
+ We assume we a have a polygon with a pole in the middle, and a point on the dateline.
+
+ We split the polygon into two, and then add copies of each point shifted up into the
+ tile in the first or last row of tiles (for the north or south pole respectively) in
+ reverse order.
+
+ This is pretty buggy at present.
+*/
+Sphere ViewportTilesPrivateOld::sphereForPole(const QList<Arc> &arcs, int zeroIndex1) const
+{
+// QVector3D northPole = QVector3D(0, sphere().radius(), 0);
+// QVector3D southPole = QVector3D(0, -1.0 * sphere().radius(), 0);
+
+// qWarning() << "north";
+// for (int i = 0; i < size; ++i) {
+// qWarning() << " " << arcs.at(i).plane().distanceTo(northPole);
+// }
+
+// qWarning() << "south";
+// for (int i = 0; i < size; ++i) {
+// qWarning() << " " << arcs.at(i).plane().distanceTo(southPole);
+// }
+
+ int size = arcs.size();
+ double y = 0.0;
+ for (int i = 0; i < size; ++i) {
+ y += arcs.at(i).start().y();
+ }
+
+ int z = 1 << zoomLevel();
+ double newY = 0.5 / z;
+ if (y < 0.0)
+ newY = (z - 0.5) / z;
+
+ QPlane3D datelinePlane(QVector3D(0.0, 0.0, 0.0),
+ QVector3D(0.0, 0.0, 1.0));
+
+ double topY = sphere().mercatorToPoint(0, newY).y();
+
+ QPlane3D topPlane(QVector3D(0.0, topY, 0.0),
+ QVector3D(0.0, -1.0, 0.0));
+
+ QList<SpherePatch> patches;
+
+ QList<Arc> patch1;
+
+ for (int i = zeroIndex1; i < zeroIndex1 + size; ++i) {
+ int index = i % size;
+ patch1 << arcs.at(index);
+ }
+
+ QList<Arc> patch2;
+
+ for (int i = zeroIndex1; i < zeroIndex1 + size; ++i) {
+ int index = size - (i % size) - 1;
+
+ QVector2D start = sphere().pointToMercator(arcs.at(index).end());
+ QVector2D end = sphere().pointToMercator(arcs.at(index).start());
+
+ QVector3D start2 = sphere().mercatorToPoint(start.x(), newY);
+ QVector3D end2 = sphere().mercatorToPoint(end.x(), newY);
+
+ Arc a = Arc(topPlane, sphere().radius(), start2, end2);
+
+ patch2 << a;
+ }
+
+ Arc endCap1 = Arc(datelinePlane, sphere().radius(), patch1.last().end(), patch2.first().start());
+ Arc endCap2 = Arc(datelinePlane, sphere().radius(), patch2.last().end(), patch1.first().start());
+
+ QList<Arc> patch;
+
+ patch.append(patch1);
+ patch.append(endCap1);
+ patch.append(patch2);
+ patch.append(endCap2);
+
+ patches << SpherePatch(sphere().radius(), patch, false);
+
+ return Sphere(sphere().radius(), patches);
+}
+
+// This assumes that addDatelineCrossings has already been called, in which
+// case the polygon points will have points on the dateline instead of lines
+// crossing the dateline.
+
+// In that case we just need to split the polygon into two - one before the dateline
+// and one after the dateline - and add the visible tiles for both polygons.
+Sphere ViewportTilesPrivateOld::sphereForDateline(const QList<Arc> &arcs, int zeroIndex1, int zeroIndex2) const
+{
+ QList<SpherePatch> patches;
+
+ int size = arcs.size();
+
+ QList<Arc> lines1;
+ bool roundUp1 = false;
+ for (int i = zeroIndex1; i < zeroIndex2; ++i) {
+ Arc v = arcs.at(i);
+ if ((i != zeroIndex1) && (v.start().x() < 0))
+ roundUp1 = true;
+ lines1.append(v);
+ }
+
+ QPlane3D datelinePlane(QVector3D(0.0, 0.0, 0.0),
+ QVector3D(0.0, 0.0, 1.0));
+
+ lines1 << Arc(datelinePlane, sphere().radius(), lines1.last().end(), lines1.first().start());
+
+ patches << SpherePatch(sphere().radius(), lines1, roundUp1);
+
+ QList<Arc> lines2;
+ bool roundUp2 = false;
+ for (int i = zeroIndex2; i < zeroIndex1 + size; ++i) {
+ int index = i % size;
+ Arc v = arcs.at(index);
+ if ((i != zeroIndex2) && (v.start().x() < 0))
+ roundUp2 = true;
+ lines2.append(v);
+ }
+
+ lines2 << Arc(datelinePlane, sphere().radius(), lines2.last().end(), lines2.first().start());
+
+ patches << SpherePatch(sphere().radius(), lines2, roundUp2);
+
+ return Sphere(sphere().radius(), patches);
+}
+
+QList<int> ViewportTilesPrivateOld::addDatelineCrossings(QList<Arc> &points) const
+{
+ QList<int> results;
+
+ for (int i = 0; i < points.size(); ++i) {
+ Arc p = points.at(i);
+ QPair<double, double> factors = p.xIntersectFactor(0.0);
+
+ bool found = false;
+ double tf;
+ double te = 0.0;
+
+ if ((factors.first > 0.0) && (factors.first < 1.0)) {
+ QVector3D v = p.interpolate(factors.first);
+ if ((qAbs(v.x()) / sphere().radius() < 1e-6) && (v.z() >= 0.0)) {
+ found = true;
+ tf = factors.first;
+ te = qAbs(v.x());
+ }
+ }
+
+ if ((factors.second > 0.0) && (factors.second < 1.0)) {
+ QVector3D v = p.interpolate(factors.second);
+ if ((qAbs(v.x()) / sphere().radius() < 1e-6) && (v.z() >= 0.0)) {
+ if (!found || (qAbs(v.x()) < te)) {
+ found = true;
+ tf = factors.second;
+ }
+ }
+ }
+
+// for (int j = 0; j < factors.size(); ++j) {
+// double n = factors.at(j);
+// if ((n == 0.0) || (n == 1.0))
+// continue;
+
+// QVector3D v = p.interpolate(n);
+
+// double relativeError = qAbs(v.x() / sphere().radius());
+
+//// qWarning() << " checked " << i << n << v.x() << v.z() << relativeError;
+
+// if ((relativeError < 1e-6) && (v.z() >= 0)) {
+// double e = qAbs(v.x());
+// if (!found || (e < te)) {
+// tf = n;
+// te = e;
+// found = true;
+// }
+// }
+// }
+
+ if (found) {
+ QVector3D v = p.interpolate(tf);
+
+ qWarning() << " found " << tf << v.x() << v.z();
+
+ Arc q = p;
+ p.setEnd(v);
+ points[i] = p;
+ q.setStart(v);
+ points.insert(i + 1, q);
+ ++i;
+ results << i;
+ }
+ }
+
+ return results;
+
+// QVector3D s = points.at(i)
+// QVector3D e = points.at((i + 1) % points.size());
+// if ((s.x() != 0.0) && (e.x() != 0) && (s.x() != e.x())) {
+// double n = s.x() / (s.x() - e.x());
+// QVector3D v = (1.0 - n) * s + n * e;
+// if ((v.z() >= 0.0) && (0.0 <= n) && (n <= 1.0))
+// points.insert(i + 1, v);
+// }
+}
+
+bool ViewportTilesPrivateOld::LengthSorter::operator()(const IntersectionPoint &lhs, const IntersectionPoint &rhs)
+{
+ bool lPlane = (lhs.planes & base.planes);
+ bool rPlane = (rhs.planes & base.planes);
+ if (lPlane == rPlane)
+ return (lhs.point - base.point).lengthSquared() < (rhs.point - base.point).lengthSquared();
+ else
+ return lPlane;
+}
+
+/*
+ We find all of the points of intersection between the earth sphere and
+ the lines along the edges of the view frustum.
+
+ We then sort them so that form a polygon. The last point becomes
+ the first result. We then sort the points by distance^2 from the last
+ result, and the nearest point becomes the last result.
+*/
+QList<Arc> ViewportTilesPrivateOld::pointIntersections(const Frustum &frustum, int *linesIntersected) const
+{
+ QList<ViewportTilesPrivateOld::IntersectionPoint> points;
+
+ if (linesIntersected)
+ *linesIntersected = 0;
+
+ double radius = sphere().radius();
+
+ QList<ViewportTilesPrivateOld::IntersectionPoint> v;
+
+ v = lineIntersectsSphere(radius,
+ frustum.topLeftNear(),
+ frustum.topLeftFar(),
+ Frustum::TopLeftNear,
+ Frustum::TopLeftFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.topRightNear(),
+ frustum.topRightFar(),
+ Frustum::TopRightNear,
+ Frustum::TopRightFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomRightNear(),
+ frustum.bottomRightFar(),
+ Frustum::BottomRightNear,
+ Frustum::BottomRightFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomLeftNear(),
+ frustum.bottomLeftFar(),
+ Frustum::BottomLeftNear,
+ Frustum::BottomLeftFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.topLeftFar(),
+ frustum.topRightFar(),
+ Frustum::TopLeftFar,
+ Frustum::TopRightFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.topRightFar(),
+ frustum.bottomRightFar(),
+ Frustum::TopRightFar,
+ Frustum::BottomRightFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomRightFar(),
+ frustum.bottomLeftFar(),
+ Frustum::BottomRightFar,
+ Frustum::BottomLeftFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomLeftFar(),
+ frustum.topLeftFar(),
+ Frustum::BottomLeftFar,
+ Frustum::TopLeftFar);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.topLeftNear(),
+ frustum.topRightNear(),
+ Frustum::TopLeftNear,
+ Frustum::TopRightNear);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.topRightNear(),
+ frustum.bottomRightNear(),
+ Frustum::TopRightNear,
+ Frustum::BottomRightNear);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomRightNear(),
+ frustum.bottomLeftNear(),
+ Frustum::BottomRightNear,
+ Frustum::BottomLeftNear);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ v = lineIntersectsSphere(radius,
+ frustum.bottomLeftNear(),
+ frustum.topLeftNear(),
+ Frustum::BottomLeftNear,
+ Frustum::TopLeftNear);
+ if (linesIntersected && !v.isEmpty())
+ ++(*linesIntersected);
+ points.append(v);
+
+ QList<Arc> results;
+
+ if (points.isEmpty())
+ return results;
+
+ LengthSorter sorter;
+ sorter.base = points.first();
+ qSort(points.begin(), points.end(), sorter);
+ for (int i = points.size() - 1; i > 0; --i) {
+ if (points.at(i).point == points.at(i - 1).point)
+ points.removeAt(i);
+ }
+
+ QList<ViewportTilesPrivateOld::IntersectionPoint>::iterator i;
+ for (i = points.begin(); i != points.end(); ++i) {
+ sorter.base = *i;
+ if (i + 1 != points.end())
+ qSort(i + 1, points.end(), sorter);
+ }
+
+ QVector3D origin;
+
+
+ int size = points.size();
+ for (int i = 0; i < size; ++i) {
+ ViewportTilesPrivateOld::IntersectionPoint a = points.at(i);
+ ViewportTilesPrivateOld::IntersectionPoint b = points.at((i + 1) % size);
+
+
+ QPlane3D plane = frustum.plane(a.planes & b.planes);
+ if (plane.origin() != origin)
+ results << Arc(plane, sphere().radius(), a.point, b.point);
+
+// if (plane.origin() == origin) {
+// result.center = origin;
+// result.radius = sphere_.radius();
+// } else {
+// results << Arc(plane, sphere_.radius(), a.point, b.point);
+// result.center = -1.0 * plane.distanceTo(origin) * plane.normal().normalized();
+// result.radius = sqrt(sphere_.radius() * sphere_.radius() - result.center().lengthSquared());
+// }
+// result.setStart(a.point);
+// result.setEnd(b.point);
+
+// results << result;
+ }
+
+ return results;
+}
+
+/*
+ This returns the points along the line from start to end that intersect a sphere with radius \a radius.
+
+ It returns the intersection in order of proximity to start.
+*/
+QList<ViewportTilesPrivateOld::IntersectionPoint> ViewportTilesPrivateOld::lineIntersectsSphere(double radius,
+ const QVector3D &start,
+ const QVector3D &end,
+ Frustum::Planes planesStart,
+ Frustum::Planes planesEnd)
+{
+ QVector3D v = end - start;
+
+ double maxN = v.length();
+
+ v.normalize();
+
+ double b = 2 * QVector3D::dotProduct(start, v);
+ double c = start.lengthSquared() - (radius * radius);
+
+ double s = (b * b) - (4 * c);
+
+ if (s < 0)
+ return QList<ViewportTilesPrivateOld::IntersectionPoint>();
+
+ double s2 = sqrt(s);
+
+ double n1 = -1.0 * (b - s2) / 2.0;
+ if (n1 > maxN)
+ n1 = -1.0;
+ if (n1 < 0)
+ n1 = -1.0;
+
+ double n2 = -1.0 * (b + s2) / 2.0;
+ if (n2 > maxN)
+ n2 = -1.0;
+ if (n2 < 0)
+ n2 = -1.0;
+
+ if (n1 < 0.0) {
+ if (n2 >= 0)
+ n1 = n2;
+ } else if (n2 < 0) {
+ n2 = n1;
+ } else {
+ if (n2 < n1)
+ qSwap(n1, n2);
+ }
+
+ QList<ViewportTilesPrivateOld::IntersectionPoint> results;
+
+ if (n1 != -1.0) {
+ ViewportTilesPrivateOld::IntersectionPoint r1;
+
+ r1.point = interpolate(start, end, n1);
+
+ if (r1.point == start)
+ r1.planes = planesStart;
+ else if (r1.point == end)
+ r1.planes = planesEnd;
+ else
+ r1.planes = (planesStart & planesEnd);
+ results << r1;
+
+ if ((n2 != -1.0) && (n2 != n1)) {
+ ViewportTilesPrivateOld::IntersectionPoint r2;
+
+ r2.point = interpolate(start, end, n2);
+
+ if (r2.point == start)
+ r2.planes = planesStart;
+ else if (r2.point == end)
+ r2.planes = planesEnd;
+ else
+ r2.planes = (planesStart & planesEnd);
+ results << r2;
+ }
+ }
+
+ return results;
+}
+
+QVector3D ViewportTilesPrivateOld::interpolate(const QVector3D &start, const QVector3D &end, double n)
+{
+ QVector3D v = end - start;
+ v.normalize();
+ return start + n * v;
+}
+
+QPair<QVector3D, double> ViewportTilesPrivateOld::tileInfo(const TileSpec &spec) const
+{
+ int z = 1 << spec.zoom();
+
+ double xl = spec.x() * 1.0 / z;
+ double xc = (spec.x() + 0.5) / z;
+ double xr = ((spec.x() + 1) % z * 1.0) / z;
+ double yt = (spec.y() * 1.0) / z;
+ double yc = (spec.y() + 0.5) / z;
+ double yb = ((spec.y() + 1) * 1.0) / z;
+
+ QVector3D tl = sphere().mercatorToPoint(xl, yt);
+ QVector3D br = sphere().mercatorToPoint(xr, yb);
+ QVector3D c = sphere().mercatorToPoint(xc, yc);
+
+ double r = sqrt(qMax((tl - c).lengthSquared(), (br - c).lengthSquared()));
+
+ return QPair<QVector3D, double>(c, 2 * r);
+}
+
+/*
+ This is the least good of the functions in here.
+
+ It's used when we don't have enough of a frustum intersect to determine which
+ tiles to fetch analytically.
+
+ It treats tiles as spheres and then determines if the sphere is inside
+ the frustum. If it is, it considers the neighbours of the tile.
+
+ There are smarter ways to do this via plane intersection (hence the
+ function name). I'll revisit this soon.
+*/
+QList<TileSpec> ViewportTilesPrivateOld::visibleTilesFromPlanes(const ViewportCamera &viewportCamera) const
+{
+ QList<TileSpec> results;
+
+ QVector3D center = viewportCamera.center();
+ QVector3D eye = viewportCamera.eye();
+
+ QVector3D v = center - eye;
+ v.normalize();
+
+ QVector2D t = sphere().pointToTile(center, zoomLevel());
+
+ QLinkedList<TileSpec> queue;
+ QSet<TileSpec> queued;
+ QSet<TileSpec> done;
+
+ int zoom = zoomLevel();
+
+ queue << TileSpec(zoom, t.x(), t.y());
+ queued << TileSpec(zoom, t.x(), t.y());
+
+ int z = 1 << zoom;
+
+ Frustum frustum = viewportCamera.toFrustum();
+
+ while (!queue.isEmpty()) {
+ TileSpec spec = queue.takeLast();
+ QPair<QVector3D, double> info = tileInfo(spec);
+ if (frustum.contains(info.first, info.second) && (QVector3D::dotProduct(v, info.first - eye) > 0)) {
+ results << spec;
+
+ QList<TileSpec> tiles;
+
+ int xp = spec.x() - 1;
+ if (xp < 0)
+ xp = z - 1;
+ int xn = (spec.x() + 1) % z;
+
+ tiles << TileSpec(zoom, xp, spec.y());
+ tiles << TileSpec(zoom, xn, spec.y());
+
+ if (spec.y() == 0) {
+ int x2 = (spec.x() + z / 2) % z;
+ int xp2 = ((spec.x() + z / 2 - 1) % z);
+ if (xp2 < 0)
+ xp2 += z;
+ int xn2 = ((spec.x() + z / 2 + 1) % z);
+ tiles << TileSpec(zoom, xp2, spec.y());
+ tiles << TileSpec(zoom, x2, spec.y());
+ tiles << TileSpec(zoom, xn2, spec.y());
+ } else {
+ tiles << TileSpec(zoom, xp, spec.y() - 1);
+ tiles << TileSpec(zoom, spec.x(), spec.y() - 1);
+ tiles << TileSpec(zoom, xn, spec.y() - 1);
+ }
+
+ if (spec.y() == (z - 1)) {
+ int x2 = (spec.x() + z / 2) % z;
+ int xp2 = ((spec.x() + z / 2 - 1) % z);
+ if (xp2 < 0)
+ xp2 += z;
+ int xn2 = ((spec.x() + z / 2 + 1) % z);
+ tiles << TileSpec(zoom, xp2, spec.y());
+ tiles << TileSpec(zoom, x2, spec.y());
+ tiles << TileSpec(zoom, xn2, spec.y());
+ } else {
+ tiles << TileSpec(zoom, xp, spec.y() + 1);
+ tiles << TileSpec(zoom, t.x(), spec.y() + 1);
+ tiles << TileSpec(zoom, xn, spec.y() + 1);
+ }
+
+ for (int i = 0; i < tiles.size(); ++i) {
+ TileSpec ts = tiles.at(i);
+ if (!done.contains(ts) && !queued.contains(ts)) {
+ queue << ts;
+ queued << ts;
+ }
+ }
+ }
+ done << spec;
+ queued.remove(spec);
+ }
+
+ return results;
+}
diff --git a/src/location/projwrapper_p.h b/src/location/mapsgl/map3d/viewporttilesold_p.h
index e0a7040a..8a2a7414 100644
--- a/src/location/projwrapper_p.h
+++ b/src/location/mapsgl/map3d/viewporttilesold_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,10 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-
-#ifndef PROJWRAPPER_P_H
-#define PROJWRAPPER_P_H
+#ifndef VIEWPORTTILESOLD_P_H
+#define VIEWPORTTILESOLD_P_H
//
// W A R N I N G
@@ -54,76 +52,57 @@
// We mean it.
//
-#include "qmobilityglobal.h"
-#include <QSharedDataPointer>
-#include <QString>
-#include <QList>
-#include <QPolygonF>
-
-QT_BEGIN_NAMESPACE
-
-class ProjCoordinate;
-class QGeoCoordinate;
-
-class ProjCoordinateSystemPrivate;
-class ProjCoordinateSystem
-{
-public:
- ProjCoordinateSystem(const QString &projection = QString::fromLatin1("+proj=latlon +ellps=WGS84"), bool latLon=true);
- ProjCoordinateSystem(const ProjCoordinateSystem &other);
- ~ProjCoordinateSystem();
+#include "viewporttiles_p_p.h"
- bool isLatLon() const;
+#include "frustum_p.h"
-private:
- QSharedDataPointer<ProjCoordinateSystemPrivate> d;
+QT_BEGIN_NAMESPACE
- friend class ProjCoordinate;
-};
+class ViewportCamera;
-class ProjPolygon;
+class Arc;
-class ProjCoordinatePrivate;
-class ProjCoordinate
-{
+class ViewportTilesPrivateOld : public ViewportTilesPrivate {
public:
- ProjCoordinate(double x, double y, double z, const ProjCoordinateSystem &system);
- ProjCoordinate(const ProjCoordinate &other);
- ~ProjCoordinate();
+ ViewportTilesPrivateOld();
+ ~ViewportTilesPrivateOld();
- double x() const;
- double y() const;
- double z() const;
+ QList<TileSpec> visibleTiles(const ViewportCamera &viewportCamera) const;
- QGeoCoordinate toGeoCoordinate() const;
+private:
+ void calculateVisibleTiles();
- bool convert(const ProjCoordinateSystem &system);
+ class IntersectionPoint {
+ public:
+ Frustum::Planes planes;
+ QVector3D point;
+ bool operator == (const IntersectionPoint &rhs) const {
+ return ((planes == rhs.planes) && (point == rhs.point));
+ }
+ };
- ProjCoordinate &operator=(const ProjCoordinate &other);
+ class LengthSorter {
+ public:
+ IntersectionPoint base;
+ bool operator()(const IntersectionPoint &lhs, const IntersectionPoint &rhs);
+ };
-private:
- ProjCoordinatePrivate *d;
+ QList<Arc> pointIntersections(const Frustum &frustum, int *linesIntersected = 0) const;
- friend class ProjPolygon;
-};
+ Sphere sphereFromArcs(QList<Arc> &arcs) const;
-class ProjPolygonPrivate;
-class ProjPolygon : public QList<ProjCoordinate>
-{
-public:
- ProjPolygon(const ProjCoordinateSystem &system);
- ProjPolygon(const QPolygonF &poly, const ProjCoordinateSystem &system, double scale=1.0);
- ~ProjPolygon();
+ Sphere sphereForPole(const QList<Arc> &Arcs, int zeroIndex1) const;
+ Sphere sphereForDateline(const QList<Arc> &arcs, int zeroIndex1, int zeroIndex2) const;
- void scalarMultiply(double sx, double sy, double sz);
+ static QList<IntersectionPoint> lineIntersectsSphere(double radius, const QVector3D &start, const QVector3D &end, Frustum::Planes planesStart, Frustum::Planes planesEnd);
+ static QVector3D interpolate(const QVector3D &start, const QVector3D &end, double n);
- bool convert(const ProjCoordinateSystem &system);
- QPolygonF toPolygonF(double scale=1.0) const;
+ QList<int> addDatelineCrossings(QList<Arc> &points) const;
-private:
- ProjPolygonPrivate *d;
+ QPair<QVector3D, double> tileInfo(const TileSpec &spec) const;
+ QList<TileSpec> visibleTilesFromPlanes(const ViewportCamera &viewportCamera) const;
};
QT_END_NAMESPACE
-#endif // PROJWRAPPER_P_H
+#endif // VIEWPORTTILESOLD_P_H
diff --git a/src/location/mapsgl/map_p.h b/src/location/mapsgl/map_p.h
new file mode 100644
index 00000000..37aaeb9c
--- /dev/null
+++ b/src/location/mapsgl/map_p.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MAP_P_H
+#define MAP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QList>
+#include <QSet>
+
+#include "cameradata.h"
+#include "frustum_p.h"
+
+#include <QSharedPointer>
+
+class QGeoMappingManager;
+
+class Tile;
+class TileCache;
+class TileSpec;
+class Map;
+class MapSphere;
+class Projection;
+class MapItem;
+
+class QGLCamera;
+class QGLSceneNode;
+class QGLPainter;
+
+class MapPrivate
+{
+public:
+ MapPrivate(Map *parent, TileCache *cache);
+ virtual ~MapPrivate();
+
+ void setMappingManager(QGeoMappingManager *manager);
+
+ QGLCamera* glCamera() const;
+ void paintGL(QGLPainter *painter);
+
+ QSharedPointer<Projection> projection() const;
+
+ void setCameraData(const CameraData &cameraData);
+ CameraData cameraData() const;
+
+ void resize(int width, int height);
+
+ virtual QGLSceneNode* createTileNode(const Tile &tile) = 0;
+
+ void update();
+
+ int numMapItems() const;
+ MapItem* mapItem(int index) const;
+ QList<MapItem*> mapItems() const;
+ void addMapItem(MapItem *item);
+ void removeMapItem(MapItem *item);
+ void clearMapItems();
+
+ virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const = 0;
+ virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const = 0;
+
+ QVector2D pointToTile(const QVector3D &point, int zoom, bool roundUp = false) const;
+ QVector3D tileXIntersectToPoint(int zoomLevel, int x) const;
+ QVector3D tileYIntersectToPoint(int zoomLevel, int y) const;
+
+protected:
+ Frustum frustum() const;
+
+ void setProjection(const QSharedPointer<Projection> &projection);
+
+ int width() const;
+ int height() const;
+ double aspectRatio() const;
+
+ QGeoMappingManager* manager() const;
+
+private:
+ virtual void updateGlCamera(QGLCamera* glCamera) = 0;
+ virtual void updateFrustum(Frustum &frustum) = 0;
+ virtual QList<TileSpec> updateVisibleTiles() = 0;
+ virtual void updateMapItemSceneNode(MapItem *item) = 0;
+ void GLContextAvailable();
+
+ int width_;
+ int height_;
+ double aspectRatio_;
+
+ QGeoMappingManager *manager_;
+
+ QSharedPointer<Projection> projection_;
+
+ QGLCamera *glCamera_;
+ QGLSceneNode *mapSceneNode_;
+ QGLSceneNode *objectSceneNode_;
+
+ CameraData cameraData_;
+ Frustum frustum_;
+ QList<TileSpec> visibleTiles_;
+
+ MapSphere *sphere_;
+
+ QList<MapItem*> mapItems_;
+ QSet<MapItem*> obsoleteItems_;
+ QSet<MapItem*> newItems_;
+};
+
+#endif // MAP_P_H
diff --git a/src/location/mapsgl/mapitem.cpp b/src/location/mapsgl/mapitem.cpp
new file mode 100644
index 00000000..7bd98497
--- /dev/null
+++ b/src/location/mapsgl/mapitem.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "mapitem.h"
+
+#include <Qt3D/qglscenenode.h>
+#include <Qt3D/qgltexture2d.h>
+#include <Qt3D/qglmaterial.h>
+
+MapItem::MapItem()
+ : zoom_(8.0),
+ sceneNode_(0),
+ textureId_(0), // invalid value according to specs
+ textureDirty_(false),
+ texture_(0),
+ defaultMaterial_(0)
+{
+ // TODO optimize the defaultMaterial be common for all
+ defaultMaterial_ = new QGLMaterial();
+ defaultMaterial_->setColor(QColor(255, 128, 0));
+ defaultMaterial_->setSpecularColor(QColor(255, 128, 0));
+ defaultMaterial_->setDiffuseColor(QColor(255, 128, 0));
+ defaultMaterial_->setShininess(1.0);
+}
+
+MapItem::~MapItem()
+{
+ delete defaultMaterial_;
+}
+
+void MapItem::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ coordinate_ = coordinate;
+}
+
+QGeoCoordinate MapItem::coordinate() const
+{
+ return coordinate_;
+}
+
+void MapItem::setAnchor(const QPointF &anchor)
+{
+ anchor_ = anchor;
+}
+
+void MapItem::setTextureId(GLuint textureId)
+{
+ if (textureId_ == textureId)
+ return;
+ textureId_ = textureId;
+ textureDirty_ = true;
+}
+
+GLuint MapItem::textureId()
+{
+ return textureId_;
+}
+
+// Note: this function 'must be only' / 'is guaranteed only to be called'
+// when running in the thread that has valid GL context (rendering thread).
+// TODO refactor this function, poorly written
+void MapItem::update()
+{
+ if (!textureDirty_ || !sceneNode_)
+ return;
+ textureDirty_ = false;
+ if (texture_) {
+ // todo this will likely crash..
+ sceneNode_->material()->setTexture(0);
+ sceneNode_->material()->setColor(QColor(255, 128, 0));
+ sceneNode_->material()->setSpecularColor(QColor(255, 128, 0));
+ sceneNode_->material()->setDiffuseColor(QColor(255, 128, 0));
+ sceneNode_->material()->setShininess(1.0);
+ sceneNode_->setEffect(QGL::LitMaterial);
+ delete texture_;
+ texture_ = 0;
+ }
+ if (textureId_ != 0) {
+ texture_ = QGLTexture2D::fromTextureId(textureId_, size_.toSize()); // todo optimize out the .toSize() call
+ sceneNode_->material()->setTexture(texture_);
+ sceneNode_->setEffect(QGL::LitDecalTexture2D);
+ }
+}
+
+QGLTexture2D* MapItem::texture()
+{
+ return texture_;
+}
+
+QPointF MapItem::anchor() const
+{
+ return anchor_;
+}
+
+void MapItem::setSize(const QSizeF &size)
+{
+ size_ = size;
+}
+
+QSizeF MapItem::size() const
+{
+ return size_;
+}
+
+void MapItem::setZoom(double zoom)
+{
+ zoom_ = zoom;
+}
+
+double MapItem::zoom() const
+{
+ return zoom_;
+}
+
+void MapItem::setSceneNode(QGLSceneNode *sceneNode)
+{
+ if (sceneNode_ == sceneNode)
+ return;
+ sceneNode_ = sceneNode;
+ if (sceneNode_ && !sceneNode_->material()) {
+ // todo figure out default material setting if
+ // texture for any reason disappears. this crashes:
+ //sceneNode_->setMaterial(defaultMaterial_);
+ }
+}
+
+QGLSceneNode* MapItem::sceneNode() const
+{
+ return sceneNode_;
+}
diff --git a/src/location/maps/qgeomapobject_p.h b/src/location/mapsgl/mapitem.h
index 0d0c160a..906667ca 100644
--- a/src/location/maps/qgeomapobject_p.h
+++ b/src/location/mapsgl/mapitem.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,53 +38,58 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef MAPITEM_H
+#define MAPITEM_H
-#ifndef QGEOMAPOBJECT_P_H
-#define QGEOMAPOBJECT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeomapobject.h"
-#include "qgeomapobjectinfo.h"
#include "qgeocoordinate.h"
-
+#include <QPointF>
+#include <QSizeF>
+#include <QtOpenGL/qgl.h>
QT_BEGIN_NAMESPACE
-class QGraphicsItem;
-class QGeoMapObject;
-class QGeoMapData;
+class QGLTexture2D;
+class QGLMaterial;
+class QGLSceneNode;
-class QGeoMapObjectPrivate
+class Q_LOCATION_EXPORT MapItem
{
public:
- QGeoMapObjectPrivate();
- virtual ~QGeoMapObjectPrivate();
+ MapItem();
+ ~MapItem();
+
+ void setCoordinate(const QGeoCoordinate &coordinate);
+ QGeoCoordinate coordinate() const;
+
+ void setTextureId(GLuint textureId);
+ GLuint textureId();
+ QGLTexture2D* texture();
+ void update();
+
+ void setAnchor(const QPointF &anchor);
+ QPointF anchor() const;
- int zValue;
- quint32 serial;
- bool isVisible;
- bool isSelected;
+ void setSize(const QSizeF &size);
+ QSizeF size() const;
- QGeoMapData *mapData;
- mutable QGeoMapObjectInfo *info;
+ void setZoom(double zoom);
+ double zoom() const;
- QGeoMapObject::CoordinateUnit units;
- QGeoMapObject::TransformType transType;
- QGeoCoordinate origin;
+ void setSceneNode(QGLSceneNode *sceneNode);
+ QGLSceneNode* sceneNode() const;
- Q_DISABLE_COPY(QGeoMapObjectPrivate)
+private:
+ QGeoCoordinate coordinate_;
+ QPointF anchor_;
+ QSizeF size_;
+ double zoom_;
+ QGLSceneNode* sceneNode_;
+ GLuint textureId_;
+ bool textureDirty_;
+ QGLTexture2D* texture_;
+ QGLMaterial* defaultMaterial_;
};
QT_END_NAMESPACE
-#endif
+#endif // MAPITEM_H
diff --git a/src/location/mapsgl/mapsgl.pri b/src/location/mapsgl/mapsgl.pri
new file mode 100644
index 00000000..59f40f08
--- /dev/null
+++ b/src/location/mapsgl/mapsgl.pri
@@ -0,0 +1,33 @@
+
+INCLUDEPATH += mapsgl
+
+QT += network
+CONFIG += qt3d
+
+include(map2d/map2d.pri)
+include(map3d/map3d.pri)
+
+SOURCES += \
+ mapsgl/cameradata.cpp \
+ mapsgl/frustum.cpp \
+ mapsgl/map.cpp \
+ mapsgl/mapitem.cpp \
+ mapsgl/mapsphere.cpp \
+ mapsgl/projection.cpp \
+ mapsgl/tilecache.cpp \
+ mapsgl/tile.cpp \
+ mapsgl/tilespec.cpp
+
+PUBLIC_HEADERS += \
+ mapsgl/cameradata.h \
+ mapsgl/map.h \
+ mapsgl/mapitem.h \
+ mapsgl/tilecache.h \
+ mapsgl/tile.h \
+ mapsgl/tilespec.h
+
+PRIVATE_HEADERS += \
+ mapsgl/frustum_p.h \
+ mapsgl/map_p.h \
+ mapsgl/mapsphere_p.h \
+ mapsgl/projection_p.h
diff --git a/src/location/mapsgl/mapsphere.cpp b/src/location/mapsgl/mapsphere.cpp
new file mode 100644
index 00000000..529d88e6
--- /dev/null
+++ b/src/location/mapsgl/mapsphere.cpp
@@ -0,0 +1,234 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "mapsphere_p.h"
+
+#include "tilecache.h"
+#include "tilespec.h"
+#include "tile.h"
+#include "map.h"
+#include "map_p.h"
+
+#include <Qt3D/qglscenenode.h>
+
+#include <QVector>
+
+MapSphere::MapSphere(Map* map, MapPrivate *mapPrivate, TileCache *tileCache)
+ : QObject(0),
+ tileCache_(tileCache),
+ mapPrivate_(mapPrivate)
+{
+
+ sphereNode_ = new QGLSceneNode(this);
+
+ connect(tileCache_,
+ SIGNAL(prefetchingFinished()),
+ this,
+ SLOT(prefetchingFinished()));
+ connect(tileCache_,
+ SIGNAL(tileFetched(TileSpec)),
+ this,
+ SLOT(tileFetched(TileSpec)));
+
+ connect(this,
+ SIGNAL(tileUpdated()),
+ map,
+ SIGNAL(updateRequired()));
+
+ connect(this,
+ SIGNAL(sphereUpdated()),
+ map,
+ SIGNAL(updatesFinished()));
+}
+
+MapSphere::~MapSphere()
+{
+ QList<QGLSceneNode*> nodes = built_.values();
+ for (int i = 0; i < nodes.size(); ++i) {
+ QGLSceneNode *node = nodes.at(i);
+ //node->material()->texture()->release();
+ node->geometry().clear();
+ sphereNode_->removeNode(node);
+ delete node;
+ }
+}
+
+void MapSphere::setMappingManager(QGeoMappingManager *manager)
+{
+ tileCache_->setMappingManager(manager);
+}
+
+QGLSceneNode* MapSphere::sphereSceneNode() const
+{
+ return sphereNode_;
+}
+
+void MapSphere::clearCache()
+{
+ // clear cache
+}
+
+// Function to perform housekeeping that require access to GL context
+// (access to GL context varies depending on if we are running as
+// c++ app or QML app).
+void MapSphere::GLContextAvailable()
+{
+ // need something like this in the cache for
+ // releasing textures and freeing nodes that
+ // have been evicted from the GPU
+ tileCache_->GLContextAvailable(sphereNode_);
+// qDeleteAll(obsoleteNodes_);
+// obsoleteNodes_.clear();
+}
+
+void MapSphere::update(const QList<TileSpec> &tiles)
+{
+ QHash<TileSpec, QGLSceneNode*> stillBuilt;
+
+ QVector<TileSpec> req(tiles.size());
+ QVector<TileSpec> draw(tiles.size());
+
+ int reqSize = 0;
+ int drawSize = 0;
+ QList<TileSpec>::const_iterator i = tiles.constBegin();
+ QList<TileSpec>::const_iterator tilesEnd = tiles.constEnd();
+ while (i != tilesEnd) {
+ bool use = true;
+
+ /*
+ If the tile is already built or has been requested then we
+ shouldn't use it (where "use" means drawing a cached tile or
+ requested an uncached tile).
+ */
+
+ if (built_.contains(*i)) {
+ stillBuilt.insert(*i, built_.value(*i));
+ use = false;
+ } else if (requested_.contains(*i)){
+ use = false;
+ }
+
+ /*
+ Otherwise we add it to the correct list
+ */
+
+ if (use) {
+ if (tileCache_->contains(*i)) {
+ draw[drawSize] = *i;
+ ++drawSize;
+ } else {
+ req[reqSize] = *i;
+ ++reqSize;
+ requested_.insert(*i);
+ }
+ }
+
+ ++i;
+ }
+
+ req.resize(reqSize);
+// draw.resize(drawSize);
+
+ updateMutex.lock();
+
+ QHash<TileSpec, QGLSceneNode*>::const_iterator j = built_.constBegin();
+ QHash<TileSpec, QGLSceneNode*>::const_iterator end = built_.constEnd();
+ while (j != end) {
+ TileSpec spec = j.key();
+ if (!stillBuilt.contains(spec)) {
+ sphereNode_->removeNode(j.value());
+ }
+ ++j;
+ }
+ built_.swap(stillBuilt);
+
+ updateMutex.unlock();
+
+ for (int i = 0; i < drawSize; ++i)
+ displayTile(draw.at(i));
+
+ if (req.isEmpty()) {
+ emit sphereUpdated();
+ } else {
+ tileCache_->prefetch(req.toList());
+ }
+}
+
+void MapSphere::prefetchingFinished()
+{
+ emit sphereUpdated();
+}
+
+void MapSphere::tileFetched(const TileSpec &spec)
+{
+ if (!requested_.contains(spec))
+ return;
+
+ displayTile(spec);
+
+ requested_.remove(spec);
+
+ emit tileUpdated();
+}
+
+void MapSphere::displayTile(const TileSpec &spec)
+{
+ if (built_.contains(spec))
+ return;
+
+ updateMutex.lock();
+ Tile tile = tileCache_->get(spec);
+ QGLSceneNode *node = tile.sceneNode();
+ if (!node) {
+ node = mapPrivate_->createTileNode(tile);
+ tile.setSceneNode(node);
+ tile.bind();
+ tileCache_->update(spec, tile);
+ }
+ if (node) {
+ sphereNode_->addNode(node);
+ built_.insert(spec, node);
+ }
+ updateMutex.unlock();
+
+// qWarning() << tileCache_->diskUsage() << tileCache_->maxDiskUsage()
+// << tileCache_->memoryUsage() << tileCache_->maxMemoryUsage()
+// << tileCache_->textureUsage() << tileCache_->maxTextureUsage();
+}
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/mapsgl/mapsphere_p.h
index 1bd1ccc5..95d015a1 100644
--- a/src/location/maps/qgeomapdata_p.h
+++ b/src/location/mapsgl/mapsphere_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOMAPDATA_P_H
-#define QGEOMAPDATA_P_H
+#ifndef MAPSPHERE_H
+#define MAPSPHERE_H
//
// W A R N I N G
@@ -53,58 +52,71 @@
// We mean it.
//
-#include "qgeomapgroupobject.h"
+#include "qglobal.h"
-#include <QGraphicsScene>
-#include <QGraphicsItem>
-#include "qgeocoordinate.h"
-#include "qgraphicsgeomap.h"
-#include <private/projwrapper_p.h>
+#include <QObject>
+#include <QSet>
+#include <QHash>
#include <QList>
+#include <QMutex>
+
QT_BEGIN_NAMESPACE
-class QGeoMappingManagerEngine;
-class QGeoMapObjectEngine;
-class QGeoMapOverlay;
+class QGLSceneNode;
+
+class TileSpec;
+class TileCache;
+
+class Map;
+class MapPrivate;
+
+class QGeoMappingManager;
-class QGeoMapDataPrivate : public QObject
+class Q_LOCATION_EXPORT MapSphere : public QObject
{
Q_OBJECT
public:
- QGeoMapDataPrivate(QGeoMapData *parent, QGeoMappingManagerEngine *engine);
- virtual ~QGeoMapDataPrivate();
+ MapSphere(Map* map, MapPrivate *mapPrivate, TileCache *tileCache);
+ ~MapSphere();
- QGeoMappingManagerEngine *engine;
- QGeoMapGroupObject* containerObject;
+ void setMappingManager(QGeoMappingManager *manager);
- qreal zoomLevel;
- QPointF shiftSinceLastInval;
- qreal bearing;
- qreal tilt;
- QGeoCoordinate center;
- QSizeF windowSize;
- QGraphicsGeoMap::MapType mapType;
- QGraphicsGeoMap::ConnectivityMode connectivityMode;
+ QGLSceneNode* sphereSceneNode() const;
- QList<QGeoMapOverlay*> overlays;
+ // TODO Quick temporary thread protection.
+ QMutex updateMutex;
+ // when running as QML app we can't access GL context anywhere
+ // but QSG rendering thread.
+ void GLContextAvailable();
- bool blockPropertyChangeSignals;
+public slots:
+ void clearCache();
+ void update(const QList<TileSpec> &tiles);
- virtual void addObject(QGeoMapObject *object);
- virtual void removeObject(QGeoMapObject *object);
- void clearObjects();
+private slots:
+ void tileFetched(const TileSpec &spec);
+ void prefetchingFinished();
- virtual QPointF coordinateToScreenPosition(double lon, double lat) const;
+signals:
+ void tileUpdated();
+ void sphereUpdated();
- void emitUpdateMapDisplay(const QRectF &target = QRectF());
-
- QGeoMapData *q_ptr;
- Q_DECLARE_PUBLIC(QGeoMapData)
private:
- Q_DISABLE_COPY(QGeoMapDataPrivate)
+ void displayTile(const TileSpec &spec);
+
+ TileCache *tileCache_;
+ int minZoom_;
+
+ QSet<TileSpec> requested_;
+ QHash<TileSpec, QGLSceneNode*> built_;
+
+ QGLSceneNode* sphereNode_;
+
+ MapPrivate* mapPrivate_;
+ QList<QGLSceneNode*> obsoleteNodes_;
};
QT_END_NAMESPACE
-#endif
+#endif // MAPSPHERE_H
diff --git a/src/location/mapsgl/projection.cpp b/src/location/mapsgl/projection.cpp
new file mode 100644
index 00000000..906fe47f
--- /dev/null
+++ b/src/location/mapsgl/projection.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "projection_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <qvector2d.h>
+#include <qvector3d.h>
+#include <QMatrix4x4>
+#include <qnumeric.h>
+
+#include <cmath>
+
+Projection::Projection() {}
+
+Projection::~Projection() {}
+
+QVector3D Projection::mercatorToPoint(const QVector2D &mercator) const
+{
+ return this->coordToPoint(mercatorToCoord(mercator));
+}
+
+QVector2D Projection::pointToMercator(const QVector3D &point) const
+{
+ return coordToMercator(this->pointToCoord(point));
+}
+
+QVector2D Projection::coordToMercator(const QGeoCoordinate &coord) const
+{
+ const double pi = M_PI;
+
+ double lon = coord.longitude() / 360.0 + 0.5;
+
+ double lat = coord.latitude();
+ lat = 0.5 - (log(tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
+ lat = qMax(0.0, lat);
+ lat = qMin(1.0, lat);
+
+ return QVector2D(lon, lat);
+}
+
+double Projection::realmod(const double a, const double b)
+{
+ quint64 div = static_cast<quint64>(a / b);
+ return a - static_cast<double>(div) * b;
+}
+
+QGeoCoordinate Projection::mercatorToCoord(const QVector2D &mercator) const
+{
+ const double pi = M_PI;
+
+ double fx = mercator.x();
+ double fy = mercator.y();
+
+ if (fy < 0.0)
+ fy = 0.0;
+ else if (fy > 1.0)
+ fy = 1.0;
+
+ double lat;
+
+ if (fy == 0.0)
+ lat = 90.0;
+ else if (fy == 1.0)
+ lat = -90.0;
+ else
+ lat = (180.0 / pi) * (2.0 * atan(exp(pi * (1.0 - 2.0 * fy))) - (pi / 2.0));
+
+ double lng;
+ if (fx >= 0) {
+ lng = realmod(fx, 1.0);
+ } else {
+ lng = realmod(1.0 - realmod(-1.0 * fx, 1.0), 1.0);
+ }
+
+ lng = lng * 360.0 - 180.0;
+
+ return QGeoCoordinate(lat, lng, 0.0);
+}
diff --git a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h b/src/location/mapsgl/projection_p.h
index 1dec8a55..d3585503 100644
--- a/src/location/maps/tiled/qgeotiledmappolygonobjectinfo_p.h
+++ b/src/location/mapsgl/projection_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,9 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-#ifndef QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
-#define QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
+#ifndef PROJECTION_H
+#define PROJECTION_H
//
// W A R N I N G
@@ -53,38 +52,34 @@
// We mean it.
//
-#include "qgeotiledmapobjectinfo_p.h"
-
-#include <QPen>
-#include <QBrush>
-#include <QPolygonF>
-
+#include "qglobal.h"
QT_BEGIN_NAMESPACE
-class QGraphicsPolygonItem;
-class QGeoMapPolygonObject;
+class QGeoCoordinate;
+class QVector2D;
+class QVector3D;
-class QGeoTiledMapPolygonObjectInfo : public QGeoTiledMapObjectInfo
+class Q_AUTOTEST_EXPORT Projection
{
- Q_OBJECT
public:
- QGeoTiledMapPolygonObjectInfo(QGeoTiledMapData *mapData, QGeoMapObject *mapObject);
- ~QGeoTiledMapPolygonObjectInfo();
+ Projection();
+ virtual ~Projection();
- QGeoMapPolygonObject *polygon;
- QGraphicsPolygonItem *polygonItem;
+ virtual QVector3D coordToPoint(const QGeoCoordinate &coord) const = 0;
+ virtual QGeoCoordinate pointToCoord(const QVector3D &point) const = 0;
-public slots:
- void pathChanged(const QList<QGeoCoordinate> &path);
- void penChanged(const QPen &pen);
- void brushChanged(const QBrush &brush);
+ QVector2D coordToMercator(const QGeoCoordinate &coord) const;
+ QGeoCoordinate mercatorToCoord(const QVector2D &mercator) const;
+ virtual QVector3D mercatorToPoint(const QVector2D &mercator) const;
+ virtual QVector2D pointToMercator(const QVector3D &point) const;
+
+ virtual QGeoCoordinate interpolate(const QGeoCoordinate &start, const QGeoCoordinate &end, qreal progress) = 0;
private:
- void genPoly();
+ static double realmod(const double a, const double b);
};
QT_END_NAMESPACE
-#endif //QGEOTILEDMAPPOLYGONOBJECT_INFO_P_H
-
+#endif // PROJECTION_H
diff --git a/src/location/maps/qgeomappolylineobject.h b/src/location/mapsgl/tile.cpp
index ec343841..4e1d24a1 100644
--- a/src/location/maps/qgeomappolylineobject.h
+++ b/src/location/mapsgl/tile.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,49 +38,75 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "tile.h"
-#ifndef QGEOMAPPOLYLINEOBJECT_H
-#define QGEOMAPPOLYLINEOBJECT_H
+#include <Qt3D/qgltexture2d.h>
+#include <Qt3D/qglscenenode.h>
-#include "qgeomapobject.h"
+QT_BEGIN_NAMESPACE
-#include <QList>
-#include <QPen>
+Tile::Tile() {}
-QT_BEGIN_NAMESPACE
+Tile::Tile(const TileSpec &spec)
+ : spec_(spec),
+ texture_(0),
+ sceneNode_(0),
+ bound_(false) {}
-class QGeoCoordinate;
+bool Tile::operator == (const Tile &rhs) const
+{
+ return (spec_ == rhs.spec_);
+}
-class QGeoMapPolylineObjectPrivate;
+void Tile::setTileSpec(const TileSpec &spec)
+{
+ spec_ = spec;
+}
-class Q_LOCATION_EXPORT QGeoMapPolylineObject : public QGeoMapObject
+TileSpec Tile::tileSpec() const
{
- Q_OBJECT
- Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
+ return spec_;
+}
-public:
- QGeoMapPolylineObject();
- ~QGeoMapPolylineObject();
+void Tile::setTexture(QGLTexture2D *texture)
+{
+ texture_ = texture;
+}
- QGeoMapObject::Type type() const;
+QGLTexture2D* Tile::texture() const
+{
+ return texture_;
+}
- void setPath(const QList<QGeoCoordinate> &path);
- QList<QGeoCoordinate> path() const;
+void Tile::setSceneNode(QGLSceneNode *sceneNode)
+{
+ sceneNode_ = sceneNode;
+}
- void setPen(const QPen &pen);
- QPen pen() const;
+QGLSceneNode* Tile::sceneNode() const
+{
+ return sceneNode_;
+}
-Q_SIGNALS:
- void pathChanged(const QList<QGeoCoordinate> &path);
- void penChanged(const QPen &pen);
+void Tile::bind()
+{
+ if (bound_)
+ return;
-private:
- QGeoMapPolylineObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapPolylineObject)
- Q_DISABLE_COPY(QGeoMapPolylineObject)
-};
+ texture_->bind();
+// texture_->clearImage();
-QT_END_NAMESPACE
+ bound_ = true;
+}
+
+void Tile::setBound(bool bound)
+{
+ bound_ = bound;
+}
-#endif
+bool Tile::isBound() const
+{
+ return bound_;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapoverlay.h b/src/location/mapsgl/tile.h
index 2e887282..6a83bf78 100644
--- a/src/location/maps/qgeomapoverlay.h
+++ b/src/location/mapsgl/tile.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,44 +38,46 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef TILE_H
+#define TILE_H
-#ifndef QGEOMAPOVERLAY_H
-#define QGEOMAPOVERLAY_H
+#include "qglobal.h"
-#include "qmobilityglobal.h"
-
-#include <QList>
-#include <QObject>
+#include "tilespec.h"
QT_BEGIN_NAMESPACE
-class QPainter;
-class QStyleOptionGraphicsItem;
-
-class QGeoMapData;
-class QGeoMapOverlayPrivate;
+class QGLTexture2D;
+class QGLSceneNode;
-class Q_LOCATION_EXPORT QGeoMapOverlay
+class Q_LOCATION_EXPORT Tile
{
public:
- QGeoMapOverlay();
- virtual ~QGeoMapOverlay();
+ Tile();
+ Tile(const TileSpec &spec);
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option) = 0;
+ bool operator == (const Tile &rhs) const;
-protected:
- QGeoMapData const * mapData() const;
+ void setTileSpec(const TileSpec &spec);
+ TileSpec tileSpec() const;
-private:
- void setMapData(QGeoMapData * mapData);
+ void setTexture(QGLTexture2D *texture);
+ QGLTexture2D* texture() const;
- QGeoMapOverlayPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapOverlay)
- Q_DISABLE_COPY(QGeoMapOverlay)
+ void setSceneNode(QGLSceneNode *sceneNode);
+ QGLSceneNode *sceneNode() const;
- friend class QGeoMapData;
+ void bind();
+ void setBound(bool bound);
+ bool isBound() const;
+
+private:
+ TileSpec spec_;
+ QGLTexture2D *texture_;
+ QGLSceneNode *sceneNode_;
+ bool bound_;
};
QT_END_NAMESPACE
-#endif
+#endif // TILE_H
diff --git a/src/location/mapsgl/tilecache.cpp b/src/location/mapsgl/tilecache.cpp
new file mode 100644
index 00000000..50111e2e
--- /dev/null
+++ b/src/location/mapsgl/tilecache.cpp
@@ -0,0 +1,455 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "tilecache.h"
+
+#include "tile.h"
+#include "tilespec.h"
+
+#include "qgeomappingmanager.h"
+
+#include <QDir>
+#include <QRegExp>
+#include <QThread>
+#include <QMetaType>
+#include <QDebug>
+
+#include <Qt3D/qgltexture2d.h>
+#include <Qt3D/qglscenenode.h>
+
+Q_DECLARE_METATYPE(TileSpec)
+Q_DECLARE_METATYPE(QList<TileSpec>)
+
+struct TileDisk
+{
+ ~TileDisk()
+ {
+// qWarning() << "evicting (disk) " << spec;
+ cache->evictFromDiskCache(this);
+ }
+
+ TileSpec spec;
+ QString filename;
+ TileCache *cache;
+};
+
+struct TileMemory
+{
+ ~TileMemory()
+ {
+// qWarning() << "evicting (memory) " << spec;
+ cache->evictFromMemoryCache(this);
+ }
+
+ TileSpec spec;
+ QPixmap pixmap;
+ TileCache *cache;
+};
+
+struct TileTexture
+{
+ ~TileTexture()
+ {
+// qWarning() << "evicting (texture) " << spec;
+ cache->evictFromTextureCache(this);
+ }
+
+ TileSpec spec;
+ bool bound;
+ QGLTexture2D *texture;
+ QGLSceneNode *node;
+ TileCache *cache;
+};
+
+TileCache::TileCache(
+ const QString &directory,
+ QObject *parent)
+ : QObject(parent),
+ directory_(directory)
+{
+ qRegisterMetaType<TileSpec>();
+ qRegisterMetaType<QList<TileSpec> >();
+
+
+ if (directory_.isEmpty()) {
+ QString dirname = QLatin1String(".tilecache");
+ QDir home = QDir::home();
+ if (!home.exists(dirname))
+ home.mkdir(dirname);
+ directory_ = home.filePath(dirname);
+ }
+ qDebug() << __FUNCTION__ << directory_;
+
+ diskCache_.setMaxCost(100 * 1024 * 1024);
+ memoryCache_.setMaxCost(50 * 1024 * 1024);
+ textureCache_.setMaxCost(100 * 1024 * 1024);
+
+ loadTiles();
+}
+
+TileCache::~TileCache()
+{
+ delete manager_;
+}
+
+void TileCache::setMappingManager(QGeoMappingManager *manager)
+{
+ manager_ = manager;
+ connect(manager_,
+ SIGNAL(tileFinished(TileSpec,QByteArray)),
+ this,
+ SLOT(insert(TileSpec,QByteArray)));
+ connect(manager_,
+ SIGNAL(tileError(TileSpec,QString)),
+ this,
+ SLOT(handleError(TileSpec,QString)));
+ connect(manager_,
+ SIGNAL(queueFinished()),
+ this,
+ SIGNAL(prefetchingFinished()));
+}
+
+void TileCache::setMaxDiskUsage(int diskUsage)
+{
+ diskCache_.setMaxCost(diskUsage);
+}
+
+int TileCache::maxDiskUsage() const
+{
+ return diskCache_.maxCost();
+}
+
+int TileCache::diskUsage() const
+{
+ return diskCache_.totalCost();
+}
+
+void TileCache::setMaxMemoryUsage(int memoryUsage)
+{
+ memoryCache_.setMaxCost(memoryUsage);
+}
+
+int TileCache::maxMemoryUsage() const
+{
+ return memoryCache_.maxCost();
+}
+
+int TileCache::memoryUsage() const
+{
+ return memoryCache_.totalCost();
+}
+
+void TileCache::setMaxTextureUsage(int textureUsage)
+{
+ textureCache_.setMaxCost(textureUsage);
+}
+
+int TileCache::maxTextureUsage() const
+{
+ return textureCache_.maxCost();
+}
+
+int TileCache::textureUsage() const
+{
+ return textureCache_.totalCost();
+}
+
+void TileCache::prefetch(const QList<TileSpec> &tiles)
+{
+ if (!manager_)
+ return;
+
+ manager_->requestTiles(tiles);
+}
+
+void TileCache::GLContextAvailable(QGLSceneNode *parentNode)
+{
+ int size = cleanupList_.size();
+ for (int i = 0; i < size; ++i) {
+ Tile t = cleanupList_.at(i);
+ QGLSceneNode *node = t.sceneNode();
+ if (node) {
+ parentNode->removeNode(node);
+ delete node;
+ }
+ QGLTexture2D *texture = t.texture();
+ if (texture) {
+ texture->release();
+ delete texture;
+ }
+ }
+ cleanupList_.clear();
+}
+
+bool TileCache::contains(const TileSpec &spec) const
+{
+ return keys_.contains(spec);
+}
+
+Tile TileCache::get(const TileSpec &spec)
+{
+ if (textureCache_.contains(spec)) {
+ TileTexture *tt = textureCache_.object(spec);
+
+ Tile t = Tile(tt->spec);
+ t.setTexture(tt->texture);
+ t.setSceneNode(tt->node);
+ t.setBound(tt->bound);
+ return t;
+ }
+// if (memoryCache_.contains(spec)) {
+// TileMemory *tm = memoryCache_.object(spec);
+// TileTexture *tt = addToTextureCache(tm->spec, tm->pixmap);
+
+// Tile t = Tile(tt->spec);
+// t.setTexture(tt->texture);
+// t.setSceneNode(tt->node);
+// t.setBound(tt->bound);
+// return t;
+// }
+ if (diskCache_.contains(spec)) {
+ TileDisk *td = diskCache_.object(spec);
+// TileMemory *tm = addToMemoryCache(td->spec, QPixmap(td->filename));
+// TileTexture *tt = addToTextureCache(tm->spec, tm->pixmap);
+ TileTexture *tt = addToTextureCache(td->spec, QPixmap(td->filename));
+
+ Tile t = Tile(tt->spec);
+ t.setTexture(tt->texture);
+ t.setSceneNode(tt->node);
+ t.setBound(tt->bound);
+ return t;
+ }
+
+ return Tile();
+}
+
+// TODO rename so this is less strange
+// OR do node creation in here somehow
+void TileCache::update(const TileSpec &spec, const Tile &tile)
+{
+ TileTexture *tt = textureCache_.object(spec);
+ if (tt) {
+ tt->node = tile.sceneNode();
+ tt->texture = tile.texture();
+ tt->bound = tile.isBound();
+ }
+}
+
+void TileCache::insert(const TileSpec &spec, const QByteArray &bytes)
+{
+ keys_.insert(spec);
+
+ QString filename = tileSpecToFilename(spec, directory_);
+
+ QPixmap pixmap;
+ if (!pixmap.loadFromData(bytes)) {
+ handleError(spec, QLatin1String("Problem with tile image"));
+ return;
+ }
+
+ QFile file(filename);
+ file.open(QIODevice::WriteOnly);
+ file.write(bytes);
+ file.close();
+
+ addToDiskCache(spec, filename);
+// addToMemoryCache(spec, pixmap);
+ addToTextureCache(spec, pixmap);
+
+ emit tileFetched(spec);
+}
+
+void TileCache::evictFromDiskCache(TileDisk *td)
+{
+ keys_.remove(td->spec);
+ QFile::remove(td->filename);
+}
+
+void TileCache::evictFromMemoryCache(TileMemory */*tm*/)
+{
+}
+
+void TileCache::evictFromTextureCache(TileTexture *tt)
+{
+ Tile t(tt->spec);
+ t.setTexture(tt->texture);
+ t.setSceneNode(tt->node);
+ cleanupList_ << t;
+}
+
+TileDisk* TileCache::addToDiskCache(const TileSpec &spec, const QString &filename)
+{
+ keys_.insert(spec);
+
+// qWarning() << "adding (disk) " << spec;
+
+ TileDisk *td = new TileDisk;
+ td->spec = spec;
+ td->filename = filename;
+ td->cache = this;
+
+ QFileInfo fi(filename);
+ int diskCost = fi.size();
+
+ diskCache_.insert(spec,
+ td,
+ diskCost);
+
+ return td;
+}
+
+TileMemory* TileCache::addToMemoryCache(const TileSpec &spec, const QPixmap &pixmap)
+{
+ keys_.insert(spec);
+
+// qWarning() << "adding (memory) " << spec;
+
+ TileMemory *tm = new TileMemory;
+ tm->spec = spec;
+ tm->pixmap = pixmap;
+ tm->cache = this;
+
+ int memoryCost = pixmap.width() * pixmap.height() * pixmap.depth() / 8;
+
+ memoryCache_.insert(spec,
+ tm,
+ memoryCost);
+
+ return tm;
+}
+
+TileTexture* TileCache::addToTextureCache(const TileSpec &spec, const QPixmap &pixmap)
+{
+ keys_.insert(spec);
+
+// qWarning() << "adding (texture) " << spec;
+
+ TileTexture *tt = new TileTexture;
+ tt->spec = spec;
+ tt->texture = new QGLTexture2D();
+ tt->texture->setPixmap(pixmap);
+ tt->texture->setHorizontalWrap(QGL::ClampToEdge);
+ tt->texture->setVerticalWrap(QGL::ClampToEdge);
+
+// tt->texture->bind();
+// tt->texture->clearImage();
+
+ tt->node = 0;
+ tt->cache = this;
+
+ int textureCost = pixmap.width() * pixmap.height() * pixmap.depth() / 8;;
+
+ textureCache_.insert(spec,
+ tt,
+ textureCost);
+
+ return tt;
+}
+
+void TileCache::handleError(const TileSpec &, const QString &error)
+{
+ qWarning() << "tile request error " << error;
+}
+
+void TileCache::loadTiles()
+{
+ QStringList formats;
+ formats << QLatin1String("*.png");
+
+ QDir dir(directory_);
+ //QStringList files = dir.entryList(formats, QDir::Files, QDir::Time | QDir::Reversed);
+ QStringList files = dir.entryList(formats, QDir::Files);
+
+ qDebug() << __FUNCTION__ << "tiles: " << files.size();
+ for (int i = 0; i < files.size(); ++i) {
+
+ TileSpec spec = filenameToTileSpec(files.at(i));
+ if (spec.zoom() == -1)
+ continue;
+ QString filename = dir.filePath(files.at(i));
+ qDebug() << __FUNCTION__ << "tile iteration: " << i;
+ addToDiskCache(spec, filename);
+ }
+}
+
+QString TileCache::tileSpecToFilename(const TileSpec &spec, const QString &directory)
+{
+ QString filename = QString::number(spec.zoom());
+ filename += QLatin1String("-");
+ filename += QString::number(spec.x());
+ filename += QLatin1String("-");
+ filename += QString::number(spec.y());
+ filename += QLatin1String(".png");
+
+ QDir dir = QDir(directory);
+
+ return dir.filePath(filename);
+}
+
+TileSpec TileCache::filenameToTileSpec(const QString &filename)
+{
+ TileSpec spec;
+ QRegExp r(QLatin1String("(\\d+)-(\\d+)-(\\d+).png"));
+
+ int index = r.indexIn(filename);
+ if (index != -1) {
+ bool ok = false;
+
+ int zoom = r.cap(1).toInt(&ok);
+ if (!ok)
+ return spec;
+
+ ok = false;
+ int x = r.cap(2).toInt(&ok);
+ if (!ok)
+ return spec;
+
+ ok = false;
+ int y = r.cap(3).toInt(&ok);
+ if (!ok)
+ return spec;
+
+ spec.setZoom(zoom);
+ spec.setX(x);
+ spec.setY(y);
+ }
+
+ return spec;
+}
diff --git a/src/location/mapsgl/tilecache.h b/src/location/mapsgl/tilecache.h
new file mode 100644
index 00000000..8dba2221
--- /dev/null
+++ b/src/location/mapsgl/tilecache.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TILECACHE_H
+#define TILECACHE_H
+
+#include "qmobilityglobal.h"
+
+#include <QObject>
+#include <QCache>
+#include <QSet>
+
+class QGeoMappingManager;
+
+class TileSpec;
+class Tile;
+
+class TileDisk;
+class TileMemory;
+class TileTexture;
+
+class QGLSceneNode;
+
+class QPixmap;
+class QThread;
+
+class Q_LOCATION_EXPORT TileCache : public QObject
+{
+ Q_OBJECT
+public:
+ TileCache(const QString &directory = QString(), QObject *parent = 0);
+ ~TileCache();
+
+ void setMappingManager(QGeoMappingManager *manager);
+
+ void setMaxDiskUsage(int diskUsage);
+ int maxDiskUsage() const;
+ int diskUsage() const;
+
+ void setMaxMemoryUsage(int memoryUsage);
+ int maxMemoryUsage() const;
+ int memoryUsage() const;
+
+ void setMaxTextureUsage(int textureUsage);
+ int maxTextureUsage() const;
+ int textureUsage() const;
+
+ void GLContextAvailable(QGLSceneNode *parentNode);
+
+ bool contains(const TileSpec &spec) const;
+ Tile get(const TileSpec &spec);
+
+ void update(const TileSpec &spec, const Tile &tile);
+
+ void prefetch(const QList<TileSpec> &tiles);
+
+ void evictFromDiskCache(TileDisk *td);
+ void evictFromMemoryCache(TileMemory *tm);
+ void evictFromTextureCache(TileTexture *tt);
+
+private slots:
+ void insert(const TileSpec &spec, const QByteArray &bytes);
+ void handleError(const TileSpec &spec, const QString &errorString);
+
+signals:
+ void beginPrefetch(const QList<TileSpec> &tiles);
+ void tileFetched(const TileSpec &spec);
+ void prefetchingFinished();
+
+private:
+ void loadTiles();
+
+ TileDisk* addToDiskCache(const TileSpec &spec, const QString &filename);
+ TileMemory* addToMemoryCache(const TileSpec &spec, const QPixmap &pixmap);
+ TileTexture* addToTextureCache(const TileSpec &spec, const QPixmap &pixmap);
+
+ static QString tileSpecToFilename(const TileSpec &spec, const QString &directory);
+ static TileSpec filenameToTileSpec(const QString &filename);
+
+ QString directory_;
+
+ int diskSize_;
+ int memorySize_;
+ int textureSize_;
+
+ QSet<TileSpec> keys_;
+ QCache<TileSpec, TileDisk > diskCache_;
+ QCache<TileSpec, TileMemory > memoryCache_;
+ QCache<TileSpec, TileTexture > textureCache_;
+
+ QList<Tile> cleanupList_;
+
+ QGeoMappingManager *manager_;
+};
+
+
+#endif // TILECACHE_H
diff --git a/src/location/mapsgl/tilecamera.cpp b/src/location/mapsgl/tilecamera.cpp
new file mode 100644
index 00000000..9c10f423
--- /dev/null
+++ b/src/location/mapsgl/tilecamera.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "tilecamera.h"
+
+#include "spheregeometry.h"
+
+#include <QVector3D>
+#include <qnumeric.h>
+#include <qglcamera.h>
+
+#include <cmath>
+
+TileCamera::TileCamera()
+ : latitude_(-27.5),
+ longitude_(153),
+ distance_(0.1),
+ bearing_(0.0),
+ tilt_(0.0),
+ aspectRatio_(1.0),
+ camera_(new QGLCamera())
+{
+}
+
+TileCamera::~TileCamera()
+{
+ delete camera_;
+}
+
+// Up and right units are bit obscure still, fixme
+void TileCamera::rotateCamera(const SphereGeometry & sphere, double up, double right)
+{
+ QVector3D view = camera_->eye() - camera_->center();
+ QVector3D side = QVector3D::normal(view, camera_->upVector());
+ QMatrix4x4 rotationMatrix;
+ // First determine how big angle and about which axis' to rotate
+ // and express them with a rotation matrix (spherical rotation around origin)
+ rotationMatrix.rotate(right / sphere.zoomLevel(), camera_->upVector());
+ rotationMatrix.rotate(up / sphere.zoomLevel(), side);
+ // Then rotate the eye and center of the camera
+ camera_->setCenter(camera_->center() * rotationMatrix);
+ camera_->setEye(camera_->eye() * rotationMatrix);
+}
+
+void TileCamera::setCamera(const SphereGeometry &sphere,
+ double latitude,
+ double longitude,
+ double distance,
+ double bearing,
+ double tilt,
+ double aspectRatio)
+{
+ QVector3D c = sphere.coordToPoint(latitude, longitude);
+ QVector3D e = sphere.coordToPoint(latitude, longitude, sphere.radius() * distance);
+
+ camera_->setCenter(c);
+ camera_->setEye(e);
+
+ QVector3D view = camera_->eye() - camera_->center();
+ QVector3D side = QVector3D::normal(view, QVector3D(0.0, 1.0, 0.0));
+ QVector3D up = QVector3D::normal(side, view);
+
+ // define rotation around view vector and apply it to up vector
+ QMatrix4x4 mBearing;
+ mBearing.rotate(-1.0 * bearing, view);
+ camera_->setUpVector(mBearing * up);
+
+ // define rotation around new side vector and apply it to eye
+ QVector3D side2 = QVector3D::normal(mBearing * up, view);
+ QMatrix4x4 mTilt;
+ mTilt.rotate(tilt, side2);
+ camera_->setEye((mTilt * view) + c);
+
+ // reset the up vector after tilting
+ view = camera_->eye() - camera_->center();
+ up = QVector3D::normal(view, side2);
+ camera_->setUpVector(up);
+
+ // set near and far planes
+ camera_->setNearPlane(1);
+ camera_->setFarPlane(2.0 * sphere.radius() * distance);
+ zoom_ = sphere.zoomLevel();
+}
+
+/* TODO improve zoomCamera a lot. Current implementation is very hacky.
+
+ @factor: fractions of a zoom level to zoom in. Doubling a zoom level
+ roughly doubles the distance from the earth.
+
+ @detailPreference: whether the distance from the earth should be that of the eye from
+ closest point on earth, or from eye to center (center is where we are looking at).
+
+ */
+void TileCamera::zoomCamera(SphereGeometry& sphere, double factor, DetailPreference detailPreference)
+{
+ if (!(-1.0 < factor && factor < 1.0)) {
+ qWarning() << "Zoom factor must be between -1.0 and 1.0, you gave: " << factor;
+ return;
+ }
+
+ QVector3D view = camera_->eye() - camera_->center();
+ Q_ASSERT(view.length() > 0.0);
+ double viewVectorLength = view.length();
+ double eyeVectorLength = camera_->eye().length();
+ double sphereRadius = sphere.radius();
+ double zoomDistance;
+ if (detailPreference == DetailPreferenceNear) {
+ qDebug() << "Zooming, preferring details/tiles near, factor: " << factor;
+ double viewEyeDotProduct = QVector3D::dotProduct(view, camera_->eye());
+ // Dodgy, fixme
+ bool zoomOut = false;
+ if (factor < 0.0) {
+ factor = -factor;
+ zoomOut = true;
+ }
+ factor += 1.0;
+ // Look for the multiplication factor so that multiplying the view with the factor
+ // will result in eye height changing according to given factor.
+ double sqrtResult = sqrt(pow(viewEyeDotProduct, 2) - 4 * pow(viewVectorLength, 2) * (pow(eyeVectorLength, 2) - pow(sphereRadius + factor * eyeVectorLength - factor * sphereRadius , 2)));
+ double viewVectorFactor = (-viewEyeDotProduct + sqrtResult) / (2 * pow(viewVectorLength, 2));
+ // Dodgy, fixme
+ if (!zoomOut)
+ camera_->setEye(camera_->eye() - view * viewVectorFactor);
+ else
+ camera_->setEye(view * viewVectorFactor + camera_->eye());
+ // Fixme, far too big farplane (no pun intended)
+ view = camera_->eye() - camera_->center();
+ camera_->setFarPlane(sphere.radius() + view.length());
+ zoomDistance = camera_->eye().length() - sphere.radius();
+ } else if (detailPreference == DetailPreferenceCenter) {
+ qDebug() << "Zooming, preferring details/tiles at center, factor: " << factor;
+ factor = -factor;
+ factor += 1;
+ camera_->setEye(camera_->center() + view * factor);
+ view = camera_->eye() - camera_->center();
+ camera_->setFarPlane(sphere.radius() + view.length());
+ zoomDistance = view.length();
+ } else {
+ qWarning("Unsupported detail preference for zoom.");
+ return;
+ }
+ // Adjust sphere zoom level if necessary
+ double maxZoomLevel = 18; // TODO this needs to come from the current plugin
+ double zoomCoefficient = 0.5; // TODO just initial guess
+ int zoomLevel = int(maxZoomLevel - log(zoomDistance / zoomCoefficient) / log(2.0));
+ qDebug() << "Zoom, tilesphere zoom was : " << sphere.zoomLevel();
+ qDebug() << "Zoom level (fractional) would be : " << maxZoomLevel - log2(zoomDistance / zoomCoefficient);
+ if ((int)zoomLevel != sphere.zoomLevel() && zoomLevel < maxZoomLevel && zoomLevel >= 0) {
+ sphere.setZoomLevel(int(zoomLevel));
+// sphere.update(*this);
+ }
+}
+
+// Can be done like this if quaternions ease the animation
+//void TileCamera::tiltCamera(double tilt, QQuaternion = QQuaternion()) {
+// {
+// if (!quaternion.isIdentity()) // use quaternion. However, keeping track of 'tilt_' needs to be done
+// ...
+// else // use tilt angle
+
+void TileCamera::tiltCamera(const SphereGeometry& sphere, double tilt)
+{
+ Q_ASSERT(!qIsNaN(tilt));
+ camera_->rotateCenter(camera_->tilt(tilt));
+ // Don't fall through the sphere surface
+ if (camera_->eye().length() - sphere.radius() < 0.0) {
+ qDebug() << "Camera tilt safestop, would go through earth.";
+ camera_->rotateCenter(camera_->tilt(-tilt));
+ }
+}
+
+void TileCamera::rollCamera(const SphereGeometry& sphere, double roll)
+{
+ Q_UNUSED(sphere);
+ Q_ASSERT(!qIsNaN(roll));
+ camera_->rotateCenter(camera_->roll(roll));
+}
+
+void TileCamera::panCamera(const SphereGeometry& sphere, double pan)
+{
+ Q_ASSERT(!qIsNaN(pan));
+ camera_->rotateCenter(camera_->pan(pan));
+ if (camera_->eye().length() - sphere.radius() < 0.0) {
+ qDebug() << "Camera pan safety stop, would go through earth.";
+ camera_->rotateCenter(camera_->pan(-pan));
+ }
+}
+
+QGLCamera* TileCamera::camera() const
+{
+ return camera_;
+}
+
+QVector3D TileCamera::eye() const
+{
+ return camera_->eye();
+}
+
+QVector3D TileCamera::view(double x, double y) const
+{
+ double fov = atan(camera_->viewSize().height() / (2 * camera_->nearPlane()));
+
+ double hf = 2 * tan(fov) * camera_->farPlane();
+ double wf = hf * aspectRatio_;
+
+ QVector3D p = camera_->eye();
+ QVector3D d = camera_->center() - camera_->eye();
+ d.normalize();
+
+ QVector3D up = camera_->upVector();
+ up.normalize();
+
+ QVector3D right = QVector3D::normal(d, up);
+
+ double x1 = qMin(qMax(x, 0.0), 1.0) - 0.5;
+ double y1 = qMin(qMax(y, 0.0), 1.0) - 0.5;
+
+ QVector3D c = d * camera_->farPlane();
+ c += up * hf * y1;
+ c += right * wf * x1;
+
+ return c.normalized();
+}
+
diff --git a/src/location/maps/qgeomapgroupobject.h b/src/location/mapsgl/tilecamera.h
index 364e01fd..5fde909b 100644
--- a/src/location/maps/qgeomapgroupobject.h
+++ b/src/location/mapsgl/tilecamera.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,50 +38,59 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef TILECAMERA_H
+#define TILECAMERA_H
-#ifndef QGEOMAPGROUPOBJECT_H
-#define QGEOMAPGROUPOBJECT_H
-
-#include "qgeomapobject.h"
+#include "qglobal.h"
QT_BEGIN_NAMESPACE
-class QGeoCoordinate;
-class QGeoBoundingBox;
-class QGeoMapGroupObjectPrivate;
+class SphereGeometry;
+class QGLCamera;
+class QGLSceneNode;
+class QVector3D;
-class Q_LOCATION_EXPORT QGeoMapGroupObject : public QGeoMapObject
+class Q_LOCATION_EXPORT TileCamera
{
- Q_OBJECT
public:
- QGeoMapGroupObject();
- ~QGeoMapGroupObject();
-
- QGeoMapObject::Type type() const;
-
- QGeoBoundingBox boundingBox() const;
- bool contains(const QGeoCoordinate &coordinate) const;
+ TileCamera();
+ ~TileCamera();
- QList<QGeoMapObject*> childObjects() const;
- void addChildObject(QGeoMapObject *childObject);
- void removeChildObject(QGeoMapObject *childObject);
- void clearChildObjects();
+ enum DetailPreference {
+ DetailPreferenceNear,
+ DetailPreferenceCenter
+ };
- void setVisible(bool visible);
+ // Reset the camera (to look at lon,lat, with given distance, tilt etc.)
+ void setCamera(const SphereGeometry &sphere,
+ double latitude,
+ double longitude,
+ double distance,
+ double bearing,
+ double tilt,
+ double aspectRatio);
+ void tiltCamera(const SphereGeometry& sphere, double tilt);
+ void rollCamera(const SphereGeometry& sphere, double roll);
+ void panCamera(const SphereGeometry& sphere, double pan);
+ void rotateCamera(const SphereGeometry& sphere, double up, double right);
+ void zoomCamera(SphereGeometry& sphere, double factor, DetailPreference detailPreference = DetailPreferenceNear);
- void setMapData(QGeoMapData *mapData);
+ QGLCamera* camera() const;
-Q_SIGNALS:
- void childAdded(QGeoMapObject *childObject);
- void childUpdated(QGeoMapObject *childObject);
- void childRemoved(QGeoMapObject *childObject);
+ QVector3D eye() const;
+ QVector3D view(double x, double y) const;
private:
- QGeoMapGroupObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapGroupObject)
- Q_DISABLE_COPY(QGeoMapGroupObject)
+ double latitude_;
+ double longitude_;
+ double distance_;
+ double bearing_;
+ double tilt_;
+ double zoom_;
+ double aspectRatio_;
+ QGLCamera* camera_;
};
QT_END_NAMESPACE
-#endif
+#endif // TILECAMERA_H
diff --git a/src/location/maps/qgeomaprouteobject.h b/src/location/mapsgl/tilespec.cpp
index 7ea74723..17d51682 100644
--- a/src/location/maps/qgeomaprouteobject.h
+++ b/src/location/mapsgl/tilespec.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,55 +38,93 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "tilespec.h"
+#include <QDebug>
-#ifndef QGEOMAPROUTEOBJECT_H
-#define QGEOMAPROUTEOBJECT_H
+QT_BEGIN_NAMESPACE
-#include "qgeomapobject.h"
-#include "qgeoroute.h"
+TileSpec::TileSpec()
+ : zoom_(-1),
+ x_(-1),
+ y_(-1) {}
-#include <QPen>
+TileSpec::TileSpec(int zoom, int x, int y)
+ : zoom_(zoom),
+ x_(x),
+ y_(y) {}
-QT_BEGIN_NAMESPACE
+void TileSpec::setZoom(int zoom)
+{
+ zoom_ = zoom;
+}
-class QGeoMapRouteObjectPrivate;
-class QGeoRoute;
-class QGeoCoordinate;
+int TileSpec::zoom() const
+{
+ return zoom_;
+}
-class Q_LOCATION_EXPORT QGeoMapRouteObject : public QGeoMapObject
+void TileSpec::setX(int x)
{
- Q_OBJECT
- Q_PROPERTY(QGeoRoute route READ route WRITE setRoute NOTIFY routeChanged)
- Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
- Q_PROPERTY(quint32 detailLevel READ detailLevel WRITE setDetailLevel NOTIFY detailLevelChanged)
+ x_ = x;
+}
-public:
- QGeoMapRouteObject();
- QGeoMapRouteObject(const QGeoRoute &route);
- ~QGeoMapRouteObject();
+int TileSpec::x() const
+{
+ return x_;
+}
- QGeoMapObject::Type type() const;
+void TileSpec::setY(int y)
+{
+ y_ = y;
+}
- QGeoRoute route() const;
- void setRoute(const QGeoRoute &route);
+int TileSpec::y() const
+{
+ return y_;
+}
- QPen pen() const;
- void setPen(const QPen &pen);
+bool TileSpec::operator == (const TileSpec &rhs) const
+{
+ if (zoom_ != rhs.zoom_)
+ return false;
- quint32 detailLevel() const;
- void setDetailLevel(quint32 detailLevel);
+ if (x_ != rhs.x_)
+ return false;
-Q_SIGNALS:
- void routeChanged(const QGeoRoute &route);
- void penChanged(const QPen &pen);
- void detailLevelChanged(quint32 detailLevel);
+ if (y_ != rhs.y_)
+ return false;
-private:
- QGeoMapRouteObjectPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapRouteObject)
- Q_DISABLE_COPY(QGeoMapRouteObject)
-};
+ return true;
+}
-QT_END_NAMESPACE
+bool TileSpec::operator < (const TileSpec &rhs) const
+{
+ if (zoom_ < rhs.zoom_)
+ return true;
+ if (zoom_ > rhs.zoom_)
+ return false;
+
+ if (x_ < rhs.x_)
+ return true;
+ if (x_ > rhs.x_)
+ return false;
+
+ return (y_ < rhs.y_);
-#endif
+}
+
+unsigned int qHash(const TileSpec &spec)
+{
+ unsigned int result = (spec.zoom() * 17) % 31;
+ result += ((spec.x() * 19) % 31) << 5;
+ result += ((spec.y() * 23) % 31) << 10;
+ return result;
+}
+
+QDebug operator<< (QDebug dbg, const TileSpec &spec)
+{
+ dbg << spec.zoom() << spec.x() << spec.y();
+ return dbg;
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapgroupobject_p.h b/src/location/mapsgl/tilespec.h
index 9971b533..121ed08e 100644
--- a/src/location/maps/qgeomapgroupobject_p.h
+++ b/src/location/mapsgl/tilespec.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
@@ -38,36 +38,41 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#ifndef TILESPEC_H
+#define TILESPEC_H
-#ifndef QGEOMAPGROUPOBJECT_P_H
-#define QGEOMAPGROUPOBJECT_P_H
-
-#include "qgeomapobject.h"
-
-#include <QObject>
-#include <QList>
+#include "qglobal.h"
QT_BEGIN_NAMESPACE
-class QGeoMapGroupObject;
-
-class QGeoMapGroupObjectPrivate : public QObject
+class Q_LOCATION_EXPORT TileSpec
{
- Q_OBJECT
public:
- QGeoMapGroupObjectPrivate(QGeoMapGroupObject *p);
- ~QGeoMapGroupObjectPrivate();
+ TileSpec();
+ TileSpec(int zoom, int x, int y);
+
+ void setZoom(int zoom);
+ int zoom() const;
- QList<QGeoMapObject *> children;
- quint32 serial;
+ void setX(int x);
+ int x() const;
-public slots:
- void childChangedZValue(int zValue);
+ void setY(int y);
+ int y() const;
+
+ bool operator == (const TileSpec &rhs) const;
+ bool operator < (const TileSpec &rhs) const;
private:
- QGeoMapGroupObject *q_ptr;
+ int zoom_;
+ int x_;
+ int y_;
};
+unsigned int qHash(const TileSpec &spec);
+
+QDebug operator<<(QDebug, const TileSpec &);
+
QT_END_NAMESPACE
-#endif
+#endif // TILESPEC_H
diff --git a/src/location/projwrapper_p.cpp b/src/location/projwrapper_p.cpp
deleted file mode 100644
index 463cc735..00000000
--- a/src/location/projwrapper_p.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "projwrapper_p.h"
-#include <proj_api.h>
-#include <QSharedData>
-#include <QString>
-#include <QPolygonF>
-#include <QPointF>
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-class ProjCoordinateSystemPrivate : public QSharedData
-{
-public:
- ProjCoordinateSystemPrivate(const QString &projection, bool latLon);
- ProjCoordinateSystemPrivate(const ProjCoordinateSystemPrivate &other);
- ~ProjCoordinateSystemPrivate();
-
- projPJ projection;
- bool latLon;
-};
-
-ProjCoordinateSystemPrivate::ProjCoordinateSystemPrivate(const QString &projStr, bool isLatLon)
-{
- projection = pj_init_plus(projStr.toLatin1().constData());
- Q_ASSERT_X(projection, "pj_init_plus", "invalid projection string");
- latLon = isLatLon;
-}
-
-ProjCoordinateSystemPrivate::ProjCoordinateSystemPrivate(const ProjCoordinateSystemPrivate &other) :
- QSharedData(other),
- latLon(other.latLon)
-{
- char *str = pj_get_def(other.projection, 0);
- projection = pj_init_plus(str);
- Q_ASSERT_X(projection, "pj_init_plus", "invalid projection string");
- free(str);
-}
-
-ProjCoordinateSystemPrivate::~ProjCoordinateSystemPrivate()
-{
- pj_free(projection);
-}
-
-ProjCoordinateSystem::ProjCoordinateSystem(const QString &projection, bool latLon) :
- d(new ProjCoordinateSystemPrivate(projection, latLon))
-{}
-
-ProjCoordinateSystem::ProjCoordinateSystem(const ProjCoordinateSystem &other) :
- d(other.d)
-{}
-
-ProjCoordinateSystem::~ProjCoordinateSystem()
-{}
-
-bool ProjCoordinateSystem::isLatLon() const
-{
- return d->latLon;
-}
-
-class ProjCoordinatePrivate
-{
-public:
- ProjCoordinateSystem currentSystem;
- double x;
- double y;
- double z;
-};
-
-ProjCoordinate::ProjCoordinate(double x, double y, double z, const ProjCoordinateSystem &system) :
- d(new ProjCoordinatePrivate)
-{
- d->x = x;
- d->y = y;
- d->z = z;
- d->currentSystem = system;
-}
-
-ProjCoordinate::ProjCoordinate(const ProjCoordinate &other) :
- d(new ProjCoordinatePrivate)
-{
- *this = other;
-}
-
-ProjCoordinate &ProjCoordinate::operator=(const ProjCoordinate &other)
-{
- d->x = other.d->x;
- d->y = other.d->y;
- d->z = other.d->z;
- d->currentSystem = other.d->currentSystem;
- return *this;
-}
-
-ProjCoordinate::~ProjCoordinate()
-{
- delete d;
-}
-
-double ProjCoordinate::x() const
-{
- return d->x;
-}
-
-double ProjCoordinate::y() const
-{
- return d->y;
-}
-
-double ProjCoordinate::z() const
-{
- return d->z;
-}
-
-bool ProjCoordinate::convert(const ProjCoordinateSystem &system)
-{
- int result;
- double x = d->x, y = d->y, z = d->z;
-
- if (d->currentSystem.isLatLon()) {
- x *= DEG_TO_RAD;
- y *= DEG_TO_RAD;
- }
-
- result = pj_transform(d->currentSystem.d->projection,
- system.d->projection,
- 1, 1, &x, &y, &z);
- if (result) {
- return false;
- } else {
- if (system.isLatLon()) {
- x *= RAD_TO_DEG;
- y *= RAD_TO_DEG;
- }
- d->x = x;
- d->y = y;
- d->z = z;
- d->currentSystem = system;
- return true;
- }
-}
-
-QGeoCoordinate ProjCoordinate::toGeoCoordinate() const
-{
- double x = d->x;
- double y = d->y;
-
- if (x < -180.0)
- x = -180.0;
- if (x > 180.0)
- x = 180.0;
-
- if (y < -90.0)
- y = -90.0;
- if (y > 90.0)
- y = 90.0;
-
- return QGeoCoordinate(y, x, d->z);
-}
-
-class ProjPolygonPrivate
-{
-public:
- ProjCoordinateSystem currentSystem;
-};
-
-ProjPolygon::ProjPolygon(const ProjCoordinateSystem &system) :
- QList<ProjCoordinate>(),
- d(new ProjPolygonPrivate)
-{
- d->currentSystem = system;
-}
-
-ProjPolygon::ProjPolygon(const QPolygonF &poly, const ProjCoordinateSystem &system, double scale) :
- QList<ProjCoordinate>(),
- d(new ProjPolygonPrivate)
-{
- d->currentSystem = system;
- foreach (QPointF point, poly) {
- double x = point.x();
- x /= scale;
- double y = point.y();
- y /= scale;
- append(ProjCoordinate(x, y, 0.0, system));
- }
-}
-
-ProjPolygon::~ProjPolygon()
-{
- delete d;
-}
-
-bool ProjPolygon::convert(const ProjCoordinateSystem &system)
-{
- for (int i=0; i<size(); ++i) {
- ProjCoordinate coord = at(i);
- if (!coord.convert(system))
- return false;
- replace(i, coord);
- }
-
- d->currentSystem = system;
- return true;
-}
-
-void ProjPolygon::scalarMultiply(double sx, double sy, double sz)
-{
- for (int i=0; i<size(); ++i) {
- ProjCoordinate &c = operator [](i);
- c.d->x *= sx;
- c.d->y *= sy;
- c.d->z *= sz;
- }
-}
-
-QPolygonF ProjPolygon::toPolygonF(double scale) const
-{
- QPolygonF poly;
- for (int i=0; i<size(); ++i) {
- const ProjCoordinate &coord = at(i);
- double x = coord.x() * scale;
- double y = coord.y() * scale;
- poly << QPointF(x, y);
- }
- return poly;
-}
-
-QT_END_NAMESPACE