Page MenuHomePhabricator

Input type 'leaflet' permits entry of longitude beyond ±180°
Closed, ResolvedPublic

Description

In the leaflet map (e.g.) it's possible to pan the map to the left or right and click beyond ±180 and the higher value for longitude will be entered in the form. Instead, it should be normalised to within 360°.

This is with PageForms 4.6 (42e02fb).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 27 2019, 12:27 AM

Actually I didn't pan. Rather the map that opened for me was quite wide and had the globe repeating 2 or 3 times. That is, there were multiple Australia's on screen. I clicked on a random Australia and then zoomed in. So the problem may be seen as either there should not be more than one globe shown or the longitude should be calculated down to the range -180 to 180.

Ah, good point!

I don't think we can easily prevent the infinite-sideways map thing, so I think the easiest fix is to let the user click wherever, and calculate the right coordinate. This technically means that you'd click on one place on the map, save and re-open the editing for, and your pin would be in a 'different' place... but it's not really a different place, so I don't think anyone will mind. Wouldn't work for other non-geographic maps maybe, but they're not supported here.

Here's a related discussion, with a fix: https://gis.stackexchange.com/questions/303300/calculating-correct-longitude-when-its-over-180

Agreed. I don't think anyone will be saying "no no, my event's being held in the other australia". :-)

Change 546394 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/extensions/PageForms@master] Prevent Leaflet markers from being outside -180° to 180°.

https://gerrit.wikimedia.org/r/546394

Change 546394 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Prevent Leaflet markers from being outside -180° to 180°.

https://gerrit.wikimedia.org/r/546394

No worries.

And thanks @Kerry_Raymond for finding the bug!

Actually... just testing this a bit more, and it's not quite good: the pin appears in a different place to where you click now! I guess the coordinate normalization shouldn't happen when placing the marker, but when updating the coords field (so the coords of the marker and the coords of the field can be different).

Change 547693 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/extensions/PageForms@master] Only normalize longitude when setting form value, not for marker

https://gerrit.wikimedia.org/r/547693

Change 547693 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Only normalize longitude when setting form value, not for marker

https://gerrit.wikimedia.org/r/547693

Samwilson closed this task as Resolved.Nov 1 2019, 1:53 AM
Samwilson claimed this task.
Samwilson added a project: Wikimedia Australia.

All sorted now I think. I've updated the WMAU wiki.

Kerry, can you confirm that it's working better now?

Looks good. I must admit I am only seeing one globe this time but it seems it can be scrolled left and right forever (well, I did about 5-10 of scrolls in before I got bored and clicked on Brisbane). Each time I got coords that looked plausible.