Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Documented Map.js and WorldviewMap.js

Mike McGanne2a40a085e5a
diff --git a/doc/NaturalDocs/Menu.txt b/doc/NaturalDocs/Menu.txt
index 47c370ff5..0531af446 100644
--- a/doc/NaturalDocs/Menu.txt
+++ b/doc/NaturalDocs/Menu.txt
@@ -99,6 +99,13 @@ Group: Code Reference {
} # Group: Palette
File: Permalink (/Users/jmcgann/Code/Aptana/worldview/js/Worldview/Permalink.js)
+
+ Group: Widget {
+
+ File: Map (no auto-title, /Users/jmcgann/Code/Aptana/worldview/js/Worldview/Widget/Map.js)
+ File: WorldviewMap (no auto-title, /Users/jmcgann/Code/Aptana/worldview/js/Worldview/Widget/WorldviewMap.js)
+ } # Group: Widget
+
} # Group: Worldview
Group: TestSuite {
diff --git a/js/Worldview/Permalink.js b/js/Worldview/Permalink.js
index 6a64e7440..687e3757b 100644
--- a/js/Worldview/Permalink.js
+++ b/js/Worldview/Permalink.js
@@ -115,6 +115,7 @@ $(function() {
};
/**
+ * Function: show
* Display a dialog box to the user showing the current permalink.
*/
ns.show = function() {
diff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.js
index 32ee1a543..146bc59e6 100644
--- a/js/Worldview/Widget/Map.js
+++ b/js/Worldview/Widget/Map.js
@@ -11,12 +11,37 @@
Worldview.namespace("Widget");
+/**
+ * Class: Worldview.Widget.Map
+ * Widget that provides the map for displaying data layers.
+ *
+ * Constructor: Worldview.Widget.Map
+ * Creates a new instance.
+ *
+ * Parameters:
+ * containerId - The id of the div element to place the map into
+ * spec.dataSourceUrl - The endpoint where configuration information should
+ * be obtained from.
+ * spec.onReady - function to be invoked once the map has read in the
+ * configuration and is ready to be used.
+ */
Worldview.Widget.Map = function(containerId, spec) {
var self = {};
var log = Logging.Logger("Worldview.Map");
+ /**
+ * Property: productMap
+ * The <Worldview.Map.ProductMap> that contains the map objects, one for
+ * each projection.
+ */
self.productMap = null;
+
+ /**
+ * Property: config
+ * The <Worldview.JSON.MapConfig> object retrieved from the server that
+ * defines the available projections and data products.
+ */
self.config = null;
var init = function() {
@@ -30,12 +55,30 @@ Worldview.Widget.Map = function(containerId, spec) {
.error(Worldview.ajaxError(onConfigLoadError));
};
+ /**
+ * Method: setValue
+ * Zooms to the specified extent.
+ *
+ * Parameters:
+ * value - String in the form of L_B_R_U where L is the left X value,
+ * B is the bottom Y value, R is the right X value, and U is the upper
+ * Y value. Commas instead of underscores are also accepted.
+ */
self.setValue = function(value) {
log.debug("setValue: " + extent);
var extent = Worldview.Widget.Map.extentFromValue(value);
self.productMap.map.zoomToExtent(extent, true);
};
+ /**
+ * Method: getValue
+ * Returns the current extent as a query string.
+ *
+ * Returns:
+ * The value in the form of I=L_B_R_U where I is the container id, L is the
+ * left X value, B is the bottom Y value, R is the right X value,
+ * and U is the upper Y value.
+ */
self.getValue = function() {
var queryString = containerId + "=" +
Worldview.Widget.Map.valueFromExtent(
@@ -44,6 +87,17 @@ Worldview.Widget.Map = function(containerId, spec) {
return queryString;
};
+ /**
+ * Method: loadFromQuery
+ * Sets the projection and zooms to the extent given values in a query
+ * string.
+ *
+ * Parameters:
+ * queryString: If switch=X appears in the string, the projection is
+ * set to X. If containerId=Y where containerId is the id that was used
+ * to construct this object, the map is zoomed to extent Y as defined
+ * in <setValue>
+ */
self.loadFromQuery = function(queryString) {
log.debug("loadFromQuery: " + queryString);
@@ -58,26 +112,58 @@ Worldview.Widget.Map = function(containerId, spec) {
}
};
+ /**
+ * Method: validate
+ * Always returns true.
+ */
self.validate = function() {
return true;
};
+ /**
+ * Method: setDataSourceUrl
+ * Throws an unsupported exception.
+ */
self.setDataSourceUrl = function(url) {
throw "setDataSourceUrl: unsupported";
};
+ /**
+ * Method: getDataSourceUrl
+ * Gets the URL endpoint where configuration data is obtained.
+ *
+ * Returns:
+ * The URL to the configuration endpoint.
+ */
self.getDataSourceUrl = function() {
return spec.dataSourceUrl;
};
+ /**
+ * Method: setStatus
+ * Throws an unsupported exception as it seems this method is never
+ * invoked.
+ */
self.setStatus = function(status) {
throw "setStatus: unsupported";
};
+ /**
+ * Method: getStatus
+ * Throws an unsupported exception as it seems this method is never
+ * invoked.
+ */
self.getStatus = function() {
throw "getStatus: unsupported";
};
-
+
+ /**
+ * Indicates if the map is ready to be used.
+ *
+ * Returns:
+ * true if the map has loaded configuration from the remote server and
+ * has initialized, otherwise returns false.
+ */
self.isReady = function() {
return self.productMap != null;
}
@@ -116,12 +202,42 @@ Worldview.Widget.Map = function(containerId, spec) {
return self;
};
+/**
+ * Namespace: Worldview.Widget.Map
+ * Utility functions.
+ */
(function(ns) {
+ /**
+ * Function: extentFromValue
+ * Converts an extent value in a query string to an OpenLayers.Bounds
+ * object.
+ *
+ * Parameters:
+ * value - String in the form of L_B_R_U where L is the left X value,
+ * B is the bottom Y value, R is the right X value, and U is the upper
+ * Y value. Commas instead of underscores are also accepted.
+ *
+ * Returns:
+ * The OpenLayers.Bound object that represents the given extent.
+ */
ns.extentFromValue = function(value) {
return OpenLayers.Bounds.fromString(value.replace(/_/g, ","));
};
+ /**
+ * Function: valueFromExtent
+ * Converts an OpenLayers.Bounds object to a value that can be used
+ * in a query string.
+ *
+ * Parameters:
+ * extent - The extent as an OpenLayers.Bounds object.
+ *
+ * Returns:
+ * String in the form of L_B_R_U where L is the left X value,
+ * B is the bottom Y value, R is the right X value, and U is the upper
+ * Y value.
+ */
ns.valueFromExtent = function(extent) {
return extent.toBBOX().replace(/,/g, "_");
};
diff --git a/js/Worldview/Widget/WorldviewMap.js b/js/Worldview/Widget/WorldviewMap.js
index 320b79a79..6254ec4fd 100644
--- a/js/Worldview/Widget/WorldviewMap.js
+++ b/js/Worldview/Widget/WorldviewMap.js
@@ -11,6 +11,23 @@
Worldview.namespace("Widget");
+/**
+ * Class: Worldview.Widget.WorldviewMap
+ * Map features that are specific to Worldview.
+ *
+ * Delegates to:
+ * <Worldview.Widget.Map>
+ *
+ * Constructor: Worldview.Widget.WorldviewMap
+ * Creates a new instance.
+ *
+ * Parameters:
+ * containerId - The id of the div element to place the map into
+ * spec.dataSourceUrl - The endpoint where configuration information should
+ * be obtained from.
+ * spec.onReady - function to be invoked once the map has read in the
+ * configuration and is ready to be used.
+ */
Worldview.Widget.WorldviewMap = function(containerId, spec) {
var ns = Worldview.Widget;
@@ -30,7 +47,16 @@ Worldview.Widget.WorldviewMap = function(containerId, spec) {
var log = Logging.Logger("Worldview.Map");
var lastState = {};
var last = null;
-
+
+ /**
+ * Method: updateComponent
+ * Updates the map when the state of the application changes.
+ *
+ * Parameters:
+ * queryString - If products=X is defined, ensure that only the layers for
+ * X are visible. If switch=Y is defined, changes the projection of the
+ * map to Y if necessary.
+ */
self.updateComponent = function(queryString) {
try {
if ( !self.isReady() ) {
@@ -68,16 +94,17 @@ Worldview.Widget.WorldviewMap = function(containerId, spec) {
}
};
+ /* Set default extent according to time of day:
+ * at 00:00 UTC, start at far eastern edge of map:
+ * "20.6015625,-46.546875,179.9296875,53.015625"
+ * at 23:00 UTC, start at far western edge of map:
+ * "-179.9296875,-46.546875,-20.6015625,53.015625"
+ */
var setExtentToLeading = function() {
if ( self.productMap.projection !== "geographic" ) {
return;
}
- // Set default extent according to time of day:
- // at 00:00 UTC, start at far eastern edge of map:
- // "20.6015625,-46.546875,179.9296875,53.015625"
- // at 23:00 UTC, start at far western edge of map:
- // "-179.9296875,-46.546875,-20.6015625,53.015625"
var curHour = new Date().getUTCHours();
// For earlier hours when data is still being filled in, force a far
@@ -99,7 +126,10 @@ Worldview.Widget.WorldviewMap = function(containerId, spec) {
//this.fire();
};
-
+
+ /**
+ * Converts the product listed in the query string into an array.
+ */
var splitProducts = function(state) {
var results = [];
var sets = state.products.split("~");