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/BaseTypes/Pixel.js @ 76

Revision 76, 2.9 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/Console.js
8 */
9
10/**
11 * Class: OpenLayers.Pixel
12 * This class represents a screen coordinate, in x and y coordinates
13 */
14OpenLayers.Pixel = OpenLayers.Class({
15   
16    /**
17     * APIProperty: x
18     * {Number} The x coordinate
19     */
20    x: 0.0,
21
22    /**
23     * APIProperty: y
24     * {Number} The y coordinate
25     */
26    y: 0.0,
27   
28    /**
29     * Constructor: OpenLayers.Pixel
30     * Create a new OpenLayers.Pixel instance
31     *
32     * Parameters:
33     * x - {Number} The x coordinate
34     * y - {Number} The y coordinate
35     *
36     * Returns:
37     * An instance of OpenLayers.Pixel
38     */
39    initialize: function(x, y) {
40        this.x = parseFloat(x);
41        this.y = parseFloat(y);
42    },
43   
44    /**
45     * Method: toString
46     * Cast this object into a string
47     *
48     * Returns:
49     * {String} The string representation of Pixel. ex: "x=200.4,y=242.2"
50     */
51    toString:function() {
52        return ("x=" + this.x + ",y=" + this.y);
53    },
54
55    /**
56     * APIMethod: clone
57     * Return a clone of this pixel object
58     *
59     * Returns:
60     * {<OpenLayers.Pixel>} A clone pixel
61     */
62    clone:function() {
63        return new OpenLayers.Pixel(this.x, this.y); 
64    },
65   
66    /**
67     * APIMethod: equals
68     * Determine whether one pixel is equivalent to another
69     *
70     * Parameters:
71     * px - {<OpenLayers.Pixel>}
72     *
73     * Returns:
74     * {Boolean} The point passed in as parameter is equal to this. Note that
75     * if px passed in is null, returns false.
76     */
77    equals:function(px) {
78        var equals = false;
79        if (px != null) {
80            equals = ((this.x == px.x && this.y == px.y) ||
81                      (isNaN(this.x) && isNaN(this.y) && isNaN(px.x) && isNaN(px.y)));
82        }
83        return equals;
84    },
85
86    /**
87     * APIMethod: add
88     *
89     * Parameters:
90     * x - {Integer}
91     * y - {Integer}
92     *
93     * Returns:
94     * {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the
95     * values passed in.
96     */
97    add:function(x, y) {
98        if ( (x == null) || (y == null) ) {
99            var msg = OpenLayers.i18n("pixelAddError");
100            OpenLayers.Console.error(msg);
101            return null;
102        }
103        return new OpenLayers.Pixel(this.x + x, this.y + y);
104    },
105
106    /**
107    * APIMethod: offset
108    *
109    * Parameters
110    * px - {<OpenLayers.Pixel>}
111    *
112    * Returns:
113    * {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the
114    *                      x&y values of the pixel passed in.
115    */
116    offset:function(px) {
117        var newPx = this.clone();
118        if (px) {
119            newPx = this.add(px.x, px.y);
120        }
121        return newPx;
122    },
123
124    CLASS_NAME: "OpenLayers.Pixel"
125});
Note: See TracBrowser for help on using the repository browser.