From 3c1cb550795a3cb1332df7d5afab00b2e3607429 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 26 Jun 2014 14:25:35 -0400 Subject: [PATCH] Remove IView and IView2D --- examples/drag-and-drop-image-vector.js | 3 +- examples/drag-and-drop.js | 3 +- externs/olx.js | 9 ++-- src/ol/control/zoomtoextentcontrol.js | 4 +- src/ol/interaction/dragzoominteraction.js | 4 +- src/ol/interaction/interaction.js | 21 +++------ src/ol/iview.js | 27 ------------ src/ol/iview2d.js | 54 ----------------------- src/ol/map.js | 11 +++-- src/ol/view.js | 6 +-- src/ol/view2d.js | 12 +++-- 11 files changed, 32 insertions(+), 122 deletions(-) delete mode 100644 src/ol/iview.js delete mode 100644 src/ol/iview2d.js diff --git a/examples/drag-and-drop-image-vector.js b/examples/drag-and-drop-image-vector.js index 18cb0812e6..cae7a3640e 100644 --- a/examples/drag-and-drop-image-vector.js +++ b/examples/drag-and-drop-image-vector.js @@ -124,7 +124,8 @@ dragAndDropInteraction.on('addfeatures', function(event) { }) })); var view2D = map.getView().getView2D(); - view2D.fitExtent(vectorSource.getExtent(), map.getSize()); + view2D.fitExtent( + vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize())); }); var displayFeatureInfo = function(pixel) { diff --git a/examples/drag-and-drop.js b/examples/drag-and-drop.js index 9225d8fcd5..65d8d6d2ee 100644 --- a/examples/drag-and-drop.js +++ b/examples/drag-and-drop.js @@ -120,7 +120,8 @@ dragAndDropInteraction.on('addfeatures', function(event) { style: styleFunction })); var view2D = map.getView().getView2D(); - view2D.fitExtent(vectorSource.getExtent(), map.getSize()); + view2D.fitExtent( + vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize())); }); var displayFeatureInfo = function(pixel) { diff --git a/externs/olx.js b/externs/olx.js index db8ea75762..94445fa18d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -110,7 +110,7 @@ olx.GeolocationOptions.prototype.projection; * overlays: (ol.Collection|Array.|undefined), * renderer: (ol.RendererType|Array.|string|undefined), * target: (Element|string|undefined), - * view: (ol.IView|undefined)}} + * view: (ol.View2D|undefined)}} * @todo api */ olx.MapOptions; @@ -201,10 +201,9 @@ olx.MapOptions.prototype.target; /** - * The map's view. Currently {@link ol.View2D} is the only available view. - * No layer sources will be fetched unless this is specified at construction - * time or through {@link ol.Map#setView}. - * @type {ol.IView|undefined} + * The map's view. No layer sources will be fetched unless this is specified at + * construction time or through {@link ol.Map#setView}. + * @type {ol.View2D|undefined} */ olx.MapOptions.prototype.view; diff --git a/src/ol/control/zoomtoextentcontrol.js b/src/ol/control/zoomtoextentcontrol.js index 8c992e985b..308cbb04b7 100644 --- a/src/ol/control/zoomtoextentcontrol.js +++ b/src/ol/control/zoomtoextentcontrol.js @@ -103,5 +103,7 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() { var view2D = view.getView2D(); var extent = goog.isNull(this.extent_) ? view2D.getProjection().getExtent() : this.extent_; - view2D.fitExtent(extent, map.getSize()); + var size = map.getSize(); + goog.asserts.assert(goog.isDef(size)); + view2D.fitExtent(extent, size); }; diff --git a/src/ol/interaction/dragzoominteraction.js b/src/ol/interaction/dragzoominteraction.js index 4398d4f233..9189e33cb7 100644 --- a/src/ol/interaction/dragzoominteraction.js +++ b/src/ol/interaction/dragzoominteraction.js @@ -57,7 +57,9 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() { var view = map.getView().getView2D(); var extent = this.getGeometry().getExtent(); var center = ol.extent.getCenter(extent); + var size = map.getSize(); + goog.asserts.assert(goog.isDef(size)); ol.interaction.Interaction.zoom(map, view, - view.getResolutionForExtent(extent, map.getSize()), + view.getResolutionForExtent(extent, size), center, ol.DRAGZOOM_ANIMATION_DURATION); }; diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index e028bae89c..63cb77a1bf 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -5,7 +5,6 @@ goog.provide('ol.interaction.Interaction'); goog.require('goog.asserts'); goog.require('ol.MapBrowserEvent'); goog.require('ol.Observable'); -goog.require('ol.View2D'); goog.require('ol.animation'); goog.require('ol.easing'); @@ -69,13 +68,12 @@ ol.interaction.Interaction.prototype.setMap = function(map) { /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {ol.Coordinate} delta Delta. * @param {number=} opt_duration Duration. */ ol.interaction.Interaction.pan = function( map, view, delta, opt_duration) { - goog.asserts.assertInstanceof(view, ol.View2D); var currentCenter = view.getCenter(); if (goog.isDef(currentCenter)) { if (goog.isDef(opt_duration) && opt_duration > 0) { @@ -94,14 +92,13 @@ ol.interaction.Interaction.pan = function( /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {number|undefined} rotation Rotation. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ ol.interaction.Interaction.rotate = function(map, view, rotation, opt_anchor, opt_duration) { - goog.asserts.assertInstanceof(view, ol.View2D); rotation = view.constrainRotation(rotation, 0); ol.interaction.Interaction.rotateWithoutConstraints( map, view, rotation, opt_anchor, opt_duration); @@ -110,14 +107,13 @@ ol.interaction.Interaction.rotate = /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {number|undefined} rotation Rotation. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ ol.interaction.Interaction.rotateWithoutConstraints = function(map, view, rotation, opt_anchor, opt_duration) { - goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(rotation)) { var currentRotation = view.getRotation(); var currentCenter = view.getCenter(); @@ -136,7 +132,6 @@ ol.interaction.Interaction.rotateWithoutConstraints = })); } } - goog.asserts.assertInstanceof(view, ol.View2D); view.rotate(rotation, opt_anchor); } }; @@ -144,7 +139,7 @@ ol.interaction.Interaction.rotateWithoutConstraints = /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. @@ -159,7 +154,6 @@ ol.interaction.Interaction.rotateWithoutConstraints = */ ol.interaction.Interaction.zoom = function(map, view, resolution, opt_anchor, opt_duration, opt_direction) { - goog.asserts.assertInstanceof(view, ol.View2D); resolution = view.constrainResolution(resolution, 0, opt_direction); ol.interaction.Interaction.zoomWithoutConstraints( map, view, resolution, opt_anchor, opt_duration); @@ -168,14 +162,13 @@ ol.interaction.Interaction.zoom = /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {number} delta Delta from previous zoom level. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ ol.interaction.Interaction.zoomByDelta = function(map, view, delta, opt_anchor, opt_duration) { - goog.asserts.assertInstanceof(view, ol.View2D); var currentResolution = view.getResolution(); var resolution = view.constrainResolution(currentResolution, delta, 0); ol.interaction.Interaction.zoomWithoutConstraints( @@ -185,14 +178,13 @@ ol.interaction.Interaction.zoomByDelta = /** * @param {ol.Map} map Map. - * @param {ol.IView2D} view View. + * @param {ol.View2D} view View. * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ ol.interaction.Interaction.zoomWithoutConstraints = function(map, view, resolution, opt_anchor, opt_duration) { - goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(resolution)) { var currentResolution = view.getResolution(); var currentCenter = view.getCenter(); @@ -211,7 +203,6 @@ ol.interaction.Interaction.zoomWithoutConstraints = })); } } - goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(opt_anchor)) { var center = view.calculateCenterZoom(resolution, opt_anchor); view.setCenter(center); diff --git a/src/ol/iview.js b/src/ol/iview.js deleted file mode 100644 index 4b238a3711..0000000000 --- a/src/ol/iview.js +++ /dev/null @@ -1,27 +0,0 @@ -goog.provide('ol.IView'); - -goog.require('ol.IView2D'); - - - -/** - * Interface for views. - * @interface - * @extends {goog.events.Listenable} - */ -ol.IView = function() { -}; - - -/** - * @return {ol.IView2D} View2D. - */ -ol.IView.prototype.getView2D = function() { -}; - - -/** - * @return {boolean} Is defined. - */ -ol.IView.prototype.isDef = function() { -}; diff --git a/src/ol/iview2d.js b/src/ol/iview2d.js deleted file mode 100644 index 50ad5aa1cf..0000000000 --- a/src/ol/iview2d.js +++ /dev/null @@ -1,54 +0,0 @@ -goog.provide('ol.IView2D'); - -goog.require('ol.Coordinate'); - - - -/** - * Interface for views. - * @interface - */ -ol.IView2D = function() { -}; - - -/** - * @return {ol.Coordinate|undefined} The center of the view. - */ -ol.IView2D.prototype.getCenter = function() { -}; - - -/** - * @return {ol.proj.Projection|undefined} The projection of the view. - */ -ol.IView2D.prototype.getProjection = function() { -}; - - -/** - * @return {number|undefined} The resolution of the view. - */ -ol.IView2D.prototype.getResolution = function() { -}; - - -/** - * @return {number|undefined} The rotation of the view. - */ -ol.IView2D.prototype.getRotation = function() { -}; - - -/** - * @return {olx.View2DState} View2D state. - */ -ol.IView2D.prototype.getView2DState = function() { -}; - - -/** - * @return {boolean} Is defined. - */ -ol.IView2D.prototype.isDef = function() { -}; diff --git a/src/ol/map.js b/src/ol/map.js index 07aedc3fd4..33a9987bfa 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -30,7 +30,6 @@ goog.require('goog.vec.Mat4'); goog.require('ol.BrowserFeature'); goog.require('ol.Collection'); goog.require('ol.CollectionEventType'); -goog.require('ol.IView'); goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEventHandler'); @@ -748,14 +747,14 @@ goog.exportProperty( /** - * Get the view associated with this map. This can be a 2D or 3D view. A 2D - * view manages properties such as center and resolution. - * @return {ol.IView|undefined} The view that controls this map. + * Get the view associated with this map. A view manages properties such as + * center and resolution. + * @return {ol.View2D|undefined} The view that controls this map. * @todo observable * @todo api stable */ ol.Map.prototype.getView = function() { - return /** @type {ol.IView} */ (this.get(ol.MapProperty.VIEW)); + return /** @type {ol.View2D} */ (this.get(ol.MapProperty.VIEW)); }; goog.exportProperty( ol.Map.prototype, @@ -1319,7 +1318,7 @@ goog.exportProperty( /** * Set the view for this map. - * @param {ol.IView} view The view that controls this map. + * @param {ol.View2D} view The view that controls this map. * @todo observable * @todo api stable */ diff --git a/src/ol/view.js b/src/ol/view.js index 57879d45d9..73b2af8b3f 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -3,7 +3,6 @@ goog.provide('ol.ViewHint'); goog.require('goog.array'); goog.require('goog.asserts'); -goog.require('ol.IView'); goog.require('ol.Object'); @@ -29,7 +28,6 @@ ol.ViewHint = { * Only {@link ol.View2D} is currently implemented. * * @constructor - * @implements {ol.IView} * @extends {ol.Object} */ ol.View = function() { @@ -55,7 +53,7 @@ ol.View.prototype.getHints = function() { /** - * @inheritDoc + * @return {ol.View2D} View2D. */ ol.View.prototype.getView2D = function() { // FIXME for some reason, we can't use goog.abstractMethod here @@ -65,7 +63,7 @@ ol.View.prototype.getView2D = function() { /** - * @inheritDoc + * @return {boolean} Is defined. */ ol.View.prototype.isDef = function() { // FIXME for some reason, we can't use goog.abstractMethod here diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 22289051df..f87bbf40c7 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -5,7 +5,6 @@ goog.require('goog.asserts'); goog.require('ol'); goog.require('ol.CenterConstraint'); goog.require('ol.Constraints'); -goog.require('ol.IView2D'); goog.require('ol.ResolutionConstraint'); goog.require('ol.RotationConstraint'); goog.require('ol.RotationConstraintType'); @@ -78,7 +77,6 @@ ol.View2DProperty = { * rotation value to zero when approaching the horizontal. * * @constructor - * @implements {ol.IView2D} * @extends {ol.View} * @param {olx.View2DOptions=} opt_options View2D options. * @todo api @@ -219,7 +217,7 @@ ol.View2D.prototype.constrainRotation = function(rotation, opt_delta) { /** - * @inheritDoc + * @return {ol.Coordinate|undefined} The center of the view. * @todo observable * @todo api */ @@ -253,7 +251,7 @@ ol.View2D.prototype.calculateExtent = function(size) { /** - * @inheritDoc + * @return {ol.proj.Projection|undefined} The projection of the view. * @todo observable * @todo api */ @@ -268,7 +266,7 @@ goog.exportProperty( /** - * @inheritDoc + * @return {number|undefined} The resolution of the view. * @todo observable * @todo api */ @@ -323,7 +321,7 @@ ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) { /** - * @inheritDoc + * @return {number|undefined} The rotation of the view. * @todo observable * @todo api */ @@ -371,7 +369,7 @@ ol.View2D.prototype.getView2D = function() { /** - * @inheritDoc + * @return {olx.View2DState} View2D state. */ ol.View2D.prototype.getView2DState = function() { goog.asserts.assert(this.isDef());