Constructor
new DownloadPanelView()
- Since:
- Source:
Extends
Members
The buttons that have been rendered in the toolbar. Formatted as an
object with the button name as the key and the button element as the
value. Initialized in initialize() to avoid shared state across
instances.
Type:
- Source:
The buttons to display in the toolbar.
Type:
- Source:
className :string
The HTML classes to use for this view's element
Type:
- Source:
color :string
The color of the polygon that is being drawn as a hex string.
Type:
- Source:
dataDownloadLinks :object
The array that store the list of URLs for each data layer that is
selected for partial download. Initialized in initialize() to avoid
shared state across instances.
Type:
- Source:
downloadSizeLimit :number
The maximum size of the download in bytes. If download is estimated to exceed
this size, the download will be blocked.
Type:
- Source:
dropdownOptions :object
UI options for the dropdowns
Type:
Properties:
| Name |
Type |
Description |
resolution |
object
|
The resolution dropdown options |
fileType |
object
|
The file type dropdown options |
label |
string
|
The label for the dropdown |
defaultValue |
string
|
The default value for the dropdown |
defaultText |
string
|
The default text for the dropdown |
- Source:
fileSizes :object
The estimated file size per tile for each format, in bytes.
Type:
- Source:
A reference to the MapInteraction model on the MapModel that is used to
listen for clicks on the map.
Type:
- Source:
The CesiumVectorData model that will display the polygon that is being
drawn.
Type:
- Source:
mapModel :Map
The Cesium map model to draw on. This must be the same model that the
mapWidget is using.
Type:
- Source:
The GeoPoints collection that stores the points of the polygon that is
being drawn.
Type:
- Source:
mode
The current mode of the draw tool. This can be "draw", "move",
"remove", or "add" - any of the "name" properties of the buttons array,
excluding buttons like "clear" and "save" that have a method property.
- Source:
objectServiceUrl :string
The objectServiceUrl from the MapModel
Type:
- Source:
opacity :number
The initial opacity of the polygon that is being drawn. A number
between 0 and 1.
Type:
- Source:
The GeoPoints collection that stores the points of the polygon that is
being drawn.
Type:
- Source:
template :Underscore.template
The primary HTML template for this view
Type:
- Source:
tileMatrixSet :string
The TileMatrixSet.
Type:
- Source:
type :string
The type of View this is
Type:
- Source:
zoomLevels :object
The z levels available for download along with their approximate pixel
resolution.
Type:
- Source:
Methods
addPoint(point) → {GeoPoint}
Adds a point to the polygon that is being drawn.
Parameters:
| Name |
Type |
Description |
point |
object
|
The point to add to the polygon. This should
have a latitude and longitude property. |
- Source:
Returns:
The GeoPoint model that was added to the polygon.
-
Type
-
GeoPoint
clearPoints()
Clears the polygon that is being drawn.
- Source:
close()
Closes the download panel and resets the draw tool to its initial
state.
- Source:
downloadData() → {Promise}
Downloads data for each layer specified in `dataDownloadLinks` and
provides progress updates. This function iterates through the
`dataDownloadLinks` object, retrieves data for each layer, and
generates a ZIP file for download. It updates a progress bar to reflect
the download status and handles errors or cases where no data is
available.
Properties:
| Name |
Type |
Description |
dataDownloadLinks |
object
|
An object containing data layer
information.
Properties
| Name |
Type |
Description |
layerID |
string
|
The unique identifier
for the data layer. |
data |
object
|
Metadata for the data
layer.
Properties
| Name |
Type |
Description |
urls |
Array.<string>
|
Array of URLs to
retrieve data from. |
baseURL |
string
|
Base URL for the
data layer. |
fileType |
string
|
The file type of
the data (e.g., "zip"). |
fileSize |
number
|
null
|
The size of
the data file in bytes, or null for WMTS layers. |
wmtsUrl |
string
|
null
|
The WMTS
service URL for the layer, or null for non-WMTS layers. |
layerName |
string
|
The name of the
data layer. |
metadataPid |
string
|
The metadata
pid of the data layer. |
|
|
- Source:
Returns:
Resolves when all data layers have been processed.
-
Type
-
Promise
events()
- Source:
fileTypeSelection(layerID)
Handles the selection of file type and updates the state of the save
button and other UI elements based on whether any checkboxes are
checked.
Parameters:
| Name |
Type |
Description |
layerID |
string
|
The ID of the map layer being interacted
with. |
- Source:
generatePreviewPanel()
Generates the preview panel for downloading selected map layers.
Retrieves the selected layers, removes duplicates, and dynamically
creates a user interface for selecting resolution, file type, and
initiating downloads. It also handles UI interactions such as toggling
panels, enabling/disabling buttons, and updating file size information
based on user selections.
- Source:
getBoundingBox(polygon) → {object}
Calculates the bounding box of a given polygon.
Parameters:
| Name |
Type |
Description |
polygon |
Array.<Array.<number>>
|
An array of points representing the
polygon, where each point is an array of two numbers [longitude,
latitude]. |
- Source:
Returns:
An object representing the bounding box with the
following properties:
- {number} west - The minimum longitude (x-coordinate).
- {number} south - The minimum latitude (y-coordinate).
- {number} east - The maximum longitude (x-coordinate).
- {number} north - The maximum latitude (y-coordinate).
-
Type
-
object
getPolygon(jsonData) → {Array.<Array.<number>>}
Converts an array of geographic points into a polygon representation.
The input array is reversed, and the first point is appended to the end
to close the polygon.
Parameters:
| Name |
Type |
Description |
jsonData |
Array.<object>
|
An array of objects representing
geographic points. Each object should have `longitude` and `latitude`
properties. |
- Source:
Returns:
An array of arrays representing the polygon.
-
Type
-
Array.<Array.<number>>
getRawFileSize(resolution, fileFormat, layerID, fullDownloadLink, pngDownloadLink, gpkgDownloadLink, id, layerName, wmtsDownloadLinkopt, metadataURL, tiffDownloadLink) → {number}
Calculates the total file size for a given map layer based on the file
type, zoom level, and bounding box. Generates URLs for individual tiles
or retrieves a single download link for the layer. Updates the
`dataDownloadLinks` object with the generated URLs and metadata for the
specified layer.
Parameters:
| Name |
Type |
Attributes |
Description |
resolution |
number
|
|
The zoom level for the map tiles. |
fileFormat |
string
|
|
The format of the file to download (e.g.,
"png", "tif", "wmts"). |
layerID |
string
|
|
The unique identifier for the data layer. |
fullDownloadLink |
string
|
|
The full download link for the
layer. |
pngDownloadLink |
string
|
|
The template URL for downloading PNG
tiles. |
gpkgDownloadLink |
string
|
|
The template URL for downloading
Geopackage tiles. |
id |
string
|
|
A unique identifier for the layer or dataset. |
layerName |
string
|
|
The name of the data layer. |
wmtsDownloadLink |
string
|
<optional>
|
(Optional) The WMTS download link
for the layer. Currently unused. |
metadataURL |
string
|
|
The metadata URL for the layer. |
tiffDownloadLink |
string
|
|
The template URL for downloading
TIFF tiles. |
- Source:
Returns:
The estimated total file size for the specified layer
in bytes.
-
Type
-
number
getTileCoordinates(boundingBox, zoomLevel) → {object}
Calculates the tile coordinates for a given bounding box and zoom
level.
Parameters:
| Name |
Type |
Description |
boundingBox |
object
|
The geographical bounding box.
Properties
| Name |
Type |
Description |
west |
number
|
The western longitude |
east |
number
|
The eastern longitude |
south |
number
|
The southern latitude |
north |
number
|
The northern latitude |
|
zoomLevel |
number
|
The zoom level for which to calculate the
tile coordinates. |
- Source:
Returns:
An object containing the zoom level and the tile
coordinates:
- `zoom`: The zoom level.
- `tileXWest`: The tile column for the western edge.
- `tileXEast`: The tile column for the eastern edge.
- `tileYSouth`: The tile row for the southern edge.
- `tileYNorth`: The tile row for the northern edge.
-
Type
-
object
Handles a click on a button in the toolbar. If the button has a
method property, it will call that method. Otherwise, it will toggle the
mode of the draw tool.
Parameters:
| Name |
Type |
Description |
event |
Event
|
The click event. |
- Source:
handleClick(throttleopt)
Handles a click on the map. If the draw tool is active, it will add the
coordinates of the click to the polygon being drawn.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
throttle |
number
|
<optional>
|
50
|
The number of milliseconds to block
clicks for after a click is handled. This prevents double clicks. |
- Source:
handleCopyIconClick(event)
Handles a click on the copy icon in the WMTS info box. Copies the WMTS
URL text to the clipboard and briefly shows a confirmation message.
Parameters:
| Name |
Type |
Description |
event |
Event
|
The click event. |
- Source:
initialize(options)
Initializes the DrawTool
Parameters:
| Name |
Type |
Description |
options |
object
|
A literal object with options to pass to the
view
Properties
| Name |
Type |
Attributes |
Description |
model |
Map
|
|
The Cesium map model to draw on. This must
be the same model that the mapWidget is using. |
cesiumWidgetView |
CesiumWidgetView
|
|
The
CesiumWidgetView that contains the map. |
mode |
string
|
<optional>
|
The initial mode of the draw tool. |
|
- Source:
layerSelection()
Handles the selection of map layers and updates the state of the save
button and other UI elements based on whether any checkboxes are
checked.
- Source:
remove()
- Source:
removeClickListeners()
Removes the click listeners from the map model and sets the
clickFeatureAction back to its original value.
- Source:
removeLayer()
Removes the polygon object from the map
- Source:
Render the view by updating the HTML of the element. The new HTML is
computed from an HTML template that is passed an object with relevant
view state.
- Source:
Returns:
This view
-
Type
-
DownloadPanelView
Create and insert the buttons for drawing and clearing the polygon.
- Source:
reset()
Resets the draw tool to its initial state.
- Source:
retrieveDataFromURL(layerID, urls, baseURL, fileType, onProgressopt) → {Promise.<JSZip>}
Retrieves data from a list of URLs, processes the data, and packages it
into a ZIP file.
Parameters:
| Name |
Type |
Attributes |
Description |
layerID |
string
|
|
The identifier for the layer being processed. |
urls |
Array.<string>
|
|
An array of URLs to fetch data from. |
baseURL |
string
|
|
The base URL used to sanitize and structure
file paths. |
fileType |
string
|
|
The type of file being processed (e.g.,
"wmts"). |
onProgress |
function
|
<optional>
|
Optional callback
function to report download progress as a percentage. |
- Source:
Throws:
-
If there is an issue with fetching or processing the
data.
-
-
Type
-
Error
Returns:
A promise that resolves to a JSZip instance
containing the downloaded files.
-
Type
-
Promise.<JSZip>
Sets the status of the button to either "enabled", "deactivated", or
"active".
Parameters:
| Name |
Type |
Description |
name |
string
|
The name of the button to set the status for. |
status |
"enabled"
|
"deactivated"
|
"active"
|
The status to set
the button to. |
- Source:
Set the status on multiple buttons at once
Parameters:
| Name |
Type |
Description |
statues |
object
|
An object with the button names as keys and
the status as values |
- Source:
setClickListeners()
Set listeners to call the handleClick method when the user clicks on
the map.
- Source:
setUpConnectors()
Sets up the connector to connect the GeoPoints collection to the
CesiumVectorData model. Adds the connector and points properties to
this view.
- Source:
Sets up the layer to show the polygon on the map that is being drawn.
Adds the layer property to this view.
- Source:
Returns:
The CesiumVectorData model that will
display the polygon that is being drawn.
-
Type
-
CesiumVectorData
setUpMapModel()
Adds reference to interaction model to view
- Source:
showError(messageopt)
Show an error message to the user if the map model is not available or
any other error occurs.
Parameters:
| Name |
Type |
Attributes |
Description |
message |
string
|
<optional>
|
The error message to show to the user. |
- Source:
tileFromLatLon(lon, lat, zoom) → {Object}
Converts geographic coordinates (longitude and latitude) into tile
coordinates for a given zoom level, based on the WGS1984Quad tiling
scheme.
Parameters:
| Name |
Type |
Description |
lon |
number
|
The longitude in degrees, ranging from -180 to
180. |
lat |
number
|
The latitude in degrees, ranging from -90 to 90. |
zoom |
number
|
The zoom level, where higher values represent
greater detail. |
- Source:
Returns:
An object containing the
tile coordinates:
- `x`: The horizontal tile index.
- `y`: The vertical tile index (inverted for WGS84).
- `z`: The zoom level.
-
Type
-
Object
toggleDraw(drawopt, offStatusopt)
Toggles the draw tool on and off.
Parameters:
| Name |
Type |
Attributes |
Description |
draw |
boolean
|
<optional>
|
If true, the draw tool will be turned on. If
false, it will be turned off. If not provided, the draw tool will
toggle to the opposite of the current state. |
offStatus |
"enabled"
|
"deactivated"
|
<optional>
|
The status to set the
button to when the toggle is off. |
- Source:
updateLayerInfoEl(informationEl, fileSizeBytes, fileType, layerID)
Updates the text content of the provided HTML element with file size
details or a wmts link to copy.
Parameters:
| Name |
Type |
Description |
informationEl |
HTMLElement
|
The HTML element where the file size
information will be displayed. |
fileSizeBytes |
number
|
null
|
The estimated size of the file
in bytes, or null for WMTS layers. |
fileType |
string
|
The type of the file (e.g., "wmts"). |
layerID |
string
|
The ID of the map layer being interacted
with. |
- Source:
updateStatusBar(options)
Updates the status bar with a message, progress, and visibility
options.
Parameters:
| Name |
Type |
Description |
options |
object
|
The options for updating the status bar.
Properties
| Name |
Type |
Attributes |
Description |
message |
string
|
<optional>
|
The message to display in the
status bar. |
progress |
number
|
null
|
<optional>
|
The progress percentage
(0-100) to display. Ignored if a message is provided. |
show |
boolean
|
<optional>
|
Whether to show or hide the status
bar. |
error |
boolean
|
<optional>
|
Whether the status bar should
indicate an error state. |
|
- Source: