New documentation. authored by Ramices Silva's avatar Ramices Silva
```markdown
# Earth Engine Utilities
This code file provides utility functions for geographic calculations using the Google Earth Engine (GEE) service. It includes functions to compute displacement and bearing between geographic coordinates.
## Dependencies
- Google Earth Engine (GEE) service
## Constants
- `EARTHS_RADIUS`: The radius of the Earth in meters (6371000 meters).
## Functions
### `toDegrees(lng, lat)`
Converts longitude and latitude from radians to degrees.
#### Parameters
- `lng` (ee.Number): Longitude in radians.
- `lat` (ee.Number): Latitude in radians.
#### Returns
- `Array`: An array containing the converted longitude and latitude in degrees.
### `toRadians(value)`
Converts a value from degrees to radians.
#### Parameters
- `value` (Number): The value in degrees.
#### Returns
- `ee.Number`: The value converted to radians.
### `computeDisplacement(lng, lat, theta, distance)`
Computes the new geographic coordinates after moving a certain distance in a specified direction from a starting point.
#### Parameters
- `lng` (Number): Longitude of the starting point in degrees.
- `lat` (Number): Latitude of the starting point in degrees.
- `theta` (Number): Bearing angle in degrees.
- `distance` (Number): Distance to move in meters.
#### Returns
- `Array`: An array containing the new longitude and latitude in degrees.
#### Example Usage
```javascript
const newCoords = computeDisplacement(-73.935242, 40.730610, 45, 1000);
console.log(newCoords); // [newLng, newLat]
```
### `computeBearing(lng1, lat1, lng2, lat2)`
Computes the bearing angle between two geographic coordinates.
#### Parameters
- `lng1` (Number): Longitude of the first point in degrees.
- `lat1` (Number): Latitude of the first point in degrees.
- `lng2` (Number): Longitude of the second point in degrees.
- `lat2` (Number): Latitude of the second point in degrees.
#### Returns
- `ee.Number`: The bearing angle in radians.
#### Example Usage
```javascript
const bearing = computeBearing(-73.935242, 40.730610, -74.0060, 40.7128);
console.log(bearing); // Bearing angle in radians
```
## Edge Cases and Assumptions
- Assumes input coordinates are in degrees.
- Assumes the Earth is a perfect sphere with a radius of 6371000 meters.
- The functions rely on the Google Earth Engine (GEE) service for numerical operations.
## References
- [Google Earth Engine API](https://developers.google.com/earth-engine)
```