An in-memory time-series index that can be loaded manually, or automatically from image (using EXIF) and GPS data-log files. In the case of image files, we will attempt to extract a coordinate from GPS information in the EXIF (if present).
This is the underlying storage mechanism of the go-geographic-autogroup-images project.
- github.com/dsoprea/go-time-index
- github.com/dsoprea/go-jpeg-image-structure
- github.com/dsoprea/go-exif
- github.com/dsoprea/go-gpx
Records can be added to the index either directly or automatically from recursively processing a given path and extracting locations from GPS data-log and image files (those supporting and having EXIF). Currently, only GPX files are supported for data-logs and JPEG files for images.
Excerpt from GeographicCollector.ReadFromPath example:
index := NewTimeIndex()
gc := NewGeographicCollector(index)
err := RegisterImageFileProcessors(gc, 0, nil)
log.PanicIf(err)
err = RegisterDataFileProcessors(gc)
log.PanicIf(err)
err = gc.ReadFromPath(testAssetsPath)
log.PanicIf(err)
Excerpt from Index.Add example:
index := NewTimeIndex()
epochUtc := (time.Time{}).UTC()
hasGeographic := true
latitude := float64(123.456)
longitude := float64(789.012)
var metadata interface{}
index.Add(SourceGeographicGpx, "data.gpx", epochUtc, hasGeographic, latitude, longitude, metadata)
The ordered index data can also be exported back to a GPX file:
Excerpt from Index.ExportGpx example:
index := NewTimeIndex()
gc := NewGeographicCollector(index)
err := RegisterImageFileProcessors(gc, 0, nil)
log.PanicIf(err)
err = RegisterDataFileProcessors(gc)
log.PanicIf(err)
err = gc.ReadFromPath(testAssetsPath)
log.PanicIf(err)
buffer := new(bytes.Buffer)
err = gc.index.ExportGpx(buffer)
log.PanicIf(err)