Moved from gim to gg for image creation
This commit is contained in:
27
convert.go
27
convert.go
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
/*
|
||||
P2gc - Portal code to galactic coordinates
|
||||
Requires 1 var and returns 1 var string
|
||||
Requires 1 var and returns 1 var string and an error
|
||||
var p string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
Return var string
|
||||
@@ -27,19 +27,19 @@ func P2gc(p string) (gc string, err error) {
|
||||
var coord [4]int64
|
||||
coord[1], err = strconv.ParseInt(p[4:6], 16, 16) // Y coordinate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [4:6]")
|
||||
}
|
||||
coord[2], err = strconv.ParseInt(p[6:9], 16, 16) // Z cooridnate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [6:9]")
|
||||
}
|
||||
coord[3], err = strconv.ParseInt(p[9:12], 16, 16) // X coordinate
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [9:12]")
|
||||
}
|
||||
coord[0], err = strconv.ParseInt(p[1:4], 16, 16) // SSI (Star System Identifier)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [1:4]")
|
||||
}
|
||||
|
||||
// apply shifts to Handle the shape/boundaries of the galaxy
|
||||
@@ -72,13 +72,16 @@ Requires 1 string and 1 int returns a string and error
|
||||
Galactic address (ex. 042F:0079:0D55:006A)
|
||||
var p int
|
||||
Planet ID [1-6]
|
||||
Return var string
|
||||
Return portalcode string
|
||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||
*/
|
||||
func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
// split and store string
|
||||
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
||||
// coords[3] == SSI coords[4] == P
|
||||
if len(gc) != 19 {
|
||||
return "", errors.New("galatic code is the wrong length")
|
||||
}
|
||||
if p > 6 {
|
||||
p = 1
|
||||
}
|
||||
@@ -91,23 +94,23 @@ func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
var hexCoords [5]int64
|
||||
hexCoords[0], err = strconv.ParseInt(coords[4], 16, 16) // P
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [4]")
|
||||
}
|
||||
hexCoords[1], err = strconv.ParseInt(coords[3], 16, 16) // SSI
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [3]")
|
||||
}
|
||||
hexCoords[2], err = strconv.ParseInt(coords[1], 16, 16) // Y
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [1]")
|
||||
}
|
||||
hexCoords[3], err = strconv.ParseInt(coords[2], 16, 16) // Z
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [2]")
|
||||
}
|
||||
hexCoords[4], err = strconv.ParseInt(coords[0], 16, 16) // X
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", errors.New("error parsing intergers from string: [0]")
|
||||
}
|
||||
|
||||
// Apply shifts to Handle the shape/boundaries of the galaxy
|
||||
@@ -130,5 +133,5 @@ func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||
portalcode = portalcode + fmt.Sprintf("%03X", hexCoords[n])
|
||||
}
|
||||
}
|
||||
return portalcode, err // return formated string and error
|
||||
return // return formated string and error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user