diff --git a/skeleton.js b/skeleton.js index 30f5db27a7..5f01f80e5d 100644 --- a/skeleton.js +++ b/skeleton.js @@ -1,5 +1,5 @@ -goog.require('goog.math.Coordinate'); goog.require('goog.object'); +goog.require('ol.Coordinate'); goog.require('ol.RendererHint'); goog.require('ol.createMap'); goog.require('ol.tilelayer.createOpenStreetMap'); @@ -18,7 +18,7 @@ layer = ol.tilelayer.createOpenStreetMap({ map.getLayers().push(layer); var resolutions = layer.getStore().getResolutions(); -map1.setCenter(new goog.math.Coordinate(0, 0)); +map1.setCenter(new ol.Coordinate(0, 0)); map1.setResolution(resolutions[0]); if (twoMaps) { diff --git a/src/ol/control/drag.js b/src/ol/control/drag.js index 3f54b46ea4..bbc7703d24 100644 --- a/src/ol/control/drag.js +++ b/src/ol/control/drag.js @@ -6,6 +6,7 @@ goog.provide('ol.control.Drag'); goog.require('goog.events.EventType'); goog.require('goog.functions'); goog.require('ol.Control'); +goog.require('ol.Coordinate'); goog.require('ol.MapBrowserEvent'); @@ -45,12 +46,12 @@ ol.control.Drag = function() { this.offsetY = 0; /** - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} */ this.startCenter = null; /** - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} */ this.startCoordinate = null; diff --git a/src/ol/control/dragpan.js b/src/ol/control/dragpan.js index f0390b2c56..d02d7cee9f 100644 --- a/src/ol/control/dragpan.js +++ b/src/ol/control/dragpan.js @@ -1,6 +1,6 @@ goog.provide('ol.control.DragPan'); -goog.require('goog.math.Coordinate'); +goog.require('ol.Coordinate'); goog.require('ol.MapBrowserEvent'); goog.require('ol.control.Drag'); @@ -22,7 +22,7 @@ goog.inherits(ol.control.DragPan, ol.control.Drag); ol.control.DragPan.prototype.handleDrag = function(mapBrowserEvent) { var map = mapBrowserEvent.map; var resolution = map.getResolution(); - var center = new goog.math.Coordinate( + var center = new ol.Coordinate( this.startCenter.x - resolution * this.deltaX, this.startCenter.y + resolution * this.deltaY); map.setCenter(center); diff --git a/src/ol/coordinate.js b/src/ol/coordinate.js new file mode 100644 index 0000000000..2c22bd98a0 --- /dev/null +++ b/src/ol/coordinate.js @@ -0,0 +1,24 @@ +goog.provide('ol.Coordinate'); + +goog.require('goog.math.Coordinate'); + + + +/** + * @constructor + * @extends {goog.math.Coordinate} + * @param {number} x X. + * @param {number} y Y. + */ +ol.Coordinate = function(x, y) { + goog.base(this, x, y); +}; +goog.inherits(ol.Coordinate, goog.math.Coordinate); + + +/** + * @return {ol.Coordinate} Clone. + */ +ol.Coordinate.prototype.clone = function() { + return new ol.Coordinate(this.x, this.y); +}; diff --git a/src/ol/dom/layerrenderer.js b/src/ol/dom/layerrenderer.js index 6707d103ff..98a99456e6 100644 --- a/src/ol/dom/layerrenderer.js +++ b/src/ol/dom/layerrenderer.js @@ -1,5 +1,6 @@ goog.provide('ol.dom.LayerRenderer'); +goog.require('ol.Coordinate'); goog.require('ol.LayerRenderer'); @@ -23,7 +24,7 @@ ol.dom.LayerRenderer = function(map, layer, target) { /** * Top left corner of the target in map coords. * - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} * @protected */ this.origin = null; @@ -44,7 +45,7 @@ ol.dom.LayerRenderer.prototype.getMap = function() { /** * Set the location of the top left corner of the target. * - * @param {goog.math.Coordinate} origin Origin. + * @param {ol.Coordinate} origin Origin. */ ol.dom.LayerRenderer.prototype.setOrigin = function(origin) { this.origin = origin; diff --git a/src/ol/dom/map.js b/src/ol/dom/map.js index 2225346b63..79faa165fe 100644 --- a/src/ol/dom/map.js +++ b/src/ol/dom/map.js @@ -3,8 +3,8 @@ goog.provide('ol.dom.Map'); goog.require('goog.asserts'); goog.require('goog.dom'); goog.require('goog.dom.TagName'); -goog.require('goog.math.Coordinate'); goog.require('goog.style'); +goog.require('ol.Coordinate'); goog.require('ol.Map'); goog.require('ol.TileLayer'); goog.require('ol.dom.TileLayerRenderer'); @@ -48,7 +48,7 @@ ol.dom.Map = function(target, opt_values) { this.layerPanes_ = {}; /** - * @type {goog.math.Coordinate|undefined} + * @type {ol.Coordinate|undefined} * @private */ this.renderedCenter_ = undefined; @@ -56,7 +56,7 @@ ol.dom.Map = function(target, opt_values) { /** * The pixel offset of the layers pane with respect to its container. * - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} * @private */ this.layersPaneOffset_ = null; @@ -77,7 +77,7 @@ goog.inherits(ol.dom.Map, ol.Map); * @private */ ol.dom.Map.prototype.resetLayersPane_ = function() { - var offset = new goog.math.Coordinate(0, 0); + var offset = new ol.Coordinate(0, 0); goog.style.setPosition(this.layersPane_, offset); this.layersPaneOffset_ = offset; @@ -97,7 +97,7 @@ ol.dom.Map.prototype.setOrigin_ = function() { var targetSize = this.getSize(); var targetWidth = targetSize.width; var targetHeight = targetSize.height; - var origin = new goog.math.Coordinate( + var origin = new ol.Coordinate( center.x - resolution * targetWidth / 2, center.y + resolution * targetHeight / 2); goog.object.forEach(this.layerRenderers, function(layerRenderer) { diff --git a/src/ol/dom/tilelayerrenderer.js b/src/ol/dom/tilelayerrenderer.js index 6941bded32..1a49082e78 100644 --- a/src/ol/dom/tilelayerrenderer.js +++ b/src/ol/dom/tilelayerrenderer.js @@ -1,5 +1,6 @@ goog.provide('ol.dom.TileLayerRenderer'); +goog.require('ol.Coordinate'); goog.require('ol.dom.LayerRenderer'); @@ -91,7 +92,7 @@ ol.dom.TileLayerRenderer.prototype.redraw = function() { * @param {ol.Extent} extent Map extent. * @param {ol.TileBounds} tileBounds Tile bounds. * @param {number} resolution Resolution. - * @return {goog.math.Coordinate} Offset. + * @return {ol.Coordinate} Offset. */ ol.dom.TileLayerRenderer.prototype.getTilesMapOffset_ = function( extent, tileBounds, resolution) { @@ -103,7 +104,7 @@ ol.dom.TileLayerRenderer.prototype.getTilesMapOffset_ = function( var tileCoord = new ol.TileCoord(z, tileBounds.minX, tileBounds.maxY); var tileCoordExtent = tileGrid.getTileCoordExtent(tileCoord); - var offset = new goog.math.Coordinate( + var offset = new ol.Coordinate( Math.round((this.origin.x - tileCoordExtent.minX) / resolution), Math.round((tileCoordExtent.maxY - this.origin.y) / resolution)); diff --git a/src/ol/extent.js b/src/ol/extent.js index 8807bc5c00..0e8db0a3ff 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -1,5 +1,6 @@ goog.provide('ol.Extent'); +goog.require('ol.Coordinate'); goog.require('ol.Rectangle'); goog.require('ol.TransformFunction'); @@ -20,7 +21,7 @@ goog.inherits(ol.Extent, ol.Rectangle); /** - * @param {...goog.math.Coordinate} var_args Coordinates. + * @param {...ol.Coordinate} var_args Coordinates. * @return {!ol.Extent} Boundin extent. */ ol.Extent.boundingExtent = function(var_args) { @@ -52,7 +53,7 @@ ol.Extent.prototype.clone = function() { * @return {ol.Extent} Extent. */ ol.Extent.prototype.transform = function(transform) { - var min = transform(new goog.math.Coordinate(this.minX, this.minY)); - var max = transform(new goog.math.Coordinate(this.maxX, this.maxY)); + var min = transform(new ol.Coordinate(this.minX, this.minY)); + var max = transform(new ol.Coordinate(this.maxX, this.maxY)); return new ol.Extent(min.x, min.y, max.x, max.y); }; diff --git a/src/ol/extent_test.js b/src/ol/extent_test.js index 45b8997fed..4cf509f607 100644 --- a/src/ol/extent_test.js +++ b/src/ol/extent_test.js @@ -1,4 +1,3 @@ -goog.require('goog.math.Coordinate'); goog.require('goog.testing.jsunit'); goog.require('ol.Extent'); goog.require('ol.Projection'); diff --git a/src/ol/map.js b/src/ol/map.js index 4eab27e50c..e98aa3f1d1 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -15,11 +15,11 @@ goog.require('goog.events.MouseWheelHandler'); goog.require('goog.events.MouseWheelHandler.EventType'); goog.require('goog.fx.anim'); goog.require('goog.fx.anim.Animated'); -goog.require('goog.math.Coordinate'); goog.require('goog.math.Size'); goog.require('goog.object'); goog.require('ol.Array'); goog.require('ol.Control'); +goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.LayerRenderer'); goog.require('ol.Object'); @@ -264,10 +264,10 @@ ol.Map.prototype.getBackgroundColor = function() { /** - * @return {goog.math.Coordinate|undefined} Center. + * @return {ol.Coordinate|undefined} Center. */ ol.Map.prototype.getCenter = function() { - return /** @type {goog.math.Coordinate} */ (this.get(ol.MapProperty.CENTER)); + return /** @type {ol.Coordinate} */ (this.get(ol.MapProperty.CENTER)); }; @@ -280,8 +280,8 @@ ol.Map.prototype.getControls = function() { /** - * @param {goog.math.Coordinate} pixel Pixel. - * @return {goog.math.Coordinate} Coordinate. + * @param {ol.Coordinate} pixel Pixel. + * @return {ol.Coordinate} Coordinate. */ ol.Map.prototype.getCoordinateFromPixel = function(pixel) { var center = this.getCenter(); @@ -292,7 +292,7 @@ ol.Map.prototype.getCoordinateFromPixel = function(pixel) { goog.asserts.assert(goog.isDef(size)); var x = center.x + resolution * (pixel.x - size.width / 2); var y = center.y - resolution * (pixel.y - size.height / 2); - return new goog.math.Coordinate(x, y); + return new ol.Coordinate(x, y); }; @@ -326,8 +326,8 @@ ol.Map.prototype.getLayers = function() { /** - * @param {goog.math.Coordinate} coordinate Coordinate. - * @return {goog.math.Coordinate} Pixel. + * @param {ol.Coordinate} coordinate Coordinate. + * @return {ol.Coordinate} Pixel. */ ol.Map.prototype.getPixelFromCoordinate = function(coordinate) { var center = this.getCenter(); @@ -338,7 +338,7 @@ ol.Map.prototype.getPixelFromCoordinate = function(coordinate) { goog.asserts.assert(goog.isDef(size)); var x = (coordinate.x - center.x) / resolution + size.width / 2; var y = (center.y - coordinate.y) / resolution + size.height / 2; - return new goog.math.Coordinate(x, y); + return new ol.Coordinate(x, y); }; @@ -389,7 +389,7 @@ ol.Map.prototype.getTarget = function() { /** - * @return {goog.math.Coordinate|undefined} Center in user projection. + * @return {ol.Coordinate|undefined} Center in user projection. */ ol.Map.prototype.getUserCenter = function() { var center = this.getCenter(); @@ -681,7 +681,7 @@ ol.Map.prototype.setBackgroundColor = function(backgroundColor) { /** - * @param {goog.math.Coordinate} center Center. + * @param {ol.Coordinate} center Center. */ ol.Map.prototype.setCenter = function(center) { this.set(ol.MapProperty.CENTER, center); @@ -744,7 +744,7 @@ ol.Map.prototype.setProjection = function(projection) { /** - * @param {goog.math.Coordinate} userCenter Center in user projection. + * @param {ol.Coordinate} userCenter Center in user projection. */ ol.Map.prototype.setUserCenter = function(userCenter) { this.setCenter(this.userToMapTransform_(userCenter)); diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index c78a4c0844..95716b0ec4 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -1,7 +1,7 @@ goog.provide('ol.MapBrowserEvent'); goog.require('goog.events.BrowserEvent'); -goog.require('goog.math.Coordinate'); +goog.require('ol.Coordinate'); goog.require('ol.MapEvent'); @@ -29,20 +29,20 @@ goog.inherits(ol.MapBrowserEvent, ol.MapEvent); /** * @private - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} */ ol.MapBrowserEvent.prototype.coordinate_; /** - * @return {goog.math.Coordinate} Coordinate. + * @return {ol.Coordinate} Coordinate. */ ol.MapBrowserEvent.prototype.getCoordinate = function() { if (goog.isDef(this.coordinate_)) { return this.coordinate_; } else { var browserEventObject = this.getBrowserEventObject(); - var pixel = new goog.math.Coordinate( + var pixel = new ol.Coordinate( browserEventObject.offsetX, browserEventObject.offsetY); var coordinate = this.map.getCoordinateFromPixel(pixel); this.coordinate_ = coordinate; diff --git a/src/ol/projection.js b/src/ol/projection.js index 976cb894cf..84ce030a80 100644 --- a/src/ol/projection.js +++ b/src/ol/projection.js @@ -2,8 +2,8 @@ goog.provide('ol.Projection'); goog.require('goog.array'); goog.require('goog.asserts'); -goog.require('goog.math.Coordinate'); goog.require('goog.object'); +goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.TransformFunction'); @@ -215,8 +215,8 @@ ol.Projection.getTransformFromCodes = function(sourceCode, destinationCode) { /** - * @param {goog.math.Coordinate} point Point. - * @return {goog.math.Coordinate} Point. + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. */ ol.Projection.identityTransform = function(point) { return point; @@ -224,8 +224,8 @@ ol.Projection.identityTransform = function(point) { /** - * @param {goog.math.Coordinate} point Point. - * @return {goog.math.Coordinate} Point. + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. */ ol.Projection.cloneTransform = function(point) { return point.clone(); @@ -233,10 +233,10 @@ ol.Projection.cloneTransform = function(point) { /** - * @param {goog.math.Coordinate} point Point. + * @param {ol.Coordinate} point Point. * @param {ol.Projection} source Source. * @param {ol.Projection} destination Destination. - * @return {goog.math.Coordinate} Point. + * @return {ol.Coordinate} Point. */ ol.Projection.transform = function(point, source, destination) { var transform = ol.Projection.getTransform(source, destination); @@ -245,10 +245,10 @@ ol.Projection.transform = function(point, source, destination) { /** - * @param {goog.math.Coordinate} point Point. + * @param {ol.Coordinate} point Point. * @param {string} sourceCode Source code. * @param {string} destinationCode Destination code. - * @return {goog.math.Coordinate} Point. + * @return {ol.Coordinate} Point. */ ol.Projection.transformWithCodes = function(point, sourceCode, destinationCode) { @@ -266,26 +266,26 @@ ol.Projection.EPSG_3857_RADIUS = 6378137; /** - * @param {goog.math.Coordinate} point Point. - * @return {goog.math.Coordinate} Point. + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. */ ol.Projection.forwardSphericalMercator = function(point) { var x = ol.Projection.EPSG_3857_RADIUS * Math.PI * point.x / 180; var y = ol.Projection.EPSG_3857_RADIUS * Math.log(Math.tan(Math.PI * (point.y + 90) / 360)); - return new goog.math.Coordinate(x, y); + return new ol.Coordinate(x, y); }; /** - * @param {goog.math.Coordinate} point Point. - * @return {goog.math.Coordinate} Point. + * @param {ol.Coordinate} point Point. + * @return {ol.Coordinate} Point. */ ol.Projection.inverseSphericalMercator = function(point) { var x = 180 * point.x / (ol.Projection.EPSG_3857_RADIUS * Math.PI); var y = 360 * Math.atan( Math.exp(point.y / ol.Projection.EPSG_3857_RADIUS)) / Math.PI - 90; - return new goog.math.Coordinate(x, y); + return new ol.Coordinate(x, y); }; diff --git a/src/ol/projection_test.js b/src/ol/projection_test.js index 7200f1236a..d105ace417 100644 --- a/src/ol/projection_test.js +++ b/src/ol/projection_test.js @@ -1,6 +1,6 @@ goog.require('goog.array'); -goog.require('goog.math.Coordinate'); goog.require('goog.testing.jsunit'); +goog.require('ol.Coordinate'); goog.require('ol.Projection'); @@ -36,7 +36,7 @@ function testEpsg4326Equivalence() { function testIdentityTransform() { var epsg4326 = ol.Projection.getFromCode('EPSG:4326'); var uniqueObject = {}; - var sourcePoint = new goog.math.Coordinate(uniqueObject, uniqueObject); + var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject); var destinationPoint = ol.Projection.transform( sourcePoint, epsg4326, epsg4326); assertFalse(sourcePoint === destinationPoint); @@ -47,7 +47,7 @@ function testIdentityTransform() { function testForwardSphericalMercatorOrigin() { var point = ol.Projection.transformWithCodes( - new goog.math.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857'); + new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857'); assertNotNullNorUndefined(point); assertEquals(0, point.x); assertRoughlyEquals(0, point.y, 1e-9); @@ -56,7 +56,7 @@ function testForwardSphericalMercatorOrigin() { function testInverseSphericalMercatorOrigin() { var point = ol.Projection.transformWithCodes( - new goog.math.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326'); + new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326'); assertNotNullNorUndefined(point); assertEquals(0, point.x); assertEquals(0, point.y); @@ -66,7 +66,7 @@ function testInverseSphericalMercatorOrigin() { function testForwardSphericalMercatorAlastaira() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ var point = ol.Projection.transformWithCodes( - new goog.math.Coordinate(-5.625, 52.4827802220782), + new ol.Coordinate(-5.625, 52.4827802220782), 'EPSG:4326', 'EPSG:900913'); assertNotNullNorUndefined(point); @@ -78,7 +78,7 @@ function testForwardSphericalMercatorAlastaira() { function testInverseSphericalMercatorAlastaira() { // http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/ var point = ol.Projection.transformWithCodes( - new goog.math.Coordinate(-626172.13571216376, 6887893.4928337997), + new ol.Coordinate(-626172.13571216376, 6887893.4928337997), 'EPSG:900913', 'EPSG:4326'); assertNotNullNorUndefined(point); diff --git a/src/ol/rectangle.js b/src/ol/rectangle.js index c0a3d3eba6..2b099e899a 100644 --- a/src/ol/rectangle.js +++ b/src/ol/rectangle.js @@ -1,8 +1,8 @@ goog.provide('ol.Rectangle'); goog.require('goog.asserts'); -goog.require('goog.math.Coordinate'); goog.require('goog.math.Size'); +goog.require('ol.Coordinate'); @@ -63,7 +63,7 @@ ol.Rectangle.prototype.clone = function() { /** - * @param {goog.math.Coordinate} coordinate Coordinate. + * @param {ol.Coordinate} coordinate Coordinate. * @return {boolean} Contains. */ ol.Rectangle.prototype.contains = function(coordinate) { @@ -73,10 +73,10 @@ ol.Rectangle.prototype.contains = function(coordinate) { /** - * @return {goog.math.Coordinate} Center. + * @return {ol.Coordinate} Center. */ ol.Rectangle.prototype.getCenter = function() { - return new goog.math.Coordinate( + return new ol.Coordinate( (this.minX + this.maxX) / 2, (this.minY + this.maxY) / 2); }; @@ -106,11 +106,11 @@ ol.Rectangle.prototype.getWidth = function() { /** - * @param {goog.math.Coordinate} coordinate Coordinate. - * @return {goog.math.Coordinate} Coordinate. + * @param {ol.Coordinate} coordinate Coordinate. + * @return {ol.Coordinate} Coordinate. */ ol.Rectangle.prototype.normalize = function(coordinate) { - return new goog.math.Coordinate( + return new ol.Coordinate( (coordinate.x - this.minX) / this.getWidth(), (coordinate.y - this.minY) / this.getHeight()); }; diff --git a/src/ol/rectangle_test.js b/src/ol/rectangle_test.js index a492f4afe2..3e5d716f1c 100644 --- a/src/ol/rectangle_test.js +++ b/src/ol/rectangle_test.js @@ -1,5 +1,5 @@ -goog.require('goog.math.Coordinate'); goog.require('goog.testing.jsunit'); +goog.require('ol.Coordinate'); goog.require('ol.Rectangle'); @@ -25,36 +25,36 @@ function testClone() { function testContainsPositive() { var rectangle = new ol.Rectangle(1, 2, 3, 4); - assertTrue(rectangle.contains(new goog.math.Coordinate(1, 2))); - assertTrue(rectangle.contains(new goog.math.Coordinate(1, 3))); - assertTrue(rectangle.contains(new goog.math.Coordinate(1, 4))); - assertTrue(rectangle.contains(new goog.math.Coordinate(2, 2))); - assertTrue(rectangle.contains(new goog.math.Coordinate(2, 3))); - assertTrue(rectangle.contains(new goog.math.Coordinate(2, 4))); - assertTrue(rectangle.contains(new goog.math.Coordinate(3, 2))); - assertTrue(rectangle.contains(new goog.math.Coordinate(3, 3))); - assertTrue(rectangle.contains(new goog.math.Coordinate(3, 4))); + assertTrue(rectangle.contains(new ol.Coordinate(1, 2))); + assertTrue(rectangle.contains(new ol.Coordinate(1, 3))); + assertTrue(rectangle.contains(new ol.Coordinate(1, 4))); + assertTrue(rectangle.contains(new ol.Coordinate(2, 2))); + assertTrue(rectangle.contains(new ol.Coordinate(2, 3))); + assertTrue(rectangle.contains(new ol.Coordinate(2, 4))); + assertTrue(rectangle.contains(new ol.Coordinate(3, 2))); + assertTrue(rectangle.contains(new ol.Coordinate(3, 3))); + assertTrue(rectangle.contains(new ol.Coordinate(3, 4))); } function testContainsNegative() { var rectangle = new ol.Rectangle(1, 2, 3, 4); - assertFalse(rectangle.contains(new goog.math.Coordinate(0, 1))); - assertFalse(rectangle.contains(new goog.math.Coordinate(0, 2))); - assertFalse(rectangle.contains(new goog.math.Coordinate(0, 3))); - assertFalse(rectangle.contains(new goog.math.Coordinate(0, 4))); - assertFalse(rectangle.contains(new goog.math.Coordinate(0, 5))); - assertFalse(rectangle.contains(new goog.math.Coordinate(1, 1))); - assertFalse(rectangle.contains(new goog.math.Coordinate(1, 5))); - assertFalse(rectangle.contains(new goog.math.Coordinate(2, 1))); - assertFalse(rectangle.contains(new goog.math.Coordinate(2, 5))); - assertFalse(rectangle.contains(new goog.math.Coordinate(3, 1))); - assertFalse(rectangle.contains(new goog.math.Coordinate(3, 5))); - assertFalse(rectangle.contains(new goog.math.Coordinate(4, 1))); - assertFalse(rectangle.contains(new goog.math.Coordinate(4, 2))); - assertFalse(rectangle.contains(new goog.math.Coordinate(4, 3))); - assertFalse(rectangle.contains(new goog.math.Coordinate(4, 4))); - assertFalse(rectangle.contains(new goog.math.Coordinate(4, 5))); + assertFalse(rectangle.contains(new ol.Coordinate(0, 1))); + assertFalse(rectangle.contains(new ol.Coordinate(0, 2))); + assertFalse(rectangle.contains(new ol.Coordinate(0, 3))); + assertFalse(rectangle.contains(new ol.Coordinate(0, 4))); + assertFalse(rectangle.contains(new ol.Coordinate(0, 5))); + assertFalse(rectangle.contains(new ol.Coordinate(1, 1))); + assertFalse(rectangle.contains(new ol.Coordinate(1, 5))); + assertFalse(rectangle.contains(new ol.Coordinate(2, 1))); + assertFalse(rectangle.contains(new ol.Coordinate(2, 5))); + assertFalse(rectangle.contains(new ol.Coordinate(3, 1))); + assertFalse(rectangle.contains(new ol.Coordinate(3, 5))); + assertFalse(rectangle.contains(new ol.Coordinate(4, 1))); + assertFalse(rectangle.contains(new ol.Coordinate(4, 2))); + assertFalse(rectangle.contains(new ol.Coordinate(4, 3))); + assertFalse(rectangle.contains(new ol.Coordinate(4, 4))); + assertFalse(rectangle.contains(new ol.Coordinate(4, 5))); } @@ -113,23 +113,23 @@ function testNormalize() { var rectangle = new ol.Rectangle(0, 1, 2, 3); var coordinate; - coordinate = rectangle.normalize(new goog.math.Coordinate(1, 2)); + coordinate = rectangle.normalize(new ol.Coordinate(1, 2)); assertEquals(0.5, coordinate.x); assertEquals(0.5, coordinate.y); - coordinate = rectangle.normalize(new goog.math.Coordinate(0, 3)); + coordinate = rectangle.normalize(new ol.Coordinate(0, 3)); assertEquals(0, coordinate.x); assertEquals(1, coordinate.y); - coordinate = rectangle.normalize(new goog.math.Coordinate(2, 1)); + coordinate = rectangle.normalize(new ol.Coordinate(2, 1)); assertEquals(1, coordinate.x); assertEquals(0, coordinate.y); - coordinate = rectangle.normalize(new goog.math.Coordinate(0, 0)); + coordinate = rectangle.normalize(new ol.Coordinate(0, 0)); assertEquals(0, coordinate.x); assertEquals(-0.5, coordinate.y); - coordinate = rectangle.normalize(new goog.math.Coordinate(-1, 1)); + coordinate = rectangle.normalize(new ol.Coordinate(-1, 1)); assertEquals(-0.5, coordinate.x); assertEquals(0, coordinate.y); diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index d1525ae6a6..693fa8b870 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -1,13 +1,13 @@ goog.provide('ol.TileCoord'); goog.require('goog.array'); -goog.require('goog.math.Coordinate'); +goog.require('ol.Coordinate'); /** * @constructor - * @extends {goog.math.Coordinate} + * @extends {ol.Coordinate} * @param {number} z Z. * @param {number} x X. * @param {number} y Y. @@ -22,7 +22,7 @@ ol.TileCoord = function(z, x, y) { this.z = z; }; -goog.inherits(ol.TileCoord, goog.math.Coordinate); +goog.inherits(ol.TileCoord, ol.Coordinate); /** diff --git a/src/ol/tilegrid/openstreetmap.js b/src/ol/tilegrid/openstreetmap.js index 7e8955c0d6..c3778fc55d 100644 --- a/src/ol/tilegrid/openstreetmap.js +++ b/src/ol/tilegrid/openstreetmap.js @@ -1,7 +1,7 @@ goog.provide('ol.tilegrid.createOpenStreetMap'); -goog.require('goog.math.Coordinate'); goog.require('goog.math.Size'); +goog.require('ol.Coordinate'); goog.require('ol.Projection'); goog.require('ol.TileGrid'); @@ -19,7 +19,7 @@ ol.tilegrid.createOpenStreetMap = function(maxZoom) { } var extent = ol.Projection.EPSG_3857_EXTENT; - var origin = new goog.math.Coordinate( + var origin = new ol.Coordinate( -ol.Projection.EPSG_3857_HALF_SIZE, ol.Projection.EPSG_3857_HALF_SIZE); var tileSize = new goog.math.Size(256, 256); diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index 3e5f3ca51a..75406a104d 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -2,8 +2,8 @@ goog.provide('ol.TileGrid'); goog.require('goog.array'); goog.require('goog.asserts'); -goog.require('goog.math.Coordinate'); goog.require('goog.math.Size'); +goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.TileBounds'); goog.require('ol.TileCoord'); @@ -14,7 +14,7 @@ goog.require('ol.TileCoord'); * @constructor * @param {!Array.} resolutions Resolutions. * @param {ol.Extent} extent Extent. - * @param {goog.math.Coordinate|!Array.} origin Origin. + * @param {ol.Coordinate|!Array.} origin Origin. * @param {goog.math.Size=} opt_tileSize Tile size. */ ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) { @@ -42,17 +42,17 @@ ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) { /** * @private - * @type {goog.math.Coordinate} + * @type {ol.Coordinate} */ this.origin_ = null; /** * @private - * @type {Array.} + * @type {Array.} */ this.origins_ = null; - if (origin instanceof goog.math.Coordinate) { + if (origin instanceof ol.Coordinate) { this.origin_ = origin; } else if (goog.isArray(origin)) { goog.asserts.assert(origin.length == this.numResolutions_); @@ -101,17 +101,15 @@ ol.TileGrid.prototype.getExtent = function() { * @return {ol.TileBounds} Tile bounds. */ ol.TileGrid.prototype.getExtentTileBounds = function(z, extent) { - var min = - this.getTileCoord(z, new goog.math.Coordinate(extent.minX, extent.minY)); - var max = - this.getTileCoord(z, new goog.math.Coordinate(extent.maxX, extent.maxY)); + var min = this.getTileCoord(z, new ol.Coordinate(extent.minX, extent.minY)); + var max = this.getTileCoord(z, new ol.Coordinate(extent.maxX, extent.maxY)); return new ol.TileBounds(min.x, min.y, max.x, max.y); }; /** * @param {number} z Z. - * @return {goog.math.Coordinate} Origin. + * @return {ol.Coordinate} Origin. */ ol.TileGrid.prototype.getOrigin = function(z) { if (!goog.isNull(this.origin_)) { @@ -144,7 +142,7 @@ ol.TileGrid.prototype.getResolutions = function() { /** * @param {number} z Z. - * @param {goog.math.Coordinate} coordinate Coordinate. + * @param {ol.Coordinate} coordinate Coordinate. * @return {ol.TileCoord} Tile coordinate. */ ol.TileGrid.prototype.getTileCoord = function(z, coordinate) { @@ -160,7 +158,7 @@ ol.TileGrid.prototype.getTileCoord = function(z, coordinate) { /** * @param {ol.TileCoord} tileCoord Tile coordinate. - * @return {goog.math.Coordinate} Tile center. + * @return {ol.Coordinate} Tile center. */ ol.TileGrid.prototype.getTileCoordCenter = function(tileCoord) { var origin = this.getOrigin(tileCoord.z); @@ -168,7 +166,7 @@ ol.TileGrid.prototype.getTileCoordCenter = function(tileCoord) { var tileSize = this.tileSize_; var x = origin.x + (tileCoord.x + 0.5) * tileSize.width * resolution; var y = origin.y + (tileCoord.y + 0.5) * tileSize.height * resolution; - return new goog.math.Coordinate(x, y); + return new ol.Coordinate(x, y); }; diff --git a/src/ol/tilegrid/tilegrid_test.js b/src/ol/tilegrid/tilegrid_test.js index 68278cb614..0b609390fd 100644 --- a/src/ol/tilegrid/tilegrid_test.js +++ b/src/ol/tilegrid/tilegrid_test.js @@ -1,6 +1,6 @@ -goog.require('goog.math.Coordinate'); goog.require('goog.math.Size'); goog.require('goog.testing.jsunit'); +goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.TileCoord'); goog.require('ol.TileGrid'); @@ -16,7 +16,7 @@ var tileSize; function setUp() { resolutions = [1000, 500, 250, 100]; extent = new ol.Extent(0, 0, 100000, 100000); - origin = new goog.math.Coordinate(0, 0); + origin = new ol.Coordinate(0, 0); origins = []; tileSize = new goog.math.Size(100, 100); } @@ -74,27 +74,26 @@ function testCreateTooManyOrigins() { function testGetTileCoord() { - origin = new goog.math.Coordinate(0, 0); + origin = new ol.Coordinate(0, 0); var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize); var tileCoord; - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(0, 0)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(0, 0)); assertEquals(3, tileCoord.z); assertEquals(0, tileCoord.x); assertEquals(0, tileCoord.y); - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(0, 100000)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(0, 100000)); assertEquals(3, tileCoord.z); assertEquals(0, tileCoord.x); assertEquals(10, tileCoord.y); - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(100000, 0)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(100000, 0)); assertEquals(3, tileCoord.z); assertEquals(10, tileCoord.x); assertEquals(0, tileCoord.y); - tileCoord = - tileGrid.getTileCoord(3, new goog.math.Coordinate(100000, 100000)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(100000, 100000)); assertEquals(3, tileCoord.z); assertEquals(10, tileCoord.x); assertEquals(10, tileCoord.y); @@ -104,27 +103,26 @@ function testGetTileCoord() { function testGetTileCoordYSouth() { - origin = new goog.math.Coordinate(0, 100000); + origin = new ol.Coordinate(0, 100000); var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize); var tileCoord; - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(0, 0)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(0, 0)); assertEquals(3, tileCoord.z); assertEquals(0, tileCoord.x); assertEquals(-10, tileCoord.y); - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(0, 100000)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(0, 100000)); assertEquals(3, tileCoord.z); assertEquals(0, tileCoord.x); assertEquals(0, tileCoord.y); - tileCoord = tileGrid.getTileCoord(3, new goog.math.Coordinate(100000, 0)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(100000, 0)); assertEquals(3, tileCoord.z); assertEquals(10, tileCoord.x); assertEquals(-10, tileCoord.y); - tileCoord = - tileGrid.getTileCoord(3, new goog.math.Coordinate(100000, 100000)); + tileCoord = tileGrid.getTileCoord(3, new ol.Coordinate(100000, 100000)); assertEquals(3, tileCoord.z); assertEquals(10, tileCoord.x); assertEquals(0, tileCoord.y); diff --git a/src/ol/tilestore/tilestore_test.js b/src/ol/tilestore/tilestore_test.js index 4125f45696..12dd05d27b 100644 --- a/src/ol/tilestore/tilestore_test.js +++ b/src/ol/tilestore/tilestore_test.js @@ -1,4 +1,5 @@ goog.require('goog.testing.jsunit'); +goog.require('ol.Coordinate'); goog.require('ol.TileCoord'); goog.require('ol.tilestore.createOpenStreetMap'); @@ -13,8 +14,7 @@ function testOpenStreetMap() { var tileStore = ol.tilestore.createOpenStreetMap(8); var tileGrid = tileStore.getTileGrid(); - var coordinate = - new goog.math.Coordinate(829330.2064098881, 5933916.615134273); + var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273); var tileUrl; tileUrl = tileStore.getTileCoordUrl(tileGrid.getTileCoord(0, coordinate)); diff --git a/src/ol/transformfunction.js b/src/ol/transformfunction.js index 2f2f2ed532..a8be2c0f28 100644 --- a/src/ol/transformfunction.js +++ b/src/ol/transformfunction.js @@ -1,9 +1,9 @@ goog.provide('ol.TransformFunction'); -goog.require('goog.math.Coordinate'); +goog.require('ol.Coordinate'); /** - * @typedef {function(goog.math.Coordinate): goog.math.Coordinate} + * @typedef {function(ol.Coordinate): ol.Coordinate} */ ol.TransformFunction; diff --git a/src/ol/webgl/tilelayerrenderer.js b/src/ol/webgl/tilelayerrenderer.js index 2d2b030789..8a700abf1d 100644 --- a/src/ol/webgl/tilelayerrenderer.js +++ b/src/ol/webgl/tilelayerrenderer.js @@ -8,6 +8,7 @@ goog.require('goog.asserts'); goog.require('goog.events.EventType'); goog.require('goog.vec.Mat4'); goog.require('goog.webgl'); +goog.require('ol.Coordinate'); goog.require('ol.TileLayer'); goog.require('ol.webgl.LayerRenderer'); goog.require('ol.webgl.shader.Fragment'); @@ -217,7 +218,7 @@ ol.webgl.TileLayerRenderer.prototype.redraw = function() { var gl = this.getGL(); var map = this.getMap(); - var center = /** @type {!goog.math.Coordinate} */ map.getCenter(); + var center = /** @type {!ol.Coordinate} */ map.getCenter(); var extent = /** @type {!ol.Extent} */ map.getExtent(); var resolution = /** @type {number} */ map.getResolution();