Members
(private, constant) featureTypeToRenderer
Properties:
Name | Type | Description |
---|---|---|
featureTypeToRenderer |
Object |
Maps GeoJSON geometry types to a set of default renders defined in GlobalStorage.DefaultRenders
(constant) serviceType
Properties:
Name | Type | Description |
---|---|---|
serviceType |
Object |
Different types of services that a URL could point to
Methods
addHilight(graphic)
- Source:
Add a graphic or array of graphics to the highlight layer. Remove any previous graphics.
Parameters:
Name | Type | Description |
---|---|---|
graphic |
Graphic | Array | an ESRI graphic, or array of ESRI graphics. Should be in map spatialReference, and not bound to a layer |
addPin(point)
- Source:
Add a graphic to indicate where user clicked.
Parameters:
Name | Type | Description |
---|---|---|
point |
Point | an ESRI point object to use as the graphic location |
allComb(M, N)
Generate all permutations of length M, with exactly N true
values.
Parameters:
Name | Type | Description |
---|---|---|
M |
int | the size of the array (must be greater than 0) |
N |
int | the number of entries which should be true (must not be greater than M) |
Returns:
an array containing all possible size M arrays of boolean values with N true entries
(private) allocateLayersToSections(layers, sectionsAvailable, mapHeight)
Parameters:
Name | Type | Description |
---|---|---|
layers |
Array | a list of layers to be updated (modified in place) |
sectionsAvailable |
int | the maximum number of sections to use |
mapHeight |
int | the rendered height of the map image |
Returns:
the same layers array as passed in
(private) arrayBufferToString(buffer) → {String}
Converts an array buffer to a string
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Arraybuffer | an array buffer containing stuff (ideally string-friendly) |
Returns:
array buffer in string form
- Type
- String
assignIds()
Performs in place assignment of integer ids for a GeoJSON FeatureCollection. If at least one feature has an existing id outside the geoJson properties section, the original id value is copied in a newly created property ID_FILE of the properties object and the existing id value is replaced by an autogenerated number. Features without existing id from that same dataset will get a new properties ID_FILE with an empty string as value.
If at least one feature has an existing OBJECTID inside the geoJson properties section, the original OBJECTID value is copied in a newly created property OBJECTID_FILE of the properties object and the existing OBJECTID value is replaced by an autogenerated number. Features without existing OBJECTID from that same dataset will get a new properties OBJECTID_FILE with an empty string as value.
(private) assignLayerSplits(layers, splitPoints)
Convenience function for assigning the splitBefore
property on layers at specified points.
NOTE: this function modifies data in place
Parameters:
Name | Type | Description |
---|---|---|
layers |
Array | a list of layers to be updated (modified in place) |
splitPoints |
Array | an array of boolean values indicating if the layer list should be split at that point (must be layers.length-1 in size) |
Returns:
layers the same array as passed in
checkProj(spatialReference, epsgLookup) → {Object}
Check whether or not a spatialReference is supported by proj4 library.
Parameters:
Name | Type | Description |
---|---|---|
spatialReference |
Object | to be checked to see if it's supported by proj4 |
epsgLookup |
function | an optional lookup function for EPSG codes which are not loaded in the proj4 definitions, the function should take a numeric EPSG code and return a Promise resolving with a proj4 style definition string |
Returns:
with the structure { foundProj: (bool) indicates if the projection was found, message: (string) provides a reason why the projection was not found, lookupPromise: (Promise) an optional promise resolving with true or false if a lookup function was provided and had to be invoked }
- Type
- Object
clearHilight()
- Source:
Remove hilight from map
(private) clipExtentCoords(mid, max, min, mapMax, mapMin, len) → {Array}
- Source:
Compares to sets of co-ordinates for extents (valid for both x and y). If center of input co-ordinates falls outside map co-ordiantes, function will adjust them so the center is inside the map co-ordinates.
Parameters:
Name | Type | Description |
---|---|---|
mid |
Numeric | middle of the the range to test |
max |
Numeric | maximum value of the range to test |
min |
Numeric | minimum value of the range to test |
mapMax |
Numeric | maximum value of the map range |
mapMin |
Numeric | minimum value of the map range |
len |
Numeric | length of the adjusted range, if adjusted |
Returns:
two element array of Numeric, containing result max and min values
- Type
- Array
cloneLayerGraphic(graphic) → {Object}
- Source:
Clone a graphic from a map-bound layer.
Parameters:
Name | Type | Description |
---|---|---|
graphic |
Graphic | an ESRI graphic that resides in a map layer. |
Returns:
an unbound copy of the graphic
- Type
- Object
convertImageToCanvas(url, canvas, crossOrigin) → {Promise}
Convert an image to a canvas element
Parameters:
Name | Type | Default | Description |
---|---|---|---|
url |
String | image url to convert (result from the esri print task) |
|
canvas |
Object |
null
|
[optional = null] canvas to draw the image upon; if not supplied, a new canvas will be made |
crossOrigin |
Boolean |
true
|
[optional = true] when set, tries to fetch an image with crossOrigin = anonymous |
Returns:
conversion promise resolving into a canvas of the image
- Type
- Promise
convertImagetoDataURL(imageUri, imageType) → {Promise}
Loads an image (as crossing) and converts it to dataURL. If a supplied imageUri is already a dataURL, just return it. If an image fails to load with the crossing attribute, return the original imageUri
Parameters:
Name | Type | Description |
---|---|---|
imageUri |
String | url of the image to load and convert |
imageType |
String | [optional = 'image/png'] format of the image representation |
Returns:
promise resolving with the dataURL of the image
- Type
- Promise
(private) crawlLayerInfos(layerInfos, urlMap)
- Source:
Recursively crawl a wms layer info structure. Store any legends in the provided map object.
Parameters:
Name | Type | Description |
---|---|---|
layerInfos |
Array | array of ESRI WMSLayerInfo objects |
urlMap |
Map | a Map of sublayer names to legend urls |
(private) createAttribSet(oidField, featureData) → {Object}
- Source:
Will generate attribute package with object id indexes
Parameters:
Name | Type | Description |
---|---|---|
oidField |
String | field containing object id |
featureData |
Array | feature objects to index and return |
Returns:
object containing features and an index by object id
- Type
- Object
csvPeek(csvData, delimiter) → {Array}
Peek at the CSV output (useful for checking headers)
Parameters:
Name | Type | Description |
---|---|---|
csvData |
string | the CSV data to be processed |
delimiter |
string | the delimiter used by the data |
Returns:
an array of arrays containing the parsed CSV
- Type
- Array
enforceBoundary(extent, maxExtent) → {Object}
- Source:
Checks if the center of the given extent is outside of the maximum extent. If it is, will determine an adjusted extent with a center inside the maximum extent. Returns both an indicator flag if an adjustment happened, and the adjusted extent.
Parameters:
Name | Type | Description |
---|---|---|
extent |
Object | an ESRI extent to test |
maxExtent |
Object | an ESRI extent indicating the boundary of the map |
Returns:
an object with two properties. adjusted - boolean, true if extent was adjusted. newExtent - object, adjusted ESRI extent
- Type
- Object
enhanceRenderer(renderer, legend) → {Promise}
- Source:
Will add extra properties to a renderer to support images. New properties .svgcode and .defaultsvgcode contains image source for app on each renderer item.
Parameters:
Name | Type | Description |
---|---|---|
renderer |
Object | an ESRI renderer object in server JSON form. Param is modified in place |
legend |
Object | object for the layer that maps legend label to data url of legend image |
Returns:
resolving when the renderer has been enhanced
- Type
- Promise
extractFields()
Extracts fields from the first feature in the feature collection, does no guesswork on property types and calls everything a string.
findClosestLOD(lods, scale) → {Object}
- Source:
Finds the level of detail closest to the provided scale.
Parameters:
Name | Type | Description |
---|---|---|
lods |
Array | list of levels of detail objects |
scale |
Number | scale value to search for in the levels of detail |
Returns:
the level of detail object closest to the scale
- Type
- Object
(private) findOptimalSplit(layer, splitCount)
Find the optimal split points for the given layer.
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | a layer object to be split into |
splitCount |
int | the number of pieces which the layer should be broken into |
Returns:
a reference to the layer passed in
generateLocalCanvas(map, options, canvas) → {Promise}
- Source:
Create a canvas from the user added layers (svg tag)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
map |
Object | esri map object |
|
options |
Object |
null
|
[optional = null] { width, height } values; needed to get canvas of a size different from default width {Number} height {Number} |
canvas |
Object |
null
|
[optional = null] canvas to draw the image upon; if not supplied, a new canvas will be made |
Returns:
resolving when the canvas have been created resolve with a canvas element with user added layer on it
- Type
- Promise
(private) generatePlaceholderSymbology(name, colour) → {Object}
- Source:
Generates a placeholder symbology graphic. Returns a promise for consistency
Parameters:
Name | Type | Description |
---|---|---|
name |
String | label symbology label |
colour |
String | colour to use in the graphic |
Returns:
symbology svg code and its label
- Type
- Object
generateServerImage(esriBundle, map, options) → {Promise}
- Source:
Generate the image from the esri print task
Parameters:
Name | Type | Description |
---|---|---|
esriBundle |
Object | bundle of API classes |
map |
Object | esri map object |
options |
Object | options for the print task url - for the esri geometry server format - output format width - target image height if different from default height - target image width if different from default |
Returns:
resolving when the print task created the image resolve with a "response: { url: value }" where url is the path for the print task export image
- Type
- Promise
generateUUID() → {String}
Get a 'good enough' uuid. For backup purposes if client does not supply its own unique layer id
Returns:
a uuid
- Type
- String
generateWMSSymbology(name, imageUri) → {Promise}
- Source:
Generates svg symbology for WMS layers.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | label for the symbology item (it's not used right now, but is required to be consistent with other symbology generating functions) |
imageUri |
String | url or dataUrl of the legend image |
Returns:
a promise resolving with symbology svg code and its label
- Type
- Promise
geomToGraphic(geometry, symbol) → {Object}
- Source:
Generating a graphic from server geometry.
Parameters:
Name | Type | Description |
---|---|---|
geometry |
Object | feature geometry conforming to ESRI Geometry standard |
symbol |
Object | esri symbol in server format |
Returns:
an ESRI GraphicsLayer
- Type
- Object
getAttribs() → {Promise}
- Source:
Returns attribute data for this layer.
Returns:
resolves with a layer attribute data object
- Type
- Promise
getAttribs() → {Promise}
- Source:
Returns attribute data for this FC.
Returns:
resolves with a layer attribute data object
- Type
- Promise
getAttribs(childIndex) → {Promise}
- Source:
Returns attribute data for a child layer.
Parameters:
Name | Type | Description |
---|---|---|
childIndex |
String | the index of the child layer |
Returns:
resolves with a layer attribute data object
- Type
- Promise
getExtentFromJson(extentJson) → {Object}
- Source:
Create an ESRI Extent object from extent setting JSON object.
Parameters:
Name | Type | Description |
---|---|---|
extentJson |
Object | that follows config spec |
Returns:
an ESRI Extent object
- Type
- Object
getFeatureName(objId, attribs) → {Promise}
- Source:
Extract the feature name from a feature as best we can. Support for dynamic layers is limited at the moment. // TODO explain this comment
Parameters:
Name | Type | Description |
---|---|---|
objId |
String | the object id of the attribute |
attribs |
Object | optional. the dictionary of attributes for the feature. uses internal attributes if not provided. |
Returns:
resolves with the name of the feature
- Type
- Promise
getGraphicIcon(attributes, renderer) → {String}
- Source:
Given feature attributes, return the image URL for that feature/graphic object.
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object | object of feature attribute key value pairs |
renderer |
Object | an enhanced renderer (see function enhanceRenderer) |
Returns:
svgcode Url to the features symbology image
- Type
- String
getGraphicSymbol(attributes, renderer) → {Object}
- Source:
Given feature attributes, return the symbol for that feature/graphic object.
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object | object of feature attribute key value pairs |
renderer |
Object | an enhanced renderer (see function enhanceRenderer) |
Returns:
an ESRI Symbol object in server format
- Type
- Object
getLayerData(childIndex) → {Promise}
- Source:
Returns layer-specific data for a child layer
Parameters:
Name | Type | Description |
---|---|---|
childIndex |
String | the index of the child layer |
Returns:
resolves with a layer data object
- Type
- Promise
getLayerData() → {Promise}
- Source:
Returns layer-specific data for this FC.
Returns:
resolves with a layer data object
- Type
- Promise
getLayerData() → {Promise}
- Source:
Returns layer-specific data for this Record
Returns:
resolves with a layer data object
- Type
- Promise
getLayerType(layer) → {String}
Will return a string indicating the type of layer a layer object is.
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | an ESRI API layer object |
Returns:
layer type
- Type
- String
getLegendUrls(wmsLayer, layerList) → {Array}
- Source:
Finds the appropriate legend URLs for WMS layers.
Parameters:
Name | Type | Description |
---|---|---|
wmsLayer |
WMSLayer | an ESRI WMSLayer object to be queried |
layerList |
Array | a list of strings identifying the WMS layers to be queried |
Returns:
a list of strings containing URLs for specified layers (order is preserved)
- Type
- Array
(private) getMapServerLegend(layerUrl, esriBundle) → {Promise}
- Source:
Returns the legend information of an ESRI map service.
Parameters:
Name | Type | Description |
---|---|---|
layerUrl |
String | service url (root service, not indexed endpoint) |
esriBundle |
Object | collection of ESRI API objects |
Returns:
resolves in an array of legend data
- Type
- Promise
getNorthArrowAngle() → {Number}
- Source:
Calculate north arrow bearing. Angle returned is to to rotate north arrow image. http://www.movable-type.co.uk/scripts/latlong.html
Returns:
map rotation angle (in degree)
- Type
- Number
getScaleRatio(mapWidth) → {Object}
- Source:
Calculate distance between min and max extent to know the pixel ratio between screen size and earth distance. http://www.movable-type.co.uk/scripts/latlong.html
Parameters:
Name | Type | Description |
---|---|---|
mapWidth |
Number | optional the map width to use to calculate ratio |
Returns:
contain information about the scale
- distance: distance between min and max extentId
- ratio: measure for 1 pixel in earth distance
- units: array of units [metric, imperial]
- Type
- Object
getUnboundGraphics(graphicBundles, spatialReference) → {Array}
- Source:
Generating a graphic from server geometry.
Parameters:
Name | Type | Description |
---|---|---|
graphicBundles |
Array | set of graphic bundles with properties .graphic, .source, .layer, .featureIdx. |
spatialReference |
Object | the projection the unbound graphics should be in |
Returns:
a set of promises that resolve with an unbound graphic, one for each graphic bundle provided
- Type
- Array
(private) getWMSLayerTitle(wmsLayer, wmsLayerId) → {String}
- Source:
Searches for a layer title defined by a wms.
Parameters:
Name | Type | Description |
---|---|---|
wmsLayer |
Object | esri layer object for the wms |
wmsLayerId |
String | layers id as defined in the wms (i.e. not wmsLayer.id) |
Returns:
layer title as defined on the service, '' if no title defined
- Type
- String
getZoomLevel(lods, maxScale) → {Number}
- Source:
Takes the lod list and finds level as close to and above scale limit
Parameters:
Name | Type | Description |
---|---|---|
lods |
Array | array of esri LODs https://developers.arcgis.com/javascript/jsapi/lod-amd.html |
maxScale |
Integer | object largest zoom level for said layer |
Returns:
current LOD
- Type
- Number
(private) guessCSVfields(rows) → {Object}
From provided CSV data, guesses which columns are long and lat. If guessing is no successful, returns null for one or both fields.
Parameters:
Name | Type | Description |
---|---|---|
rows |
Array | csv data |
Returns:
an object with lat and long string properties indicating corresponding field names
- Type
- Object
hideLayers(map) → {Array}
- Source:
Set svg-based layer visibility to false to avoid CORS error
Parameters:
Name | Type | Description |
---|---|---|
map |
Object | esri map object |
Returns:
layer array of layers where visibility is true
- Type
- Array
identify(opts) → {Object}
- Source:
Run a query on a dynamic layer, return the result as a promise.
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | additional argumets like map object, clickEvent, etc. |
Returns:
an object with identify results array and identify promise resolving when identify is complete; if an empty object is returned, it will be skipped
- Type
- Object
identify(opts) → {Object}
- Source:
Run a query on a feature layer, return the result as a promise. Fills the panelData array on resolution. // TODO update
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | additional argumets like map object, clickEvent, etc. |
Returns:
an object with identify results array and identify promise resolving when identify is complete; if an empty object is returned, it will be skipped
- Type
- Object
initBasemaps(esriBundle, basemapsConfig, map) → {Object}
- Source:
Make basemap gallery based on the settings of basemap metadata.
Parameters:
Name | Type | Description |
---|---|---|
esriBundle |
Object | ESRI modules from the initial startup |
basemapsConfig |
Array | array of basemap settings in the form { id: string, layers: [string], title: string, thumbnailUrl: string, wkid: integer } |
map |
esriMap | ESRI map object |
Returns:
an object with the following properties:
- setBasemap {function} set current basemap with a basemap uid
- basemapGallery {object} basemapGallery object
- Type
- Object
(static) isSpatialRefEqual(sr1, sr2) → {Boolean}
Checks if two spatial reference objects are equivalent. Handles both wkid and wkt definitions.
Parameters:
Name | Type | Description |
---|---|---|
sr1 |
type | Esri Spatial Reference First to compare |
sr2 |
type | Esri Spatial Reference Second to compare |
Returns:
true if the two spatial references are equivalent. False otherwise.
- Type
- Boolean
(private) loadDataBatch(opts, callerDef)
- Source:
Recursive function to load a full set of attributes, regardless of the maximum output size of the service. Passes result back on the provided Deferred object.
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | options object that consists of these properties
|
callerDef |
Object | deferred object that resolves when current data has been downloaded |
loadFeatureAttribs(layerUrl, featureIdx, attribs, esriBundle) → {Object}
- Source:
fetch attributes from an ESRI ArcGIS Server Feature Layer Service endpoint
Parameters:
Name | Type | Description |
---|---|---|
layerUrl |
String | an arcgis feature layer service endpoint |
featureIdx |
Integer | index of where the endpoint is. used for legend output |
attribs |
String | a comma separated list of attributes to download. '*' will download all |
esriBundle |
Object | bundle of API classes |
Returns:
attributes in a packaged format for asynch access
- Type
- Object
localProjectExtent(extent, sr) → {Object}
Reproject an EsriExtent object on the client. Does not require network traffic, but may not handle conversion between projection types as well. Internally it tests 8 points along each edge and takes the max extent of the result.
Parameters:
Name | Type | Description |
---|---|---|
extent |
EsriExtent | to reproject |
sr |
Object | is the target spatial reference (if a number it will be treated as a WKID) |
Returns:
an extent as an unstructured object
- Type
- Object
localProjectGeometry(destProj, geometry) → {Object}
Project a single point.
Parameters:
Name | Type | Description |
---|---|---|
destProj |
Object | Integer | String | the spatial reference of the result (as ESRI SpatialReference, integer WKID or an EPSG string) |
geometry |
Object | an object conforming to ESRI Geometry object standards containing the coordinates to Reproject |
Returns:
an object conforming to ESRI Geomtery object standards containing the input geometry in the destination projection
- Type
- Object
localProjectPoint(srcProj, destProj, point) → {Array|Object}
Project a single point.
Parameters:
Name | Type | Description |
---|---|---|
srcProj |
Object | Integer | String | the spatial reference of the point (as ESRI SpatialReference, integer WKID or an EPSG string) |
destProj |
Object | Integer | String | the spatial reference of the result (as ESRI SpatialReference, integer WKID or an EPSG string) |
point |
Array | Object | a 2d array or object with {x,y} props containing the coordinates to Reproject |
Returns:
a 2d array or object containing the projected point
- Type
- Array | Object
makeBoundingBox(id, extent, targetSr) → {GraphicsLayer}
- Source:
Makes a bounding box layer (a graphics layer with one rectangle graphic matching the supplied extent).
Parameters:
Name | Type | Description |
---|---|---|
id |
String | the id of the bounding box to be created |
extent |
EsriExtent | an ESRI extent object to be used for the graphics boundaries |
targetSr |
SpatialReference | an ESRI spatial reference which is used for projecting the result |
Returns:
an ESRI GraphicsLayer
- Type
- GraphicsLayer
makeGeoJsonLayer(geoJson, opts) → {Promise}
Converts a GeoJSON object into a FeatureLayer. Expects GeoJSON to be formed as a FeatureCollection containing a uniform feature type (FeatureLayer type will be set according to the type of the first feature entry). Accepts the following options:
- targetWkid: Required. an integer for an ESRI wkid to project geometries to
- renderer: a string identifying one of the properties in defaultRenders
- sourceProjection: a string matching a proj4.defs projection to be used for the source data (overrides geoJson.crs)
- fields: an array of fields to be appended to the FeatureLayer layerDefinition (OBJECTID is set by default)
- epsgLookup: a function that takes an EPSG code (string or number) and returns a promise of a proj4 style definition or null if not found
- layerId: a string to use as the layerId
- colour: a hex string to define the symbol colour. e.g. '#33DD6A'
Parameters:
Name | Type | Description |
---|---|---|
geoJson |
Object | An object following the GeoJSON specification, should be a FeatureCollection with Features of only one type |
opts |
Object | An object for supplying additional parameters |
Returns:
a promise resolving with a {FeatureLayer}
- Type
- Promise
makeHilightLayer(options) → {Object}
- Source:
Generate a graphic layer to handle feature hilighting.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | optional settings for the hilight layer layerId - id to use for the hilight layer. defaults to rv_hilight pinSymbol - esri symbol in server json format to symbolize the click marker. defaults to a red pin hazeOpacity - how opaque the haze sheet behind the hilight is. 0 to 255, 0 being transparent. defaults to 127 |
Returns:
an ESRI GraphicsLayer
- Type
- Object
(private) makeLayerInfo(type, name, url, json) → {Object}
Returns a standard information object with info common for most ESRI endpoints .serviceName .serviceType .tileSupport .rootUrl
Parameters:
Name | Type | Description |
---|---|---|
type |
String | serviceType enum value for layer |
name |
String | property in json parameter containing a service name |
url |
String | url we are investigating |
json |
Object | data result from service we interrogated |
Returns:
- Type
- Object
makeLegend(layerList, sectionsAvailable, mapHeight)
Generate the structure for a legend given a set of layers.
Parameters:
Name | Type | Description |
---|---|---|
layerList |
Array | a list of layers to be updated (modified in place) |
sectionsAvailable |
int | the maximum number of sections to use |
mapHeight |
int | the rendered height of the map image |
Returns:
an object with properties layers, sectionsUsed. (layerList is modified in place)
mapDefault(key, valueopt)
- Source:
Sets or gets map default config values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
String | name of the default property |
|
value |
Any |
<optional> |
optional value to set for the specified default property |
(private) mapServerLegendToRenderer(serverLegend, layerIndex) → {Object}
- Source:
Our symbology engine works off of renderers. When dealing with layers with no renderers, we need to take server-side legend and convert it to a fake renderer, which lets us leverage all the existing symbology code.
Parameters:
Name | Type | Description |
---|---|---|
serverLegend |
Object | legend json from an esri map server |
layerIndex |
Integer | the index of the layer in the legend we are interested in |
Returns:
a fake unique value renderer based off the legend
- Type
- Object
mapServerToLocalLegend(mapServerUrl, layerIndex) → {Promise}
- Source:
Orchestrator function that will:
- Fetch a legend from an esri map server
- Extract legend for a specific sub layer
- Convert server legend to a temporary renderer
- Convert temporary renderer to a viewer-formatted legend (return value)
Parameters:
Name | Type | Description |
---|---|---|
mapServerUrl |
String | service url (root service, not indexed endpoint) |
layerIndex |
Integer | the index of the layer in the legend we are interested in |
Returns:
resolves in a viewer-compatible legend for the given server and layer index
- Type
- Promise
(private) newLayerBundle() → {Object}
- Source:
Will generate an empty object structure to store a bundle of attributes for a full layer
Returns:
empty layer bundle object
- Type
- Object
(private) newLayerPackage(featureIdx, esriBundle) → {Object}
- Source:
Will generate an empty object structure to store attributes for a single layer of features
Parameters:
Name | Type | Description |
---|---|---|
featureIdx |
Integer | server index of the layer |
esriBundle |
Object | bundle of API classes |
Returns:
empty layer package object
- Type
- Object
(private) newProp(target, propName, getter)
- Source:
Worker function to add or override a get property on an object
Parameters:
Name | Type | Description |
---|---|---|
target |
Object | the object that will receive the new property |
propName |
String | name of the get property |
getter |
function | the function defining the guts of the get property. |
(private) normalizeProj(proj) → {String}
Convert a projection to an string that is compatible with proj4. If it is an ESRI SpatialReference or an integer it will be converted.
Parameters:
Name | Type | Description |
---|---|---|
proj |
Object | Integer | String | an ESRI SpatialReference, integer or string. Strings will be unchanged and unchecked, ints and SpatialReference objects will be converted. |
Returns:
A string in the form EPSG:####
- Type
- String
onLoad()
- Source:
Triggers when the layer loads.
onLoad()
- Source:
Triggers when the layer loads. Returns an array of promises that need to resolve for layer to be loaded.
onLoad()
- Source:
Triggers when the layer loads.
onLoad()
- Source:
Triggers when the layer loads.
onLoad()
- Source:
Triggers when the layer loads.
onLoad()
- Source:
Triggers when the layer loads.
(private) packLayersIntoExactSections(layers, sections) → {Object}
Groups multiple layers into each section while attempting to minimize the legend height.
Allocates to the exact number specified in the sections
argument.
NOTE: don't call this with too many layers as it tests all possible groupings and can be
computationally expensive (< 15 layers should be fine)
Parameters:
Name | Type | Description |
---|---|---|
layers |
Array | a list of layers to be fitted |
sections |
int | the number of sections to use |
Returns:
an object in the form { layers, sectionsUsed, bestPerm, bestHeight }
- Type
- Object
(private) packLayersIntoOptimalSections(layers, sections) → {Object}
Groups multiple layers into each section while attempting to minimize the legend height. Repeats as necessary to use the least number of sections while still keeping the resulting legend height within 20% of optimal. NOTE: don't call this with too many layers as it tests all possible groupings and can be computationally expensive (< 15 layers should be fine)
Parameters:
Name | Type | Description |
---|---|---|
layers |
Array | a list of layers to be updated (modified in place) |
sections |
int | the number of sections to use |
Returns:
an object in the form { layers, sectionsUsed }
- Type
- Object
predictLayerUrl(url, hint) → {Promise}
Attempts to determine what kind of layer the URL most likely is, and if possible, return back some useful information about the layer
- serviceType: the type of layer the function thinks the url is referring to. is a value of serviceType enumeration (string)
- fileData: file contents in an array buffer. only present if the URL points to a file that exists on an internet server (i.e. not a local disk drive)
- name: best attempt at guessing the name of the service (string). only present for ESRI service URLs
- fields: array of field definitions for the layer. conforms to ESRI's REST field standard. only present for feature layer and image service URLs.
- geometryType: describes the geometry of the layer (string). conforms to ESRI's REST geometry type enum values. only present for feature layer URLs.
- groupIdx: property only available if a group layer is queried. it is the layer index of the group layer in the list under its parent dynamic layer
Parameters:
Name | Type | Description |
---|---|---|
url |
String | a url to something that is hopefully a map service |
hint |
String | optional. allows the caller to specify the url type, forcing the function to run the data logic for that type |
Returns:
a promise resolving with an infomation object
- Type
- Promise
(private) processDynamicLayer(layer, options, esriBundle) → {Object}
- Source:
Ochestrate the attribute extraction of a dynamic map service layer object.
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | an ESRI API Dynamic Map Service layer object |
options |
Object | information on layer and attribute skipping |
esriBundle |
Object | bundle of API classes |
Returns:
attributes in layer bundle format (see newLayerBundle)
- Type
- Object
(private) processFeatureLayer(layer, options, esriBundle) → {Object}
- Source:
Ochestrate the attribute extraction of a feature layer object.
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | an ESRI API Feature layer object |
options |
Object | information on layer and attribute skipping |
esriBundle |
Object | bundle of API classes |
Returns:
attributes in layer bundle format (see newLayerBundle)
- Type
- Object
projectGeojson(geojson, outputSpatialReference, inputSpatialReference)
Reproject a GeoJSON object in place. This is a wrapper around terraformer-proj4js.
Parameters:
Name | Type | Description |
---|---|---|
geojson |
Object | the GeoJSON to be reprojected, this will be modified in place |
outputSpatialReference |
String | Number | the target spatial reference, 'EPSG:4326' is used by default; if a number is suppied it will be used as an EPSG code |
inputSpatialReference |
String | Number | same rules as outputSpatialReference if suppied if missing it will attempt to find it encoded in the GeoJSON |
projectionLookup()
Makes an attempt to load and register a projection definition. Returns promise resolving when process is complete projModule - proj module from geoApi projCode - the string or int epsg code we want to lookup epsgLookup - function that will do the epsg lookup, taking code and returning promise of result or null
repokeEsriService(url, esriBundle, childInfo) → {Promise}
handles the situation where our first poke revealed a child layer (i.e. an indexed endpoint in an arcgis server). We need to extract some extra information about the service it resides in (the root service) and add it to our info package.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | the url of the original endpoint (including the index) |
esriBundle |
Object | has ESRI API objects |
childInfo |
Object | the information we have gathered on the child layer from the first poke |
Returns:
resolves with information object containing child and root information
- Type
- Promise
(private) resizeSVGElement(element, targetSize, targetViewbox) → {Object}
- Source:
Scales up or down the specified svg element. To scale it, we need to set the viewbox to the current size and change the size of the element itself.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | target svg element to be resized |
targetSize |
Object | object with target sizes in the form of { width, height } width {Number} height {Number} |
targetViewbox |
Object | [optional = null] target viewbox sizes in the form of { minX, minY, width, height }; if not specified, the original size will be used as the viewbox minX {Number} minxY {Number} width {Number} height {Number} |
Returns:
returns original size and viewbox of the svg element in the form of { originalSize: { width, height }, originalViewbox: { minX, minY, width, height } }; can be used to restore the element to its original state originalSize: width {Number} height {Number} originalViewbox: minX {Number} minxY {Number} width {Number} height {Number}
- Type
- Object
(private) scrapeListRenderer(renderer, childList, window) → {Array}
- Source:
Generate an array of legend items for an ESRI unique value or class breaks renderer.
Parameters:
Name | Type | Description |
---|---|---|
renderer |
Object | an ESRI unique value or class breaks renderer |
childList |
Array | array of children items of the renderer |
window |
Object | reference to the browser window |
Returns:
a legend object populated with the symbol and label
- Type
- Array
searchRenderer(attributes, renderer) → {Object}
- Source:
Given feature attributes, find the renderer node that would draw it
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object | object of feature attribute key value pairs |
renderer |
Object | an enhanced renderer (see function enhanceRenderer) |
Returns:
an Object with svgcode and symbol properties for the matched renderer item
- Type
- Object
serverLayerIdentify(layer, opts) → {Promise}
Perform a server-side identify on a layer (usually an ESRI dynamic layer) Accepts the following options:
- geometry: Required. geometry in map co-ordinates for the area to identify. will usually be an ESRI Point, though a polygon would work.
- mapExtent: Required. ESRI Extent of the current map view
- width: Required. Width of the map in pixels
- height: Required. Height of the map in pixels
- layerIds: an array of integers specifying the layer indexes to be examined. Will override the current visible indexes in the layer parameter
- returnGeometry: a boolean indicating if result geometery should be returned with results. Defaults to false
- tolerance: an integer indicating how many screen pixels away from the mouse is valid for a hit. Defaults to 5
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | an ESRI dynamic layer object |
opts |
Object | An object for supplying additional parameters |
Returns:
a promise resolving with an array of identify results (empty array if no hits)
- Type
- Promise
showLayers(layers)
- Source:
Set user added layer visibility to true for those whoe where visible
Parameters:
Name | Type | Description |
---|---|---|
layers |
Array | array of graphic layers to set visibility to true |
(private) splitLayer(layer, chunkSize, splitCount)
Split a layer into splitCount
parts of roughly equal size.
Parameters:
Name | Type | Description |
---|---|---|
layer |
Object | a layer object to be split into |
chunkSize |
int | the maximum height in pixels of the legend sections |
splitCount |
int | the number of pieces which the layer should be broken into |
Returns:
an object with properties whiteSpace:
(private) svgDrawImage(draw, imageUri, width, height, crossOrigin) → {Promise}
- Source:
Renders a specified image on an svg element. This is a helper function that wraps around async draw.image
call in the svg library.
Parameters:
Name | Type | Description |
---|---|---|
draw |
Object | svg element to render the image onto |
imageUri |
String | image url or dataURL of the image to render |
width |
Number | [optional = 0] width of the image |
height |
Number | [optional = 0] height of the image |
crossOrigin |
Boolean | [optional = true] specifies if the image should be loaded as crossOrigin |
Returns:
promise resolving with the loaded image and its loader object (see svg.js http://documentup.com/wout/svg.js#image for details)
- Type
- Promise
(private) symbolToLegend(symbol, label, window) → {Object}
- Source:
Generate a legend item for an ESRI symbol.
Parameters:
Name | Type | Description |
---|---|---|
symbol |
Object | an ESRI symbol object in server format |
label |
String | label of the legend item |
window |
Object | reference to the browser window |
Returns:
a legend object populated with the symbol and label
- Type
- Object
(private) validateCSV(data) → {Promise}
Performs validation on csv data. Returns a promise resolving with the validation object. Worker function for validateFile, see that file for return value specs
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | csv data as string |
Returns:
promise resolving with information on the csv data
- Type
- Promise
validateFile(type, data) → {Promise}
Validates file content. Does some basic checking for errors. Attempts to get field list, and if possible, provide the file in a more useful format. Promise rejection indicates failed validation
- formattedData: file contents in a more useful format. JSON for GeoJSON and Shapefile. String for CSV
- fields: array of field definitions for the file. conforms to ESRI's REST field standard.
- geometryType: describes the geometry of the file (string). conforms to ESRI's REST geometry type enum values.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | the format of file. aligns to serviceType enum (CSV, Shapefile, GeoJSON) |
data |
Arraybuffer | the file content in binary |
Returns:
a promise resolving with an infomation object
- Type
- Promise
(private) validateGeoJson(geoJson) → {Promise}
Performs validation on GeoJson object. Returns a promise resolving with the validation object. Worker function for validateFile, see that file for return value specs
Parameters:
Name | Type | Description |
---|---|---|
geoJson |
Object | feature collection in geojson form |
Returns:
promise resolving with information on the geoJson object
- Type
- Promise
validateLatLong(arr, ind1, ind2) → {Boolean}
Given 2D array in column x row format, check if all entries in the two given columns are numeric.
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | is a 2D array based on the CSV file that contains row information for all of the rows |
ind1 |
Integer | is a user specified index when uploading the CSV that specifies lat or long column (whichever isn't specified by ind2) |
ind2 |
Integer | is a user specified index when uploading the CSV that specifies lat or long column (whichever isn't specified by ind1) |
Returns:
returns true or false based on whether or not all all columns at ind1 and ind2 are numbers
- Type
- Boolean
wrapEvents(esriObject, handlers)
Wire up any supplied handlers to the corresponding dojo .on events on layer. Purpose is to keep Dojo .on events contained in geoApi.
Parameters:
Name | Type | Description |
---|---|---|
esriObject |
esriObject | which contains the dojo events to be wrapped |
handlers |
handlers | is an object which contains all handlers needed |