Merge lp:~nik90/unav/reverse-geocode into lp:unav

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 46
Proposed branch: lp:~nik90/unav/reverse-geocode
Merge into: lp:unav
Diff against target: 208 lines (+100/-14)
3 files modified
qml/FavoritesPage.qml (+7/-7)
qml/Main.qml (+87/-6)
qml/components/PoiPopup.qml (+6/-1)
To merge this branch: bzr merge lp:~nik90/unav/reverse-geocode
Reviewer Review Type Date Requested Status
costales Approve
JkB Approve
Review via email: mp+291821@code.launchpad.net

Description of the change

This MP implements,
- Reverse geocoding (clicking on a point will now check if it is a just generic point or a POI. If it is a generic point, we just show the address. If it is a POI, we show the POI popup)
- Minor bug fixes

To post a comment you must log in.
Revision history for this message
JkB (joergberroth) wrote :

Hey, thanks a lot for finishing that!!
It's a great feature and it works perfectly!! Great work! Approve!

FavButtons Approve.

clickButtons approve.

Thx Joerg

review: Approve
lp:~nik90/unav/reverse-geocode updated
52. By Nekhelesh Ramananthan

Merged lp:unav

Revision history for this message
costales (costales) wrote :

So great improvement :)

What do you think about a bit smaller font for the address?

Issue:
 1. Click on map (reverse geolocation appears).
 2. Go to favorites and click in one.
 3. Bug: Popup is the previous.
Solution? Clear/Hide popup when user clicks on Route.

Improvement: It's working for a POI from coordinates. Is it possible working to for POIs from Search and Favorites?

Thanks in advance!

review: Needs Fixing
lp:~nik90/unav/reverse-geocode updated
53. By Nekhelesh Ramananthan

hide popover when clicking the menu

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Thanks Marcos. Good catch on the bug. I managed to fix it with your suggestion as well.

Revision history for this message
costales (costales) wrote :

