After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735842 - placeEntry: Add support for plain coordinates
placeEntry: Add support for plain coordinates
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-01 19:40 UTC by Damián Nohales
Modified: 2014-09-06 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
placeEntry: Add support for plain coordinates (2.65 KB, patch)
2014-09-01 19:45 UTC, Damián Nohales
reviewed Details | Review
turnPointMarker: Adapt to PlaceEntry's plain coordinates support (1.01 KB, patch)
2014-09-01 19:46 UTC, Damián Nohales
reviewed Details | Review
searchResultBubble: Show plain coordinates based places properly (1.10 KB, patch)
2014-09-01 19:46 UTC, Damián Nohales
reviewed Details | Review
placeEntry: Add support for RFC5870 URIs and plain coordinates (3.79 KB, patch)
2014-09-04 22:34 UTC, Damián Nohales
needs-work Details | Review
turnPointMarker: Remove custom name (1002 bytes, patch)
2014-09-04 22:35 UTC, Damián Nohales
reviewed Details | Review
searchResultMarker: Disable bubble for unnamed places (1.06 KB, patch)
2014-09-04 22:35 UTC, Damián Nohales
reviewed Details | Review
placeEntry: Add support for plain coordinates (2.92 KB, patch)
2014-09-05 22:05 UTC, Damián Nohales
committed Details | Review
turnPointMarker: Remove custom name (1002 bytes, patch)
2014-09-05 22:06 UTC, Damián Nohales
committed Details | Review
searchResultMarker: Disable bubble for unnamed places (1.06 KB, patch)
2014-09-05 22:07 UTC, Damián Nohales
committed Details | Review
placeEntry: Add parseOnFocusOut option (2.74 KB, patch)
2014-09-05 22:07 UTC, Damián Nohales
committed Details | Review

Description Damián Nohales 2014-09-01 19:40:16 UTC
It'd be great to have the possibility to introduce plain coordinates ("<latitude>, <longitude>") to search for a place.

This is a very useful feature but really catch my attention during the review of via points feature (#731068) in which you can drag the destination markers, causing place entry to update with the plain coordinates of the new place, the user then is not able to modify this coordinates by hand and that can be unintuitive.

You can see more discussion about this here [1], item (d).

https://bugzilla.gnome.org/show_bug.cgi?id=731068#c259
Comment 1 Damián Nohales 2014-09-01 19:43:44 UTC
Sorry, mispelled the link [1] reference.
Comment 2 Damián Nohales 2014-09-01 19:45:56 UTC
Created attachment 285071 [details] [review]
placeEntry: Add support for plain coordinates

This adds support for parsing plain coordinates with the format
"<latitude>, <longitude>" in PlaceEntry class. When PlaceEntry
detects a valid plain coordinate (valid format, between valid ranges)
being introduced, it will skip the place search, also, no reverse
search is performed.

Plain coordinates places are internally represented by a GeocodePlace
object whose "name" property is null.
Comment 3 Damián Nohales 2014-09-01 19:46:19 UTC
Created attachment 285072 [details] [review]
turnPointMarker: Adapt to PlaceEntry's plain coordinates support
Comment 4 Damián Nohales 2014-09-01 19:46:42 UTC
Created attachment 285073 [details] [review]
searchResultBubble: Show plain coordinates based places properly
Comment 5 Damián Nohales 2014-09-01 19:48:07 UTC
Please note that this patch-set must be applied after #731068 patch-set.
Comment 6 Jonas Danielsson 2014-09-04 05:24:07 UTC
Review of attachment 285071 [details] [review]:

Thanks!

::: src/placeEntry.js
@@ +124,3 @@
 
+    _parseCoordinates: function(text) {
+        let match = /^\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*,\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*$/g.exec(text);

When grepping in gnome-shell I think that the construct:

let matches = text.match(...) is more common.

Also if you find a way to shorten that line it would be nice :)
And maybe a common somewhere on what it is matching? Parsing regexp is not always the most fun you can have before drinking your first cup of coffee.

Is regex called for? Could it be parsed with simpler means?

@@ +145,3 @@
         }
 
+        let parsedCoordinates = this._parseCoordinates(this.text);

Maybe a comment above about what we are doing here?

Also, maybe let location = ...? And return a Geocode.Location?
Comment 7 Jonas Danielsson 2014-09-04 05:25:36 UTC
Review of attachment 285072 [details] [review]:

Looks fine.

The commit shortlog is a bit long, maybe:

turnPointerMarker: Remove custom name

And a sentence in the message about it is no longer needed.
Comment 8 Jonas Danielsson 2014-09-04 05:26:16 UTC
Review of attachment 285073 [details] [review]:

