Class: Util

cercalia.Util


Static util functions.

new cercalia.Util()

src/cercalia/util.js, line 21

Methods

cercalia.Util.areaMetricToImperial(area){string}

src/cercalia/util.js, line 423
Name Type Description
area number

Area in ha

Returns:
Area in acrees.

cercalia.Util.convertDmsToDecimal(input){string}

src/cercalia/util.js, line 556

Convert degrees minutes seconds to decimal format.

Name Type Description
input string

Input string. Format examples: 40° 03' 49.3" N, 3° 24' 42.2" W, 40°03'49"N 3°24'42" W

Returns:
Decimal format. Example 41.431,2.41431

cercalia.Util.convertLatLngToDms(position){string}

src/cercalia/util.js, line 546

Convert degrees minutes seconds to decimal format.

Name Type Description
position cercalia.LonLat

Output string. Format examples: 40° 03' 49.3" N, 3° 24' 42.2" W, 40°03'49"N 3°24'42" W

Returns:
Output string. Format examples: 40° 03' 49.3" N, 3° 24' 42.2" W, 40°03'49"N 3°24'42" W

cercalia.Util.createCircleGeometry(center, radius, opt_isPolygon){ol.geom.Polygon|ol.geom.Circle}

src/cercalia/util.js, line 514
Name Type Description
center cercalia.LonLat

Center.

radius number

Radius in meters.

isPolygon boolean

If true, it creates a circular polygon ol.geom.Polygon, else creates a Circle ol.geom.Circle. Default false.

Returns:
Obtains Circle geometry or Circular polygon geometry.

cercalia.Util.distanceMetricToImperial(distance){string}

src/cercalia/util.js, line 406
Name Type Description
distance number

Distance in meters.

Returns:
distanceImp Distance imperial format string.

cercalia.Util.distanceMetricToNauticMiles(distance){string}

src/cercalia/util.js, line 433
Name Type Description
distance number

Distance in meters

Returns:
Nautic miles

cercalia.Util.distanceTo(coordA, coordB){number}

src/cercalia/util.js, line 256

Calculation distance between two coordinates.

Name Type Description
coordA cercalia.LonLat

Coordinate 1,

coordB cercalia.LonLat

Coordinate 2.

Returns:
distance between two coordinates.

cercalia.Util.downloadKmlFromWkt(wkt, otp_filename)

src/cercalia/util.js, line 384

SaveW route as KML.

Name Type Description
wkt string

WKT.

otp_filename string

Filename.

cercalia.Util.downloadXmlToFile(strXML, filename)

src/cercalia/util.js, line 442
Name Type Description
strXML string

XML in string format

filename string

Filename to dowonload.

cercalia.Util.geofencing(polygon, lonLat){boolean}

src/cercalia/util.js, line 154

Returns true if the coordinate is inside polygon. Polygon must be in WKT format.

Name Type Description
polygon string

WKT String de un poligono

lonLat cercalia.LonLat

Punto

Returns:
Return true if position is inside polygon.

cercalia.Util.geometryToWKT(geometry, projectionCode){string}

src/cercalia/util.js, line 88

Transfrom geometry to WKT EPSG:4326.

Name Type Description
geometry ol.geom.Geometry

Object geometry ol.Geometry.

projectionCode string

Projection code

Returns:
WKT

cercalia.Util.getCircleData(feature){cercalia.CircleData}

src/cercalia/util.js, line 489

Obtains circle radius and circle center. {center: cercalia.LonLat, radius: number}

Name Type Description
feature cercalia.Feature

Feature.

Returns:
data Circle data

cercalia.Util.getClosestFeatureByPosition(position, features){cercalia.Feature}

src/cercalia/util.js, line 234

Funcion para obtener de una lista de features cercalia.Feature la feature mas cercana respecto a una cercalia.LonLat.

Name Type Description
position cercalia.LonLat

Position

features

Features

Returns:
Feature

cercalia.Util.getClosestLonLatOfFeature(position, feature){cercalia.LonLat}

src/cercalia/util.js, line 217

Funcionn para obtener la coordenada mas cercana de cercalia.Feature respecto cercalia.LonLat. Puede ser una feature del tipo Point, LineString, Polygon.

Name Type Description
position cercalia.LonLat

Position

feature cercalia.Feature

Feature

Returns:
Coordinate of closest feature.

cercalia.Util.getDistanceFromFeature(position, feature){number}

src/cercalia/util.js, line 199

Obtiene la distancia en metro de una cercalia.LonLat respecto el punto más cercano de cercalia.Feature. Puede ser una feature del tipo Point, LineString, Polygon.

Name Type Description
position cercalia.LonLat

Coordenada de referencia

feature cercalia.Feature

Feature. No hace falta que esté pintada en el mapa para hacer este cálculo.

Returns:
Distancia en metros

cercalia.Util.getHexFromRgb(rgb){string}

src/cercalia/util.js, line 45

Convert hexadecimal to RGB color

Name Type Description
rgb string

Rgb Color

Returns:
rgba color.

cercalia.Util.getPartialLinestring(feature, startfraction, endfraction){string|null}

src/cercalia/util.js, line 599

It obtains a partial line in WKT format specifying minimum and maximum percentages in base 1.

Name Type Description
feature cercalia.Feature | ol.Feature

Feature

startfraction number

Min fraction [0..1]

endfraction number

Max fraction [0..1]

Returns:
WKT

cercalia.Util.getProximityFormattedAddress(data){string}

src/cercalia/util.js, line 464

Get formatted adrress from proximity server data response.

Name Type Description
data

Proximity result

Name Type Description
cercalia cercaliax.ProximityResultData

Required.

Returns:
Formatted address.

cercalia.Util.splitWktGeomCollection(wktGeomCollection){Array.<string>|null}

src/cercalia/util.js, line 313
Name Type Description
wktGeomCollection string

wkt WKT of geomCollection

Returns:
array of WKT in geomcollection

cercalia.Util.transformColor2rgba(hexcolor, opacity){string|null}

src/cercalia/util.js, line 32

Convert color and opacity to RGBA format.

Name Type Description
hexcolor string

Color in hexadecimal. P.e: #ff0001

opacity number

Opacity. Decimal value 0 to 1.

Returns:
color p.e: rgba(0, 0, 255, 0.1)

cercalia.Util.transformFeatureToKML(feature, opt_srs){string}

src/cercalia/util.js, line 364
Name Type Description
feature cercalia.Feature

Feature

srs string

SRS system. Default: cercalia.proj.EPSG4326.

Returns:
KML object.

cercalia.Util.transformWKT(wkt, projectionSrc, projectionDst){string}

src/cercalia/util.js, line 116

Transform WKT string to another projection.

Name Type Description
wkt string

WKT http://es.wikipedia.org/wiki/Well_Known_Text

projectionSrc string

Projection WKT origin

projectionDst string

Projection WKT destination

Returns:
Geometry in WKT format transformed.

cercalia.Util.transformWktToKML(wkt, opt_srs){string}

src/cercalia/util.js, line 343
Name Type Description
wkt string

Geometry in WKT format.

srs string

SRS system. Default: cercalia.proj.EPSG4326.

Returns:
KML object.

cercalia.Util.wktToGeometry(wkt){ol.geom.Geometry|undefined}

src/cercalia/util.js, line 101
Name Type Description
wkt string

WKT http://es.wikipedia.org/wiki/Well_Known_Text

Returns:
Geometry OL3 ol.geom.Geometry