Go package wrapping RTKLIB via CGo for PPK (Post-Processed Kinematic) GNSS post-processing. Works with drone image metadata, RINEX observation files, .pos solutions, and .MRK timestamp files.
import "github.com/flywave/go-rtk"
Single flat package rtk — no sub-packages.
| Dependency | Source |
|---|---|
| RTKLIB (C) | external/rtklib/ — prebuilt as lib/librtklib.a |
| go-proj | coordinate transforms via PROJ |
| go-geoid | EGM84/96/2008 geoid height conversions |
| goexif | EXIF tag parsing |
| go-xmp | XMP metadata parsing |
| gocsv | CSV marshaling for .MRK files |
go-proj and go-geoid are local replaces in go.mod — they must exist as siblings at ../go-proj and ../go-geoid.
go build ./...
go test ./...
go vet ./...lib/librtklib.a is checked in. To rebuild from source: cmake external/rtklib && make.
poses, trange := rtk.ReadPos("solution.pos")
mrks, err := rtk.ReadMRK(mrkFile)
rtk.PPKInitPos(poses, mrks)
rtk.PPKUpdatedMrks(mrks)
sols, err := rtk.PPKSolution("solution.pos", "marks.MRK",
rtk.WGS84, rtk.HAE, "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
rtk.HAE, 0.0)gt := rtk.NewGTimeFromGPSTime(2024, 275295.301059)
week, sec := gt.GpsTime()
ep := gt.Epoch() // [year, month, day, hour, min, sec]
utc := gt.UTC()
diff := gt.Diff(otherGT)
gt.Add(30.0) // add secondsf, _ := os.Open("image.jpg")
err, fields := rtk.ReadExifXMP(f)
// fields["drone-dji: RtkFlag"], fields["drone-dji: RtkStdLon"], etc.h := rtk.MSLToWGS84(100.0, 120.0, 30.0, geoid.EGM2008)
h = rtk.WGS84ToMSL(120.0, 30.0, 100.0, geoid.EGM96)
h = rtk.HAEToMSL(120.0, 30.0, 100.0, 0.0, geoid.EGM84)err := rtk.Solution("rover.obs", "base.obs", "brdc.nav", "output.pos")| Format | Reader | Description |
|---|---|---|
.pos |
ReadPos |
RTKLIB solution file (tab-separated, header lines start with %) |
.MRK |
ReadMRK |
Tab-separated timestamp marks with GPS week/SOW, phase center offsets, and RTK state |
.exif / XMP |
ReadExifXMP |
DJI drone image metadata (RtkFlag, RtkStd, absolute altitude) |
.obs / .nav |
Solution |
RINEX observation and navigation files (via RTKLIB) |
.bin |
RawToRIndex |
RTCM3 binary → RINEX conversion |
Sequence GPSSecondOfWeek GPSWeek NorthOff EastOff VelOff Latitude Longitude EllipsoidHeight Std RtkState
Tab-delimited, no header row.
proj_data/— PROJ datum grids and transform filesgeoid_data/— EGM84/96/2008 geoid height grids (PGM format)testdata/— sample.pos,.MRK,.exif, and RINEX files for testing
Paths are set automatically via init() — no environment variables needed.
- Go 1.13 compatible (no generics, no
errors.Is/errors.As, noos.ReadFile) - CGo with per-file
#cgodirectives ingtime.go,pos.go,solution.go,ppkraw.go - Tests use
t.FailNow()on failure (no error messages) go.sumhas no entries for replace-only deps — CI may need-mod=mod