Loading app/src/js/AstroMap.js +26 −33 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import "leaflet-fullscreen"; /** * @fileOverview The central class that creates an interactive map in the HTML. * @class AstroMap * @aka L.Map.AstroMap * @extends L.Map * * @classdesc The central class that creates an interactive map in the HTML. * Works with all target bodies supported by the USGS by loading the body's * base layers and overlays in a LayerCollection. Allows users to change * the projection of the map. * * @example * // initialize the map on the "map" div with the target Mars * L.Map.AstroMap("map", "Mars", {}); * * @param {String} mapDiv - ID of the div for the map. * * @param {String} target - Name of target to display layers for. * * @param {Object} options - Options for the map. */ export default L.Map.AstroMap = L.Map.extend({ options: { Loading @@ -17,18 +30,6 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, /** * @constructor AstroMap * * @description Initializes the map by loading the LayerCollection for * each supported projection and setting default options. * * @param {String} mapDiv - ID of the div for the map. * * @param {String} target - Name of target to display layers for. * * @param {Object} options - Options for the map. */ initialize: function(mapDiv, target, options) { this._mapDiv = mapDiv; this._target = target; Loading Loading @@ -69,8 +70,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method loadLayerCollection * @memberOf AstroMap# * @function AstroMap.prototype.loadLayerCollection * @description Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. Loading @@ -80,8 +80,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method changeProjection * @memberOf AstroMap# * @function AstroMap.prototype.changeProjection * @description Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. Loading Loading @@ -109,8 +108,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method hasNorthPolar * @memberOf AstroMap# * @function AstroMap.prototype.hasNorthPolar * @description Checks if the map has a layer collection for northPolar. * * @return {Boolean} Returns true if there is a northPolar collection. Loading @@ -120,8 +118,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method hasSouthPolar * @memberOf AstroMap# * @function AstroMap.prototype.hasSouthPolar * @description Checks if the map has a layer collection for southPolar. * * @return {Boolean} Returns true if there is a southPolar collection. Loading @@ -131,8 +128,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method target * @memberOf AstroMap# * @function AstroMap.prototype.target * @description Returns the name of the target. * * @return {String} Name of target. Loading @@ -142,8 +138,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method projection * @memberOf AstroMap# * @function AstroMap.prototype.projection * @description Returns the name of the current projection of the map. * * @return {String} Proj-code of the projection. Loading @@ -153,8 +148,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method setCurrentLayer * @memberOf AstroMap# * @function AstroMap.prototype.setCurrentLayer * @description Sets the value of the current layer of the map. * Set by the LayerCollection in the onAdd method. */ Loading @@ -163,8 +157,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method currentLayer * @memberOf AstroMap# * @function AstroMap.prototype.currentLayer * @description Returns the current layer of the map. Used by the LayerCollection * so that it can remove the layer of the map without having to * remove all layers, including drawn shapes. Loading app/src/js/AstroMath.js +28 −22 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * @fileOverview A helper class that can be used by any mapping application, not just Leaflet, to calculate different * longitude and latitude domains and ranges for a specific target. * It uses a JSON file in the background to store the targets and their associated radii. */ /** * @class AstroMath * @description A helper class that can be used by any mapping application, not just Leaflet, to calculate different * @classdesc A helper class that can be used by any mapping application, not just Leaflet, to calculate different * longitude and latitude domains and ranges for a specific target. * It uses a JSON file in the background to store the targets and their associated radii. */ export default class AstroMath { /** * @constructor AstroMath * @description Creates an instance of of AstroMath by taking in a target name and finds the * dMajorRadius and dMinorRadius that corresponds to that specific target. * @param {String} targetName - the name of the specific target. */ export default class AstroMath { constructor(targetName) { this.targetName = targetName; Loading @@ -38,8 +27,9 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.getMajorRadius * @description Returns the Major radius for the specific target. * * @return {double} The Major radius value. */ getMajorRadius() { Loading @@ -47,8 +37,9 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.getMinorRadius * @description Returns the Minor radius for the specific target. * * @return {double} The Minor radius value. */ getMinorRadius() { Loading @@ -56,27 +47,34 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.toRadians * @description Converts degrees to radians. * * @param {double} degrees - The degree value that is going to be converted. * * @return {double} The converted value in radians. */ toRadians(degrees) { return (degrees * Math.PI) / 180; } /** * @memberOf AstroMath# * @function AstroMath.prototype.toDegrees * @description Converts radians to degrees * * @param {double} radians - The radian value that is going to be converted. * * @return {double} The converted value in degrees. */ toDegrees(radians) { return (radians * 180) / Math.PI; } /** * @memberOf AstroMath# * @description Converts from planetOcentric latitude to planetOgrpahic Latitude based on a target's radii. * @function AstroMath.prototype.latToPlanetOgraphic * @description Converts from planetOcentric latitude to planetOgrpahic Latitude * based on a target's radii. * * @param {double} lat - The latitude value that is going to be converted * * @return {double} The latitude converted into planetOgrpahic */ latToPlanetOgraphic(lat) { Loading @@ -90,10 +88,13 @@ export default class AstroMath { return convertedLatitude; } /** * @memberOf AstroMath# * @function AstroMath.prototype.lonTo360 * @description Converts from -180 to 180 longitude range to 0 to 360 longtitude range. * * @param {double} lng - The longitude value that is going to be converted * * @param {boolean} projection - The current projection of the map * * @return {double} The converted longitude range. */ lonTo360(lon, projection) { Loading @@ -110,10 +111,13 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.domainToPositiveWest * @description Converts the longitude domain from positive east to positive west. * * @param {double} lng - The longitude value that is going to be converted. * * @param {boolean} normalRange - True if the current range is -180 to 180, false otherwise. * * @return {double} The longitude value converted to postive west. */ domainToPositiveWest(lng, normalRange) { Loading @@ -127,9 +131,11 @@ export default class AstroMath { return convertedLng; } /** * @memberOf AstroMath# * @function AstroMath.prototype.wrapLongitude * @description Wraps the longitude of the map. * * @param {double} lng - The longitude that needs to be wrapped. * * @return {double} The longitude value thats wrapped. */ wrapLongitude(lng) { Loading app/src/js/AstroProj.js +3 −8 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; /** * @fileOverview Helper class that stores projections for each target supported * by the USGS. */ /** * @class AstroProj * @description Helper class that stores projections for each target supported * @classdesc Helper class that stores projections for each target supported * by the USGS. */ export default class AstroProj { /** * @memberOf AstroProj# * @function AstroProj.prototype.getRadii * @description Finds the a and c radii of a given target. * * @param {String} target - Name of the target. Loading @@ -35,7 +30,7 @@ export default class AstroProj { } /** * @memberOf AstroProj# * @function AstroProj.prototype.getStringAndCode * @description Returns the proj-string for a requested target and projection name. * * @param {String} target - Name of the target. Loading Loading
app/src/js/AstroMap.js +26 −33 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import "leaflet-fullscreen"; /** * @fileOverview The central class that creates an interactive map in the HTML. * @class AstroMap * @aka L.Map.AstroMap * @extends L.Map * * @classdesc The central class that creates an interactive map in the HTML. * Works with all target bodies supported by the USGS by loading the body's * base layers and overlays in a LayerCollection. Allows users to change * the projection of the map. * * @example * // initialize the map on the "map" div with the target Mars * L.Map.AstroMap("map", "Mars", {}); * * @param {String} mapDiv - ID of the div for the map. * * @param {String} target - Name of target to display layers for. * * @param {Object} options - Options for the map. */ export default L.Map.AstroMap = L.Map.extend({ options: { Loading @@ -17,18 +30,6 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, /** * @constructor AstroMap * * @description Initializes the map by loading the LayerCollection for * each supported projection and setting default options. * * @param {String} mapDiv - ID of the div for the map. * * @param {String} target - Name of target to display layers for. * * @param {Object} options - Options for the map. */ initialize: function(mapDiv, target, options) { this._mapDiv = mapDiv; this._target = target; Loading Loading @@ -69,8 +70,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method loadLayerCollection * @memberOf AstroMap# * @function AstroMap.prototype.loadLayerCollection * @description Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. Loading @@ -80,8 +80,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method changeProjection * @memberOf AstroMap# * @function AstroMap.prototype.changeProjection * @description Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. Loading Loading @@ -109,8 +108,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method hasNorthPolar * @memberOf AstroMap# * @function AstroMap.prototype.hasNorthPolar * @description Checks if the map has a layer collection for northPolar. * * @return {Boolean} Returns true if there is a northPolar collection. Loading @@ -120,8 +118,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method hasSouthPolar * @memberOf AstroMap# * @function AstroMap.prototype.hasSouthPolar * @description Checks if the map has a layer collection for southPolar. * * @return {Boolean} Returns true if there is a southPolar collection. Loading @@ -131,8 +128,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method target * @memberOf AstroMap# * @function AstroMap.prototype.target * @description Returns the name of the target. * * @return {String} Name of target. Loading @@ -142,8 +138,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method projection * @memberOf AstroMap# * @function AstroMap.prototype.projection * @description Returns the name of the current projection of the map. * * @return {String} Proj-code of the projection. Loading @@ -153,8 +148,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method setCurrentLayer * @memberOf AstroMap# * @function AstroMap.prototype.setCurrentLayer * @description Sets the value of the current layer of the map. * Set by the LayerCollection in the onAdd method. */ Loading @@ -163,8 +157,7 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @method currentLayer * @memberOf AstroMap# * @function AstroMap.prototype.currentLayer * @description Returns the current layer of the map. Used by the LayerCollection * so that it can remove the layer of the map without having to * remove all layers, including drawn shapes. Loading
app/src/js/AstroMath.js +28 −22 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * @fileOverview A helper class that can be used by any mapping application, not just Leaflet, to calculate different * longitude and latitude domains and ranges for a specific target. * It uses a JSON file in the background to store the targets and their associated radii. */ /** * @class AstroMath * @description A helper class that can be used by any mapping application, not just Leaflet, to calculate different * @classdesc A helper class that can be used by any mapping application, not just Leaflet, to calculate different * longitude and latitude domains and ranges for a specific target. * It uses a JSON file in the background to store the targets and their associated radii. */ export default class AstroMath { /** * @constructor AstroMath * @description Creates an instance of of AstroMath by taking in a target name and finds the * dMajorRadius and dMinorRadius that corresponds to that specific target. * @param {String} targetName - the name of the specific target. */ export default class AstroMath { constructor(targetName) { this.targetName = targetName; Loading @@ -38,8 +27,9 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.getMajorRadius * @description Returns the Major radius for the specific target. * * @return {double} The Major radius value. */ getMajorRadius() { Loading @@ -47,8 +37,9 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.getMinorRadius * @description Returns the Minor radius for the specific target. * * @return {double} The Minor radius value. */ getMinorRadius() { Loading @@ -56,27 +47,34 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.toRadians * @description Converts degrees to radians. * * @param {double} degrees - The degree value that is going to be converted. * * @return {double} The converted value in radians. */ toRadians(degrees) { return (degrees * Math.PI) / 180; } /** * @memberOf AstroMath# * @function AstroMath.prototype.toDegrees * @description Converts radians to degrees * * @param {double} radians - The radian value that is going to be converted. * * @return {double} The converted value in degrees. */ toDegrees(radians) { return (radians * 180) / Math.PI; } /** * @memberOf AstroMath# * @description Converts from planetOcentric latitude to planetOgrpahic Latitude based on a target's radii. * @function AstroMath.prototype.latToPlanetOgraphic * @description Converts from planetOcentric latitude to planetOgrpahic Latitude * based on a target's radii. * * @param {double} lat - The latitude value that is going to be converted * * @return {double} The latitude converted into planetOgrpahic */ latToPlanetOgraphic(lat) { Loading @@ -90,10 +88,13 @@ export default class AstroMath { return convertedLatitude; } /** * @memberOf AstroMath# * @function AstroMath.prototype.lonTo360 * @description Converts from -180 to 180 longitude range to 0 to 360 longtitude range. * * @param {double} lng - The longitude value that is going to be converted * * @param {boolean} projection - The current projection of the map * * @return {double} The converted longitude range. */ lonTo360(lon, projection) { Loading @@ -110,10 +111,13 @@ export default class AstroMath { } /** * @memberOf AstroMath# * @function AstroMath.prototype.domainToPositiveWest * @description Converts the longitude domain from positive east to positive west. * * @param {double} lng - The longitude value that is going to be converted. * * @param {boolean} normalRange - True if the current range is -180 to 180, false otherwise. * * @return {double} The longitude value converted to postive west. */ domainToPositiveWest(lng, normalRange) { Loading @@ -127,9 +131,11 @@ export default class AstroMath { return convertedLng; } /** * @memberOf AstroMath# * @function AstroMath.prototype.wrapLongitude * @description Wraps the longitude of the map. * * @param {double} lng - The longitude that needs to be wrapped. * * @return {double} The longitude value thats wrapped. */ wrapLongitude(lng) { Loading
app/src/js/AstroProj.js +3 −8 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; /** * @fileOverview Helper class that stores projections for each target supported * by the USGS. */ /** * @class AstroProj * @description Helper class that stores projections for each target supported * @classdesc Helper class that stores projections for each target supported * by the USGS. */ export default class AstroProj { /** * @memberOf AstroProj# * @function AstroProj.prototype.getRadii * @description Finds the a and c radii of a given target. * * @param {String} target - Name of the target. Loading @@ -35,7 +30,7 @@ export default class AstroProj { } /** * @memberOf AstroProj# * @function AstroProj.prototype.getStringAndCode * @description Returns the proj-string for a requested target and projection name. * * @param {String} target - Name of the target. Loading