Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Layer/MultiMap.js @ 76

Revision 76, 7.1 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the Clear BSD license. 
3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4 * full text of the license. */
5
6/**
7 * @requires OpenLayers/Layer/EventPane.js
8 * @requires OpenLayers/Layer/FixedZoomLevels.js
9 */
10
11/**
12 * Class: OpenLayers.Layer.MultiMap
13 * Note that MultiMap does not fully support the sphericalMercator
14 * option. See Ticket #953 for more details.
15 *
16 * Inherits from:
17 *  - <OpenLayers.Layer.EventPane>
18 *  - <OpenLayers.Layer.FixedZoomLevels>
19 */
20OpenLayers.Layer.MultiMap = OpenLayers.Class(
21  OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {
22   
23    /**
24     * Constant: MIN_ZOOM_LEVEL
25     * {Integer} 1
26     */
27    MIN_ZOOM_LEVEL: 1,
28   
29    /**
30     * Constant: MAX_ZOOM_LEVEL
31     * {Integer} 17
32     */
33    MAX_ZOOM_LEVEL: 17,
34
35    /**
36     * Constant: RESOLUTIONS
37     * {Array(Float)} Hardcode these resolutions so that they are more closely
38     *                tied with the standard wms projection
39     */
40    RESOLUTIONS: [
41        9, 
42        1.40625,
43        0.703125,
44        0.3515625,
45        0.17578125,
46        0.087890625,
47        0.0439453125,
48        0.02197265625,
49        0.010986328125,
50        0.0054931640625,
51        0.00274658203125,
52        0.001373291015625,
53        0.0006866455078125,
54        0.00034332275390625,
55        0.000171661376953125,
56        0.0000858306884765625,
57        0.00004291534423828125
58    ],
59
60    /**
61     * APIProperty: type
62     * {?}
63     */
64    type: null,
65
66    /**
67     * Constructor: OpenLayers.Layer.MultiMap
68     *
69     * Parameters:
70     * name - {String}
71     * options - {Object}
72     */
73    initialize: function(name, options) {
74        OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
75        OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 
76                                                                    arguments);
77        if (this.sphericalMercator) {
78            OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
79            this.initMercatorParameters();
80            this.RESOLUTIONS.unshift(10); 
81        }   
82    },
83   
84    /**
85     * Method: loadMapObject
86     */
87    loadMapObject:function() {
88        try { //crash proofing
89            this.mapObject = new MultimapViewer(this.div);
90        } catch (e) { }
91    },
92
93    /**
94     * APIMethod: getWarningHTML
95     *
96     * Returns:
97     * {String} String with information on why layer is broken, how to get
98     *          it working.
99     */
100    getWarningHTML:function() {
101        return OpenLayers.i18n(
102            "getLayerWarning", {'layerType':"MM", 'layerLib':"MultiMap"}
103        );
104    },
105
106
107
108    /************************************
109     *                                  *
110     *   MapObject Interface Controls   *
111     *                                  *
112     ************************************/
113
114
115  // Get&Set Center, Zoom
116
117    /**
118     * APIMethod: setMapObjectCenter
119     * Set the mapObject to the specified center and zoom
120     *
121     * Parameters:
122     * center - {Object} MapObject LonLat format
123     * zoom - {int} MapObject zoom format
124     */
125    setMapObjectCenter: function(center, zoom) {
126        this.mapObject.goToPosition(center, zoom); 
127    },
128   
129    /**
130     * APIMethod: getMapObjectCenter
131     *
132     * Returns:
133     * {Object} The mapObject's current center in Map Object format
134     */
135    getMapObjectCenter: function() {
136        return this.mapObject.getCurrentPosition();
137    },
138
139    /**
140     * APIMethod: getMapObjectZoom
141     *
142     * Returns:
143     * {Integer} The mapObject's current zoom, in Map Object format
144     */
145    getMapObjectZoom: function() {
146        return this.mapObject.getZoomFactor();
147    },
148
149
150  // LonLat - Pixel Translation
151 
152    /**
153     * APIMethod: getMapObjectLonLatFromMapObjectPixel
154     *
155     * Parameters:
156     * moPixel - {Object} MapObject Pixel format
157     *
158     * Returns:
159     * {Object} MapObject LonLat translated from MapObject Pixel
160     */
161    getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
162        moPixel.x = moPixel.x - (this.map.getSize().w/2);
163        moPixel.y = moPixel.y - (this.map.getSize().h/2);
164        return this.mapObject.getMapPositionAt(moPixel);
165    },
166
167    /**
168     * APIMethod: getMapObjectPixelFromMapObjectLonLat
169     *
170     * Parameters:
171     * moLonLat - {Object} MapObject LonLat format
172     *
173     * Returns:
174     * {Object} MapObject Pixel transtlated from MapObject LonLat
175     */
176    getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
177        return this.mapObject.geoPosToContainerPixels(moLonLat);
178    },
179
180
181    /************************************
182     *                                  *
183     *       MapObject Primitives       *
184     *                                  *
185     ************************************/
186
187
188  // LonLat
189   
190    /**
191     * APIMethod: getLongitudeFromMapObjectLonLat
192     *
193     * Parameters:
194     * moLonLat - {Object} MapObject LonLat format
195     *
196     * Returns:
197     * {Float} Longitude of the given MapObject LonLat
198     */
199    getLongitudeFromMapObjectLonLat: function(moLonLat) {
200        return this.sphericalMercator ? 
201            this.forwardMercator(moLonLat.lon, moLonLat.lat).lon :
202            moLonLat.lon;
203    },
204
205    /**
206     * APIMethod: getLatitudeFromMapObjectLonLat
207     *
208     * Parameters:
209     * moLonLat - {Object} MapObject LonLat format
210     *
211     * Returns:
212     * {Float} Latitude of the given MapObject LonLat
213     */
214    getLatitudeFromMapObjectLonLat: function(moLonLat) {
215        return this.sphericalMercator ? 
216            this.forwardMercator(moLonLat.lon, moLonLat.lat).lat :
217            moLonLat.lat;
218    },
219
220    /**
221     * APIMethod: getMapObjectLonLatFromLonLat
222     *
223     * Parameters:
224     * lon - {Float}
225     * lat - {Float}
226     *
227     * Returns:
228     * {Object} MapObject LonLat built from lon and lat params
229     */
230    getMapObjectLonLatFromLonLat: function(lon, lat) {
231        var mmLatLon;
232        if(this.sphericalMercator) {
233            var lonlat = this.inverseMercator(lon, lat);
234            mmLatLon = new MMLatLon(lonlat.lat, lonlat.lon);
235        } else {
236            mmLatLon = new MMLatLon(lat, lon);
237        }
238        return mmLatLon;
239    },
240
241  // Pixel
242   
243    /**
244     * APIMethod: getXFromMapObjectPixel
245     *
246     * Parameters:
247     * moPixel - {Object} MapObject Pixel format
248     *
249     * Returns:
250     * {Integer} X value of the MapObject Pixel
251     */
252    getXFromMapObjectPixel: function(moPixel) {
253        return moPixel.x;
254    },
255
256    /**
257     * APIMethod: getYFromMapObjectPixel
258     *
259     * Parameters:
260     * moPixel - {Object} MapObject Pixel format
261     *
262     * Returns:
263     * {Integer} Y value of the MapObject Pixel
264     */
265    getYFromMapObjectPixel: function(moPixel) {
266        return moPixel.y;
267    },
268
269    /**
270     * APIMethod: getMapObjectPixelFromXY
271     *
272     * Parameters:
273     * x - {Integer}
274     * y - {Integer}
275     *
276     * Returns:
277     * {Object} MapObject Pixel from x and y parameters
278     */
279    getMapObjectPixelFromXY: function(x, y) {
280        return new MMPoint(x, y);
281    },
282
283    CLASS_NAME: "OpenLayers.Layer.MultiMap"
284});
Note: See TracBrowser for help on using the repository browser.