Loading .gitignore +5 −2 Original line number Diff line number Diff line .cache/ coverage/ dist/ dist/* app/node_modules/ .dist/ node_modules package-lock.json *.log app/package-lock.json .dist/ app/node_modules # OS generated files .DS_Store Loading app/package.json +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ "@material-ui/core": "^4.9.0", "@material-ui/icons": "^4.5.1", "@material-ui/lab": "^4.0.0-alpha.41", "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-fullscreen": "^1.0.2", "leaflet-sidebar-v2": "^3.2.2", Loading app/src/js/AstroMap.js +83 −23 Original line number Diff line number Diff line Loading @@ -28,49 +28,109 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, // @method initialize(mapDiv: String, target: String, options?: Zoom/pan options) // Initializes the map by loading the LayerCollection for each supported projection // and setting the default options. /** * @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; this.AstroProj = new AstroProj(); this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); // Could not work with _ this.layers = { geodesic: new LayerCollection(this.target, "cylindrical"), northPolar: new LayerCollection(this.target, "north-polar stereographic"), southPolar: new LayerCollection(this.target, "south-polar stereographic") northPolar: new LayerCollection( this._target, "north-polar stereographic" ), southPolar: new LayerCollection( this._target, "south-polar stereographic" ), cylindrical: new LayerCollection(this._target, "cylindrical") }; if (this.layers["northPolar"].isEmpty()) { this._hasNorthPolar = false; } else { this._hasNorthPolar = true; } if (this.layers["southPolar"].isEmpty()) { this._hasSouthPolar = false; } else { this._hasSouthPolar = true; } this._defaultProj = L.extend({}, L.CRS.EPSG4326, { R: this._radii["a"] }); this.options["crs"] = this._defaultProj; L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); }, // @method loadLayerCollection(name: String) // Adds the LayerCollection with the requrested projection name. /** * @details Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. */ loadLayerCollection: function(name) { this.layers[name].addTo(this); }, // @method changeProjection(name: String, center: List) // Changes the projection of the map and resets the center and view. /** * @details Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. * * @param {List} center - Center of map based off of projection. ] */ changeProjection: function(name, center) { let newCRS = null; if (name == "geodesic") { newCRS = L.CRS.EPSG4326; if (name == "cylindrical") { newCRS = this._defaultProj; } else { let proj = this.AstroProj.getStringAndCode(this.target, name); let proj = this._astroProj.getStringAndCode(this._target, name); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] }); } this.options.crs = newCRS; this._resetView(center, 1, true); this.setView(center, 1, true); this.loadLayerCollection(name); }, /** * @details Checks if the map has a layer collection for northPolar. * * @return {Boolean} Returns true if there is a northPolar collection. */ hasNorthPolar: function() { return this._hasNorthPolar; }, /** * @details Checks if the map has a layer collection for southPolar. * * @return {Boolean} Returns true if there is a southPolar collection. */ hasSouthPolar: function() { return this._hasSouthPolar; }, /** * @details Returns the name of the target. * @return {String} Name of target. */ target: function() { return this._target; } }); // exports.L.map.astroMap = function(mapDiv, target, options) { // return new L.map.astroMap(mapDiv, target, options); // }; app/src/js/AstroMath.js +38 −23 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * * @class AstroMap Loading @@ -24,25 +27,37 @@ export default class AstroMath { constructor(targetName) { this.targetName = targetName; switch (this.targetName) { case "mars": this.dMajorRadius = 3396190.0; this.dMinorRadius = 3376200.0; break; case "moon": this.dMajorRadius = 1737400.0; this.dMinorRadius = 1737400.0; break; case "mercury": this.dMajorRadius = 2439400.0; this.dMinorRadius = 2439400.0; let targets = MY_JSON_MAPS['targets']; for(let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget['name'].toLowerCase() == targetName ) { this.dMajorRadius = parseFloat(currentTarget['aaxisradius'] * 1000); this.dMinorRadius = parseFloat(currentTarget['caxisradius'] * 1000); break; default: this.dMajorRadius = 0; this.dMinorRadius = 0; console.log("target not supported"); } } } /** * Returns the Major radius for the specific target. * @return {double} The Major radius value. */ getMajorRadius() { return this.dMajorRadius } /** * Returns the Minor radius for the specific target. * @return {double} The Minor radius value. */ getMinorRadius() { return this.dMinorRadius } /** * Converts degrees to radians. * @param {double} degrees - The degree value that is going to be converted. Loading app/src/js/AstroProj.js +50 −40 Original line number Diff line number Diff line const projectionDefs = { mars: [ { name: "northpolar", code: "EPSG:32661", string: "+proj=stere +lat_0=90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs" }, { name: "southpolar", code: "EPSG:32761", string: "+proj=stere +lat_0=-90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs" }, { name: "geodesic", code: "EPSG:4326", string: "+proj=longlat +a=3396190 +b=3396190 +no_defs" } ] }; import { MY_JSON_MAPS } from "./layers"; /* * @class AstroProj Loading @@ -27,30 +7,60 @@ const projectionDefs = { * by the USGS. */ export default class AstroProj { // @method getString(target: String, code: String): String // Returns the proj-string for a requested target given the proj-code. getString(target, code) { let projections = projectionDefs[target.toLowerCase()]; for (let i = 0; i < projections.length; i++) { if (code == projections[i]["code"]) { return projections[i]["string"]; /** * @details Finds the a and c radii of a given target. * * @param {String} target - Name of the target. * * @return {Object} Radii Object in form: {'a': , 'c': }. */ getRadii(target) { var targets = MY_JSON_MAPS["targets"]; let radii = {}; for (let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget["name"].toLowerCase() == target.toLowerCase()) { radii["a"] = parseFloat(currentTarget["aaxisradius"] * 1000); radii["c"] = parseFloat(currentTarget["caxisradius"] * 1000); break; } } console.log("No projection found for the target"); return radii; } // @method getStringAndCode(target: String, name: String): [String, String] // Returns the proj-string for a requested target and projection name. /** * @details Returns the proj-string for a requested target and projection name. * * @param {String} target - Name of the target. * * @param {String} name - Name of the projection. * * @return {Object} Object storing the proj-string and code * in the form: {'code': , 'string'}. */ getStringAndCode(target, name) { let projections = projectionDefs[target.toLowerCase()]; for (let i = 0; i < projections.length; i++) { if (name.toLowerCase() == projections[i]["name"]) { let radii = this.getRadii(target); if (name == "northPolar") { return { code: projections[i]["code"], string: projections[i]["string"] code: "EPSG:32661", string: "+proj=stere +lat_0=90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=${radii['a']} +b=${radii['c']} +units=m +no_defs" }; } else if (name == "southPolar") { return { code: "EPSG:32761", string: "+proj=stere +lat_0=-90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=${radii['a']} +b=${radii['c']} +units=m +no_defs" }; } else if (name == "cylindrical") { return { code: "EPSG:4326", string: "+proj=longlat +a=${radii['a']} +b=${radii['c']} +no_defs" }; } else { console.log("No projection found for the target and name given."); } } console.log("No projection found for the target"); } } Loading
.gitignore +5 −2 Original line number Diff line number Diff line .cache/ coverage/ dist/ dist/* app/node_modules/ .dist/ node_modules package-lock.json *.log app/package-lock.json .dist/ app/node_modules # OS generated files .DS_Store Loading
app/package.json +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ "@material-ui/core": "^4.9.0", "@material-ui/icons": "^4.5.1", "@material-ui/lab": "^4.0.0-alpha.41", "jquery": "^3.4.1", "leaflet": "^1.6.0", "leaflet-fullscreen": "^1.0.2", "leaflet-sidebar-v2": "^3.2.2", Loading
app/src/js/AstroMap.js +83 −23 Original line number Diff line number Diff line Loading @@ -28,49 +28,109 @@ export default L.Map.AstroMap = L.Map.extend({ fullscreenControl: true }, // @method initialize(mapDiv: String, target: String, options?: Zoom/pan options) // Initializes the map by loading the LayerCollection for each supported projection // and setting the default options. /** * @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; this.AstroProj = new AstroProj(); this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); // Could not work with _ this.layers = { geodesic: new LayerCollection(this.target, "cylindrical"), northPolar: new LayerCollection(this.target, "north-polar stereographic"), southPolar: new LayerCollection(this.target, "south-polar stereographic") northPolar: new LayerCollection( this._target, "north-polar stereographic" ), southPolar: new LayerCollection( this._target, "south-polar stereographic" ), cylindrical: new LayerCollection(this._target, "cylindrical") }; if (this.layers["northPolar"].isEmpty()) { this._hasNorthPolar = false; } else { this._hasNorthPolar = true; } if (this.layers["southPolar"].isEmpty()) { this._hasSouthPolar = false; } else { this._hasSouthPolar = true; } this._defaultProj = L.extend({}, L.CRS.EPSG4326, { R: this._radii["a"] }); this.options["crs"] = this._defaultProj; L.setOptions(this, options); L.Map.prototype.initialize.call(this, this.mapDiv, this.options); this.loadLayerCollection("geodesic"); L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); }, // @method loadLayerCollection(name: String) // Adds the LayerCollection with the requrested projection name. /** * @details Adds the LayerCollection with the requrested projection name. * * @param {String} name - Name of the projection. */ loadLayerCollection: function(name) { this.layers[name].addTo(this); }, // @method changeProjection(name: String, center: List) // Changes the projection of the map and resets the center and view. /** * @details Changes the projection of the map and resets the center and view. * * @param {String} name - Name of Projection. * * @param {List} center - Center of map based off of projection. ] */ changeProjection: function(name, center) { let newCRS = null; if (name == "geodesic") { newCRS = L.CRS.EPSG4326; if (name == "cylindrical") { newCRS = this._defaultProj; } else { let proj = this.AstroProj.getStringAndCode(this.target, name); let proj = this._astroProj.getStringAndCode(this._target, name); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128], origin: [0, 0] }); } this.options.crs = newCRS; this._resetView(center, 1, true); this.setView(center, 1, true); this.loadLayerCollection(name); }, /** * @details Checks if the map has a layer collection for northPolar. * * @return {Boolean} Returns true if there is a northPolar collection. */ hasNorthPolar: function() { return this._hasNorthPolar; }, /** * @details Checks if the map has a layer collection for southPolar. * * @return {Boolean} Returns true if there is a southPolar collection. */ hasSouthPolar: function() { return this._hasSouthPolar; }, /** * @details Returns the name of the target. * @return {String} Name of target. */ target: function() { return this._target; } }); // exports.L.map.astroMap = function(mapDiv, target, options) { // return new L.map.astroMap(mapDiv, target, options); // };
app/src/js/AstroMath.js +38 −23 Original line number Diff line number Diff line import { MY_JSON_MAPS } from "./layers"; import "./MousePosition"; /** * * @class AstroMap Loading @@ -24,25 +27,37 @@ export default class AstroMath { constructor(targetName) { this.targetName = targetName; switch (this.targetName) { case "mars": this.dMajorRadius = 3396190.0; this.dMinorRadius = 3376200.0; break; case "moon": this.dMajorRadius = 1737400.0; this.dMinorRadius = 1737400.0; break; case "mercury": this.dMajorRadius = 2439400.0; this.dMinorRadius = 2439400.0; let targets = MY_JSON_MAPS['targets']; for(let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget['name'].toLowerCase() == targetName ) { this.dMajorRadius = parseFloat(currentTarget['aaxisradius'] * 1000); this.dMinorRadius = parseFloat(currentTarget['caxisradius'] * 1000); break; default: this.dMajorRadius = 0; this.dMinorRadius = 0; console.log("target not supported"); } } } /** * Returns the Major radius for the specific target. * @return {double} The Major radius value. */ getMajorRadius() { return this.dMajorRadius } /** * Returns the Minor radius for the specific target. * @return {double} The Minor radius value. */ getMinorRadius() { return this.dMinorRadius } /** * Converts degrees to radians. * @param {double} degrees - The degree value that is going to be converted. Loading
app/src/js/AstroProj.js +50 −40 Original line number Diff line number Diff line const projectionDefs = { mars: [ { name: "northpolar", code: "EPSG:32661", string: "+proj=stere +lat_0=90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs" }, { name: "southpolar", code: "EPSG:32761", string: "+proj=stere +lat_0=-90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=3396190 +b=3376200 +units=m +no_defs" }, { name: "geodesic", code: "EPSG:4326", string: "+proj=longlat +a=3396190 +b=3396190 +no_defs" } ] }; import { MY_JSON_MAPS } from "./layers"; /* * @class AstroProj Loading @@ -27,30 +7,60 @@ const projectionDefs = { * by the USGS. */ export default class AstroProj { // @method getString(target: String, code: String): String // Returns the proj-string for a requested target given the proj-code. getString(target, code) { let projections = projectionDefs[target.toLowerCase()]; for (let i = 0; i < projections.length; i++) { if (code == projections[i]["code"]) { return projections[i]["string"]; /** * @details Finds the a and c radii of a given target. * * @param {String} target - Name of the target. * * @return {Object} Radii Object in form: {'a': , 'c': }. */ getRadii(target) { var targets = MY_JSON_MAPS["targets"]; let radii = {}; for (let i = 0; i < targets.length; i++) { let currentTarget = targets[i]; if (currentTarget["name"].toLowerCase() == target.toLowerCase()) { radii["a"] = parseFloat(currentTarget["aaxisradius"] * 1000); radii["c"] = parseFloat(currentTarget["caxisradius"] * 1000); break; } } console.log("No projection found for the target"); return radii; } // @method getStringAndCode(target: String, name: String): [String, String] // Returns the proj-string for a requested target and projection name. /** * @details Returns the proj-string for a requested target and projection name. * * @param {String} target - Name of the target. * * @param {String} name - Name of the projection. * * @return {Object} Object storing the proj-string and code * in the form: {'code': , 'string'}. */ getStringAndCode(target, name) { let projections = projectionDefs[target.toLowerCase()]; for (let i = 0; i < projections.length; i++) { if (name.toLowerCase() == projections[i]["name"]) { let radii = this.getRadii(target); if (name == "northPolar") { return { code: projections[i]["code"], string: projections[i]["string"] code: "EPSG:32661", string: "+proj=stere +lat_0=90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=${radii['a']} +b=${radii['c']} +units=m +no_defs" }; } else if (name == "southPolar") { return { code: "EPSG:32761", string: "+proj=stere +lat_0=-90 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=${radii['a']} +b=${radii['c']} +units=m +no_defs" }; } else if (name == "cylindrical") { return { code: "EPSG:4326", string: "+proj=longlat +a=${radii['a']} +b=${radii['c']} +no_defs" }; } else { console.log("No projection found for the target and name given."); } } console.log("No projection found for the target"); } }