Skip to content

Commit

Permalink
#313 Add Formulae_
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jan 25, 2023
1 parent b4dd759 commit d190311
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

### System Requirements

1. Install the latest version of [Node.js v14.9.0+](https://nodejs.org/en/download/). Developed with v16.13.2.
1. Install the latest version of [Node.js v16.13.2+](https://nodejs.org/en/download/).

1. Install [PostgreSQL v10.14+](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads). Detailed [install instructions](https://www.postgresqltutorial.com/postgresql-getting-started/) for all platforms.
1. Install [PostGIS 2.5+](https://postgis.net/install/). From the above install, you can use the 'Application Stack Builder' to install PostGIS or the default [PostGIS install instructions](https://postgis.net/install/) for all platforms.
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/APIs/JavaScript/JavaScript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: page
title: JavaScript API
permalink: /apis/javascript
has_children: true
nav_order: 4
parent: APIs
---
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
layout: page
title: JavaScript API
title: JavaScript API OFF
permalink: /apis/javascript
parent: APIs
parent: APIsh
---

# JavaScript API
Expand Down
185 changes: 185 additions & 0 deletions docs/pages/APIs/JavaScript/Utils/Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
layout: page
title: Utils
permalink: /apis/javascript/utils
parent: JavaScript API
grand_parent: APIs
---

# JavaScript API Utils

The `src/essence/mmgisAPI/mmgisAPI.js` file exposes functions that can be called using the global `window.mmgisAPI` object.

#### _Contents_

- [Layer Control](#layer-control)
- [clearVectorLayer(layerUUID)](#clearvectorlayerlayeruuid)
- [updateVectorLayer(layerUUID, inputData)](#updatevectorlayerlayeruuid-inputdata)
- [trimVectorLayerKeepBeforeTime(layerUUID, keepBeforeTime, timePropPath)](#trimvectorlayerkeepbeforetimelayeruuid-keepbeforetime-timeproppath)
- [trimVectorLayerKeepAfterTime(layerUUID, keepBeforeTime, timePropPath)](#trimvectorlayerkeepaftertimelayeruuid-keepbeforetime-timeproppath)
- [keepFirstN(layerUUID, keepLastN)](#keepfirstnlayeruuid-keeplastn)
- [keepLastN(layerUUID, keepLastN)](#keeplastnlayeruuid-keeplastn)
- [trimLineString(layerUUID, time, timeProp, trimN, startOrEnd)](#trimlinestringlayeruuid-time-timeprop-trimn-startorend)
- [appendLineString(layerUUID, inputData, timeProp)](#appendlinestringlayeruuid-inputdata-timeprop)
- [reloadLayer(layer, evenIfOff, evenIfControlled)](#reloadlayerlayer-evenifoff-evenifcontrolled)
- [asLayerUUID(uuid)](#asLayerUUIDuuid)
- [Time Control](#time-control)
- [toggleTimeUI(visibility)](#toggletimeuivisibility)
- [setTime(startTime, endTime, isRelative, timeOffset, currentTime)](#settimestarttime-endtime-isrelative-timeoffset-currenttime)
- [setLayerTime(layer, startTime, endTime)](#setlayertimelayer-starttime-endtime)
- [getTime()](#gettime)
- [getStartTime()](#getstarttime)
- [getEndTime()](#getendtime)
- [getLayerStartTime(layer)](#getlayerstarttimelayer)
- [getLayerEndTime(layer)](#getlayerendtimelayer)
- [reloadTimeLayers()](#reloadtimelayers)
- [setLayersTimeStatus(color)](#setlayerstimestatuscolor)
- [setLayerTimeStatus(layer, color)](#setlayertimestatuslayer-color)
- [updateLayersTime()](#updatelayerstime)
- [Event Listeners](#event-listeners)
- [addEventListener(eventName, functionReference)](#addeventlistenereventname-functionreference)
- [removeEventListener(eventName, functionReference)](#removeeventlistenereventname-functionreference)
- [Map Feature Information](#map-feature-information)
- [map](#map)
- [featuresContained()](#featurescontained)
- [getActiveFeature()](#getactivefeature)
- [selectFeature(layerUUID, options)](#selectfeaturelayeruuid-options)
- [getVisibleLayers()](#getvisiblelayers)
- [getLayers()](#getlayers)
- [getLayerConfigs(match)](#getlayerconfigsmatch)
- [toggleLayer(layerUUID, on)](#toggleLayerlayeruuid-on)
- [Miscellaneous Features](#miscellaneous-features)
- [writeCoordinateURL()](#writecoordinateurl)
- [onLoaded(onLoadCallback)](#onloadedonloadcallback)
- [getActiveTool()](#getactivetool)
- [project(lnglat)](#projectlnglat)
- [unproject(xy)](#unprojectxy)

---

GeoJSONStringify(geojson)
RGBAto32RGBAto32(rgba)
areaOfTriangle(aX, aY, bX, bY, cX, cY)
arrayAverage(array, key)
arrayUnique(array)
asByteString(byte)
bearingBetweenTwoLatLngs(lat1, lng1, lat2, lng2)
bearingFromGreatArcDistance(distance)
boundingBoxToFeature(nE, sW)
bracketReplace(str, obj, replace)
calcHeightLine(i, Za, Zo)
calcPolygonArea(vertices)
chunkArray(arr, size)
circleFeatureFromTwoLngLats(lnglatCenter, lnglatRadius, steps, crs)
cleanString(str)
clone(obj)
cloneCanvas(oldCanvas)
closestPoint(p, pts)
closestToSegment(p, v, w)
closestToSegments(p, lines)
colorCodeToColor(code)
coordinateDepthTraversal(array, onEachLeaf, \_path)
copyToClipboard(text)
csvToJSON(csv)
decodeFloat(binary)
degreesToMeters(degrees)
destinationFromBearing(lat, lng, bearing, distance, round_off = undefined)
diff(arr1, arr2)
distanceFormula(x1, y1, x2, y2)
doBoundingBoxesIntersect(a, b)
doubleToTwoFloats(double)
download(filepath)
downloadArrayAsCSV(headers, array, exportName)
downloadCanvas(canvasId, name, callback)
downloadObject(exportObj, exportName, exportExt)
dynamicSort(property)
enumerate(obj)
f32round(x)
fileNameFromPath(path)
geoJSONFeatureMetersToDegrees(feature)
geojsonAddSpatialProperties(geojson)
getBase64Transparent256Tile()
getBaseGeoJSON(featuresArray)
getBrowser()
getColorFromRangeByPercent(colors, percent, asRGBString)
getColorScale(i, s, l)
getCookieValue(a)
getEarthToPlanetRatio()
getExtension(string)
getFeatureArea(feature, displayFriendly)
getFeatureLatLngs(feature)
getFeatureLength(feature, displayFriendly)
getImageData(image)
getIn(obj, keyArray, notSetValue)
getKeyByValue(obj, value)
getLatLngs(layer)
getMinMaxOfArray(arrayOfNumbers)
getPixel(imagedata, x, y)
getPtSomeDistBetween2OtherPts(x0, y0, x1, y1, d)
getSafeName(name)
getTextShadowString(color, opacity, weight)
getTimeStartsBetweenTimestamps (startTime, endTime, unit)
getValueByKeyCaseInsensitive(key, obj)
hexToRGB(hex)
hexToRGBA(hex, a)
identicalElements(arr)
inclinationBetweenTwoLatLngs(lat1, lng1, elev1, lat2, lng2, elev2)
intToRGB(i)
interpolatePointsPerun(p1, p2, p)
invertGeoJSONLatLngs(feature)
isColor(strColor)
isEmpty(obj)
isEqual(obj1, obj2, isSimple)
isInZoomRange(minZoom, maxZoom, zoom)
isNoDataElev(data)
isStringNumeric(str)
isUrlAbsolute(url)
isValidUrl(str)
lat2tileUnfloored(lat, zoom)
latlonzoomToTileCoords(lat, lon, zoom)
lineOfSight1D(heightArray, observerHeight, targetHeight)
linearScale(domain, range, value)
lngLatDistBetween(lon1, lat1, lon2, lat2)
lnglatsToDemtileElevs(lnglats, demtilesets, callback)
lon2tileUnfloored(lon, zoom)
lonLatToVector3nr(lon, lat, height)
makeColorGrid(x, y)
marsEarthSurfaceAreaRatio()
metersToDegrees(meters)
mod(n, m)
monthNumberToName(monthNumber)
noNullLength(arr)
numberToWords(n)
objectArrayIndexOfKeyWithValue(objectArray, key, value)
pad(num, size)
parseColor(color)
pointsInPoint(point, layers)
populateUrl(url, xyz, invertY)
prettifyName(name)
range (a, b)
removeDuplicatesInArray(arr)
removeDuplicatesInArrayOfObjects(arr)
rgb2hex(rgb)
rgbObjToStr(rgb, hasAlpha)
rgbToArray(rgb)
rotatePoint(pt, center, angle)
rotatePoint3D(pt, angle, center)
round(number, decimals = 0)
sanitize(str)
scaleImageInHalf(image, width, height)
setRadius(which, radius)
sortGeoJSONFeatures(geojson)
stitchArrays(keyArray, valueArray)
stringToColor(str)
stringToColor2(stringInput)
subdivideLine(line, meters)
tileContains(xyz, z, useLast)
tileIsContained(xyzContainer, xyzContained, useLast)
tilesWithin(xyz, z)
timestampToDate(timestamp)
toEllipse(lnglat, axes, crs, options)
toEllipsisString(str, length)
toHost()
toHostForceLanding()
uniqueArray(arr)
validTextColour(stringToTest)
2 changes: 1 addition & 1 deletion docs/pages/Setup/Installation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nav_order: 1

### System Requirements

1. Install the latest version of [Node.js v14.9.0+](https://nodejs.org/en/download/).
1. Install the latest version of [Node.js v16.13.2+](https://nodejs.org/en/download/).

1. Install [PostgreSQL v10.14+](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads). Detailed [install instructions](https://www.postgresqltutorial.com/postgresql-getting-started/) for all platforms.
1. Install [PostGIS 2.5+](https://postgis.net/install/). From the above install, you can use the 'Application Stack Builder' to install PostGIS or the default [PostGIS install instructions](https://postgis.net/install/) for all platforms.
Expand Down
11 changes: 0 additions & 11 deletions src/essence/Basics/Formulae_/Formulae_.js
Original file line number Diff line number Diff line change
Expand Up @@ -2010,17 +2010,6 @@ var Formulae_ = {
//prettier-ignore
return 'hsl(' + colorScaleA[i % colorScaleA.length] + ', ' + s + ', ' + l + ')'
},
ASCIIProduct(str) {
if (str == null) return 0
let product = 1
for (let i = 0; i < str.length; i++) product += str.charCodeAt(i)
return product
},
everyOtherChar(str) {
let newStr = ''
for (let i = 0; i < str.length; i += 2) newStr += str[i]
return newStr
},
cloneCanvas(oldCanvas) {
//create a new canvas
var newCanvas = document.createElement('canvas')
Expand Down
10 changes: 6 additions & 4 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ const L_ = {
* Converts lnglat geojsons into the primary coordinate type.
* @param {object} geojson - geojson object or geojson feature
*/
convertGeoJSONLngLatsToPrimaryCoordinates(geojson) {
convertGeoJSONLngLatsToPrimaryCoordinates(geojson, forceType) {
if (geojson.features) {
const nextGeoJSON = JSON.parse(JSON.stringify(geojson))
const convertedFeatures = []
Expand All @@ -1694,7 +1694,8 @@ const L_ = {
const elev = coords[2]
converted = L_.Coordinates.convertLngLat(
coords[0],
coords[1]
coords[1],
forceType
)
if (elev != null) converted[2] = elev
return converted
Expand All @@ -1718,7 +1719,8 @@ const L_ = {
const elev = coords[2]
converted = L_.Coordinates.convertLngLat(
coords[0],
coords[1]
coords[1],
forceType
)
if (elev != null) converted[2] = elev
return converted
Expand Down Expand Up @@ -2479,7 +2481,7 @@ const L_ = {
clearVectorLayerInfo: function () {
// Clear the InfoTools data
const infoTool = ToolController_.getTool('InfoTool')
if (infoTool.hasOwnProperty('clearInfo')) {
if (infoTool && infoTool.hasOwnProperty('clearInfo')) {
infoTool.clearInfo()
}

Expand Down
3 changes: 3 additions & 0 deletions src/essence/mmgisAPI/mmgisAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ var mmgisAPI = {
* @param {boolean} - on - (optional) Set true if the visibility should be on or false if visibility should be off. If not set, the current visibility state will switch to the opposite state.
*/
toggleLayer: mmgisAPI_.toggleLayer,

// Formulae_
utils: { ...F_ },
}

window.mmgisAPI = mmgisAPI
Expand Down

0 comments on commit d190311

Please sign in to comment.