Skip to content

Latest commit

 

History

History
1511 lines (878 loc) · 36.7 KB

api.md

File metadata and controls

1511 lines (878 loc) · 36.7 KB

Table of Contents

ICGC Commons

Common useful geo functions.

GeoCommons

src/geo/GeoCommons.js:10-485

Classe geoCommons

getFirstSymbolLayerId

src/geo/GeoCommons.js:17-26

getFirstSymbolLayerId form MapboxStyle.

Parameters

  • layers object Input style object map.getLayers().

Returns object layer.

getEmptyGeoJSON

src/geo/GeoCommons.js:31-36

Returns object geojson.

getGeoJSONPoint

src/geo/GeoCommons.js:42-54

Parameters

Returns object point geojson.

getRastersSources

src/geo/GeoCommons.js:63-72

GetRastersSources from Mapbox Style.

Parameters

  • sources object Input sources object map.getSources().
  • rasterSources object Output raster sources.

Returns object rasterSources

simplifyStyle

src/geo/GeoCommons.js:80-152

Simplify from Mapbox Style.

Parameters

  • currentStyle object Input styke object map.getStyle().
  • esriFy boolean Optimize for Esri Styles.
  • nonAddVisibilityNone boolean add or no Layers visibility:none

Returns object Mapbox Style

isInsideCat

src/geo/GeoCommons.js:160-172

X,Y coordinates inside Catalonia BBOX.

Parameters

Returns boolean

usedSource

src/geo/GeoCommons.js:179-190

Check is a Source is Used.

Parameters

  • source object Input style object map.getSources().
  • layersArray object Input stlke object map.getLayers().

Returns boolean

removeAccents

src/geo/GeoCommons.js:198-213

removeAccents form MapboxStyle.

Parameters

Returns string string.

isWithinCat

src/geo/GeoCommons.js:220-482

isWithinCat check if a bbox is within Catalonia.

Parameters

  • bbox array Input map.getBounds().toArray() or [1.4622,41.7139 ,1.8117 ,42.0330].

Returns boolean

GeoUtils

src/geo/geoUtils.js:8-73

Classe d'utils operacions geo

Colorizator

src/color/colorizator.js:16-349

A Colorizator object represents a given latitude and longitude coordinates.

Parameters

  • lat number Latitude, measured in degrees.
  • lon number Longitude, measured in degrees.

Examples

const color = new Colorizator();

getRandomColorFromArray

src/color/colorizator.js:36-50

Get Random color from Array

Returns string this

getRandomColor

src/color/colorizator.js:58-71

Get Random color hex

Returns color this

getColorArrayfromPositionBrewer

src/color/colorizator.js:120-125

Get Chormaarray color from brewer palette

Parameters

Returns color this

getColorsScaleRanges

src/color/colorizator.js:135-147

Get Chormaarray form two colors

Parameters

Returns color this

getHslNiceColor

src/color/colorizator.js:155-161

Gets de HSL contrast color from a given color

Parameters

Returns string this

getColorArrayfromSelectedBrewer

src/color/colorizator.js:210-215

Get Chormaarray color from brewer palette

Parameters

Returns color this

generateHTMLBrewerPalettes

src/color/colorizator.js:232-270

Get HTML palete color

Parameters

  • numberPalettes number //number of palletes max this.maxBrewerPalettes
  • numRangs number //number of colors for each palette max this.maxBrewerPalettes

Returns color this

generateHTMLLegendColor

src/color/colorizator.js:282-347

Generate HTML legend palete color

Parameters

Returns color this

ArrayStatics

src/geo/arrayStatics.js:16-102

Generate basic statistics from Array.

Parameters

Examples

Sample;

const ArrayStatics = new ArrayStatics(arrayColumn);

getUniqueValues

src/geo/arrayStatics.js:45-49

Returns Array Unique Values

Returns array

getBasicsStats

src/geo/arrayStatics.js:59-68

Returns basics stats

Parameters

Returns object

getStatsFromRangesColorsArray

src/geo/arrayStatics.js:79-99

Returns stats form RangeNum and colors Array

Parameters

  • numRanges number : 5
  • arrayColors Array : ["#ffddcc", "#ccddee", "#ffff00", "#ccddee", "#ffff00"]

Returns object

BridgeStatics

src/geo/bridgeStatics.js:12-122

A BridgeStatics object represents a given latitude and longitude coordinates.

Parameters

Examples

var ll = new BridgeStatics(42.10376, 1.84584);

CSVStatics

src/geo/csvStatics.js:21-137

Generate basic statistics from CSV array.

Parameters

  • arrayCSV Array<number>
  • numCSVColumn number
  • null/null/position numCSVColumn field array CSV

