mirror of
https://github.com/ANG13T/SatIntel.git
synced 2025-12-12 07:40:38 -08:00
feat: init Orbital Element Data for norad
This commit is contained in:
106
osint/osint.go
106
osint/osint.go
@@ -40,59 +40,59 @@ type field string
|
||||
type orderBy string
|
||||
const authURL = "https://www.space-track.org/ajaxauth/login"
|
||||
const baseurl = "https://www.space-track.org/basicspacedata/query/class"
|
||||
const epoch field = "EPOCH"
|
||||
const tle field = "TLE"
|
||||
const noradCatID field = "NORAD_CAT_ID"
|
||||
const asc orderBy = "asc"
|
||||
const desc orderBy = "desc"
|
||||
|
||||
type operator string
|
||||
|
||||
const dq operator = ""
|
||||
const lt operator = "<"
|
||||
|
||||
type SatcatResponse struct {
|
||||
Result []struct {
|
||||
InternationalDesignator string `json:"INTLDES"`
|
||||
} `json:"Results"`
|
||||
}
|
||||
|
||||
type spacetrackArgs struct {
|
||||
base string
|
||||
class field
|
||||
orderByField field
|
||||
orderByDir orderBy
|
||||
limit uint64
|
||||
filters filters
|
||||
}
|
||||
|
||||
type filters []filter
|
||||
type filter struct {
|
||||
filterType field
|
||||
operator operator
|
||||
value string
|
||||
}
|
||||
|
||||
func (f filters) render() string {
|
||||
results := []string{}
|
||||
for _, f := range f {
|
||||
results = append(results, f.render())
|
||||
}
|
||||
return strings.Join(results, "/")
|
||||
}
|
||||
|
||||
func (f filter) render() string {
|
||||
return fmt.Sprint(f.filterType, "/", f.operator, f.value)
|
||||
}
|
||||
|
||||
|
||||
// Orbital Element Data Display Code
|
||||
func OrbitalElement() {
|
||||
// NORAD ID or Catalog Display
|
||||
options, _ := ioutil.ReadFile("txt/orbital_element.txt")
|
||||
opt,_:=gradient.NewGradient("#1179ef", "cyan")
|
||||
opt.Print("\n" + string(options))
|
||||
var selection int = Option(0, 3)
|
||||
|
||||
if (selection == 1) {
|
||||
vals := url.Values{}
|
||||
vals.Add("identity", os.Getenv("SPACE_TRACK_USERNAME"))
|
||||
vals.Add("password", os.Getenv("SPACE_TRACK_PASSWORD"))
|
||||
vals.Add("query", "https://www.space-track.org/basicspacedata/query/class/satcat/orderby/SATNAME asc/limit/10/emptyresult/show")
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
resp, err := client.PostForm(authURL, vals)
|
||||
if err != nil {
|
||||
fmt.Println("0-")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
fmt.Println("1-")
|
||||
}
|
||||
respData, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("lols")
|
||||
}
|
||||
|
||||
var sats []Satellite
|
||||
if err := json.Unmarshal(respData, &sats); err != nil {
|
||||
fmt.Println("2-")
|
||||
}
|
||||
|
||||
fmt.Println(sats, len(sats))
|
||||
|
||||
} else if (selection == 2) {
|
||||
fmt.Print("\n ENTER NORAD ID > ")
|
||||
var norad string
|
||||
fmt.Scanln(&norad)
|
||||
PrintNORADInfo(norad)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func PrintNORADInfo(norad string) {
|
||||
vals := url.Values{}
|
||||
vals.Add("identity", os.Getenv("SPACE_TRACK_USERNAME"))
|
||||
vals.Add("password", os.Getenv("SPACE_TRACK_PASSWORD"))
|
||||
vals.Add("query", "https://www.space-track.org/basicspacedata/query/class/satcat/orderby/SATNAME asc/limit/10/emptyresult/show")
|
||||
vals.Add("query", "https://www.space-track.org/basicspacedata/query/class/gp_history/format/tle/NORAD_CAT_ID/" + norad + "/orderby/EPOCH%20desc/limit/1")
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
@@ -111,12 +111,12 @@ func OrbitalElement() {
|
||||
fmt.Println("lols")
|
||||
}
|
||||
|
||||
var sats []Satellite
|
||||
if err := json.Unmarshal(respData, &sats); err != nil {
|
||||
fmt.Println("2-")
|
||||
}
|
||||
|
||||
fmt.Println(sats, len(sats))
|
||||
tleLines := strings.Fields(string(respData))
|
||||
mid := (len(tleLines)/2) + 1
|
||||
lineOne := strings.Join(tleLines[:mid], " ")
|
||||
lineTwo := strings.Join(tleLines[mid:], " ")
|
||||
tle := ConstructTLE("UNSPECIFIED", lineOne, lineTwo)
|
||||
PrintTLE(tle)
|
||||
}
|
||||
|
||||
// TLE Parser Code
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package osint
|
||||
|
||||
// Struct for holding satellite information during and before propagation
|
||||
type Satellite struct {
|
||||
INTLDES string `json:"INTLDES"`
|
||||
NORAD_CAT_ID string `json:"NORAD_CAT_ID"`
|
||||
@@ -27,8 +26,3 @@ type Satellite struct {
|
||||
OBJECT_ID string `json:"OBJECT_ID"`
|
||||
OBJECT_NUMBER string `json:"OBJECT_NUMBER"`
|
||||
}
|
||||
|
||||
|
||||
type GravConst struct {
|
||||
mu, radiusearthkm, xke, tumin, j2, j3, j4, j3oj2 float64
|
||||
}
|
||||
11
txt/orbital_element.txt
Normal file
11
txt/orbital_element.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
[ 1 ] Select from Satellite Catalog
|
||||
|
||||
[ 2 ] Input NORAD Catalog ID
|
||||
|
||||
[ 3 ] Back to Main Menu
|
||||
|
||||
[ 0 ] Exit SatIntel
|
||||
|
||||
=================================================================================================================================
|
||||
Reference in New Issue
Block a user