When is this ever needed?
Comment 9 Jonas Danielsson 2014-09-04 09:20:24 UTC
Review of attachment 285071 [details] [review]:

::: src/placeEntry.js
@@ +123,3 @@
     },
 
+    _parseCoordinates: function(text) {

Also is coords or similar more descriptive than text?
Comment 10 Damián Nohales 2014-09-04 14:18:14 UTC
Review of attachment 285071 [details] [review]:

::: src/placeEntry.js
@@ +123,3 @@
     },
 
+    _parseCoordinates: function(text) {

We don't know if they are coords before parsing :), we want to parse a piece of "text" to get coordinates.

@@ +124,3 @@
 
+    _parseCoordinates: function(text) {
+        let match = /^\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*,\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*$/g.exec(text);

Maybe moving the regex to a constant, add a comment to the constant and replace [0-9] for \d can keep the code more clean.

Yes, parse an unowned regex is not an easy task... you usually need to trust on it ;)

@@ +145,3 @@
         }
 
+        let parsedCoordinates = this._parseCoordinates(this.text);

Yeah, maybe that'd be more clean.
Comment 11 Damián Nohales 2014-09-04 14:22:36 UTC
Review of attachment 285073 [details] [review]:

When you search for a plain coordinate in the main search entry, what should we show? without this change we would show a bubble with a pin image and no text, I tried to show something neater.
Comment 12 Jonas Danielsson 2014-09-04 18:45:31 UTC
Review of attachment 285071 [details] [review]:

::: src/placeEntry.js
@@ +124,3 @@
 
