Ticket #1503 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

panning off for odd-sized viewport

Reported by: tschaub Owned by:
Priority: minor Milestone: 2.6 Release
Component: Map Version: 2.6 RC1
Keywords: Cc:
State: Complete

Description

This can be demonstrated from the full screen example.

Adjust the window size until you have an odd-sized viewport. Pan in the odd direction to see problem.

The issue came up in r6492.

Imagine a map that is 10 pixels wide. Setting the center to 0 gives you a layer container origin of 0 (map units). Convert this to pixels with map.getViewPortPxFromLonLat and you get 5.

Imagine a map that is 11 pixels wide. Setting the center to 0 gives you a layer container origin of 0 (map units). Convert this to pixels with map.getViewPortPxFromLonLat and you get 6. The *real* pixel center, however, is 5.5.

Drag this odd-sized map one pixel to the right. The new center (pretend we have a resolution of 1) is -1. The DragPan control tells the map to pan with a dx of -1 (weird that this is negative, but that's the requirement from the map.pan method). The new center is correctly calculated and set.

Then map.centerLayerContainer is called with that center. The layer container origin (remember, it was 0 in map units) is one map unit to the right of the map center. However, the map.getViewPortPxFromLonLat returns 6 for both the layer container origin and the new center.

This explanation lacks some detail, but I'm out of energy.

Attachments

odd.patch Download (2.8 KB) - added by tschaub 5 years ago.
proper panning for odd-sized viewports

Change History

Changed 5 years ago by tschaub

  • state set to Needs Discussion

Oddly, only one test fails with this patch. Only the image layer tests check for an integer pixel position in the case where you might get back a float. Anyway, this is a change that I don't think will go over well - to get back fractional pixel values. If we go this solution, then Math.round should be placed anywhere the results are set as style positions.

That said, all examples seem to work (that I tried). I even changed a couple of them to use odd-sized viewports.

This one needs attention from someone else.

Changed 5 years ago by tschaub

  • milestone changed from 2.7 Release to 2.6 Release

Since it is a regression.

Changed 5 years ago by tschaub

proper panning for odd-sized viewports

Changed 5 years ago by crschmidt

Tim and I chatted about this, and agreed that since the primary way we interact with these functions is through the Map's getPixelFromLonLat, we should wrap up the rounding into that function (and internally, we have to update all the library code to round off pixels). This should leave the affect on applications using the preferred API method 'clean' going forward.

Changed 5 years ago by tschaub

Tests pass in FF. I think things might break in IE - so I'll check there.

Changed 5 years ago by tschaub

  • state changed from Needs Discussion to Review

Changed 5 years ago by crschmidt

Tests pass in Opera, Safari, no sign of example breakages in either.

Changed 5 years ago by tschaub

Tests pass in IE as well.

Changed 5 years ago by crschmidt

  • state changed from Review to Commit

Great. I'm happy with this: I think it solves our regression in a useful way. Please commit (and mark Pullup).

Changed 5 years ago by tschaub

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [6831]) Fixing panning for odd-sized viewports (broken in r6492). This makes map.getViewPortPxFromLonLat return fractional pixel values. To get integer pixel values, use map.getPixelFromLonLat. A better solution may be possible in the future. r=crschmidt (closes #1503)

Changed 5 years ago by tschaub

  • state changed from Complete to Pullup

Changed 5 years ago by crschmidt

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 5 years ago by crschmidt

  • status changed from reopened to closed
  • state changed from Pullup to Complete
  • resolution set to fixed

(In r6835) Finish pullups for RC2.

#1498 Easily turning off/overriding default select and temporary intent styles #1501 GeoRSS format tests fail in Safari #1502 Events register method fails if listeners member is not an array #1503 panning off for odd-sized viewport #1504 doc review

Note: See TracTickets for help on using tickets.