Loading .gitignore +5 −3 Original line number Diff line number Diff line .cache/ coverage/ dist/ dist/* /node_modules node_modules package-lock.json *.log ./app/package-lock.json .dist/ app/package-lock.json 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", "proj4": "^2.6.0", "proj4leaflet": "^1.0.2", Loading app/src/components/App.jsx +2 −2 Original line number Diff line number Diff line Loading @@ -18,16 +18,16 @@ export default class App extends Component { componentDidMount() { let map = new AstroMap("map-container", "mars", {}); let projectionControl = new Projection(); projectionControl.addTo(map); let mouseControl = new MousePosition({ numDigits: 2, targetPlanet: "mars" }); mouseControl.addTo(map); projectionControl.addTo(map); let scaleControl = new L.Control.Scale({ imperial: false }); scaleControl.addTo(map); mouseControl.addTo(map); } render() { Loading app/src/js/AstroMap.js +61 −13 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; /* * @class AstroMap * @aka L.Map.AstroMap Loading Loading @@ -30,25 +31,45 @@ export default L.Map.AstroMap = L.Map.extend({ * 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.radii = this.astroProj.getRadii(this.target); this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); // Could not work with _ this.layers = { cylindrical: 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") }; this.defaultProj = L.extend({}, L.CRS.EPSG4326, { R: this.radii["a"] }); this.options["crs"] = this.defaultProj; 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); L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); }, Loading @@ -65,14 +86,15 @@ export default L.Map.AstroMap = L.Map.extend({ * @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 == "cylindrical") { newCRS = this.defaultProj; 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] Loading @@ -82,5 +104,31 @@ export default L.Map.AstroMap = L.Map.extend({ this.options.crs = newCRS; 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; } }); app/src/js/AstroProj.js +5 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ export default class AstroProj { * @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'}. * * @return {Object} Radii Object in form: {'a': , 'c': }. */ getRadii(target) { var targets = MY_JSON_MAPS["targets"]; Loading @@ -28,13 +29,13 @@ export default class AstroProj { 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'}. */ Loading Loading
.gitignore +5 −3 Original line number Diff line number Diff line .cache/ coverage/ dist/ dist/* /node_modules node_modules package-lock.json *.log ./app/package-lock.json .dist/ app/package-lock.json 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", "proj4": "^2.6.0", "proj4leaflet": "^1.0.2", Loading
app/src/components/App.jsx +2 −2 Original line number Diff line number Diff line Loading @@ -18,16 +18,16 @@ export default class App extends Component { componentDidMount() { let map = new AstroMap("map-container", "mars", {}); let projectionControl = new Projection(); projectionControl.addTo(map); let mouseControl = new MousePosition({ numDigits: 2, targetPlanet: "mars" }); mouseControl.addTo(map); projectionControl.addTo(map); let scaleControl = new L.Control.Scale({ imperial: false }); scaleControl.addTo(map); mouseControl.addTo(map); } render() { Loading
app/src/js/AstroMap.js +61 −13 Original line number Diff line number Diff line import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; /* * @class AstroMap * @aka L.Map.AstroMap Loading Loading @@ -30,25 +31,45 @@ export default L.Map.AstroMap = L.Map.extend({ * 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.radii = this.astroProj.getRadii(this.target); this._mapDiv = mapDiv; this._target = target; this._astroProj = new AstroProj(); this._radii = this._astroProj.getRadii(this._target); // Could not work with _ this.layers = { cylindrical: 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") }; this.defaultProj = L.extend({}, L.CRS.EPSG4326, { R: this.radii["a"] }); this.options["crs"] = this.defaultProj; 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); L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); }, Loading @@ -65,14 +86,15 @@ export default L.Map.AstroMap = L.Map.extend({ * @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 == "cylindrical") { newCRS = this.defaultProj; 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] Loading @@ -82,5 +104,31 @@ export default L.Map.AstroMap = L.Map.extend({ this.options.crs = newCRS; 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; } });
app/src/js/AstroProj.js +5 −4 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ export default class AstroProj { * @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'}. * * @return {Object} Radii Object in form: {'a': , 'c': }. */ getRadii(target) { var targets = MY_JSON_MAPS["targets"]; Loading @@ -28,13 +29,13 @@ export default class AstroProj { 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'}. */ Loading