From 9984f0d2ea5112aa70111d9578e50aa427e58d8f Mon Sep 17 00:00:00 2001 From: David Stark Date: Wed, 4 Dec 2019 22:07:47 +0000 Subject: [PATCH] basic go to start parsing kspace --- data/main.go | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 data/main.go diff --git a/data/main.go b/data/main.go new file mode 100644 index 0000000..50db9a1 --- /dev/null +++ b/data/main.go @@ -0,0 +1,84 @@ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" +) + +// EveEyeKspace + https://mholt.github.io/json-to-go/ +// NOTE.. don't paste the whole json file in here.. just one region or else the tool won't notice gates +type EveEyeKspace struct { + Maps []struct { + MapID int `json:"mapID"` + MapName string `json:"mapName"` + Scale float64 `json:"scale"` + Gates []struct { + S int `json:"s,omitempty"` + T int `json:"t,omitempty"` + P int `json:"p,omitempty"` + } `json:"gates"` + Fid int `json:"fid,omitempty"` + AvgSec float64 `json:"avgSec,omitempty"` + MaxSec float64 `json:"maxSec,omitempty"` + MinSec float64 `json:"minSec,omitempty"` + X float64 `json:"x,omitempty"` + Y int `json:"y,omitempty"` + Systems []struct { + Sid int `json:"sid"` + Sn string `json:"sn"` + Cid int `json:"cid"` + Cn string `json:"cn"` + Rid int `json:"rid"` + Rn string `json:"rn"` + Sec float64 `json:"sec"` + D float64 `json:"d"` + Pi []int `json:"pi"` + Cel []int `json:"cel"` + Fid int `json:"fid"` + Fw bool `json:"fw"` + X float64 `json:"x"` + Y float64 `json:"y"` + Sta int `json:"sta,omitempty"` + Stasrv []int `json:"stasrv,omitempty"` + } `json:"systems"` + Npc int `json:"npc,omitempty"` + } `json:"maps"` +} + +func main() { + // we're gonna read these json files and create something sensible.. + jsonFile, err := os.Open("kspace.json") + if err != nil { + fmt.Println(err) + } + defer jsonFile.Close() + + byteValue, _ := ioutil.ReadAll(jsonFile) + var OrigKspace EveEyeKspace + + json.Unmarshal(byteValue, &OrigKspace) + + for _, data := range OrigKspace.Maps { + + Region := data.MapName + if Region == "Delve" { + fmt.Printf("######################## \n#### %v\n", Region) + + for _, system := range data.Systems { + SystemName := system.Sn + SystemID := system.Sid + fmt.Printf("[%v]: (%v) %v\n", Region, SystemID, SystemName) + } + + for _, gate := range data.Gates { + fmt.Printf("T: %v\n", gate.T) + fmt.Printf("S: %v\n", gate.S) + } + + } + + } + +}