Commit f5811ff6 authored by Kaitlyn's avatar Kaitlyn
Browse files

Added polar projections check.

parent e22683b0
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -44,6 +44,19 @@ export default L.Map.AstroMap = L.Map.extend({
      southPolar: new LayerCollection(this.target, "south-polar stereographic")
    };

    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;

@@ -82,5 +95,13 @@ export default L.Map.AstroMap = L.Map.extend({
    this.options.crs = newCRS;
    this.setView(center, 1, true);
    this.loadLayerCollection(name);
  }
  },

  hasNorthPolar: function() {
    return this._hasNorthPolar;
  },

  hasSouthPolar: function() {
    return this._hasSouthPolar;
  },
});
+17 −9
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ export default L.LayerCollection = L.Class.extend({
    this.projName = projName;
    this.baseLayers = {};
    this.overlays = {};
    this.defaultLayerIndex = 0;
    this.defaultLayerIndex = null;
    L.LayerCollection.layerControl = null;

    let layers = this.parseJSON();
@@ -31,7 +31,7 @@ export default L.LayerCollection = L.Class.extend({
   * Parses the USGS JSON, creates layer objects for a particular
   * target and projection, and stores them in a JS object.
   * @return {Object} - Dictionary containing the layer information in
   *                    the format: {base: , overlays}
   *                    the format: {base: [], overlays: []}
   */
  parseJSON: function() {
    let layers = {
@@ -128,13 +128,21 @@ export default L.LayerCollection = L.Class.extend({
      L.LayerCollection.layerControl.remove();
    }

    if(this.defaultLayerIndex != null) {
      let defaultLayer = Object.keys(this.baseLayers)[this.defaultLayerIndex];
      this.baseLayers[defaultLayer].addTo(map);
    }

    if(!this.isEmpty()) {
      L.LayerCollection.layerControl = L.control.layers(
        this.baseLayers,
        this.overlays
      );
      L.LayerCollection.layerControl.addTo(map);
    }
  },

  isEmpty: function() {
    return (Object.entries(this.baseLayers).length == 0);
  }
});
+12 −4
Original line number Diff line number Diff line
@@ -18,13 +18,21 @@ export default L.Control.Projection = L.Control.extend({
    let container = L.DomUtil.create("div");

    this.northPolar = L.DomUtil.get("projectionNorthPole");
    L.DomEvent.on(this.northPolar, "click", this.loadNorthPolar, this);
    if(!map.hasNorthPolar()) {
      this.northPolar.disabled = true;
      L.DomUtil.addClass(this.northPolar, "disabled");
    L.DomEvent.on(this.northPolar, "click", this.loadNorthPolar, this);
    this.cylindrical = L.DomUtil.get("projectionCylindrical");
    L.DomEvent.on(this.cylindrical, "click", this.loadCylindrical, this);
    }

    this.southPolar = L.DomUtil.get("projectionSouthPole");
    L.DomEvent.on(this.southPolar, "click", this.loadSouthPolar, this);
    if(!map.hasSouthPolar()) {
      this.southPolar.disabled = true;
      L.DomUtil.addClass(this.southPolar, "disabled");
    }
  
    this.cylindrical = L.DomUtil.get("projectionCylindrical");
    L.DomEvent.on(this.cylindrical, "click", this.loadCylindrical, this);

    return container;
  },