OpenLayers OpenLayers

Ticket #1503 (closed bug: fixed)

Opened 4 months ago

Last modified 4 months ago

panning off for odd-sized viewport

Reported by: tschaub Assigned to:
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 (2.8 kB) - added by tschaub on 04/09/08 10:02:00.
proper panning for odd-sized viewports

Change History

04/08/08 15:32:59 changed 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.

04/08/08 15:33:19 changed by tschaub

  • milestone changed from 2.7 Release to 2.6 Release.

Since it is a regression.

04/09/08 10:02:00 changed by tschaub

  • attachment odd.patch added.

proper panning for odd-sized viewports

04/09/08 10:02:07 changed 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.

04/09/08 10:03:53 changed by tschaub

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

04/09/08 10:04:02 changed by tschaub

  • state changed from Needs Discussion to Review.

04/09/08 10:24:34 changed by crschmidt

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

04/09/08 10:30:52 changed by tschaub

Tests pass in IE as well.

04/09/08 10:44:41 changed 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).

04/09/08 11:54:02 changed 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)

04/09/08 12:48:09 changed by tschaub

  • state changed from Complete to Pullup.

04/09/08 13:56:10 changed by crschmidt

  • status changed from closed to reopened.
  • resolution deleted.

04/09/08 14:00:32 changed 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