Examples

Sample;
const arrayCSV = [
[2, 3, 4, 3, 3],
[5, 6, 6, 4, 4],
[1, 8, 1, 5, 7]
];
const numCSVColumn = 1;
const csvStatics = new CSVStatics(arrayCSV, numCSVColumn);

getUniqueValues

src/geo/csvStatics.js:52-56

Returns Array Unique Values

Returns array

getStatsFromRangesColorsCSV

src/geo/csvStatics.js:66-84

Returns stats form RangeNum and colors Array

Parameters

  • numRanges number : 5
  • arrayColors Array : ["#ffddcc", "#ccddee", "#ffff00", "#ccddee", "#ffff00"]

Returns object

getColumFromCSV

src/geo/csvStatics.js:95-134

Returns array from csv properties field Used in the constructor

Parameters

Returns array this

GeoJSONStatistics

src/geo/geoJSONStatics.js:16-175

Return basic stats from a GeoJson data a title field from geojson properties.

Parameters

  • geoJSON object
  • keyField string
  • null geoJSON {geoJSON:geoJSON, filedName: keyField, arrayColumn: arrayColumn}

Examples

const keyField = "temp";
const geoJSON = {"type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {"temp": 2 }, "geometry": {"type": "Point", "coordinates": [2.33184814453125, 41.76926321969369] }}, { "type": "Feature", "properties": {"temp": 2 }, "geometry": {"type": "Point", "coordinates": [2.2686767578125, 41.78014491449217] }}, { "type": "Feature", "properties": {"temp": 5 }, "geometry": {"type": "Point", "coordinates": [2.2703933715820312, 41.725717979972345] }}, { "type": "Feature", "properties": {"temp": "" }, "geometry": {"type": "Point", "coordinates": [2.346096038818359, 41.74698199279457] }}, { "type": "Feature", "properties": {"temp": 1 }, "geometry": {"type": "Point", "coordinates": [2.137527465820312, 41.929868314485795] }}, { "type": "Feature", "properties": {"temp": 8 }, "geometry": {"type": "Point", "coordinates": [2.006378173828125, 41.707266387090684] }}] };
const geoSattics= new GeoJSONStatics(geoJSON, keyField)

getUniqueValues

src/geo/geoJSONStatics.js:49-54

Returns Array Unique Values

Returns array

getStatsFromRangesColorsGeoJSON

src/geo/geoJSONStatics.js:65-84

Returns stats form RangeNum and colors Array

Parameters

  • numRanges number : 5
  • arrayColors Array : ["#ffddcc", "#ccddee", "#ffff00", "#ccddee", "#ffff00"]

Returns object

getColumnFromGEOJSON

src/geo/geoJSONStatics.js:95-141

Returns array from geojson properties field Used in the constructor

Parameters

Returns array this

_getColumFromGEOJSONFilter

src/geo/geoJSONStatics.js:154-173

Returns array from geojson properties field, filtered by a value

Parameters

Returns array this

UtilsStatics

src/geo/utilsStatics.js:6-90

Classe d'utils dades estadístiques

Map

src/geo/map.js:10-231

Map using the mapbox backend

Parameters

  • options MapOptions
  • apiKey string The api key used by the map
  • containerId string The container id where the map will be drawn
  • styleId string The style id that will be used to draw the map

create

src/geo/map.js:25-41

Creates the map

Returns Promise<void> A Promise when the map has been loaded

mapCreate

src/geo/map.js:50-54

Creates the map object. Implementation specific

Parameters

  • resolve function The function to call when the map creation succeeds
  • reject function The function to call when the map creation fails

mapHasLoaded

src/geo/map.js:61-65

Function called when the map has finished loading. Subclasses must call it before setting any data

remove

src/geo/map.js:70-78

Removes the map from the element

mapRemove

src/geo/map.js:83-87

Removes the map object. Implementation specific

setOptions

src/geo/map.js:94-98

Sets the map options

Parameters

  • options MapOptions

setData

src/geo/map.js:105-118

Sets the data to draw

Parameters

  • data MapData

addData

src/geo/map.js:125-137

Adds data to draw to the existing data

Parameters

  • data MapData

addMapData

src/geo/map.js:145-149

Adds data to draw to the existing data. Implementation specific

Parameters

  • data MapData

removeMapData

src/geo/map.js:155-159

Removes all the data from the map. Implementation specific

subscribe

src/geo/map.js:169-173

Subscribe to a map event that happens on a layer

Parameters

  • eventName string The event name
  • layerName string The layer name
  • callback Function The callback to run when the event arrives

addControlMap

src/geo/map.js:184-188

AddControl to map map

Parameters

  • controlName string The event name
  • controlOptions object The layer name

MapboxMap

src/geo/mapboxMap.js:13-433

Extends Map

Map using the mapbox backend

Parameters

  • mapboxObject Object
  • apiKey string The api key used by the map
  • options MapOptions?
  • containerId string The container id where the map will be drawn
  • styleId string The style id that will be used to draw the map

mapCreate

src/geo/mapboxMap.js:41-53

  • **See: Map::create **

Creates the map. Do not call directly

Parameters

  • resolve function The function to call when the map creation succeeds
  • reject function The function to call when the map creation fails

mapRemove

src/geo/mapboxMap.js:60-64

  • **See: Map::remove **

Removes the map from the element. Do not call directly

addMapData

src/geo/mapboxMap.js:73-103

  • **See: Map::addData **

Adds data to draw to the map. Do not call directly

Parameters

  • data MapData

removeMapData

src/geo/mapboxMap.js:109-119

Removes all the data (sources and layers) from the map. Implementation specific

hasSourceName

src/geo/mapboxMap.js:126-130

Checks if the sourceName exists in the map

Parameters

  • sourceName

hasLayerID

src/geo/mapboxMap.js:136-140

Checks if the layerID exists in the map

Parameters

  • layerID

getStyle

src/geo/mapboxMap.js:149-153

  • **See: Map::getStyle **

Return the style map.

getPaintProperty

src/geo/mapboxMap.js:164-170

  • **See: Map::getPaintProperty **

Return mapStyle.

Parameters

  • layerid layerid
  • property property

setMapBaseLayer

src/geo/mapboxMap.js:178-198

  • **See: Map::setMapBaseLayer **

Sets the data to draw. Do not call directly

Parameters

  • baseLayerURL string
  • url baseLayr

fitBBOX

src/geo/mapboxMap.js:205-211

Fit a map to a bounding box

Parameters

  • bbox
  • pitch (optional, default 0)
  • Array bbox "bbox":"1.079053,41.290767,1.104497,41.308387"

setFilter

src/geo/mapboxMap.js:338-342

SetFilters

Parameters

  • layer
  • filter

getFilter

src/geo/mapboxMap.js:350-354

return filter getFilter

Parameters

  • layer

setAPIKey

src/geo/mapboxMap.js:376-380

Sets the API key used by the map

Parameters

subscribe

src/geo/mapboxMap.js:389-401

Subscribe to a map event that happens on a layer

Parameters

  • eventName string The event name
  • layerName string The layer name
  • callback Function The callback to run when the event arrives

queryRenderedFeatures

src/geo/mapboxMap.js:416-420

Queries the rendered features in a point or a bbox

Parameters

setCursor

src/geo/mapboxMap.js:427-431

Changes the cursor type

Parameters

Request

src/request.js:8-117

Request functions

processResponse

src/request.js:16-37

Processes a request response checking if the results are ok and resolves or rejects accordingly

Parameters

get

src/request.js:50-60

Does a get request

Parameters

  • url string The URL where the get request should be made including protocol

Returns Promise<Object>

delete

src/request.js:68-78

Does a get request

Parameters

  • url string The URL where the get request should be made

Returns Promise<Object>

post

src/request.js:87-97

Does a post request

Parameters

  • url string The URL where the post should be made
  • data any The data to send in the post request

Returns Promise<Object>

put

src/request.js:105-115

Does a post request

Parameters

  • url string The URL where the post should be made
  • data any The data to send in the post request

Returns Promise<Object>

removeItem

src/utils.js:13-19

Remove the item at the specified position

Parameters

  • items array array.
  • position number position of the element to remove, starting from 1.

Returns array return a new array, without modifying the original

applyFunctoDataArray

src/utils.js:28-38

Apply a function to each item of the array

Parameters

  • arr array array.
  • fn function function to apply to each item of the array

isEmptyObject

src/utils.js:83-96

Check if an object is empty

Parameters

Returns boolean true in case the object is empty, false otherwise

debounce

src/utils.js:105-119

Debounce function for more efficient event handling

Parameters

Returns function debounce function

debounceImmediate

src/utils.js:129-176

Debounce function for more efficient event handling

Parameters

  • func
  • wait
  • immediate boolean executes de function fn immediatly or not
  • fn function
  • delay number number of milisiconds of delay

Returns function debounce function

bindAll

src/utils.js:188-201

Given an array of member function names as strings, replace all of them with bound versions that will always refer to context as this. This is useful for classes where otherwise event bindings would reassign this to the evented object or some other value: this lets you ensure the this value always.

Parameters

Returns void