Skip to content

MapWidget enhancements#531

Merged
dirkhh merged 7 commits intosubsurface:masterfrom
neolit123:map
Aug 7, 2017
Merged

MapWidget enhancements#531
dirkhh merged 7 commits intosubsurface:masterfrom
neolit123:map

Conversation

@neolit123
Copy link
Member

this PR implements the requested functionality to be able to:

  1. select a trip or any list of dives and the Map widget should estimate a center coordinate and a zoom level so that the list of selected dives locations are centered in the Map viewport
  2. select a list of dives in the dive list based on selecting a list of markers on the map

for 2, i was thinking about adding tools such as circular or rectangular marquee selection or even lasso, but this is hard to maintain and is awkward on mobile. instead, the current implementation uses the viewport as the selection tool in the lines of "select visible dive locations". so, if a set of flags are visible on the map, this context menu action will select the associated dives in the dive list.

NOTES:
mapwidget: use "satallite" maps instead of "hybrid"
a subject to discussion, but i encourage that the above commit is applied, because some users might report the missing (black) tiles soon. both i and the plugin author don't have a solution for this ATM....one way to fix the "hybrid" map would be to cache tiles from the current zoom level and if the next zoom level shows a completely black tile - load tiles from the working zoom level. a very hacky solution...

also, the "satallite" map turns completely white at maximum zoom, i think this might be an issue in the QtLocation Map, because nothing works on the "googlemaps map plugin" side.

Do so until the following issue is resolved:
vladest/googlemaps#9

With the satellite map ([1]), the black tiles at relatively high
zoom levels over the Red Sea cannot be seen. Instead it shows white
tiles at the ultra-maximum zoom level at places.

As a side note, the "satellite" map does not have the country labels
which the "hybrid" map has.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
For instance, if the 'googlemaps' geoservices plugin is missing
a new message is now shown:
"qml: MapWidget.qml: cannot find a plugin with the name 'googlemaps'"

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
MapWidgetHelper::centerOnDiveSite() now checks if more than
one dive sites are selected and finds the most top-left and
bottom-right ones in the coordinate system to form
a rectangle.

It also supports the special cases where a selected dive site
does not have coordinates or the case where only a single dive site
with GPS coordinates are selected.

TODO: implement mapwidget.qml::centerOnRectangle()
This QML function will receive a QGeoCoordinate based rectangle which
has to be centered in the viewport with animation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Add stopZoomAnimations(), which is really just a precaution
function to make sure we have stopped all animation of the
map before doing calculations! Since the animation *should*
be running in a separate thread, this would make sure the Map "center"
and "zoomLevel" properties do not change.

Add pointIsVisible(), which is a helper to determine
if a point created by map.fromCoordinate() method is inside
the viewport. fromCoordinate() has to be called without the
"false" (clip) flag for this to work.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
First, this function calculates the zoom out effect until both the
current Map center and the target rectangle are visible - see the
"calculate zoom out" part.

Then it calculates a zoom level, so that the target rectangle
fits the viewport, but also so that the zoom is not too much (clamped).
see the "calculate zoom in" part.

NOTE: "centerStored" (the variable used to store the current map center)
is created using QtPositioning.coordinate(), because the code needs a new
object and not a reference of the map.center QGeoCoordinate object.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The new method selectVisibleLocations() contains a routine
to find all visible MapLocation objects in the Map viewport and
select the dives associated to said MapLocation objects.

This method is to be invoked from the QML context menu.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
MapWidgetContextMenu now has a new action (SELECT_VISIBLE_LOCATIONS),
that will invoke the MapWidgetHelper method selectVisibleLocations().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
@mention-bot
Copy link

@neolit123, thanks for your PR! By analyzing the history of the files in this pull request, we identified @atdotde and @dirkhh to be potential reviewers.

@dirkhh
Copy link
Collaborator

dirkhh commented Aug 7, 2017

This looks like awesome progress!

@dirkhh dirkhh merged commit 00e401b into subsurface:master Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants