Module: cercaliagl/util


Javascript ES5

const result = cercaliagl.util.functionName(arg1, arg2);

Methods

module:cercaliagl/util.areaMetricToImperial(area){string}

Convert area metric to imperial.

Name Type Description
area number

Area in ha

Returns:
Area in acrees.

module:cercaliagl/util.checkPolygonSegmentIntersection(feature){boolean}

Name Type Description
feature GeoJSONFeature

Polygon geojson feature

Returns:
Return true if a polygon feature has intersections

module:cercaliagl/util.convertDmsToDecimal(input){string}

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

module:cercaliagl/util.createCircleGeometry(center, radius, vertices){module:cercaliagl/util~GeometryGeoJSON}

Create circle geometry given a center, a radius and optionally number of vertices.

Name Type Description
center module:cercaliagl/LonLat~LonLat

Center.

radius number

Radius in meters

vertices number

Number of vertices. Default 64.

Returns:
geometry

module:cercaliagl/util.createMaplibreSimpleMarker(element){maplibregl.Marker}

Name Type Description
element string

HTML string

Returns:
Marker

module:cercaliagl/util.distanceBetweenPoints(coordA, coordB){number}

Name Type Description
coordA Array.<number>

Position 1

coordB Array.<number>

Position 2

Returns:
Distance

module:cercaliagl/util.distanceMetricToImperial(distance){string}

Convert distance metric to imperial.

Name Type Description
distance number

Distance in meters.

Returns:
distanceImp Distance imperial format string.

module:cercaliagl/util.distanceTo(coordA, coordB){number}

Calculation distance between two coordinates.

Name Type Description
coordA module:cercaliagl/LonLat~LonLat

Coordinate 1,

coordB module:cercaliagl/LonLat~LonLat

Coordinate 2.

Returns:
distance between two coordinates.

module:cercaliagl/util.downloadKmlFromWkt(wkt, filename)

SaveW route as KML.

Name Type Description
wkt string

WKT.

filename string

Filename.

module:cercaliagl/util.downloadXmlToFile(strXML, filename)

Download XML file passing a XML string.

Name Type Description
strXML string

XML in string format

filename string

Filename to download.

module:cercaliagl/util.geofencing(polygon, lonLat){boolean}

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

Name Type Description
polygon string

Polygon WKT string

lonLat module:cercaliagl/LonLat~LonLat

Coordinate

Returns:
Return true if position is inside polygon.

module:cercaliagl/util.geojsonToWKT(geojson){string}

Transform GeoJSON format to WKT.

Name Type Description
geojson Object

GeoJSON - https://geojson.org/

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

module:cercaliagl/util.getAnchorStringEquivalent(){Array.<number>}

Returns:
Anchor equivalent

module:cercaliagl/util.getClosestFeatureByPosition(position, features){module:cercaliagl/Feature~Feature}

Get closest feature by a position given a position and a list of features.

Name Type Description
position module:cercaliagl/LonLat~LonLat

Position

features Array.<module:cercaliagl/Feature~Feature>

Features

Returns:
Feature

module:cercaliagl/util.getClosestLonLatOfFeature(position, feature){module:cercaliagl/LonLat~LonLat}

Get closest position of a feature given a coordinate (position)

Name Type Description
position module:cercaliagl/LonLat~LonLat

Position

feature module:cercaliagl/Feature~Feature

Feature

Returns:
Coordinate of closest feature

module:cercaliagl/util.getLinestringIntersectionsWithPolygon(polygonFeature, lineFeature){Array.<GeoJSONFeature>}

Find intersections between a polygon and a linestring

Name Type Description
polygonFeature module:cercaliagl/Feature~Feature

Polygon geojson feature 1

lineFeature module:cercaliagl/Feature~Feature

Linestring geojson feature 2

Returns:
Return intersection feature

module:cercaliagl/util.getPartialLinestring(feature, startfraction, endfraction){string|null}

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

Name Type Description
feature module:cercaliagl/Feature~Feature

Feature

startfraction number

Min fraction [0..1]

endfraction number

Max fraction [0..1]

Returns:
WKT

module:cercaliagl/util.getProximityFormattedAddress(data){string}

Get formatted adrress from proximity server data response.

Name Type Description
data

Proximity result

Name Type Description
cercalia module:cercaliagl/servers~ProximityResultData
Returns:
Formatted address.

module:cercaliagl/util.toRadians(angle){number}

Convert degrees to radiants.

Name Type Description
angle number

Angle in degrees

Returns:
Angle in radiants.

module:cercaliagl/util.transformWKT(wkt, projectionSrc, projectionDst){string}

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.

module:cercaliagl/util.transformWktToKML(wkt, opt_srs){string}

Name Type Description
wkt string

Geometry in WKT format.

srs string

SRS system. Default: Proj.EPSG4326.

Returns:
KML object.

module:cercaliagl/util.wktLinestringToPolygonBuffered(wkt, radius)

Transform linestring to polygon adding a buffer.

Name Type Description
wkt string

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

radius number

Radius. Default 10.

module:cercaliagl/util.wktToGeometry(wkt){GeoJSON}

WKT to Geometry.

Name Type Description
wkt string

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

Returns:
GeoJSON - https://geojson.org/

Type Definitions

GeometryGeoJSON{Object}

Properties:
Name Type Description
type string

Geometry type

coordinates Array.<number> | Array.<Array.<number>> | Array.<Array.<Array.<number>>>