Loading app/src/components/presentational/ConsoleProjectionButtons.jsx +1 −1 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ export default function ConsoleProjectionButtons() { <StyledTooltip title={ <Typography variant="subtitle1"> Switch to a cylindrical polar projection for the target body. Switch to a cylindrical projection for the target body. </Typography> } enterDelay={800} Loading app/src/js/AstroMap.js +21 −10 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; // import "leaflet-fullscreen"; import L from "leaflet"; import "proj4"; import "proj4leaflet"; import { MY_JSON_MAPS } from "./layers"; /** Loading Loading @@ -38,15 +40,20 @@ export default L.Map.AstroMap = L.Map.extend({ this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); this._radii = { a: "", c: "" }; // Set by layer collection or baselayerchange event this._currentLayer = null; // Store layers at map creation so we only need to create layers once. let cylLayerInfo = this.parseJSON("cylindrical"); if (Object.entries(cylLayerInfo).length == 0) { throw "No entry in the JSON for {this._target}. Cannot instantiate a map."; if (Object.entries(cylLayerInfo["base"]).length == 0) { throw "No entry in the JSON for [" + this._target + "]. Cannot instantiate a map."; } // Could not work with _ Loading @@ -55,7 +62,7 @@ export default L.Map.AstroMap = L.Map.extend({ }; let northLayerInfo = this.parseJSON("north-polar stereographic"); if (Object.entries(northLayerInfo).length == 0) { if (Object.entries(northLayerInfo["base"]).length == 0) { this._hasNorthPolar = false; } else { this._hasNorthPolar = true; Loading @@ -66,11 +73,11 @@ export default L.Map.AstroMap = L.Map.extend({ } let southLayerInfo = this.parseJSON("south-polar stereographic"); if (Object.entries(southLayerInfo).length == 0) { if (Object.entries(southLayerInfo["base"]).length == 0) { this._hasSouthPolar = false; } else { this._hasSouthPolar = true; this.layers["northPolar"] = new LayerCollection( this.layers["southPolar"] = new LayerCollection( "south-polar stereographic", southLayerInfo ); Loading Loading @@ -105,6 +112,7 @@ export default L.Map.AstroMap = L.Map.extend({ * @function AstroMap.prototype.parseJSON * @description Parses the USGS JSON, creates layer objects for a particular target and projection, * and stores them in a JS object. * @param {String} [projection - Name of the projection to grab the layer information for. * @return {Object} - Dictionary containing the layer information in the format: {base: [], overlays: []} */ parseJSON: function(projection) { Loading @@ -119,6 +127,8 @@ export default L.Map.AstroMap = L.Map.extend({ let currentTarget = targets[i]; if (currentTarget["name"].toLowerCase() == this._target.toLowerCase()) { this._radii["a"] = parseFloat(currentTarget["aaxisradius"] * 1000); this._radii["c"] = parseFloat(currentTarget["caxisradius"] * 1000); let jsonLayers = currentTarget["webmap"]; for (let j = 0; j < jsonLayers.length; j++) { let currentLayer = jsonLayers[j]; Loading @@ -131,9 +141,6 @@ export default L.Map.AstroMap = L.Map.extend({ // Base layer check if (currentLayer["transparent"] == "false") { layers["base"].push(currentLayer); if (currentLayer["primary"] == "true") { this._defaultLayerIndex = layers["base"].length - 1; } } else { // Do not add "Show Feature Names" PNG layer. if (currentLayer["displayname"] != "Show Feature Names") { Loading Loading @@ -173,7 +180,11 @@ export default L.Map.AstroMap = L.Map.extend({ this._currentProj = "EPSG:4326"; this.setMaxZoom(8); } else { let proj = this._astroProj.getStringAndCode(this._target, name); let proj = this._astroProj.getStringAndCode( this._target, name, this._radii ); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128] }); Loading app/src/js/AstroProj.js +6 −27 Original line number Diff line number Diff line Loading @@ -6,29 +6,6 @@ import { MY_JSON_MAPS } from "./layers"; * by the USGS. */ export default class AstroProj { /** * @function AstroProj.prototype.getRadii * @description 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; } } return radii; } /** * @function AstroProj.prototype.getStringAndCode * @description Returns the proj-string for a requested target and projection name. Loading @@ -40,9 +17,7 @@ export default class AstroProj { * @return {Object} Object storing the proj-string and code * in the form: {'code': , 'string'}. */ getStringAndCode(target, name) { let radii = this.getRadii(target); getStringAndCode(target, name, radii) { if (name == "northPolar") { return { code: "EPSG:32661", Loading Loading @@ -70,7 +45,11 @@ export default class AstroProj { "+proj=longlat +a=" + radii["a"] + " +b=" + radii["c"] + " +no_defs" }; } else { console.log("No projection found for the target and name given."); throw "No projection found for the target [" + target + "] and the projection [" + name + "] given."; } } } app/src/js/LayerCollection.js +4 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ export default L.LayerCollection = L.Class.extend({ createBaseLayers: function(layers) { for (let i = 0; i < layers.length; i++) { let layer = layers[i]; if (layer["primary"] == "true") { this._defaultLayerIndex = layers.length - 1; } let baseLayer = L.tileLayer.wms( String(layer["url"]) + "?map=" + String(layer["map"]), { Loading Loading @@ -159,7 +162,7 @@ export default L.LayerCollection = L.Class.extend({ }; let parameters = L.Util.extend(defaultParameters); console.log(geoJsonUrl + L.Util.getParamString(parameters)); // console.log(geoJsonUrl + L.Util.getParamString(parameters)); let thisContext = this; $.ajax({ Loading app/src/js/Projection.js +2 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import "leaflet"; * @classdesc Control that allows users to change the projection of the map. Uses predefined GUI elements. */ export default L.Control.Projection = L.Control.extend({ /** * @function Projection.prototype.onAdd * @description Grabs the button GUI elements and adds onclick events to them. Loading Loading @@ -35,7 +34,6 @@ export default L.Control.Projection = L.Control.extend({ return container; }, /** * @function Projection.prototype.loadNorthPolar * @description Sets the map's projection to north-polar stereographic. Loading Loading
app/src/components/presentational/ConsoleProjectionButtons.jsx +1 −1 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ export default function ConsoleProjectionButtons() { <StyledTooltip title={ <Typography variant="subtitle1"> Switch to a cylindrical polar projection for the target body. Switch to a cylindrical projection for the target body. </Typography> } enterDelay={800} Loading
app/src/js/AstroMap.js +21 −10 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; // import "leaflet-fullscreen"; import L from "leaflet"; import "proj4"; import "proj4leaflet"; import { MY_JSON_MAPS } from "./layers"; /** Loading Loading @@ -38,15 +40,20 @@ export default L.Map.AstroMap = L.Map.extend({ this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); this._radii = { a: "", c: "" }; // Set by layer collection or baselayerchange event this._currentLayer = null; // Store layers at map creation so we only need to create layers once. let cylLayerInfo = this.parseJSON("cylindrical"); if (Object.entries(cylLayerInfo).length == 0) { throw "No entry in the JSON for {this._target}. Cannot instantiate a map."; if (Object.entries(cylLayerInfo["base"]).length == 0) { throw "No entry in the JSON for [" + this._target + "]. Cannot instantiate a map."; } // Could not work with _ Loading @@ -55,7 +62,7 @@ export default L.Map.AstroMap = L.Map.extend({ }; let northLayerInfo = this.parseJSON("north-polar stereographic"); if (Object.entries(northLayerInfo).length == 0) { if (Object.entries(northLayerInfo["base"]).length == 0) { this._hasNorthPolar = false; } else { this._hasNorthPolar = true; Loading @@ -66,11 +73,11 @@ export default L.Map.AstroMap = L.Map.extend({ } let southLayerInfo = this.parseJSON("south-polar stereographic"); if (Object.entries(southLayerInfo).length == 0) { if (Object.entries(southLayerInfo["base"]).length == 0) { this._hasSouthPolar = false; } else { this._hasSouthPolar = true; this.layers["northPolar"] = new LayerCollection( this.layers["southPolar"] = new LayerCollection( "south-polar stereographic", southLayerInfo ); Loading Loading @@ -105,6 +112,7 @@ export default L.Map.AstroMap = L.Map.extend({ * @function AstroMap.prototype.parseJSON * @description Parses the USGS JSON, creates layer objects for a particular target and projection, * and stores them in a JS object. * @param {String} [projection - Name of the projection to grab the layer information for. * @return {Object} - Dictionary containing the layer information in the format: {base: [], overlays: []} */ parseJSON: function(projection) { Loading @@ -119,6 +127,8 @@ export default L.Map.AstroMap = L.Map.extend({ let currentTarget = targets[i]; if (currentTarget["name"].toLowerCase() == this._target.toLowerCase()) { this._radii["a"] = parseFloat(currentTarget["aaxisradius"] * 1000); this._radii["c"] = parseFloat(currentTarget["caxisradius"] * 1000); let jsonLayers = currentTarget["webmap"]; for (let j = 0; j < jsonLayers.length; j++) { let currentLayer = jsonLayers[j]; Loading @@ -131,9 +141,6 @@ export default L.Map.AstroMap = L.Map.extend({ // Base layer check if (currentLayer["transparent"] == "false") { layers["base"].push(currentLayer); if (currentLayer["primary"] == "true") { this._defaultLayerIndex = layers["base"].length - 1; } } else { // Do not add "Show Feature Names" PNG layer. if (currentLayer["displayname"] != "Show Feature Names") { Loading Loading @@ -173,7 +180,11 @@ export default L.Map.AstroMap = L.Map.extend({ this._currentProj = "EPSG:4326"; this.setMaxZoom(8); } else { let proj = this._astroProj.getStringAndCode(this._target, name); let proj = this._astroProj.getStringAndCode( this._target, name, this._radii ); newCRS = new L.Proj.CRS(proj["code"], proj["string"], { resolutions: [8192, 4096, 2048, 1024, 512, 256, 128] }); Loading
app/src/js/AstroProj.js +6 −27 Original line number Diff line number Diff line Loading @@ -6,29 +6,6 @@ import { MY_JSON_MAPS } from "./layers"; * by the USGS. */ export default class AstroProj { /** * @function AstroProj.prototype.getRadii * @description 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; } } return radii; } /** * @function AstroProj.prototype.getStringAndCode * @description Returns the proj-string for a requested target and projection name. Loading @@ -40,9 +17,7 @@ export default class AstroProj { * @return {Object} Object storing the proj-string and code * in the form: {'code': , 'string'}. */ getStringAndCode(target, name) { let radii = this.getRadii(target); getStringAndCode(target, name, radii) { if (name == "northPolar") { return { code: "EPSG:32661", Loading Loading @@ -70,7 +45,11 @@ export default class AstroProj { "+proj=longlat +a=" + radii["a"] + " +b=" + radii["c"] + " +no_defs" }; } else { console.log("No projection found for the target and name given."); throw "No projection found for the target [" + target + "] and the projection [" + name + "] given."; } } }
app/src/js/LayerCollection.js +4 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ export default L.LayerCollection = L.Class.extend({ createBaseLayers: function(layers) { for (let i = 0; i < layers.length; i++) { let layer = layers[i]; if (layer["primary"] == "true") { this._defaultLayerIndex = layers.length - 1; } let baseLayer = L.tileLayer.wms( String(layer["url"]) + "?map=" + String(layer["map"]), { Loading Loading @@ -159,7 +162,7 @@ export default L.LayerCollection = L.Class.extend({ }; let parameters = L.Util.extend(defaultParameters); console.log(geoJsonUrl + L.Util.getParamString(parameters)); // console.log(geoJsonUrl + L.Util.getParamString(parameters)); let thisContext = this; $.ajax({ Loading
app/src/js/Projection.js +2 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ import "leaflet"; * @classdesc Control that allows users to change the projection of the map. Uses predefined GUI elements. */ export default L.Control.Projection = L.Control.extend({ /** * @function Projection.prototype.onAdd * @description Grabs the button GUI elements and adds onclick events to them. Loading Loading @@ -35,7 +34,6 @@ export default L.Control.Projection = L.Control.extend({ return container; }, /** * @function Projection.prototype.loadNorthPolar * @description Sets the map's projection to north-polar stereographic. Loading