Commit 5ed7bda4 authored by Kaitlyn's avatar Kaitlyn
Browse files

Updated some documetation.

parent 5e3834f6
Loading
Loading
Loading
Loading

app/.jsdoc.json

0 → 100644
+27 −0
Original line number Diff line number Diff line
{
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": ["jsdoc"]
  },
  "source": {
    "include": ["package.json", "README.md"],
    "includePattern": "./src/js/",
    "excludePattern": "(node_modules/|docs)"
  },
  "plugins": ["plugins/markdown"],
  "templates": {
    "referenceTitle": "CartoCosmos",
    "disableSort": false,
    "collapse": false,
    "resources": {
      "GitHub": "https://github.com/CartoCosmos/CartoCosmos"
    }
  },
  "opts": {
    "destination": "./docs/",
    "encoding": "utf8",
    "private": true,
    "recurse": true,
    "template": "node_modules/braintree-jsdoc-template/"
  }
}
+10 −13
Original line number Diff line number Diff line
@@ -7,12 +7,12 @@ import { func } from "prop-types";
 * @class AstroDraw
 * @aka L.Control.AstroDraw
 * @extends L.Control
 * Class that extends from the class L.Control.Draw and handles the back-end when a user draws on the leaflet map.
 * Since this class inherits L.Control, it is added to the AstroMap in the same way as other controls, like the zoom control.
 * @classdesc Class that extends from the class L.Control.Draw and handles the back-end
 *            when a user draws on the leaflet map. Since this class inherits L.Control, it is
 *            added to the AstroMap in the same way as other controls, like the zoom control.
 *
 * * @example
 * @example
 *
 * ```js
 * // add a feature group to the map
 * let drawnItems = new L.FeatureGroup();
 * map.addLayer(drawnItems);
@@ -24,7 +24,6 @@ import { func } from "prop-types";
 * },
 *    targetMap: map
 * }).addTo(map);
 * ```
 */
