157 lines
3.9 KiB
Go
157 lines
3.9 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/Jeffail/gabs/v2"
|
|
)
|
|
|
|
// 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 {
|
|
AvgSec float64 `json:"avgSec"`
|
|
Fid int64 `json:"fid"`
|
|
Gates []struct {
|
|
P int64 `json:"p"`
|
|
Q int64 `json:"q"`
|
|
S int64 `json:"s"`
|
|
T int64 `json:"t"`
|
|
} `json:"gates"`
|
|
MapID int64 `json:"mapID"`
|
|
MapName string `json:"mapName"`
|
|
MaxSec float64 `json:"maxSec"`
|
|
MinSec float64 `json:"minSec"`
|
|
Npc int64 `json:"npc"`
|
|
Scale float64 `json:"scale"`
|
|
Systems []struct {
|
|
Bnode interface{} `json:"bnode"`
|
|
Cel []int64 `json:"cel"`
|
|
Cfid bool `json:"cfid"`
|
|
Cid int64 `json:"cid"`
|
|
Cn string `json:"cn"`
|
|
D float64 `json:"d"`
|
|
Ext []int64 `json:"ext"`
|
|
Fid int64 `json:"fid"`
|
|
Fw bool `json:"fw"`
|
|
Index int64 `json:"index"`
|
|
Links []int64 `json:"links"`
|
|
Pi []int64 `json:"pi"`
|
|
Rid int64 `json:"rid"`
|
|
Rn string `json:"rn"`
|
|
Sec float64 `json:"sec"`
|
|
Sid int64 `json:"sid"`
|
|
Sn string `json:"sn"`
|
|
Snode int64 `json:"snode"`
|
|
Sta int64 `json:"sta"`
|
|
Stasrv []int64 `json:"stasrv"`
|
|
Tnode string `json:"tnode"`
|
|
Vnode int64 `json:"vnode"`
|
|
X float64 `json:"x"`
|
|
Y float64 `json:"y"`
|
|
} `json:"systems"`
|
|
X float64 `json:"x"`
|
|
Y int64 `json:"y"`
|
|
} `json:"maps"`
|
|
}
|
|
|
|
// EveSystemList asd
|
|
type EveSystemList struct {
|
|
Systems []EveSystem `json:"systems"`
|
|
}
|
|
|
|
// EveSystem ss
|
|
type EveSystem struct {
|
|
// Links []string `json:"links"`
|
|
Name string `json:"name"`
|
|
// Sec float64 `json:"sec"`
|
|
Region string `json:"region"`
|
|
// SystemID int `json:"sid"`
|
|
}
|
|
|
|
// we'll record both directions here in-memory
|
|
// then add each dest to System struct in a
|
|
type Jump struct {
|
|
Type string `json:"type"` // gate, bridge
|
|
SrcName string `json:"src"`
|
|
DstName string `json:"dst"`
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
byteValue, _ := ioutil.ReadAll(jsonFile)
|
|
var OrigKspace EveEyeKspace
|
|
|
|
json.Unmarshal(byteValue, &OrigKspace)
|
|
|
|
// jsonObjJumps := gabs.New()
|
|
jsonObjSystems := gabs.New()
|
|
|
|
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
|
|
// SystemSec := system.Sec
|
|
// fmt.Println(SystemName)
|
|
|
|
fmt.Printf("[%v]: (%v) %v -> ", Region, SystemID, SystemName)
|
|
for _, link := range system.Links {
|
|
s := strconv.FormatInt(link, 10)
|
|
fmt.Printf(" %v", s)
|
|
}
|
|
fmt.Printf("\n")
|
|
// jsonObjSystems.Set(SystemID, "systems", SystemName, "id")
|
|
// jsonObjSystems.Set(SystemSec, "systems", SystemName, "sec")
|
|
}
|
|
|
|
// for _, gate := range data.Gates {
|
|
// fmt.Printf("T: %v\n", gate.T)
|
|
// fmt.Printf("S: %v\n", gate.S)
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, data := range OrigKspace.Maps {
|
|
Region := data.MapName
|
|
if Region == "Delve" {
|
|
for _, gate := range data.Gates {
|
|
jsonObjSystems.Set(gate.S, "jumps", fmt.Sprintf("%v-%v", gate.S, gate.T), "s")
|
|
jsonObjSystems.Set(gate.T, "jumps", fmt.Sprintf("%v-%v", gate.S, gate.T), "t")
|
|
// jsonObjSystems.Set(gate.T, "jumps", "t")
|
|
// fmt.Printf("T: %v\n", gate.T)
|
|
// fmt.Printf("S: %v\n", gate.S)
|
|
}
|
|
}
|
|
}
|
|
|
|
// for key, child := range jsonObjSystems.S("systems").ChildrenMap() {
|
|
// if key == "8RQJ-2" {
|
|
// fmt.Printf("value: %v\n", child.Data())
|
|
// fmt.Printf("key: %v\n", key)
|
|
// }
|
|
// }
|
|
|
|
fmt.Println(jsonObjSystems.String())
|
|
err = jsonFile.Close()
|
|
if err != nil {
|
|
fmt.Printf("error closing file")
|
|
}
|
|
|
|
}
|