[OpenLayers-Dev] calculateBounds function

bartvde at osgis.nl bartvde at osgis.nl
Tue Nov 11 05:47:10 EST 2008


This is a very basic GIS calculation.

Resolution is how many map units per pixel. Map units can be degrees,
meters etc., but the OpenLayers terminology mostly comes from a
degree/latitude/longtitude point of view.

So if the map is 500 by 600 pixels, and the resolution is 20, then the
width of the map in map units 10.000 and the height in map units is
12.000.

The extent then ranges from:
-left: the center X (or longitude) minus half the width (in map units)
-right: the center X (or longitude) plus half the width (in map units)
-bottom: the center Y (or latitude) minus half the height (in map units)
-top: the center Y (or latitude) plus half the height (in map units)

Hope this helps, if not let us know.

Best regards,
Bart

> Can someone please tell me or point me to some literature that explains
> the
> logic behind the below piece of code (Taken from calculateBounds method of
> Map class)?
>
> var size = this.getSize();<Returns view port size>
> var w_deg = size.w * resolution;
> var h_deg = size.h * resolution;
> extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
>                                            center.lat - h_deg / 2,
>                                            center.lon + w_deg / 2,
>                                            center.lat + h_deg / 2);
>
> --
> Cheers,
> Abhi
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>





More information about the Dev mailing list