Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Refactored Worldview.OpenLayers to Worldview.Map, moved Tile.js to Worldview.Map.TileCanvas.js

Mike McGannb34ceb288179
diff --git a/ant/js.build.xml b/ant/js.build.xml
index 39d09524b..6181a594b 100644
--- a/ant/js.build.xml
+++ b/ant/js.build.xml
@@ -27,12 +27,12 @@
<file name="Logging.js"/>
<file name="Worldview.js"/>
- <file name="Worldview/OpenLayers.js"/>
- <file name="Worldview/OpenLayers/ProductMap.js"/>
- <file name="Worldview/OpenLayers/Product.js"/>
- <file name="Worldview/OpenLayers/StaticProduct.js"/>
- <file name="Worldview/OpenLayers/DailyProduct.js"/>
- <file name="Worldview/OpenLayers/GraticuleLayer.js"/>
+ <file name="Worldview/Map.js"/>
+ <file name="Worldview/Map/ProductMap.js"/>
+ <file name="Worldview/Map/Product.js"/>
+ <file name="Worldview/Map/StaticProduct.js"/>
+ <file name="Worldview/Map/DailyProduct.js"/>
+ <file name="Worldview/Map/GraticuleLayer.js"/>
<file name="Worldview/Widget/Map.js"/>
<file name="Worldview/Widget/WorldviewMap.js"/>
diff --git a/dev/map2/temporal/Temporal.js b/dev/map2/temporal/Temporal.js
index 7e3fa18f6..20ee2328c 100644
--- a/dev/map2/temporal/Temporal.js
+++ b/dev/map2/temporal/Temporal.js
@@ -52,7 +52,7 @@ $(function() {
isBaseLayer: true,
};
- var layerSet = Worldview.OpenLayers.GIBS.TemporalLayerSet({
+ var layerSet = Worldview.Map.GIBS.TemporalLayerSet({
map: map,
layerClass: OpenLayers.Layer.WMTS,
options: modis
diff --git a/doc/Topics/Worldview/JSON/MapConfig/Product.txt b/doc/Topics/Worldview/JSON/MapConfig/Product.txt
index 3aef5b3fb..4f4cd3f6b 100644
--- a/doc/Topics/Worldview/JSON/MapConfig/Product.txt
+++ b/doc/Topics/Worldview/JSON/MapConfig/Product.txt
@@ -12,7 +12,7 @@ Example:
(begin code)
"MODIS_Terra_CorrectedReflectance_TrueColor": {
"layer": "MODIS_Terra_CorrectedReflectance_TrueColor",
- "productClass": "Worldview.OpenLayers.DailyProduct",
+ "productClass": "Worldview.Map.DailyProduct",
"layerClass": "OpenLayers.Layer.WMTS",
"name": "Corrected Reflectance (True Color)",
@@ -63,7 +63,7 @@ Identifier used to reference the layer from the remote map service.
Property: productClass
The Product object to create to manage the layers for this product. Either
-<Worldview.OpenLayers.DailyProduct> or <Worldview.OpenLayers.StaticProduct>.
+<Worldview.Map.DailyProduct> or <Worldview.Map.StaticProduct>.
Property: layerClass
The OpenLayers.Layer class used to create layers for this product as needed.
diff --git a/index.html b/index.html
index dc953b779..83f2768ad 100644
--- a/index.html
+++ b/index.html
@@ -84,12 +84,12 @@
<!-- js.dev --> <script type="text/javascript" src="js/Logging.js"></script>
<!-- js.dev --> <script type="text/javascript" src="js/Worldview.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers/ProductMap.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers/Product.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers/StaticProduct.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers/DailyProduct.js"></script>
- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/OpenLayers/GraticuleLayer.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/ProductMap.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/Product.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/StaticProduct.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/DailyProduct.js"></script>
+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/GraticuleLayer.js"></script>
<!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/Map.js"></script>
<!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/WorldviewMap.js"></script>
diff --git a/js/Worldview/OpenLayers.js b/js/Worldview/Map.js
similarity index 91%
rename from js/Worldview/OpenLayers.js
rename to js/Worldview/Map.js
index 2acdaa2d2..cf3431ae4 100644
--- a/js/Worldview/OpenLayers.js
+++ b/js/Worldview/Map.js
@@ -10,10 +10,10 @@
*/
/**
- * Namespace: Worldview.OpenLayers
+ * Namespace: Worldview.Map
* Worldview specific code when using OpenLayers.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
$(function(ns) {
@@ -26,7 +26,7 @@ $(function(ns) {
*
* Example:
* (begin code)
- * var contorl = Worldview.OpenLayers.COORDINATE_CONTROLS["geographic"];
+ * var contorl = Worldview.Map.COORDINATE_CONTROLS["geographic"];
* (end code)
*/
ns.COORDINATE_CONTROLS = {
@@ -52,4 +52,4 @@ $(function(ns) {
})
};
-}(Worldview.OpenLayers));
+}(Worldview.Map));
diff --git a/js/OpenLayers/Tile/Canvas.js b/js/Worldview/Map/CanvasTile.js
similarity index 95%
rename from js/OpenLayers/Tile/Canvas.js
rename to js/Worldview/Map/CanvasTile.js
index 058a9d2d6..b10c307c6 100644
--- a/js/OpenLayers/Tile/Canvas.js
+++ b/js/Worldview/Map/CanvasTile.js
@@ -9,8 +9,10 @@
* All Rights Reserved.
*/
+Worldview.namespace("Map");
+
/**
- * Class: OpenLayers.Tile.Canvas
+ * Class: Worldview.Map.CanvasTile
*
* Cavas based tile generator. The default tile generator,
* OpenLayers.Tile.Image renders each tile in an image element. This generator
@@ -20,7 +22,7 @@
* (start code)
* var myLayer = new OpenLayers.Layer.WMTS({
* name: "My Layer",
- * tileClass: OpenLayers.Tile.Canvas,
+ * tileClass: Worldview.Map.CanvasTile,
* ...
* });
* (end code)
@@ -42,7 +44,7 @@
* };
* (end code)
*/
-OpenLayers.Tile.Canvas = OpenLayers.Class(OpenLayers.Tile.Image, {
+Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {
/*
* Element that contains the canvas to draw the tile. Initially set to
@@ -171,6 +173,6 @@ OpenLayers.Tile.Canvas = OpenLayers.Class(OpenLayers.Tile.Image, {
/*
* Name of this class per OpenLayers convention.
*/
- CLASS_NAME: "OpenLayers.Tile.Canvas"
+ CLASS_NAME: "Worldview.Map.CanvasTile"
});
diff --git a/js/Worldview/OpenLayers/DailyProduct.js b/js/Worldview/Map/DailyProduct.js
similarity index 97%
rename from js/Worldview/OpenLayers/DailyProduct.js
rename to js/Worldview/Map/DailyProduct.js
index 0d5c99263..6adbcad52 100644
--- a/js/Worldview/OpenLayers/DailyProduct.js
+++ b/js/Worldview/Map/DailyProduct.js
@@ -9,10 +9,10 @@
* All Rights Reserved.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
/**
- * Class: Worldview.OpenLayers.DailyProduct
+ * Class: Worldview.Map.DailyProduct
* Product that updates on a daily basis.
*
* A requirement in Worldview is to be able to slide between several dates
@@ -32,9 +32,9 @@ Worldview.namespace("OpenLayers");
* layerClass which defines the type of layer to create (e.g.,
* OpenLayers.Layer.WMTS)
*/
-Worldview.OpenLayers.DailyProduct = function(map, config) {
+Worldview.Map.DailyProduct = function(map, config) {
- var self = Worldview.OpenLayers.Product(config);
+ var self = Worldview.Map.Product(config);
// The current z-index for all layers.
var zIndex = 0;
diff --git a/js/Worldview/OpenLayers/GraticuleLayer.js b/js/Worldview/Map/GraticuleLayer.js
similarity index 90%
rename from js/Worldview/OpenLayers/GraticuleLayer.js
rename to js/Worldview/Map/GraticuleLayer.js
index 02b1919a5..c48baec2c 100644
--- a/js/Worldview/OpenLayers/GraticuleLayer.js
+++ b/js/Worldview/Map/GraticuleLayer.js
@@ -9,9 +9,9 @@
* All Rights Reserved.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
-Worldview.OpenLayers.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
+Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
graticuleLineStyle: null,
graticuleLabelStyle: null,
@@ -63,5 +63,5 @@ Worldview.OpenLayers.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {
/*
* Name of this class per OpenLayers convention.
*/
- CLASS_NAME: "Worldview.OpenLayers.GraticuleLayer"
+ CLASS_NAME: "Worldview.Map.GraticuleLayer"
});
diff --git a/js/Worldview/OpenLayers/Product.js b/js/Worldview/Map/Product.js
similarity index 78%
rename from js/Worldview/OpenLayers/Product.js
rename to js/Worldview/Map/Product.js
index fb19a14a2..29165eeb2 100644
--- a/js/Worldview/OpenLayers/Product.js
+++ b/js/Worldview/Map/Product.js
@@ -9,9 +9,9 @@
* All Rights Reserved.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
-Worldview.OpenLayers.Product = function(c) {
+Worldview.Map.Product = function(c) {
var self = {};
var config;
@@ -21,17 +21,17 @@ Worldview.OpenLayers.Product = function(c) {
var init = function() {
config = $.extend(true, {}, c);
- var prop = config.properties;
+ var prop = config.properties || {};
if ( prop.style === undefined ) { prop.style = ""; }
if ( prop.tileSize ) {
prop.tileSize = new OpenLayers.Size(prop.tileSize[0],
prop.tileSize[1]);
}
- if ( config.properties.bringToFront === true ) {
+ if ( prop.bringToFront === true ) {
self.bringToFront = true;
}
- if ( config.properties.transitionEffect === undefined ) {
- config.properties.transitionEffect = "resize";
+ if ( prop.transitionEffect === undefined ) {
+ prop.transitionEffect = "resize";
}
};
@@ -42,7 +42,7 @@ Worldview.OpenLayers.Product = function(c) {
} else if ( config.type === "wmts") {
return new OpenLayers.Layer.WMTS(config.properties);
} else if ( config.type === "graticule") {
- return new Worldview.OpenLayers.GraticuleLayer(config.name,
+ return new Worldview.Map.GraticuleLayer(config.name,
config.properties);
} else {
throw "Unsupported layer type: " + config.type;
diff --git a/js/Worldview/OpenLayers/ProductMap.js b/js/Worldview/Map/ProductMap.js
similarity index 97%
rename from js/Worldview/OpenLayers/ProductMap.js
rename to js/Worldview/Map/ProductMap.js
index 6823a35d6..2b8b72ba4 100644
--- a/js/Worldview/OpenLayers/ProductMap.js
+++ b/js/Worldview/Map/ProductMap.js
@@ -9,10 +9,10 @@
* All Rights Reserved.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
/**
- * Class: Worldview.OpenLayers.ProductMap
+ * Class: Worldview.Map.ProductMap
* Map object that handles GIBS products.
*
* Constructor: ProductMap
@@ -27,7 +27,7 @@ Worldview.namespace("OpenLayers");
* Throws:
* An exception if no DOM element exists with the provided containerId.
*/
-Worldview.OpenLayers.ProductMap = function(containerId, mapConfig, component) {
+Worldview.Map.ProductMap = function(containerId, mapConfig, component) {
var log = Logging.Logger("Worldview.Map");
var self = {};
@@ -347,7 +347,7 @@ Worldview.OpenLayers.ProductMap = function(containerId, mapConfig, component) {
}));
var coordinateControl =
- Worldview.OpenLayers.COORDINATE_CONTROLS[projection];
+ Worldview.Map.COORDINATE_CONTROLS[projection];
if ( coordinateControl ) {
controls.push(coordinateControl);
} else {
@@ -399,9 +399,9 @@ Worldview.OpenLayers.ProductMap = function(containerId, mapConfig, component) {
}
if ( config.product === "daily" ) {
- return Worldview.OpenLayers.DailyProduct(map, config);
+ return Worldview.Map.DailyProduct(map, config);
} else if ( config.product === "static" ) {
- return Worldview.OpenLayers.StaticProduct(map, config);
+ return Worldview.Map.StaticProduct(map, config);
}
throw "Unsupported product type: " + config.product;
};
diff --git a/js/Worldview/OpenLayers/StaticProduct.js b/js/Worldview/Map/StaticProduct.js
similarity index 92%
rename from js/Worldview/OpenLayers/StaticProduct.js
rename to js/Worldview/Map/StaticProduct.js
index e0322707c..be876754a 100644
--- a/js/Worldview/OpenLayers/StaticProduct.js
+++ b/js/Worldview/Map/StaticProduct.js
@@ -9,10 +9,10 @@
* All Rights Reserved.
*/
-Worldview.namespace("OpenLayers");
+Worldview.namespace("Map");
/**
- * Class: Worldview.OpenLayers.StaticProduct
+ * Class: Worldview.Map.StaticProduct
* Product that is not based on the current date or time.
*
* Constructor: StaticProduct
@@ -25,9 +25,9 @@ Worldview.namespace("OpenLayers");
* layerClass which defines the type of layer to create (e.g.,
* OpenLayers.Layer.WMTS)
*/
-Worldview.OpenLayers.StaticProduct = function(map, config) {
+Worldview.Map.StaticProduct = function(map, config) {
- var self = Worldview.OpenLayers.Product(config);
+ var self = Worldview.Map.Product(config);
// There is only one layer and this is it
var layer = null;
diff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.js
index cbf8220f1..5ebfc0c90 100644
--- a/js/Worldview/Widget/Map.js
+++ b/js/Worldview/Widget/Map.js
@@ -84,7 +84,7 @@ Worldview.Widget.Map = function(containerId, spec) {
var onConfigLoad = function(result) {
try {
self.config = result;
- self.productMap = Worldview.OpenLayers.ProductMap(containerId,
+ self.productMap = Worldview.Map.ProductMap(containerId,
self.config, self);
$.each(self.config.products, function(name, config) {
diff --git a/test/OpenLayers/Tile/testCanvas.js b/test/Worldview/Map/testCanvas.js
similarity index 98%
rename from test/OpenLayers/Tile/testCanvas.js
rename to test/Worldview/Map/testCanvas.js
index a170a349b..e278f1b80 100644
--- a/test/OpenLayers/Tile/testCanvas.js
+++ b/test/Worldview/Map/testCanvas.js
@@ -21,7 +21,7 @@ TestCase("CanvasTile", {
var mockMap = mock(OpenLayers.Map);
mockLayer.map = mockMap;
- tile = new OpenLayers.Tile.Canvas(
+ tile = new Worldview.Map.CanvasTile(
mockLayer,
new OpenLayers.Pixel(0, 0), // screen location
new OpenLayers.Bounds(0, 0, 1, 1), // lat/lon bb
diff --git a/test/Worldview/OpenLayers/testDailyProduct.js b/test/Worldview/Map/testDailyProduct.js
similarity index 85%
rename from test/Worldview/OpenLayers/testDailyProduct.js
rename to test/Worldview/Map/testDailyProduct.js
index 4d141a267..2709b1d26 100644
--- a/test/Worldview/OpenLayers/testDailyProduct.js
+++ b/test/Worldview/Map/testDailyProduct.js
@@ -9,15 +9,18 @@
* All Rights Reserved.
*/
-TestCase("OpenLayers.DailyProduct", TestSuite.TestCases({
+TestCase("Map.DailyProduct", TestSuite.TestCases({
ns: null,
+ patcher: null,
mockMap: null,
mockLayers: null,
product: null,
setUp: function() {
- ns = Worldview.OpenLayers;
+ ns = Worldview.Map;
+ patcher = TestSuite.Patcher();
+
mockMap = mock({
addLayer: function() {},
events: {},
@@ -34,10 +37,12 @@ TestCase("OpenLayers.DailyProduct", TestSuite.TestCases({
};
mockConfig = {
- layerClass: "__TEST_LAYER_CLASS"
+ product: "daily",
+ type: "wmts"
};
mockLayers = [];
- window.__TEST_LAYER_CLASS = function() {
+
+ patcher.apply("OpenLayers.Layer.WMTS", function() {
var self = {};
self.mergeNewParams = function() {};
self.opacity = 0;
@@ -49,21 +54,21 @@ TestCase("OpenLayers.DailyProduct", TestSuite.TestCases({
self.getVisibility = function() { return self.visibility; };
mockLayers.push(self);
return self;
- };
+ });
product = ns.DailyProduct(mockMap, mockConfig);
},
tearDown: function() {
- delete window.__TEST_LAYER_CLASS;
+ patcher.undo();
},
- // Check that an exception is thrown if the layerClass does not exist
+ // Check that an exception is thrown if the product type does not exist
testInvalidLayerClass: function() {
try {
- ns.DailyProduct(mockMap, { layerClass: "foo" });
+ ns.DailyProduct(mockMap, { type: "foo" });
fail("foo should not be a valid layerClass");
} catch ( message ) {
- assertEquals("No such layerClass: foo; In foo, foo is undefined",
+ assertEquals("Unsupported layer type: foo",
message);
}
},
diff --git a/test/Worldview/OpenLayers/testProductMap.js b/test/Worldview/Map/testProductMap.js
similarity index 89%
rename from test/Worldview/OpenLayers/testProductMap.js
rename to test/Worldview/Map/testProductMap.js
index 9c54ee8c4..edb8ef3bc 100644
--- a/test/Worldview/OpenLayers/testProductMap.js
+++ b/test/Worldview/Map/testProductMap.js
@@ -9,14 +9,14 @@
* All Rights Reserved.
*/
-TestCase("OpenLayers.ProductMap", TestSuite.TestCases({
+TestCase("Map.ProductMap", TestSuite.TestCases({
ns: null,
patcher: null,
mapConfig: null,
setUp: function() {
- ns = Worldview.OpenLayers;
+ ns = Worldview.Map;
patcher = TestSuite.Patcher();
mapConfig = {
@@ -27,8 +27,8 @@ TestCase("OpenLayers.ProductMap", TestSuite.TestCases({
},
products: {
alpha: {
- productClass: "__TEST_PRODUCT_CLASS",
- layerClass: "__TEST_LAYER_CLASS",
+ product: "daily",
+ type: "wmts",
projections: {
geographic: {},
arctic: {},
@@ -36,8 +36,8 @@ TestCase("OpenLayers.ProductMap", TestSuite.TestCases({
}
},
beta: {
- productClass: "__TEST_PRODUCT_CLASS",
- layerClass: "__TEST_LAYER_CLASS",
+ product: "daily",
+ type: "wmts",
projections: {
geographic: {},
arctic: {},
@@ -45,15 +45,15 @@ TestCase("OpenLayers.ProductMap", TestSuite.TestCases({
}
},
gamma: {
- productClass: "__TEST_PRODUCT_CLASS",
- layerClass: "__TEST_LAYER_CLASS",
+ product: "daily",
+ type: "wmts",
projections: {
arctic: {}
}
},
delta: {
- productClass: "__TEST_PRODUCT_CLASS",
- layerClass: "__TEST_LAYER_CLASS",
+ product: "daily",
+ type: "wmts",
projections: {
antarctic: {}
}
@@ -61,22 +61,20 @@ TestCase("OpenLayers.ProductMap", TestSuite.TestCases({
}
};
- window.__TEST_PRODUCT_CLASS = function() {
+ patcher.apply("Worldview.Map.DailyProduct", function() {
return {
setDay: mockFunction(),
setZIndex: mockFunction(),
dispose: mockFunction()
};
- };
- window.__TEST_LAYER_CLASS = function() {};
+ });
+ patcher.apply("OpenLayers.Layer.WMTS", function() {});
$("<div id='__TEST_PRODUCT_MAP'></div>").appendTo("body");
},
tearDown: function() {
patcher.undo();
- delete window.__TEST_PRODUCT_CLASS;
- delete window.__TEST_LAYER_CLASS;
},
// Check that an error is thrown if the map container is not defined
diff --git a/test/jsTestDriver.conf b/test/jsTestDriver.conf
index 56b8161cd..4d6a50623 100644
--- a/test/jsTestDriver.conf
+++ b/test/jsTestDriver.conf
@@ -14,14 +14,13 @@ load:
- ../js/ext/datejs/date.js
- ../js/ext/jcrop/jcrop.js
- ../js/ext/jquery.dd/jquery.dd.js
- - ../js/OpenLayers/Tile/Canvas.js
- ../js/Logging.js
- ../js/Worldview.js
- ../js/Worldview/Visual.js
- ../js/Worldview/Visual/*.js
- ../js/Worldview/Widget/*.js
- - ../js/Worldview/OpenLayers.js
- - ../js/Worldview/OpenLayers/*.js
+ - ../js/Worldview/Map.js
+ - ../js/Worldview/Map/*.js
- ../js/component.js
- ../js/registry.js
- ../js/util.js
@@ -40,7 +39,6 @@ load:
test:
- testLogging.js
- testWorldview.js
- - OpenLayers/Tile/*.js
- Worldview/*.js
- Worldview/Visual/*.js
- Worldview/TestSuite/*.js