export default L.Control.AstroDraw = L.Control.Draw.extend({
  options: {
@@ -34,8 +33,8 @@ export default L.Control.AstroDraw = L.Control.Draw.extend({
  },

  /**
   * Adds the draw control to the map provided. Creates an on-draw and on-click event
   * that allows users to draw polygons onto the leaflet map.
   * @function AstroDraw.prototype.onAdd
   * @description Adds the draw control to the map provided. Creates an on-draw and on-click event that allows users to draw polygons onto the leaflet map.
   * @param  {AstroMap} map - The AstroMap to add the control to.
   * @return {Object} The div-container the control is in.
   */
@@ -78,9 +77,8 @@ export default L.Control.AstroDraw = L.Control.Draw.extend({
  },

  /**
   * Is called when a user draws a shape using the on map drawing features.
   * Converts the shaped drawn into a Well-Known text string and inserts it into the
   * Well-Known text box.
   * @function AstroDraw.prototype.shapesToWKT
   * @description Is called when a user draws a shape using the on map drawing features. Converts the shaped drawn into a Well-Known text string and inserts it into the Well-Known text box.
   * @param  {DomEvent} e  - On draw.
   */
  shapesToWKT: function(e) {
@@ -96,9 +94,8 @@ export default L.Control.AstroDraw = L.Control.Draw.extend({
  },

  /**
   * Is called when a user clicks the draw button below the AstroMap.
   * Will take the Well-Known text string and draw the shape onto the map.
   * If the Well-Known text string is invalid an error will show in the text box.
   * @function AstroDraw.prototype.mapWKTString
   * @description  Is called when a user clicks the draw button below the AstroMap. Will take the Well-Known text string and draw the shape onto the map. If the Well-Known text string is invalid an error will show in the text box.
   * @param  {DomEvent} e  - On Click of Well-Known text button.
   */
  mapWKTString: function(e) {
+5 −0
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@ var panelContent = {
  position: "bottom" //
};

/**
 * @class FullScreenMenu
 * @aka L.Control
 * Class that adds menu container from L.control.
 */
export let FullScreenMenu = L.control
  .sidebar({
    container: "fs-menu-container"
+32 −27
Original line number Diff line number Diff line
import { MY_JSON_MAPS } from "./layers";
import $ from "jquery";

/*
/**
 * @class LayerCollection
 * @aka L.Class.LayerCollection
 * @inherits L.Class
 *
 * @classdesc
 * Holds the base layers and overlays of a particular projection
 * for quick and easy use in the AstroMap class.
 */
export default L.LayerCollection = L.Class.extend({
  /**
   * @details Constructor that creates the layers.
   *
   * @function LayerCollection.prototype.initialize
   * @description Constructor that creates the layers.
   * @param {String} target Name of the target.
   *
   * @param {String} projName Name of the projection.
   */
  initialize: function(target, projName) {
@@ -32,11 +32,9 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details 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: []}
   * @function LayerCollection.prototype.parseJSON
   * @description 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: []}
   */
  parseJSON: function() {
    let layers = {
@@ -81,8 +79,8 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details Creates WMS layers and adds them to the list of base layers.
   *
   * @function LayerCollection.prototype.createBaseLayers
   * @description Creates WMS layers and adds them to the list of base layers.
   * @param  {List} layers - List of base layer information.
   */
  createBaseLayers: function(layers) {
@@ -102,8 +100,8 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details Creates WMS layers and adds them to the list of overlays.
   *
   * @function LayerCollection.prototype.createOverlays
   * @description Creates WMS layers and adds them to the list of overlays.
   * @param  {List} layers - List of overlay information.
   */
  createOverlays: function(layers) {
@@ -124,11 +122,23 @@ export default L.LayerCollection = L.Class.extend({
    // Only add feature names to cylindrical
    if (this._projName == "cylindrical") {
      this._wfsLayer = new L.GeoJSON(null, {
        /**
         * @function LayerCollection.prototype.onEachFeature
         * @description Select each feature.
         * @param  {String} layer - Overlay information.
         * @param  {JSON} feature - Feature from json.
         */
        onEachFeature: function(feature, layer) {
          if (feature.properties && feature.properties.name) {
            layer.bindPopup(feature.properties.name);
          }
        },
        /**
         * @function LayerCollection.prototype.pointToLayer
         * @description Get point to layer.
         * @param  {Constructor} latlng - Latitude and longitude.
         * @param  {JSON} feature - Feature from json.
         */
        pointToLayer: function(feature, latlng) {
          return new L.CircleMarker(latlng, { radius: 3, fillOpacity: 1 });
        }
@@ -138,9 +148,8 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details Removes the current layers, adds the base layers and overlays to the map,
   *          and sets the default layer.
   *
   * @function LayerCollection.prototype.addTo
   * @description Removes the current layers, adds the base layers and overlays to the map, and sets the default layer.
   * @param {AstroMap} map - Map to add layers to.
   */
  addTo: function(map) {
@@ -170,18 +179,17 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details Checks to see if there are any base layers.
   * @return {Boolean} Returns true if there are no base layers,
   *                   false otherwise.
   * @function LayerCollection.prototype.isEmpty
   * @description Checks to see if there are any base layers.
   * @return {Boolean} Returns true if there are no base layers, false otherwise.
   */
  isEmpty: function() {
    return Object.entries(this._baseLayers).length == 0;
  },

  /**
   * @details Creates the GeoServer query, queries GeoServer for
   *          the feature names, and adds the data to the GeoJSON layer.
   *
   * @function LayerCollection.prototype.loadWFS
   * @description  Creates the GeoServer query, queries GeoServer for the feature names, and adds the data to the GeoJSON layer.
   * @param  {AstroMap} map - The AstroMap to add the GeoJSON layer to.
   */
  loadWFS: function(map) {
@@ -216,12 +224,9 @@ export default L.LayerCollection = L.Class.extend({
  },

  /**
   * @details Sorts the features by diameter so that smaller features are on
   *          top of the larger features on the map. Features with smaller
   *          diameters will be put at the end of the list.
   *
   * @function LayerCollection.prototype.loadWFS
   * @description  Sorts the features by diameter so that smaller features are on top of the larger features on the map. Features with smaller diameters will be put at the end of the list.
   * @param  {List} data - List of features.
   *
   * @return {Integer} Returns -1 if f1 < f2, 1 if f2 > f1, and 0 if f1==f2.
   */
  sortFeatures: function(data) {
+40 −21
Original line number Diff line number Diff line
import AstroMath from "./AstroMath";
import "leaflet";
/**
 * @class AstroMap
 * @class MousePosition
 * @aka L.Control.AstroMousePosition
 * @extends L.Control
 * Class that inherits from the class L.Control and handles the back-end when a user clicks on the lat/lon buttons.
 * Since this class inherits L.Control, it is added to the AstroMap in the same way as other controls, like the zoom control.
 *
 * * @example
 * @classdesc Class that inherits from the class L.Control and handles the back-end when a user clicks on the lat/lon buttons.
 * Since this class inherits L.Control, it is added to the AstroMap in the same way as other controls, like the zoom control.
 *
 * ```js
 * @example
 * // initialize the control with an options object.
 * mouseControl = L.astroMousePosition({numDigits: 2, prefix: "Lat Lon: ",targetPlanet: "mars"});
 * // add control to map
 * mouseControl.addTo(map);
 * ```
 */
export default L.Control.MousePosition = L.Control.extend({
  options: {
@@ -25,9 +23,8 @@ export default L.Control.MousePosition = L.Control.extend({
  },

  /**
   * Grabs the lat/lon buttons from the GUI and adds on-change events to them.
   * It also adds an on mouse-over event to the AstroMap to grab the current
   * mouse position of the user's mouse pointer.
   * @function MousePosition.prototype.onAdd
   * @description Grabs the lat/lon buttons from the GUI and adds on-change events to them. It also adds an on mouse-over event to the AstroMap to grab the current mouse position of the user's mouse pointer.
   * @param  {AstroMap} map - The AstroMap to add the control to.
   * @return {Object} The div-container the control is in.
   */
@@ -76,33 +73,35 @@ export default L.Control.MousePosition = L.Control.extend({
  },

  /**
   * Is called when a user changes the longitude domain selector.
   * Changes the longitude domain class variable to false if 0 to
   * 360 is selected and true if -180 to 180 is selected.
   * @function MousePosition.prototype.changeLonDomain
   * @description Is called when a user changes the longitude domain selector. Changes the longitude domain class variable to false if 0 to 360 is selected and true if -180 to 180 is selected.
   * @param  {DomEvent} e  - On change of consoleLonDomSelect.
   */
  changeLonDomain(e) {
    this.isLonDom180 = !this.isLonDom180;
  },

  /**
   * Is called when a user changes the latitude type selector.
   * Changes the latitude type class variable to false if planetographic is
   * selected and true if isLatTypeOcentric is selected.
   * @function MousePosition.prototype.changeLatType
   * @description Is called when a user changes the latitude type selector. Changes the latitude type class variable to false if planetographic is selected and true if isLatTypeOcentric is selected.
   * @param  {DomEvent} e - On change of consoleLatTypeSelect.
   */
  changeLatType(e) {
    this.isLatTypeOcentric = !this.isLatTypeOcentric;
  },

  /**
   * Is called when a user changes the longitude direction selector.
   * Changes the longitude direction class variable to false if positive west
   * is selected and true if positive east is selected.
   * @function MousePosition.prototype.changeLonDirection
   * @description Is called when a user changes the longitude direction selector. Changes the longitude direction class variable to false if positive west is selected and true if positive east is selected.
   * @param  {DomEvent} e - On change of consoleLonDirSelect.
   */
  changeLonDirection(e) {
    this.isLonDirEast = !this.isLonDirEast;
  },

  /**
   * @function MousePosition.prototype.onRemove
   * @description Is called when a user unselects a map.
   * @param  {AstroMap} map - The AstroMap to remove the control from.
   */
  onRemove(map) {
@@ -110,9 +109,8 @@ export default L.Control.MousePosition = L.Control.extend({
  },

  /**
   *  Is called when a user moves their mouse over the AstroMap.
   *  The function uses the class latitude and longitude class variables combined with the AstroMath class
   *  to calculate the correct coordinate mouse position of the users mouse pointer.
   * @function MousePosition.prototype.onMouseMove
   * @description Is called when a user moves their mouse over the AstroMap. The function uses the class latitude and longitude class variables combined with the AstroMath class to calculate the correct coordinate mouse position of the users mouse pointer.
   * @param  {DomEvent} e - On mouse move over the AstroMap.
   */
  onMouseMove(e) {
@@ -144,6 +142,11 @@ export default L.Control.MousePosition = L.Control.extend({
    const prefixAndValue = `${this.options.prefix}${value}`;
    this.coordDisplayElement.innerHTML = prefixAndValue;
  },
  /**
   * @function MousePosition.prototype.onMouseOut
   * @description Displays lat lon on mouse.
   * @param  {DomEvent} e - On mouse out.
   */
  onMouseOut(e) {
    if (this.options.lngFirst) {
      this.coordDisplayElement.innerHTML = "lon, lat";
@@ -153,10 +156,20 @@ export default L.Control.MousePosition = L.Control.extend({
  }
});

/**
 * @function MousePosition.prototype.mergeOptions
 * @aka L.Map.mergeOptions
 * @description Turns position control false.
 */
L.Map.mergeOptions({
  positionControl: false
});

/**
 * @function MousePosition.prototype.addInitHook
 * @aka L.Map.addInitHook
 * @description Adds position control.
 */
L.Map.addInitHook(function() {
  if (this.options.positionControl) {
    this.positionControl = new L.Control.MousePosition();
@@ -164,6 +177,12 @@ L.Map.addInitHook(function() {
  }
});

/**
 * @function MousePosition.prototype.mousePosition
 * @aka L.mousePosition
 * @description Gets mouse position.
 * @return {Object} Mouse position.
 */
L.mousePosition = function(options) {
  return new L.Control.MousePosition(options);
};
Loading