https://github.com/emanuelef/go-geo-3d
go-geo-3d implements functions to calculate distances from geospatial points considering altitude
https://github.com/emanuelef/go-geo-3d
3d geospatial-analysis geospatial-processing go
Last synced: 12 months ago
JSON representation
go-geo-3d implements functions to calculate distances from geospatial points considering altitude
- Host: GitHub
- URL: https://github.com/emanuelef/go-geo-3d
- Owner: emanuelef
- Created: 2023-06-10T15:05:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-01T12:13:53.000Z (about 2 years ago)
- Last Synced: 2025-04-10T23:42:01.495Z (about 1 year ago)
- Topics: 3d, geospatial-analysis, geospatial-processing, go
- Language: Go
- Homepage: https://emanuelef.github.io/geo-3d-website/
- Size: 33.2 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-geo-3d
[](https://github.com/emanuelef/go-geo-3d/actions/workflows/linter.yml)
[](https://github.com/emanuelef/go-geo-3d/actions/workflows/test.yml)

----
go-geo-3d is a module with zero dependencies to calculate distances of 3d geospatial points.
## Installation
```bash
go get github.com/emanuelef/go-geo-3d
```
## Example
```go
package main
import (
"fmt"
geo "github.com/emanuelef/go-geo-3d"
)
func main() {
// Coordinates are in degrees and altitude in metres
start := geo.NewCoord3d(51.39674, -0.36148, 1104.9)
end := geo.NewCoord3d(51.38463, -0.36819, 1219.2)
// Distance in metres between two 3D coordinates
distance := geo.Distance3D(start, end)
fmt.Printf("Distance 3D line from start to end: %.3fm\n", distance)
posA := geo.NewCoord3d(51.3909, -0.364, 15)
// Minimum distance in metres from one 3D point to a line in 3D coordinates
minPoint, _ := posA.ClosestPointOnLine(start, end)
// Lat: 51.39181 Lon: -0.36421 Alt: 1151.37514
distance = geo.Distance3D(posA, minPoint)
fmt.Printf("Distance from one point to a line: %.3fm\n", distance)
}
```