A class which is used to instantiate all components.
The create_components takes in a component_type, which is an attribute that you attach to a div to convert it into a component. The second parameter, options, is an object that includes the methods for your component. This method will search the dom for elements whose "component_type" attribute matches your first parameter and then bootstrap them with the options passed in.
(component_type)
(Object)
nothing
:
let create_components("button-home", {
includes: ["tooltips"],
afterContentInit: function() {
this.detect_changes();
this.extent_info = { coors: [-18022016.814888928, -7729953.450859962, 18335102.81488892, 10272495.450859962], sr: 3857 };
},
});
This function, create_component, is argueabley the most important function in GADAS. It takes in the name of a component, a component_type, and options object. This method is that one that calls the Angular methods that initialize a component. More specifically, Angular locates the element with a tag name that matches that 'name_of_component' parameter and then initializes it with the options passed in.
Note: There can only be one component with the same name (i.e. tag name), but there can be multiple components with the same component_type;
Promise
:
let promise = create_component("gadas_button_for_basemaps_on_default_map", "button", options);
Methods for components that need to draw on the map.
A base component class all other components extend.
A tie-in to an Angular functionality, whereby the view is marked within the JS as changed Prevents Angular from having to watch all data tied to the view simultaneously and waste computational power
this.change_things_that_affect_the_view();
this.detect_changes();
A tool for saving the state of the application to recreate later for personal use or send to others.
Saves the current setup of the entire application as a complex URL string, which is then saved in an HTML element, for the user to copy and either paste in a new window, bookmark, or send
components.bookmarker.bookmark();
For instances when the internal JS logic needs the result of the bookmark function without bothering the user
components.bookmarker.bookmark(); components.bookmarker.get_bookmark_without_alert();
For when the app is loaded from a bookmark (on initialization)
components.bookmarker.load();
Loads the layers and components of the application according to parsed URL string
Parses the bookmarked URL hash
A function that handles the down arrow click event for the legend, invoking the move_layer_set_down function within the layer_manager, updating the legend itself, and displaying any errors.
A function that handles the up arrow click event for the legend, invoking the move_layer_set_up function within the layer_manager, updating the legend itself, and displaying any errors.
A function that handles the delete button click event for the legend, invoking the deleteLayer function within the layer_manager, updating the legend itself, and displaying any errors. Also manages clearing the layer out of the style editor.
This function is run when a layer setElement is added to the map. It is responsible for creating the legend entry for FeatureServer layers.
A tool for identifying values at specific points or areas on the map.
A tool for identifying values at specific points or areas on the map.
A set of vanilla JS helper functions for basic tasks.
Calculates the euclidean distance of x y points. Different than turf.distance which uses haversine.
This fixes an issue that messes up with the Ag Area Affected calculation If there are horizontal lines that line up next to each other, merge them all into 1 horizontal line EX: | \ \ y value-> - - - - - (5 consecutive horizontal lines) |s
Check if a point is in a four-sided shape using Cartesian Pixel Math where origin is top-left
The top and bottom use the fomula y = m * x + b The right and left use the formula x = (y - b) / m;
Calculates slope going from point1 to point2 y2 - y1
x2 - x1
The query_admin_layer function takes in a geometry in ESRI JSON format and returns a result object.
(any)
Polygon
:
var polygons_as_geojson = polygons.map(common.convert_esri_polygon_to_geojson);
This method allows you to convert a standard JS object to a FormData object, which will allow us to post it in the body of a HTTP Request a result object.
(any)
FormData
:
let request = new Request(url, { method: "POST", body: common.convert_to_form_data(data) });
This is a function that returns when the document body and initial HTML has loaded
nothing
:
common.document_is_ready.then(function() {
var script = document.createElement("script");
script.src = src;
script.onload = resolve;
document.body.appendChild(script);
});
This is a function takes in a number or an array of numbers and checks to see if at least one of these numbers is within a min and a max number.
boolean
:
var horizontal_conflict = common.within([a.columnStart, a.columnEnd], b.columnStart, b.columnEnd) || common.within([b.columnStart, b.columnEnd], a.columnStart, a.columnEnd);
The get_extent_from_esri_geometry function takes in a geometry in ESRI JSON format and returns an object that includes the following keys, xmin, xmax, ymin, ymax
(any)
Object
:
let extent = get_extent_from_esri_geometry(esri_geometry);
console.log("xmin is " + extent.xmin);
A set of helper functions which use core GADAS libraries like ESRI's JS API.
The shard function basically slices up a polygon into smaller pieces, more easily digestible by the poor performing ESRI ArcGIS server. That is why we have to do this.
(esri_geometry)
an ESRI JS geometry object of the Polygon class.
(number)
is the width in meters of the original raster data source.
This paramater allows you to appropriately shard your geometry scaled to the size of the raster
that you'll use it on.
(number)
basically how wide can your.tif file get if you use this shard
to request a download from an ESRI ArcGIS server. We need to provide this customization to sharding because
the ESRI ArcGIS server can run download tasks on larger areas than computeHistograms. So the size of the shard
is dependent on how you plan on using it.
This version of Shard exists so that it can be used in other parts of the application such as ag profile that do not have access to dojo require statements.
Initialization logic for GADAS.
A function to load the gadas catalog. Creates promises to load the primary and secondary (compare) maps, then initializes the app when the promises resolve. Should not need to be called more than once.
A function to load the secondary (compare) ESRI map.
promise
:
A function to load the default layers, if the app is starting from a standard, non-bookmarked URL.
A function to load Google analytics tracking capabilities for the site visit
A function which determines whether loading from a standard URL or a bookmark and initializes the app/layers accordingly
Finally found a tutorial that explains jsPDF addImage parameters, because there's nothing about addImage at all in the official documentation. Tutorial here: http://findnerd.com/list/view/Adding-Image-to-PDF-Using-JSPDF/28818/ Official jsPDF documentation: https://rawgit.com/MrRio/jsPDF/master/docs/index.html
(any)
: image itself
(any)
: file extension of image
(any)
: position of image from left
(any)
: position of image from top
(any)
: width of image
(any)
: height of image
(any)
: image alias
doc.addImage(imgData, 'image format', x, y, w, h, 'alias');
The changeStyle function is the first step for a layer to have its style changed. It updates the layer style configuration, then iterates through bundled sublayers to change all of them consistently, then passes some logic to layer-type specific functions for logic pertaining specifically to lines, dots, polygons, etc. Then those in turn invoke the finalizeStyleChange() function.
(any)
Boolean
:
true if the specified value is not null and not undefined.
(any)
Boolean
:
true if the specified value is not null and not undefined.
(any)
(any)
Number
:
returns remainder of floored division, i.e., floor(a / n). Useful for consistent modulo
of negative numbers. See
http://en.wikipedia.org/wiki/Modulo_operation
.
(any)
(any)
Number
:
returns remainder of floored division, i.e., floor(a / n). Useful for consistent modulo
of negative numbers. See
http://en.wikipedia.org/wiki/Modulo_operation
.
(any)
(any)
Number
:
the value x clamped to the range
[low, high]
.
(any)
(any)
Number
:
the value x clamped to the range
[low, high]
.
Boolean
:
true if agent is probably a mobile device. Don't really care if this is accurate.
Boolean
:
true if agent is probably a mobile device. Don't really care if this is accurate.
Calculate distortion of the wind vector caused by the shape of the projection at point (x, y). The wind vector is modified in place and returned by this function.
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
Calculate distortion of the wind vector caused by the shape of the projection at point (x, y). The wind vector is modified in place and returned by this function.
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
(any)
Array
:
wind vector
[u, v, magnitude]
at the point (x, y), or
[NaN, NaN, null]
if wind
is undefined at that point.
(any)
(any)
Array
:
wind vector
[u, v, magnitude]
at the point (x, y), or
[NaN, NaN, null]
if wind
is undefined at that point.
Global class for simulating the movement of particle through a 1km wind grid credit: All the credit for this work goes to: https://github.com/cambecc for creating the repo: https://github.com/cambecc/earth. The majority of this code is directly take nfrom there, since its awesome. This class takes a canvas element and an array of data (1km GFS from http://www.emc.ncep.noaa.gov/index.php?branch=GFS) and then uses a mercator (forward/reverse) projection to correctly map wind vectors in "map space". The "start" method takes the bounds of the map at its current extent and starts the whole gridding, interpolation and animation process.
(any)
a canvas element and an array of data