Description:
The Calculate method performs mathematical calculations
based on a source location and a target location.
This is a synchronous method.
Syntax:
Calculate(parameters:Object):Object
Arguments:
parameters:
This is an object that specifies the mathematical operation to perform and the input values to use in the operation. For more information about the object properties and how to define them, see section Calculation parameters.
Return value:
The Calculate method returns an object that contains
the calculation results, an error code, and an error message.
|
Property |
Description |
Value |
|---|---|---|
|
|
This contains the results for the requested mathematical operation. The type of the value depends on the operation. |
See Calculation results. |
|
|
This is a number that specifies a predefined error code. |
|
|
|
This is a text string that describes the error. |
Remarks:
The WGS 84 datum is used to reference coordinates.
Example code:
The following sample code illustrates how to calculate the distance between specified locations:
import com.nokia.lib.Service;
var location = new Service("Service.Location", "ILocation");
var sourceDistance = {Longitude:1, Latitude:0.49, Altitude:0.5};
var destinationDistance = {Longitude:1, Latitude:0.5, Altitude:0.5};
var inParams = {MathRequest:"FindDistance", DistanceParamSource:sourceDistance, DistanceParamDestination:destinationDistance};
var outParams = location.Calculate(inParams);
if (outParams.ErrorCode == 0) {
var distance = outParams.ReturnValue;
} else {
var errorId = outParam.ErrorCode;
}