Improved Galactic coords to protal code conversion
Removed un-needed error check Added ability to pick planet id (0-6) Gc2p(gc string) ->> Gc2p(gc string, p int)
This commit is contained in:
17
convert.go
17
convert.go
@@ -70,22 +70,23 @@ func P2gc(p string) (gc string, err error) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Gc2p - Galactic coordinates to portal code
|
Gc2p - Galactic coordinates to portal code
|
||||||
Requires 1 string and returns a string and error
|
Requires 1 string and 1 int returns a string and error
|
||||||
var gc string
|
var gc string
|
||||||
Galactic address (ex. 042F:0079:0D55:006A)
|
Galactic address (ex. 042F:0079:0D55:006A)
|
||||||
|
var p int
|
||||||
|
Planet ID [1-6]
|
||||||
Return var string
|
Return var string
|
||||||
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
Portal Glyph hex string 12 chars in len (ex. 006afa556c30)
|
||||||
*/
|
*/
|
||||||
func Gc2p(gc string) (portalcode string, err error) {
|
func Gc2p(gc string, p int) (portalcode string, err error) {
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*TODO: add option for Planet choice (1-6)*/
|
|
||||||
// split and store string
|
// split and store string
|
||||||
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
// coords[0] == X; coords[1] == Y coords[2] == Z;
|
||||||
// coords[3] == SSI coords[4] == P
|
// coords[3] == SSI coords[4] == P
|
||||||
coords := strings.Split(gc+":1", ":")
|
if p > 6 {
|
||||||
|
p = 1
|
||||||
|
}
|
||||||
|
nustring := fmt.Sprintf("%s:%d", gc, p)
|
||||||
|
coords := strings.Split(nustring, ":")
|
||||||
for n := 0; n < len(coords); n++ {
|
for n := 0; n < len(coords); n++ {
|
||||||
portalcode = portalcode + coords[n]
|
portalcode = portalcode + coords[n]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user