[483] | 1 | define([ |
---|
| 2 | "dojo/_base/kernel", |
---|
| 3 | "dojo/_base/declare", |
---|
| 4 | "./_base" |
---|
| 5 | ], function(dojo, declare, openlayers){ |
---|
| 6 | |
---|
| 7 | return declare("dojox.geo.openlayers.Feature", null, { |
---|
| 8 | // summary: |
---|
| 9 | // A Feature encapsulates an item so that it can be added to a Layer. |
---|
| 10 | // This class is not attended to be used as it, but serve as a base class |
---|
| 11 | // for specific features such as GeometryFeature which can display georeferenced |
---|
| 12 | // geometries and WidgetFeature which can display georeferenced widgets. |
---|
| 13 | constructor: function(){ |
---|
| 14 | // summary: |
---|
| 15 | // Construct a new Feature |
---|
| 16 | this._layer = null; |
---|
| 17 | this._coordSys = openlayers.EPSG4326; |
---|
| 18 | }, |
---|
| 19 | |
---|
| 20 | getCoordinateSystem: function(){ |
---|
| 21 | // summary: |
---|
| 22 | // Returns the coordinate system in which coordinates of this feature are expressed. |
---|
| 23 | // returns: |
---|
| 24 | // The coordinate system in which coordinates of this feature are expressed. |
---|
| 25 | return this._coordSys; // OpenLayers.Projection |
---|
| 26 | }, |
---|
| 27 | |
---|
| 28 | setCoordinateSystem: function(/* OpenLayers.Projection */cs){ |
---|
| 29 | // summary: |
---|
| 30 | // Set the coordinate system in which coordinates of this feature are expressed. |
---|
| 31 | // cs: OpenLayers.Projection |
---|
| 32 | // The coordinate system in which coordinates of this feature are expressed. |
---|
| 33 | this._coordSys = cs; |
---|
| 34 | }, |
---|
| 35 | |
---|
| 36 | getLayer: function(){ |
---|
| 37 | // summary: |
---|
| 38 | // Returns the Layer to which this feature belongs. |
---|
| 39 | // returns: |
---|
| 40 | // The layer to which this feature belongs. |
---|
| 41 | return this._layer; // dojox/geo/openlayers/Layer |
---|
| 42 | }, |
---|
| 43 | |
---|
| 44 | _setLayer: function(/* dojox/geo/openlayers/Layer */l){ |
---|
| 45 | // summary: |
---|
| 46 | // Sets the layer to which this Feature belongs |
---|
| 47 | // description: |
---|
| 48 | // Called when the feature is added to the Layer. |
---|
| 49 | // tags: |
---|
| 50 | // private |
---|
| 51 | this._layer = l; |
---|
| 52 | }, |
---|
| 53 | |
---|
| 54 | render: function(){ |
---|
| 55 | // summary: |
---|
| 56 | // subclasses implements drawing specific behavior. |
---|
| 57 | }, |
---|
| 58 | |
---|
| 59 | remove: function(){ |
---|
| 60 | // summary: |
---|
| 61 | // Subclasses implements specific behavior. |
---|
| 62 | // Called when removed from the layer. |
---|
| 63 | }, |
---|
| 64 | |
---|
| 65 | _getLocalXY: function(p){ |
---|
| 66 | // summary: |
---|
| 67 | // From projected coordinates to screen coordinates |
---|
| 68 | // p: Object |
---|
| 69 | // Object with x and y fields |
---|
| 70 | // tags: |
---|
| 71 | // private |
---|
| 72 | var x = p.x; |
---|
| 73 | var y = p.y; |
---|
| 74 | var layer = this.getLayer(); |
---|
| 75 | var resolution = layer.olLayer.map.getResolution(); |
---|
| 76 | var extent = layer.olLayer.getExtent(); |
---|
| 77 | var rx = (x / resolution + (-extent.left / resolution)); |
---|
| 78 | var ry = ((extent.top / resolution) - y / resolution); |
---|
| 79 | return [rx, ry]; |
---|
| 80 | } |
---|
| 81 | }); |
---|
| 82 | }); |
---|