+100 |o/
Thanks Nekhelesh!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/FavoritesPage.qml'
--- qml/FavoritesPage.qml 2016-04-12 14:07:12 +0000
+++ qml/FavoritesPage.qml 2016-04-14 19:07:42 +0000
@@ -294,6 +294,13 @@
294 anchors.horizontalCenter: parent.horizontalCenter294 anchors.horizontalCenter: parent.horizontalCenter
295 spacing: units.gu(2)295 spacing: units.gu(2)
296 Button {296 Button {
297 text: i18n.tr("Cancel")
298 onClicked: {
299 clear()
300 PopupUtils.close(dialogue)
301 }
302 }
303 Button {
297 text: isOverwriteMode ? i18n.tr("Overwrite") : isAddFavoriteMode ? i18n.tr("Add") : i18n.tr("Update")304 text: isOverwriteMode ? i18n.tr("Overwrite") : isAddFavoriteMode ? i18n.tr("Add") : i18n.tr("Update")
298 color: isOverwriteMode ? UbuntuColors.red : UbuntuColors.green305 color: isOverwriteMode ? UbuntuColors.red : UbuntuColors.green
299 enabled: favNameField.text.trim() && (!isAddFavoriteMode ? favoritesPage.favName_edit !== favNameField.text : true)306 enabled: favNameField.text.trim() && (!isAddFavoriteMode ? favoritesPage.favName_edit !== favNameField.text : true)
@@ -305,13 +312,6 @@
305 PopupUtils.close(dialogue)312 PopupUtils.close(dialogue)
306 }313 }
307 }314 }
308 Button {
309 text: i18n.tr("Cancel")
310 onClicked: {
311 clear()
312 PopupUtils.close(dialogue)
313 }
314 }
315 }315 }
316 }316 }
317 }317 }
318318
=== modified file 'qml/Main.qml'
--- qml/Main.qml 2016-04-13 17:52:10 +0000
+++ qml/Main.qml 2016-04-14 19:07:42 +0000
@@ -27,6 +27,7 @@
27import QtMultimedia 5.027import QtMultimedia 5.0
28import QtFeedback 5.028import QtFeedback 5.0
29import QtSystemInfo 5.029import QtSystemInfo 5.0
30import QtQuick.XmlListModel 2.0
30import "components"31import "components"
31import "js/utils.js" as QmlJs32import "js/utils.js" as QmlJs
3233
@@ -172,6 +173,7 @@
172 text: i18n.tr("Route")173 text: i18n.tr("Route")
173 enabled: navigationPage.buttonsEnabled174 enabled: navigationPage.buttonsEnabled
174 onTriggered: {175 onTriggered: {
176 goThereActionPopover.hide();
175 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))177 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
176 }178 }
177 }179 }
@@ -268,6 +270,11 @@
268 mainPageStack.center_onpos = 1;270 mainPageStack.center_onpos = 1;
269 mainPageStack.favPopup = false;271 mainPageStack.favPopup = false;
270 goThereActionPopover.show();272 goThereActionPopover.show();
273
274 // Perform reverse geocoding only when it is a generic marker that the user clicked on the map
275 if (goThereActionPopover.poiName === "" && goThereActionPopover.osm_id === 'none') {
276 reverseXmlModel.reverseSearch(mainPageStack.clickedLat, mainPageStack.clickedLng);
277 }
271 break;278 break;
272 279
273 case "http://hide_popup/":280 case "http://hide_popup/":
@@ -385,7 +392,10 @@
385 ActionIcon {392 ActionIcon {
386 icon.name: "send"393 icon.name: "send"
387 enabled: navigationPage.buttonsEnabled394 enabled: navigationPage.buttonsEnabled
388 onClicked: mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))395 onClicked: {
396 goThereActionPopover.hide();
397 mainPageStack.push(Qt.resolvedUrl("RoutePage.qml"))
398 }
389 }399 }
390400
391 ActionIcon {401 ActionIcon {
@@ -419,22 +429,90 @@
419 onZoomedOut: mainPageStack.executeJavaScript("custom_zoom(-1)")429 onZoomedOut: mainPageStack.executeJavaScript("custom_zoom(-1)")
420 }430 }
421431
432 XmlListModel {
433 id: reverseXmlModel
434
435 readonly property string baseUrl: "https://nominatim.openstreetmap.org/reverse?format=xml&email=costales.marcos@gmail.com&addressdetails=0&extratags=1&zoom=18&namedetails=1&"
436
437 function reverseSearch(lat, lon) {
438 source = (baseUrl + "lat=" + lat + "&lon=" + lon) ;
439 console.log(source)
440 }
441
442 function clear() {
443 goThereActionPopover.reverseGeoString = "";
444 source = "";
445 }
446
447 onStatusChanged: {
448 if (status === XmlListModel.Error || (status === XmlListModel.Ready && count === 0)) {
449 goThereActionPopover.reverseGeoString = ""
450 console.log("Error reverse geocoding the location!")
451 }
452
453 else if (status === XmlListModel.Ready && count > 0) {
454 // Check if the location returned by reverse geocoding is a POI by looking for the existence of certain parameters
455 // like cuisine, phone, opening_hours, internet_access, wheelchair etc that do not apply to a generic address.
456 if (reverseXmlModel.get(0).description || reverseXmlModel.get(0).cuisine || reverseXmlModel.get(0).phone || reverseXmlModel.get(0).opening_hours
457 || reverseXmlModel.get(0).website && reverseXmlModel.get(0).wheelchair || reverseXmlModel.get(0).internet_access) {
458
459 // Check if the name, osm_id and osm_type are valid, otherwise the POI popup will break.
460 if (reverseXmlModel.get(0).name && reverseXmlModel.get(0).osm_id && reverseXmlModel.get(0).osm_type) {
461 goThereActionPopover.poiName = reverseXmlModel.get(0).name
462 goThereActionPopover.osm_id = reverseXmlModel.get(0).osm_id
463 goThereActionPopover.osm_type = reverseXmlModel.get(0).osm_type.charAt(0).toUpperCase()
464 goThereActionPopover.phone = reverseXmlModel.get(0).phone
465 } else {
466 goThereActionPopover.reverseGeoString = reverseXmlModel.get(0).result
467 }
468 }
469
470 // If nothing works, fall back to just showing the address in a generic popup
471 else {
472 goThereActionPopover.reverseGeoString = reverseXmlModel.get(0).result
473 }
474 }
475 }
476
477 source: ""
478 query: "/reversegeocode"
479
480 XmlRole { name: "osm_type"; query: "result/@osm_type/string()" }
481 XmlRole { name: "osm_id"; query: "result/@osm_id/string()" }
482 XmlRole { name: "result"; query: "result/string()" }
483 XmlRole { name: "name"; query: "namedetails/name/string()" }
484 XmlRole { name: "description"; query: "extratags/tag[@key='description']/@value/string()" }
485 XmlRole { name: "cuisine"; query: "extratags/tag[@key='cuisine']/@value/string()" }
486 XmlRole { name: "phone"; query: "extratags/tag[@key='phone']/@value/string()" }
487 XmlRole { name: "opening_hours"; query: "extratags/tag[@key='opening_hours']/@value/string()" }
488 XmlRole { name: "website"; query: "extratags/tag[@key='website']/@value/string()" }
489 XmlRole { name: "internet_access"; query: "extratags/tag[@key='internet_access']/@value/string()" }
490 XmlRole { name: "wheelchair"; query: "extratags/tag[@key='wheelchair']/@value/string()" }
491 }
492
422 PoiPopup {493 PoiPopup {
423 id: goThereActionPopover494 id: goThereActionPopover
424495
425 // Dragons be here! Don't change these values496 // Dragons be here! Don't change these values
426 hidePosition: -3*height497 hidePosition: -3*height
427 showPosition: navApp.settings.headerVisible ? 0 : -navigationPage.header.height498 showPosition: navApp.settings.headerVisible ? 0 : -navigationPage.header.height
428 anchors { top: navigationPage.header.bottom; topMargin: hidePosition }499 anchors { top: navigationPage.header.bottom }
429500
430 height: mainContentLoader.height + 2*mainContentLoader.anchors.margins501 height: mainContentLoader.height + 2*mainContentLoader.anchors.margins
431502
503 property string reverseGeoString: ""
432 property string poiName504 property string poiName
433 property string osm_type505 property string osm_type
434 property string osm_id506 property string osm_id
435 property string website507 property string website
436 property string phone508 property string phone
437509
510 onIsShownChanged: {
511 if (!goThereActionPopover.isShown) {
512 reverseXmlModel.clear()
513 }
514 }
515
438 Loader {516 Loader {
439 id: mainContentLoader517 id: mainContentLoader
440 sourceComponent: goThereActionPopover.isShown ? (goThereActionPopover.osm_id === 'none' ? genericPopupComponent : poiPopupComponent) : undefined518 sourceComponent: goThereActionPopover.isShown ? (goThereActionPopover.osm_id === 'none' ? genericPopupComponent : poiPopupComponent) : undefined
@@ -447,12 +525,15 @@
447 spacing: units.gu(2)525 spacing: units.gu(2)
448526
449 Label {527 Label {
450 textSize: Label.Large528 id: geoCodeLabel
529 maximumLineCount: 3
451 width: parent.width530 width: parent.width
452 visible: !goThereActionPopover.poiName531 wrapMode: Text.WordWrap
532 color: UbuntuColors.slate
453 horizontalAlignment: Text.AlignHCenter533 horizontalAlignment: Text.AlignHCenter
454 text: i18n.tr("Coord: %1, %2").arg(parseFloat(mainPageStack.clickedLat).toFixed(5)).arg(parseFloat(mainPageStack.clickedLng).toFixed(5))534 textSize: !truncated ? Label.Large : Label.Medium
455 color: UbuntuColors.slate535 text: goThereActionPopover.reverseGeoString ? goThereActionPopover.reverseGeoString
536 : i18n.tr("Coord: %1, %2").arg(parseFloat(mainPageStack.clickedLat).toFixed(5)).arg(parseFloat(mainPageStack.clickedLng).toFixed(5));
456 }537 }
457538
458 Row {539 Row {
459540
=== modified file 'qml/components/PoiPopup.qml'
--- qml/components/PoiPopup.qml 2016-04-12 18:47:27 +0000
+++ qml/components/PoiPopup.qml 2016-04-14 19:07:42 +0000
@@ -37,10 +37,15 @@
37 isShown = false37 isShown = false
38 }38 }
3939
40 Component.onCompleted: {
41 // Without this, the popup hides when the height is changed after the popup is visible
42 popup.anchors.topMargin = hidePosition
43 }
44
45 // This mouse area is to stop any user input from leaking from the popup into the map.
40 MouseArea {46 MouseArea {
41 z: -147 z: -1
42 anchors.fill: parent48 anchors.fill: parent
43 propagateComposedEvents: true
44 }49 }
4550
46 UbuntuNumberAnimation {51 UbuntuNumberAnimation {

Subscribers

People subscribed via source and target branches