Telogis.GeoBase.MathUtil |
Contains mathematical utility functions for manipulating spatial data.
Name | Description |
---|---|
bearing (LatLon from, LatLon to) | Finds the initial bearing that one would have to travel in to move in a straight line along a great-circle arc from one location to another. JavaScript var bearing = Telogis.GeoBase.MathUtil.bearing( new Telogis.GeoBase.LatLon(33.587137,-117.742878), new Telogis.GeoBase.LatLon(33.575037,-117.724762) ); alert('Heading from->to is '+bearing+' degrees');
Number - The bearing (degrees true) to initially travel in from MathUtil.bearing.from to MathUtil.bearing.to. That is, 0 degrees indicates direct north, 90 degrees due east, and so on. |
bearingToCompass (Number bearing) | Finds the compass point represented by a certain bearing angle. JavaScript var bearing = 135; var compass = Telogis.GeoBase.MathUtil.bearingToCompass(bearing); alert(bearing+' degrees converts to a compass direction of '+compass);
String - The compass direction closest to MathUtil.bearingToCompass.bearing. This may be any of "N", "NE", "E", "SE", "S", "SW", "W", or "NW". |
clamp (Number x, Number minValue, Number maxValue) | Finds the closest value to a specified integer that falls within a specified range. Arguments
Number - If MathUtil.clamp.x lies between MathUtil.clamp.minValue and MathUtil.clamp.maxValue, the result is MathUtil.clamp.x. Otherwise, the result is MathUtil.clamp.minValue if MathUtil.clamp.x is less than MathUtil.clamp.minValue, or MathUtil.clamp.maxValue if MathUtil.clamp.x is greater than MathUtil.clamp.maxValue. |
convertSpeedUnits (Number value, String fromUnits, String toUnits) | Converts between one kind of SpeedUnit and another. JavaScript var val = 10; var conv = Telogis.GeoBase.MathUtil.convertSpeedUnits( val, Telogis.GeoBase.SpeedUnit.MilesPerHour, Telogis.GeoBase.SpeedUnit.KilometersPerHour ); alert(val + ' mph equates to ' + conv + ' kmh');
Number - MathUtil.convertSpeedUnits.value represented in MathUtil.convertSpeedUnits.toUnits. |
convertTimeUnits (Number value, String fromUnits, String toUnits) | Converts between one kind of TimeUnit and another. JavaScript var val = 10; var conv = Telogis.GeoBase.MathUtil.convertTimeUnits( val, Telogis.GeoBase.TimeUnit.MINUTES, Telogis.GeoBase.TimeUnit.SECONDS ); alert(val + ' minutes equates to ' + conv + ' seconds');
Number - MathUtil.convertTimeUnits.value represented in MathUtil.convertTimeUnits.toUnits. |
convertUnits (Number value, String fromUnits, String toUnits) | Converts between one kind of DistanceUnit and another. JavaScript var val = 10; var conv = Telogis.GeoBase.MathUtil.convertUnits( val, Telogis.GeoBase.DistanceUnit.MILES, Telogis.GeoBase.DistanceUnit.KILOMETERS ); alert(val + ' Miles equates to ' + conv + ' Kilometers');
Number - MathUtil.convertUnits.value represented in MathUtil.convertUnits.toUnits. |
displace (LatLon from, Number dist, Number bearing, String units) | Constructs the coordinate point that is located at a displacement of a certain distance (along a shortest great-circle arc) and bearing from a given LatLon. JavaScript // Locate a point 10 miles from the specified LatLon at a bearing // of 90 degrees var displace = Telogis.GeoBase.MathUtil.displace( new Telogis.GeoBase.LatLon(33.587137,-117.742878), 10, 90, Telogis.GeoBase.DistanceUnit.MILES ); alert(displace);
LatLon - A new LatLon location the specified distance from MathUtil.displace.from and at the specified bearing relative to it. |
distance (LatLon from, LatLon to, String units) | Finds the distance covered by traveling in a great-circle from one latitude-longitude location to another, in the specified units. JavaScript var dist = Telogis.GeoBase.MathUtil.distance( new Telogis.GeoBase.LatLon(33.587137,-117.742878), new Telogis.GeoBase.LatLon(33.575037,-117.724762), Telogis.GeoBase.DistanceUnit.KILOMETERS ); alert('Point-to-point distance is ' + dist + ' Kilometers');
Number - The great-circle distance of MathUtil.distance.to from MathUtil.distance.from, measured in MathUtil.distance.units. |
positiveModulo (Number value, Number base) | Finds the positive modulo value of a given number with respect to a certain base. This differs from the built-in modulo operation in that using the % will return a negative number when used with negative values. Arguments
Number - The smallest positive number congruent to MathUtil.positiveModulo.value, relative to MathUtil.positiveModulo.base. |
toDegrees (Number radians) | Converts an angle from radians to degrees. Arguments
Number - MathUtil.toDegrees.radians represented in degrees. |
toRadians (Number degrees) | Converts an angle from degrees to radians. Arguments
Number - MathUtil.toRadians.degrees represented in radians. |