Remove IView and IView2D

This commit is contained in:
Tim Schaub
2014-06-26 14:25:35 -04:00
parent c74f945817
commit 3c1cb55079
11 changed files with 32 additions and 122 deletions

View File

@@ -124,7 +124,8 @@ dragAndDropInteraction.on('addfeatures', function(event) {
}) })
})); }));
var view2D = map.getView().getView2D(); var view2D = map.getView().getView2D();
view2D.fitExtent(vectorSource.getExtent(), map.getSize()); view2D.fitExtent(
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
}); });
var displayFeatureInfo = function(pixel) { var displayFeatureInfo = function(pixel) {

View File

@@ -120,7 +120,8 @@ dragAndDropInteraction.on('addfeatures', function(event) {
style: styleFunction style: styleFunction
})); }));
var view2D = map.getView().getView2D(); var view2D = map.getView().getView2D();
view2D.fitExtent(vectorSource.getExtent(), map.getSize()); view2D.fitExtent(
vectorSource.getExtent(), /** @type {ol.Size} */ (map.getSize()));
}); });
var displayFeatureInfo = function(pixel) { var displayFeatureInfo = function(pixel) {

View File

@@ -110,7 +110,7 @@ olx.GeolocationOptions.prototype.projection;
* overlays: (ol.Collection|Array.<ol.Overlay>|undefined), * overlays: (ol.Collection|Array.<ol.Overlay>|undefined),
* renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined), * renderer: (ol.RendererType|Array.<ol.RendererType|string>|string|undefined),
* target: (Element|string|undefined), * target: (Element|string|undefined),
* view: (ol.IView|undefined)}} * view: (ol.View2D|undefined)}}
* @todo api * @todo api
*/ */
olx.MapOptions; olx.MapOptions;
@@ -201,10 +201,9 @@ olx.MapOptions.prototype.target;
/** /**
* The map's view. Currently {@link ol.View2D} is the only available view. * The map's view. No layer sources will be fetched unless this is specified at
* No layer sources will be fetched unless this is specified at construction * construction time or through {@link ol.Map#setView}.
* time or through {@link ol.Map#setView}. * @type {ol.View2D|undefined}
* @type {ol.IView|undefined}
*/ */
olx.MapOptions.prototype.view; olx.MapOptions.prototype.view;

View File

@@ -103,5 +103,7 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
var view2D = view.getView2D(); var view2D = view.getView2D();
var extent = goog.isNull(this.extent_) ? var extent = goog.isNull(this.extent_) ?
view2D.getProjection().getExtent() : 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);
}; };

View File

@@ -57,7 +57,9 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
var view = map.getView().getView2D(); var view = map.getView().getView2D();
var extent = this.getGeometry().getExtent(); var extent = this.getGeometry().getExtent();
var center = ol.extent.getCenter(extent); var center = ol.extent.getCenter(extent);
var size = map.getSize();
goog.asserts.assert(goog.isDef(size));
ol.interaction.Interaction.zoom(map, view, ol.interaction.Interaction.zoom(map, view,
view.getResolutionForExtent(extent, map.getSize()), view.getResolutionForExtent(extent, size),
center, ol.DRAGZOOM_ANIMATION_DURATION); center, ol.DRAGZOOM_ANIMATION_DURATION);
}; };

View File