+    _parseCoordinates: function(text) {
+        let match = /^\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*,\s*(\-?[0-9]+(?:\.[0-9]+)?)\s*$/g.exec(text);

How about the possibility of an optional label/description? So that for instance user loation can set "current location" ? And for when we get uri support with the geouri extension of setting a label?

"label: lat, lon" or something like that.
Comment 13 Jonas Danielsson 2014-09-04 18:47:44 UTC
Review of attachment 285073 [details] [review]:

::: src/searchResultBubble.js
@@ +51,3 @@
 
+        if (!place.name) {
+            title = _("Unknown location");

Could we do this without introducing a translatable string? (if we want to sneak this in). We could show a label if there is one, or just the coordinates if not.

Also maybe this should be a more general bubble? So that it could also be used for uri and other non-named locations. The searchResultMarker could show that bubble if !place.name.
Comment 14 Damián Nohales 2014-09-04 19:30:00 UTC
Review of attachment 285073 [details] [review]:

::: src/searchResultBubble.js
@@ +51,3 @@
 
+        if (!place.name) {
+            title = _("Unknown location");

You're right on the translatable string, I noticed that too.

From the choices that you mention, I do prefer to not show any bubble when !place.name, showing coordinates in the bubble as a title may look ugly.

Actually yes... SearchResultBubble has some reusable code to generate bubble content for different kind of places. About the uri feature, what about fill the search bar with opened location and fire the search?
Comment 15 Damián Nohales 2014-09-04 22:28:24 UTC
(In reply to comment #12)
> How about the possibility of an optional label/description? So that for
> instance user loation can set "current location" ? And for when we get uri
> support with the geouri extension of setting a label?
> 
> "label: lat, lon" or something like that.

After discuss it a little bit with Jonas, we conclude that it'd be a good idea to make some little parsing in PlaceEntry to support geo: URIs too.

This will affect #735215, where we plan to use search bar and SearchResultMarker,Bubble directly to show opened locations via --uri command line option, substantially simplifying #735215 code.
Comment 16 Damián Nohales 2014-09-04 22:34:46 UTC
Created attachment 285429 [details] [review]
placeEntry: Add support for RFC5870 URIs and plain coordinates

The URIs supported are the same as for GeocodeGlib:

The URI should be in the geo scheme (RFC 5870) which in its simplest
form looks like:
    geo:latitude,longitude

An Android extension to set a description is also supported in the form
of:
    geo:0,0?q=latitude,longitude(description)

Since we can have unnamed places with this approach, we need to support
these in PlaceEntry to show a proper text in the entries for these
cases like the plain coordinates. As plain coordinates are now valid
values for PlaceEntry we may interpret it as well.

------

I don't know if is a good idea to add URIs and plain coordinates
support in the same commit, but since we add the chance to have
unnamed places by adding URI support and we need a way to represent
these kind of places in PlaceEntry's, don't add support for plain
coordinates as valid input as well seemed inconsistent.
Comment 17 Damián Nohales 2014-09-04 22:35:18 UTC
Created attachment 285430 [details] [review]
turnPointMarker: Remove custom name
Comment 18 Damián Nohales 2014-09-04 22:35:43 UTC
Created attachment 285431 [details] [review]
searchResultMarker: Disable bubble for unnamed places
Comment 19 Damián Nohales 2014-09-04 23:09:17 UTC
Review of attachment 285429 [details] [review]:

I can see a UX problem with this, let say that I have 2 coordinates and I want to copy into clipboard and then paste it to search the route between these two points, so, the most logic steps are:

- Copy first coordinate
- Paste in From entry
- Copy second coordinate
- Paste in To entry
- Press INTRO (I have focus in To entry)

Since I've never pressed INTRO when having focus in From entry, the _onActivate method was never executed, so the place property wasn't updated for this entry. So the result are an inconsistent search (From was filled before paste) or no search being executed (From wasn't filled before paste).

An easy way to fix it maybe is force string parsing on focus out (if we cannot parse as an URI or plain coordinate, do nothing as we are doing now), that maybe can look weird when interacting with main search entry (search triggered on focus out), we can add an option to PlaceEntry to avoid this or different classes for main search entry and route point search entry.

I also was thinking about update the place when user is writing, but right now the patch update the entry text on place change and it can be a problem if the user want to search for a place that is similar to a geographic coordinate.
Comment 20 Jonas Danielsson 2014-09-05 05:26:48 UTC
Review of attachment 285429 [details] [review]:

Thanks! Looks fine.

But. Don't include the uri parsing in this. Make it a patch of it's own. Maybe it should go in at the same time we introduce --uri.
But at least make it a patch of it's own.

About the UX bit:
Could you cook up a follow-up patch that triggers the parsing on focus-out, and introduce a property that enables it?
So that we can test the behavior. You could also hook up to the paste-clipboard signal?

https://developer.gnome.org/gtk3/stable/GtkEntry.html#GtkEntry-paste-clipboard

And the property would be "parse-on-paste" ?

::: src/placeEntry.js
@@ +149,3 @@
+        } catch(e) {
+            Utils.debug('Geo URI parsing failed: ' + e);
+            return null;

This message should be user visiable I think. Maybe with Application.notificationManager.showMessage.
Comment 21 Jonas Danielsson 2014-09-05 05:27:35 UTC
Review of attachment 285430 [details] [review]:

Looks fine.
Comment 22 Jonas Danielsson 2014-09-05 05:28:29 UTC
Review of attachment 285431 [details] [review]:

So this makes so that a search-result with no name shows no bubble.

Andreas: Is there a nice way to show a bubble that is coordinates only, or is this better?
Comment 23 Andreas Nilsson 2014-09-05 13:24:38 UTC
(In reply to comment #22)
> Review of attachment 285431 [details] [review]:
> 
> So this makes so that a search-result with no name shows no bubble.
> 
> Andreas: Is there a nice way to show a bubble that is coordinates only, or is
> this better?

I think no bubble sounds good. Just the pin.
You could kind of try and find the nearest address, but I feel it's a bit too error-prone.
Comment 24 Damián Nohales 2014-09-05 22:05:58 UTC
Created attachment 285531 [details] [review]
placeEntry: Add support for plain coordinates

This adds support for parsing plain coordinates with the format
"<latitude>, <longitude>" in PlaceEntry class. When PlaceEntry
detects a valid plain coordinate (valid format, between valid ranges)
being introduced, it will skip the place search, also, no reverse
search is performed.

Plain coordinates places are internally represented by a GeocodePlace
object whose "name" property is null.
Comment 25 Damián Nohales 2014-09-05 22:06:34 UTC
Created attachment 285532 [details] [review]
turnPointMarker: Remove custom name
Comment 26 Damián Nohales 2014-09-05 22:07:10 UTC
Created attachment 285533 [details] [review]
searchResultMarker: Disable bubble for unnamed places
Comment 27 Damián Nohales 2014-09-05 22:07:46 UTC
Created attachment 285534 [details] [review]
placeEntry: Add parseOnFocusOut option

This fix a usability issue related to plain coordinates support and
sidebar place entries, where user writes a plain coordinate in
the entry and jump to the next entry without pressing INTRO to
confirm the place.
Comment 28 Jonas Danielsson 2014-09-06 15:58:26 UTC
Attachment 285531 [details] pushed as d6f283b - placeEntry: Add support for plain coordinates
Attachment 285532 [details] pushed as 0f1e4ac - turnPointMarker: Remove custom name
Attachment 285534 [details] pushed as b839089 - placeEntry: Add parseOnFocusOut option