Skip to content

Commit

Permalink
Added JSON Metadata Output and Automatic Reprojection / Map Drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
racerxdl committed Mar 8, 2019
1 parent 333780c commit d5c0e24
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ImageProcessor/GOESABI.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func ProcessGOESABI(ip *ImageProcessor, filename string, xh *XRIT.Header) {

if ms.Done() {
SLog.Info("Got all segments for %s", name)
err, outname := ImageTools.DumpMultiSegment(ms, ip.mapDrawer, false)
err, outname := ImageTools.DumpMultiSegment(ms, ip.GetMapDrawer(), ip.reproject)
if err != nil {
SLog.Error("Error dumping Multi Segment Image %s: %s", name, err)
}
Expand Down
28 changes: 28 additions & 0 deletions ImageProcessor/ImageProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,43 @@ type ImageProcessor struct {
sync.Mutex
MultiSegmentCache map[string]*Structs.MultiSegmentImage
mapDrawer *MapDrawer.MapDrawer
reproject bool
drawmap bool
}

func MakeImageProcessor() *ImageProcessor {
return &ImageProcessor{
MultiSegmentCache: make(map[string]*Structs.MultiSegmentImage),
mapDrawer: ImageData.GetDefaultMapDrawer(),
reproject: false,
drawmap: false,
}
}

func (ip *ImageProcessor) SetDrawMap(drawMap bool) {
ip.drawmap = drawMap
}

func (ip *ImageProcessor) SetReproject(reproject bool) {
ip.reproject = reproject
}

func (ip *ImageProcessor) GetDrawMap() bool {
return ip.drawmap
}

func (ip *ImageProcessor) GetReproject() bool {
return ip.reproject
}

func (ip *ImageProcessor) GetMapDrawer() *MapDrawer.MapDrawer {
if ip.drawmap {
return ip.mapDrawer
}

return nil
}

func (ip *ImageProcessor) ProcessImage(filename string) {
ip.Lock()
defer ip.Unlock()
Expand Down
13 changes: 13 additions & 0 deletions ImageProcessor/ImageTools/MultiSegmentDump.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ImageTools

import (
"encoding/json"
"fmt"
"github.com/opensatelliteproject/SatHelperApp/ImageProcessor/MapDrawer"
"github.com/opensatelliteproject/SatHelperApp/ImageProcessor/Projector"
Expand Down Expand Up @@ -112,5 +113,17 @@ func DumpMultiSegment(msi *Structs.MultiSegmentImage, mapDrawer *MapDrawer.MapDr
return err, ""
}

meta, err := json.MarshalIndent(msi.FirstSegmentHeader, "", " ")

if err != nil {
SLog.Error("Cannot generate JSON for metadata file: %s", err)
} else {
metaName := path.Join(folder, msi.Name+".json")
err := ioutil.WriteFile(metaName, meta, os.ModePerm)
if err != nil {
SLog.Error("Cannot write Meta file %s: %s", metaName, err)
}
}

return nil, newFilename
}
2 changes: 2 additions & 0 deletions Models/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type DirectDemuxerConfig struct {
TemporaryFolder string
PurgeFilesAfterProcess bool
SkipVCID []int
ReprojectImages bool
DrawMap bool
}

type AppConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Building
That's a standard go project. Make sure you have `libSatHelper` and `libairspy` installed and run:

```bash
go get github.com/OpenSatelliteProject/SatHelperApp
go get github.com/OpenSatelliteProject/SatHelperApp/cmd/SatHelperApp
```

It will be installed into your `${GOPATH}/bin`. If you have it it on your path, just run `SatHelperApp`
Expand Down
8 changes: 8 additions & 0 deletions ccsds/FileAssembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ func (fa *FileAssembler) SetOutputFolder(folder string) {
fa.outFolder = folder
}

func (fa *FileAssembler) SetDrawMap(drawMap bool) {
fa.ip.SetDrawMap(drawMap)
}

func (fa *FileAssembler) SetReprojectImages(reproject bool) {
fa.ip.SetReproject(reproject)
}

func (fa *FileAssembler) PutMSDU(msdu *MSDU) {
if msdu.Sequence == SequenceFirstSegment || msdu.Sequence == SequenceSingleData {
if fa.msduCache[msdu.APID] != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/SatHelperApp/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os"
)

var configFile = flag.String("config", "", "write cpu profile to file")
var configFile = flag.String("config", "", "Configuration File (defaults to $HOME/SatHelperApp/SatHelperApp.cfg)")
var finalConfigFilePath string

func LoadDefaults(save bool) {
Expand Down Expand Up @@ -68,6 +68,8 @@ func LoadDefaults(save bool) {
DSP.CurrentConfig.DirectDemuxer.TemporaryFolder = "tmp"
DSP.CurrentConfig.DirectDemuxer.PurgeFilesAfterProcess = false
DSP.CurrentConfig.DirectDemuxer.SkipVCID = make([]int, 0)
DSP.CurrentConfig.DirectDemuxer.DrawMap = false
DSP.CurrentConfig.DirectDemuxer.ReprojectImages = false

if save {
SaveConfig()
Expand Down

0 comments on commit d5c0e24

Please sign in to comment.