- ICGC Commons
- GeoCommons
- GeoUtils
- Colorizator
- ArrayStatics
- BridgeStatics
- CSVStatics
- GeoJSONStatistics
- UtilsStatics
- Map
- MapboxMap
- Request
- removeItem
- applyFunctoDataArray
- isEmptyObject
- debounce
- debounceImmediate
- bindAll
Common useful geo functions.
Classe geoCommons
getFirstSymbolLayerId form MapboxStyle.
layers
object Input style object map.getLayers().
Returns object layer.
Returns object geojson.
Returns object point geojson.
GetRastersSources from Mapbox Style.
Returns object rasterSources
Simplify from Mapbox Style.
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
X,Y coordinates inside Catalonia BBOX.
Returns boolean
Check is a Source is Used.
source
object Input style object map.getSources().layersArray
object Input stlke object map.getLayers().
Returns boolean
removeAccents form MapboxStyle.
s
string
string I.
Returns string string.
isWithinCat check if a bbox is within Catalonia.
bbox
array Input map.getBounds().toArray() or [1.4622,41.7139 ,1.8117 ,42.0330].
Returns boolean
Classe d'utils operacions geo
src/color/colorizator.js:16-349
A Colorizator
object represents a given latitude and longitude coordinates.
const color = new Colorizator();
src/color/colorizator.js:36-50
Get Random color from Array
Returns string this
src/color/colorizator.js:58-71
Get Random color hex
Returns color this
src/color/colorizator.js:120-125
Get Chormaarray color from brewer palette
Returns color this
src/color/colorizator.js:135-147
Get Chormaarray form two colors
Returns color this
src/color/colorizator.js:155-161
Gets de HSL contrast color from a given color
hex
string
Returns string this
src/color/colorizator.js:210-215
Get Chormaarray color from brewer palette
Returns color this
src/color/colorizator.js:232-270
Get HTML palete color
numberPalettes
number //number of palletes max this.maxBrewerPalettesnumRangs
number //number of colors for each palette max this.maxBrewerPalettes
Returns color this
src/color/colorizator.js:282-347
Generate HTML legend palete color
Returns color this
src/geo/arrayStatics.js:16-102
Generate basic statistics from Array.
arrayColumn
Array
Sample;
const ArrayStatics = new ArrayStatics(arrayColumn);
Returns Array Unique Values
Returns array
Returns basics stats
decimals
number
Returns object
Returns stats form RangeNum and colors Array
Returns object
src/geo/bridgeStatics.js:12-122
A BridgeStatics
object represents a given latitude and longitude coordinates.
arrayColumn
Array<number>lat
number Latitude, measured in degrees.lon
number Longitude, measured in degrees.
var ll = new BridgeStatics(42.10376, 1.84584);
Generate basic statistics from CSV array.
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);
Returns Array Unique Values
Returns array
Returns stats form RangeNum and colors Array
Returns object
Returns array from csv properties field Used in the constructor
Returns array this
src/geo/geoJSONStatics.js:16-175
Return basic stats from a GeoJson data a title field from geojson properties.
geoJSON
objectkeyField
stringnull
geoJSON {geoJSON:geoJSON, filedName: keyField, arrayColumn: arrayColumn}
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)
src/geo/geoJSONStatics.js:49-54
Returns Array Unique Values
Returns array
src/geo/geoJSONStatics.js:65-84
Returns stats form RangeNum and colors Array
Returns object
src/geo/geoJSONStatics.js:95-141
Returns array from geojson properties field Used in the constructor
keyField
stringGeoJSON
objectforceNumber
boolean (optional, defaultfalse
)keyFiled
stringgeojson
object
Returns array this
src/geo/geoJSONStatics.js:154-173
Returns array from geojson properties field, filtered by a value
keyField
stringGeoJSON
objectkeyFilter
string //Filter fieldvalueFilter
stringkeyFiled
stringgeojson
object
Returns array this
Classe d'utils dades estadístiques
Map using the mapbox backend
options
MapOptionsapiKey
string The api key used by the mapcontainerId
string The container id where the map will be drawnstyleId
string The style id that will be used to draw the map
Creates the map
Returns Promise<void> A Promise when the map has been loaded
Creates the map object. Implementation specific
resolve
function The function to call when the map creation succeedsreject
function The function to call when the map creation fails
Function called when the map has finished loading. Subclasses must call it before setting any data
Removes the map from the element
Removes the map object. Implementation specific
Sets the map options
options
MapOptions
Sets the data to draw
data
MapData
Adds data to draw to the existing data
data
MapData
Adds data to draw to the existing data. Implementation specific
data
MapData
Removes all the data from the map. Implementation specific
Subscribe to a map event that happens on a layer
eventName
string The event namelayerName
string The layer namecallback
Function The callback to run when the event arrives
AddControl to map map
Extends Map
Map using the mapbox backend
mapboxObject
ObjectapiKey
string The api key used by the mapoptions
MapOptions?containerId
string The container id where the map will be drawnstyleId
string The style id that will be used to draw the map
- **See: Map::create **
Creates the map. Do not call directly
resolve
function The function to call when the map creation succeedsreject
function The function to call when the map creation fails
- **See: Map::remove **
Removes the map from the element. Do not call directly
- **See: Map::addData **
Adds data to draw to the map. Do not call directly
data
MapData
Removes all the data (sources and layers) from the map. Implementation specific
Checks if the sourceName exists in the map
sourceName
Checks if the layerID exists in the map
layerID
- **See: Map::getStyle **
Return the style map.
- **See: Map::getPaintProperty **
Return mapStyle.
layerid
layeridproperty
property
- **See: Map::setMapBaseLayer **
Sets the data to draw. Do not call directly
baseLayerURL
stringurl
baseLayr
Fit a map to a bounding box
bbox
pitch
(optional, default0
)Array
bbox "bbox":"1.079053,41.290767,1.104497,41.308387"
SetFilters
layer
filter
return filter getFilter
layer
Sets the API key used by the map
apiKey
string
Subscribe to a map event that happens on a layer
eventName
string The event namelayerName
string The layer namecallback
Function The callback to run when the event arrives
Queries the rendered features in a point or a bbox
Changes the cursor type
name
string
Request functions
Processes a request response checking if the results are ok and resolves or rejects accordingly
Does a get request
url
string The URL where the get request should be made including protocol
Does a get request
url
string The URL where the get request should be made
Does a post request
url
string The URL where the post should be madedata
any The data to send in the post request
Does a post request
url
string The URL where the post should be madedata
any The data to send in the post request
Remove the item at the specified position
Returns array return a new array, without modifying the original
Apply a function to each item of the array
Check if an object is empty
obj
Object
Returns boolean true in case the object is empty, false otherwise
Debounce function for more efficient event handling
Returns function debounce function
Debounce function for more efficient event handling
func
wait
immediate
boolean executes de function fn immediatly or notfn
functiondelay
number number of milisiconds of delay
Returns function debounce function
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.
Returns void