Commit f76fe5f1 authored by Jacob Kaufman's avatar Jacob Kaufman
Browse files

fixed using ESlint

parent 8856a7fc
Loading
Loading
Loading
Loading
+33 −44
Original line number Diff line number Diff line
class AstroMath
{
  constructor( targetName )
  {
    this.targetName = targetName
class AstroMath {
  constructor(targetName) {
    this.targetName = targetName;

    switch (this.targetName) {
      case "mars":
@@ -22,62 +20,53 @@ class AstroMath
    }
  }

  toRadians(degrees)
  {
    return degrees * Math.PI / 180;
  toRadians(degrees) {
    return (degrees * Math.PI) / 180;
  }

  toDegrees(radians)
  {
    return radians * 180 / Math.PI;
  toDegrees(radians) {
    return (radians * 180) / Math.PI;
  }

  latLonSwitcher(lat, lng, lonTo180, planetocentric, postiveEast, projection)
  {
    var convertedLatitude = 0;
  latLonSwitcher(lat, lng, lonTo180, planetocentric, postiveEast, projection) {
    let convertedLatitude = 0;
    let convertedLng = lng;
    let convertedLat = lat;
    let proj = "";

    if (projection == "EPSG:4326")
    {
    if (projection === "EPSG:4326") {
      proj = "cylindrical";
    }
    else 
    {
    } else {
      proj = "";
    }

    if (!lonTo180)
    {
      if(proj == "cylindrical") {
        lng -= 180;
    if (!lonTo180) {
      if (proj === "cylindrical") {
        convertedLng -= 180;
      }
      if(lng < 0) {
        lng += 360;
      if (convertedLng < 0) {
        convertedLng += 360;
      }
    }

    if(!postiveEast)
    {
      if(lonTo180)
      {
        lng *= -1;
      }
      else
      {
        lng = Math.abs(lng - 360);
    if (!postiveEast) {
      if (lonTo180) {
        convertedLng *= -1;
      } else {
        convertedLng = Math.abs(convertedLng - 360);
      }
    }

    if(!planetocentric)
    {
      convertedLatitude = this.toRadians(lat);
      convertedLatitude = Math.atan(((this.dMajorRadius / this.dMinorRadius)**2) * 
                                          (Math.tan(convertedLatitude)));
    if (!planetocentric) {
      convertedLatitude = this.toRadians(convertedLat);
      convertedLatitude = Math.atan(
        (this.dMajorRadius / this.dMinorRadius) ** 2 *
          Math.tan(convertedLatitude)
      );
      convertedLatitude = this.toDegrees(convertedLatitude);

      lat = convertedLatitude;
      convertedLat = convertedLatitude;
    }
    return [lat,lng]
    return [convertedLat, convertedLng];
  }
}

+55 −57
Original line number Diff line number Diff line
L.Control.AstroMousePosition = L.Control.extend({
  options: {
    separator: ' : ',
    separator: " : ",
    numDigits: 5,
    prefix: "",
    targetPlanet: ""
  },

  onAdd: function (map) {
    this._container = L.DomUtil.create('div', 'leaflet-control-mouseposition');
    L.DomEvent.disableClickPropagation(this._container);
    map.on('mousemove', this._onMouseMove, this);
  onAdd(map) {
    this.container = L.DomUtil.create("div", "leaflet-control-mouseposition");
    L.DomEvent.disableClickPropagation(this.container);
    map.on("mousemove", this.onMouseMove, this);

    this.map = map;

@@ -27,72 +27,70 @@ L.Control.AstroMousePosition = L.Control.extend({
    this.latitudeType = L.DomUtil.get("consoleLatTypeSelect");
    L.DomEvent.on(this.latitudeType, "change", this.changeLatType, this);

    return this._container;
    return this.container;
  },

  changeLonDomain: function(e) {
    var lonDomain = this.lonDomain.value
    if( lonDomain == "180")
    {
  changeLonDomain(e) {
    const lonDomain = this.lonDomain.value;
    if (lonDomain === "180") {
      this.lonTo180 = true;
    }
    else if (lonDomain == "360")
    {
    } else if (lonDomain === "360") {
      this.lonTo180 = false;
    }
  },

  changeLatType: function(e) {
    var latitudeType = this.latitudeType.value;
    if( latitudeType == "Planetographic")
    {
  changeLatType(e) {
    const latitudeType = this.latitudeType.value;
    if (latitudeType === "Planetographic") {
      this.planetocentric = false;
    }
    else if (latitudeType == "Planetocentric")
    {
    } else if (latitudeType === "Planetocentric") {
      this.planetocentric = true;
    }
  },

  changeLonDirection: function(e) {
    var lonDirection =  this.lonDirection.value;
    if (lonDirection == "PositiveWest")
    {
  changeLonDirection(e) {
    const lonDirection = this.lonDirection.value;
    if (lonDirection === "PositiveWest") {
      this.postiveEast = false;
    }
    else if (lonDirection == "PositiveEast")
    {
    } else if (lonDirection === "PositiveEast") {
      this.postiveEast = true;
    }
  },

  onRemove: function (map) {
    map.off('mousemove', this._onMouseMove)
  onRemove(map) {
    map.off("mousemove", this.onMouseMove);
  },

  _onMouseMove: function (e) {

    var lng = e.latlng.lng;
    var lat = e.latlng.lat;
  onMouseMove(e) {
    let {lng} = e.latlng;
    let {lat} = e.latlng;
    
    lat = L.Util.wrapNum(lat, [-180.0, 180.0]);
    lng = L.Util.wrapNum(lng, [-180.0, 180.0]);

    cords = this.astroMath.latLonSwitcher(lat, lng, this.lonTo180, this.planetocentric, 
                            this.postiveEast, this.map.options.crs.code);
    
    cords = this.astroMath.latLonSwitcher(
      lat,
      lng,
      this.lonTo180,
      this.planetocentric,
      this.postiveEast,
      this.map.options.crs.code
    );

    lat = cords[0];
    lng = cords[1];

    var lng = L.Util.formatNum(lng, this.options.numDigits);
    var lat = L.Util.formatNum(lat, this.options.numDigits);
    lng = L.Util.formatNum(lng, this.options.numDigits);
    lat = L.Util.formatNum(lat, this.options.numDigits);

    var value = this.options.lngFirst ? lng + this.options.separator + lat : lat + this.options.separator + lng;
    const value = this.options.lngFirst
      ? lng + this.options.separator + lat
      : lat + this.options.separator + lng;

    var prefixAndValue = this.options.prefix + ' ' + value;
    const prefixAndValue = `${this.options.prefix} ${value}`;
    this.htmlDiv.innerHTML = prefixAndValue;
  }

});

L.Map.mergeOptions({