@@ -5,7 +5,6 @@ goog.provide('ol.interaction.Interaction');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.Observable'); goog.require('ol.Observable');
goog.require('ol.View2D');
goog.require('ol.animation'); goog.require('ol.animation');
goog.require('ol.easing'); goog.require('ol.easing');
@@ -69,13 +68,12 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {ol.Coordinate} delta Delta. * @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
*/ */
ol.interaction.Interaction.pan = function( ol.interaction.Interaction.pan = function(
map, view, delta, opt_duration) { map, view, delta, opt_duration) {
goog.asserts.assertInstanceof(view, ol.View2D);
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (goog.isDef(currentCenter)) { if (goog.isDef(currentCenter)) {
if (goog.isDef(opt_duration) && opt_duration > 0) { if (goog.isDef(opt_duration) && opt_duration > 0) {
@@ -94,14 +92,13 @@ ol.interaction.Interaction.pan = function(
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {number|undefined} rotation Rotation. * @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
*/ */
ol.interaction.Interaction.rotate = ol.interaction.Interaction.rotate =
function(map, view, rotation, opt_anchor, opt_duration) { function(map, view, rotation, opt_anchor, opt_duration) {
goog.asserts.assertInstanceof(view, ol.View2D);
rotation = view.constrainRotation(rotation, 0); rotation = view.constrainRotation(rotation, 0);
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, rotation, opt_anchor, opt_duration); map, view, rotation, opt_anchor, opt_duration);
@@ -110,14 +107,13 @@ ol.interaction.Interaction.rotate =
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {number|undefined} rotation Rotation. * @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
*/ */
ol.interaction.Interaction.rotateWithoutConstraints = ol.interaction.Interaction.rotateWithoutConstraints =
function(map, view, rotation, opt_anchor, opt_duration) { function(map, view, rotation, opt_anchor, opt_duration) {
goog.asserts.assertInstanceof(view, ol.View2D);
if (goog.isDefAndNotNull(rotation)) { if (goog.isDefAndNotNull(rotation)) {
var currentRotation = view.getRotation(); var currentRotation = view.getRotation();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
@@ -136,7 +132,6 @@ ol.interaction.Interaction.rotateWithoutConstraints =
})); }));
} }
} }
goog.asserts.assertInstanceof(view, ol.View2D);
view.rotate(rotation, opt_anchor); view.rotate(rotation, opt_anchor);
} }
}; };
@@ -144,7 +139,7 @@ ol.interaction.Interaction.rotateWithoutConstraints =
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {number|undefined} resolution Resolution to go to. * @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
@@ -159,7 +154,6 @@ ol.interaction.Interaction.rotateWithoutConstraints =
*/ */
ol.interaction.Interaction.zoom = ol.interaction.Interaction.zoom =
function(map, view, resolution, opt_anchor, opt_duration, opt_direction) { function(map, view, resolution, opt_anchor, opt_duration, opt_direction) {
goog.asserts.assertInstanceof(view, ol.View2D);
resolution = view.constrainResolution(resolution, 0, opt_direction); resolution = view.constrainResolution(resolution, 0, opt_direction);
ol.interaction.Interaction.zoomWithoutConstraints( ol.interaction.Interaction.zoomWithoutConstraints(
map, view, resolution, opt_anchor, opt_duration); map, view, resolution, opt_anchor, opt_duration);
@@ -168,14 +162,13 @@ ol.interaction.Interaction.zoom =
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {number} delta Delta from previous zoom level. * @param {number} delta Delta from previous zoom level.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
*/ */
ol.interaction.Interaction.zoomByDelta = ol.interaction.Interaction.zoomByDelta =
function(map, view, delta, opt_anchor, opt_duration) { function(map, view, delta, opt_anchor, opt_duration) {
goog.asserts.assertInstanceof(view, ol.View2D);
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
var resolution = view.constrainResolution(currentResolution, delta, 0); var resolution = view.constrainResolution(currentResolution, delta, 0);
ol.interaction.Interaction.zoomWithoutConstraints( ol.interaction.Interaction.zoomWithoutConstraints(
@@ -185,14 +178,13 @@ ol.interaction.Interaction.zoomByDelta =
/** /**
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {ol.IView2D} view View. * @param {ol.View2D} view View.
* @param {number|undefined} resolution Resolution to go to. * @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @param {number=} opt_duration Duration.
*/ */
ol.interaction.Interaction.zoomWithoutConstraints = ol.interaction.Interaction.zoomWithoutConstraints =
function(map, view, resolution, opt_anchor, opt_duration) { function(map, view, resolution, opt_anchor, opt_duration) {
goog.asserts.assertInstanceof(view, ol.View2D);
if (goog.isDefAndNotNull(resolution)) { if (goog.isDefAndNotNull(resolution)) {
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
@@ -211,7 +203,6 @@ ol.interaction.Interaction.zoomWithoutConstraints =
})); }));
} }
} }
goog.asserts.assertInstanceof(view, ol.View2D);
if (goog.isDefAndNotNull(opt_anchor)) { if (goog.isDefAndNotNull(opt_anchor)) {
var center = view.calculateCenterZoom(resolution, opt_anchor); var center = view.calculateCenterZoom(resolution, opt_anchor);
view.setCenter(center); view.setCenter(center);

View File

@@ -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() {
};

View File

@@ -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() {
};

View File

@@ -30,7 +30,6 @@ goog.require('goog.vec.Mat4');
goog.require('ol.BrowserFeature'); goog.require('ol.BrowserFeature');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.CollectionEventType'); goog.require('ol.CollectionEventType');
goog.require('ol.IView');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.MapBrowserEventHandler'); 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 * Get the view associated with this map. A view manages properties such as
* view manages properties such as center and resolution. * center and resolution.
* @return {ol.IView|undefined} The view that controls this map. * @return {ol.View2D|undefined} The view that controls this map.
* @todo observable * @todo observable
* @todo api stable * @todo api stable
*/ */
ol.Map.prototype.getView = function() { 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( goog.exportProperty(
ol.Map.prototype, ol.Map.prototype,
@@ -1319,7 +1318,7 @@ goog.exportProperty(
/** /**
* Set the view for this map. * 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 observable
* @todo api stable * @todo api stable
*/ */

View File

@@ -3,7 +3,6 @@ goog.provide('ol.ViewHint');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.IView');
goog.require('ol.Object'); goog.require('ol.Object');
@@ -29,7 +28,6 @@ ol.ViewHint = {
* Only {@link ol.View2D} is currently implemented. * Only {@link ol.View2D} is currently implemented.
* *
* @constructor * @constructor
* @implements {ol.IView}
* @extends {ol.Object} * @extends {ol.Object}
*/ */
ol.View = function() { ol.View = function() {
@@ -55,7 +53,7 @@ ol.View.prototype.getHints = function() {
/** /**
* @inheritDoc * @return {ol.View2D} View2D.
*/ */
ol.View.prototype.getView2D = function() { ol.View.prototype.getView2D = function() {
// FIXME for some reason, we can't use goog.abstractMethod here // 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() { ol.View.prototype.isDef = function() {
// FIXME for some reason, we can't use goog.abstractMethod here // FIXME for some reason, we can't use goog.abstractMethod here

View File

@@ -5,7 +5,6 @@ goog.require('goog.asserts');
goog.require('ol'); goog.require('ol');
goog.require('ol.CenterConstraint'); goog.require('ol.CenterConstraint');
goog.require('ol.Constraints'); goog.require('ol.Constraints');
goog.require('ol.IView2D');
goog.require('ol.ResolutionConstraint'); goog.require('ol.ResolutionConstraint');
goog.require('ol.RotationConstraint'); goog.require('ol.RotationConstraint');
goog.require('ol.RotationConstraintType'); goog.require('ol.RotationConstraintType');
@@ -78,7 +77,6 @@ ol.View2DProperty = {
* rotation value to zero when approaching the horizontal. * rotation value to zero when approaching the horizontal.
* *
* @constructor * @constructor
* @implements {ol.IView2D}
* @extends {ol.View} * @extends {ol.View}
* @param {olx.View2DOptions=} opt_options View2D options. * @param {olx.View2DOptions=} opt_options View2D options.
* @todo api * @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 observable
* @todo api * @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 observable
* @todo api * @todo api
*/ */
@@ -268,7 +266,7 @@ goog.exportProperty(
/** /**
* @inheritDoc * @return {number|undefined} The resolution of the view.
* @todo observable * @todo observable
* @todo api * @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 observable
* @todo api * @todo api
*/ */
@@ -371,7 +369,7 @@ ol.View2D.prototype.getView2D = function() {
/** /**
* @inheritDoc * @return {olx.View2DState} View2D state.
*/ */
ol.View2D.prototype.getView2DState = function() { ol.View2D.prototype.getView2DState = function() {
goog.asserts.assert(this.isDef()); goog.asserts.assert(this.isDef());