[OpenLayers-Dev] pixels not floats
John R. Frank
john.frank at metacarta.com
Sun Nov 2 06:06:52 EST 2008
Is there a reason that getPixelFromLonLat is where pixels get turned into
integers instead of floats?
in Map.js
getPixelFromLonLat: function (lonlat) {
var px = this.getViewPortPxFromLonLat(lonlat);
px.x = Math.round(px.x);
px.y = Math.round(px.y);
return px;
},
getViewPortPxFromLonLat: function (lonlat) {
var px = null;
if (this.baseLayer != null) {
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
}
return px;
},
Shouldn't the rounding be happening here in Layer.js?
in Layers.js
getViewPortPxFromLonLat: function (lonlat) {
var px = null;
if (lonlat != null) {
var resolution = this.map.getResolution();
var extent = this.map.getExtent();
px = new OpenLayers.Pixel(
(1/resolution * (lonlat.lon - extent.left)),
(1/resolution * (extent.top - lonlat.lat))
);
}
return px;
},
With a patch like this:
- (1/resolution * (lonlat.lon - extent.left)),
- (1/resolution * (extent.top - lonlat.lat))
+ Math.round(1/resolution * (lonlat.lon - extent.left)),
+ Math.round(1/resolution * (extent.top - lonlat.lat))
and corresponding changes to getPixelFromLonLat? Or is there some reason
to have pixel values that are secretly floats...?
John
More information about the Dev
mailing list