Loading app/package.json +4 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ "build": "webpack --config webpack.prod.js", "lint": "eslint --ext .js src", "fix": "npm run lint -- --fix", "prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}" "prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}", "generate-docs": "node_modules/.bin/jsdoc src/js/ -d docs -t node_modules/braintree-jsdoc-template/" }, "devDependencies": { "@babel/core": "^7.8.3", Loading @@ -44,6 +45,7 @@ "babel-loader": "^8.0.6", "babel-plugin-import": "^1.13.0", "babel-preset-airbnb": "^4.4.0", "braintree-jsdoc-template": "^3.3.0", "clean-webpack-plugin": "^3.0.0", "css-loader": "^3.4.2", "eslint": "^6.1.0", Loading Loading @@ -71,6 +73,7 @@ "@material-ui/lab": "^4.0.0-alpha.41", "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-draw": "1.0.4", "leaflet-fullscreen": "^1.0.2", "leaflet-sidebar-v2": "^3.2.2", "proj4": "^2.6.0", Loading @@ -78,7 +81,6 @@ "react": "^16.12.0", "react-dom": "^16.12.0", "typeface-roboto": "0.0.75", "leaflet-draw": "1.0.4", "wicket": "1.3.5" } } app/src/js/AstroMap.js +25 −24 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import "leaflet-fullscreen"; /* /** * @class AstroMap * @aka L.Map.AstroMap * @inherits L.Map * @extends L.Map * * The central class that creates an interactive map in the HTML. * @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 * * ```js * // 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 @@ -27,16 +30,6 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, /** * @details 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 @@ -77,7 +70,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Adds the LayerCollection with the requrested projection name. * @function AstroMap.prototype.loadLayerCollection * @description Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. */ Loading @@ -86,7 +80,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Changes the projection of the map and resets the center and view. * @function AstroMap.prototype.changeProjection * @description Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. * Loading @@ -113,7 +108,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Checks if the map has a layer collection for northPolar. * @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 @@ -122,7 +118,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Checks if the map has a layer collection for southPolar. * @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,7 +128,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the name of the target. * @function AstroMap.prototype.target * @description Returns the name of the target. * * @return {String} Name of target. */ Loading @@ -140,7 +138,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the name of the current projection of the map. * @function AstroMap.prototype.projection * @description Returns the name of the current projection of the map. * * @return {String} Proj-code of the projection. */ Loading @@ -149,7 +148,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Sets the value of the current layer of the map. * @function AstroMap.prototype.setCurrentLayer * @description Sets the value of the current layer of the map. * Set by the LayerCollection in the onAdd method. */ setCurrentLayer: function(layer) { Loading @@ -157,7 +157,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the current layer of the map. Used by the LayerCollection * @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 +61 −52 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * * @class AstroMap * * * A helper class that can be used by any mapping application, not just Leaflet, to calculate different * @class AstroMath * @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. * * * @example * ```js * // initialize an instance of AstroMath with a target name string. * astroMath = new AstroMath("mars"); * ``` * */ export default class AstroMath { /** * 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; let targets = MY_JSON_MAPS['targets']; let targets = MY_JSON_MAPS["targets"]; for (let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget['name'].toLowerCase() == this.targetName.toLowerCase()) { this.dMajorRadius = parseFloat(currentTarget['aaxisradius'] * 1000); this.dMinorRadius = parseFloat(currentTarget['caxisradius'] * 1000); if ( currentTarget["name"].toLowerCase() == this.targetName.toLowerCase() ) { this.dMajorRadius = parseFloat(currentTarget["aaxisradius"] * 1000); this.dMinorRadius = parseFloat(currentTarget["caxisradius"] * 1000); break; } } } /** * Returns the Major radius for the specific target. * @function AstroMath.prototype.getMajorRadius * @description Returns the Major radius for the specific target. * * @return {double} The Major radius value. */ getMajorRadius() { return this.dMajorRadius getMajorRadius() { return this.dMajorRadius; } /** * Returns the Minor radius for the specific target. * @function AstroMath.prototype.getMinorRadius * @description Returns the Minor radius for the specific target. * * @return {double} The Minor radius value. */ getMinorRadius() { return this.dMinorRadius getMinorRadius() { return this.dMinorRadius; } /** * Converts degrees to radians. * @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; } /** * Converts radians to degrees * @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; } /** * 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,9 +88,13 @@ export default class AstroMath { return convertedLatitude; } /** * Converts from -180 to 180 longitude range to 0 to 360 longtitude range. * @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 @@ -109,9 +111,13 @@ export default class AstroMath { } /** * Converts the longitude domain from positive east to positive west. * @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 @@ -125,8 +131,11 @@ export default class AstroMath { return convertedLng; } /** * Wraps the longitude of the map. * @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 +7 −6 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; /* /** * @class AstroProj * * 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 { /** * @details Finds the a and c radii of a given target. * @function AstroProj.prototype.getRadii * @description Finds the a and c radii of a given target. * * @param {String} target - Name of the target. * Loading @@ -30,7 +30,8 @@ export default class AstroProj { } /** * @details Returns the proj-string for a requested target and projection name. * @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/package.json +4 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ "build": "webpack --config webpack.prod.js", "lint": "eslint --ext .js src", "fix": "npm run lint -- --fix", "prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}" "prettier-watch": "onchange '**/*.js' -- prettier --write {{changed}}", "generate-docs": "node_modules/.bin/jsdoc src/js/ -d docs -t node_modules/braintree-jsdoc-template/" }, "devDependencies": { "@babel/core": "^7.8.3", Loading @@ -44,6 +45,7 @@ "babel-loader": "^8.0.6", "babel-plugin-import": "^1.13.0", "babel-preset-airbnb": "^4.4.0", "braintree-jsdoc-template": "^3.3.0", "clean-webpack-plugin": "^3.0.0", "css-loader": "^3.4.2", "eslint": "^6.1.0", Loading Loading @@ -71,6 +73,7 @@ "@material-ui/lab": "^4.0.0-alpha.41", "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-draw": "1.0.4", "leaflet-fullscreen": "^1.0.2", "leaflet-sidebar-v2": "^3.2.2", "proj4": "^2.6.0", Loading @@ -78,7 +81,6 @@ "react": "^16.12.0", "react-dom": "^16.12.0", "typeface-roboto": "0.0.75", "leaflet-draw": "1.0.4", "wicket": "1.3.5" } }
app/src/js/AstroMap.js +25 −24 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import "leaflet-fullscreen"; /* /** * @class AstroMap * @aka L.Map.AstroMap * @inherits L.Map * @extends L.Map * * The central class that creates an interactive map in the HTML. * @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 * * ```js * // 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 @@ -27,16 +30,6 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, /** * @details 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 @@ -77,7 +70,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Adds the LayerCollection with the requrested projection name. * @function AstroMap.prototype.loadLayerCollection * @description Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. */ Loading @@ -86,7 +80,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Changes the projection of the map and resets the center and view. * @function AstroMap.prototype.changeProjection * @description Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. * Loading @@ -113,7 +108,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Checks if the map has a layer collection for northPolar. * @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 @@ -122,7 +118,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Checks if the map has a layer collection for southPolar. * @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,7 +128,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the name of the target. * @function AstroMap.prototype.target * @description Returns the name of the target. * * @return {String} Name of target. */ Loading @@ -140,7 +138,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the name of the current projection of the map. * @function AstroMap.prototype.projection * @description Returns the name of the current projection of the map. * * @return {String} Proj-code of the projection. */ Loading @@ -149,7 +148,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Sets the value of the current layer of the map. * @function AstroMap.prototype.setCurrentLayer * @description Sets the value of the current layer of the map. * Set by the LayerCollection in the onAdd method. */ setCurrentLayer: function(layer) { Loading @@ -157,7 +157,8 @@ export default L.Map.AstroMap = L.Map.extend({ }, /** * @details Returns the current layer of the map. Used by the LayerCollection * @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 +61 −52 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * * @class AstroMap * * * A helper class that can be used by any mapping application, not just Leaflet, to calculate different * @class AstroMath * @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. * * * @example * ```js * // initialize an instance of AstroMath with a target name string. * astroMath = new AstroMath("mars"); * ``` * */ export default class AstroMath { /** * 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; let targets = MY_JSON_MAPS['targets']; let targets = MY_JSON_MAPS["targets"]; for (let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget['name'].toLowerCase() == this.targetName.toLowerCase()) { this.dMajorRadius = parseFloat(currentTarget['aaxisradius'] * 1000); this.dMinorRadius = parseFloat(currentTarget['caxisradius'] * 1000); if ( currentTarget["name"].toLowerCase() == this.targetName.toLowerCase() ) { this.dMajorRadius = parseFloat(currentTarget["aaxisradius"] * 1000); this.dMinorRadius = parseFloat(currentTarget["caxisradius"] * 1000); break; } } } /** * Returns the Major radius for the specific target. * @function AstroMath.prototype.getMajorRadius * @description Returns the Major radius for the specific target. * * @return {double} The Major radius value. */ getMajorRadius() { return this.dMajorRadius getMajorRadius() { return this.dMajorRadius; } /** * Returns the Minor radius for the specific target. * @function AstroMath.prototype.getMinorRadius * @description Returns the Minor radius for the specific target. * * @return {double} The Minor radius value. */ getMinorRadius() { return this.dMinorRadius getMinorRadius() { return this.dMinorRadius; } /** * Converts degrees to radians. * @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; } /** * Converts radians to degrees * @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; } /** * 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,9 +88,13 @@ export default class AstroMath { return convertedLatitude; } /** * Converts from -180 to 180 longitude range to 0 to 360 longtitude range. * @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 @@ -109,9 +111,13 @@ export default class AstroMath { } /** * Converts the longitude domain from positive east to positive west. * @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 @@ -125,8 +131,11 @@ export default class AstroMath { return convertedLng; } /** * Wraps the longitude of the map. * @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 +7 −6 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; /* /** * @class AstroProj * * 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 { /** * @details Finds the a and c radii of a given target. * @function AstroProj.prototype.getRadii * @description Finds the a and c radii of a given target. * * @param {String} target - Name of the target. * Loading @@ -30,7 +30,8 @@ export default class AstroProj { } /** * @details Returns the proj-string for a requested target and projection name. * @function AstroProj.prototype.getStringAndCode * @description Returns the proj-string for a requested target and projection name. * * @param {String} target - Name of the target. * Loading