mirror of
https://github.com/ANG13T/SatIntel.git
synced 2025-12-12 15:49:47 -08:00
feat: init satellite locations
This commit is contained in:
@@ -13,11 +13,7 @@ import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
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"
|
||||
|
||||
|
||||
func extractNorad(str string) string {
|
||||
start := strings.Index(str, "(")
|
||||
|
||||
23
osint/position.go
Normal file
23
osint/position.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package osint
|
||||
|
||||
type SatelliteInfo struct {
|
||||
Satname string `json:"satname"`
|
||||
Satid int `json:"satid"`
|
||||
Transactionscount int `json:"transactionscount"`
|
||||
}
|
||||
|
||||
type Position struct {
|
||||
Satlatitude float64 `json:"satlatitude"`
|
||||
Satlongitude float64 `json:"satlongitude"`
|
||||
Sataltitude float64 `json:"sataltitude"`
|
||||
Azimuth float64 `json:"azimuth"`
|
||||
Elevation float64 `json:"elevation"`
|
||||
Ra float64 `json:"ra"`
|
||||
Dec float64 `json:"dec"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
SatelliteInfo SatelliteInfo `json:"info"`
|
||||
Positions []Position `json:"positions"`
|
||||
}
|
||||
@@ -4,8 +4,16 @@ import (
|
||||
"io/ioutil"
|
||||
"fmt"
|
||||
"github.com/iskaa02/qalam/gradient"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Marker struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
|
||||
|
||||
// Satellite Position Visualization Code
|
||||
func SatellitePositionVisualization() {
|
||||
options, _ := ioutil.ReadFile("txt/orbital_element.txt")
|
||||
@@ -20,7 +28,8 @@ func SatellitePositionVisualization() {
|
||||
return
|
||||
}
|
||||
|
||||
PrintNORADInfo(extractNorad(result), result)
|
||||
// PrintNORADInfo(extractNorad(result), result)
|
||||
GetLocation(extractNorad(result))
|
||||
|
||||
} else if (selection == 2) {
|
||||
fmt.Print("\n ENTER NORAD ID > ")
|
||||
@@ -30,4 +39,67 @@ func SatellitePositionVisualization() {
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Show visualization and info in box
|
||||
func GetLocation(norad string) {
|
||||
// fmt.Print("\n ENTER LATITUDE > ")
|
||||
// var latitude string
|
||||
// fmt.Print("\n ENTER LONGITUDE > ")
|
||||
// var longitude string
|
||||
// fmt.Print("\n ENTER ALTITUDE > ")
|
||||
// var altitude string
|
||||
|
||||
// marker := getXYfromLonLat(strconv.Atoi(latitude, longitude))
|
||||
|
||||
url := "https://api.n2yo.com/rest/v1/satellite/positions/25544/41.702/-76.014/0/2/&apiKey=46REG9-PS2V7M-H3B76Q-5103"
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var data Response
|
||||
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Satellite Name: %s\n", data.SatelliteInfo.Satname)
|
||||
fmt.Printf("Satellite ID: %d\n", data.SatelliteInfo.Satid)
|
||||
|
||||
for _, pos := range data.Positions {
|
||||
fmt.Printf("Latitude: %f\n", pos.Satlatitude)
|
||||
fmt.Printf("Longitude: %f\n", pos.Satlongitude)
|
||||
fmt.Printf("Altitude: %f\n", pos.Sataltitude)
|
||||
fmt.Printf("Azimuth: %f\n", pos.Azimuth)
|
||||
fmt.Printf("Elevation: %f\n", pos.Elevation)
|
||||
fmt.Printf("RA: %f\n", pos.Ra)
|
||||
fmt.Printf("Dec: %f\n", pos.Dec)
|
||||
fmt.Printf("Timestamp: %d\n", pos.Timestamp)
|
||||
fmt.Println("------------------------")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func DisplayMap() {
|
||||
|
||||
}
|
||||
|
||||
func getXYfromLonLat(lat int, lon int) Marker {
|
||||
marker := Marker{}
|
||||
// Normalise the X, Y in their min -> max space
|
||||
normalX := (lat + 219) / (293 + 219);
|
||||
normalY := (lon + 244) / (266 + 244);
|
||||
|
||||
// Stretch them to match the ASCII map
|
||||
const width = 70
|
||||
const height = 42
|
||||
realX := normalX * width - 3;
|
||||
realY := normalY * height - 9;
|
||||
|
||||
marker.X = realX
|
||||
marker.Y = realY
|
||||
|
||||
return marker
|
||||
}
|
||||
|
||||
23
txt/map.txt
Normal file
23
txt/map.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
. _..::__: ,-"-"._ |] , _,.__
|
||||
_.___ _ _<_>\`!(._\`.\`-. / _._ \`_ ,_/ ' '-._.---.-.__
|
||||
.{ " " \`-==,',._\\{ \\ / {) _ / _ ">_,-' \` /-/_
|
||||
\\_.:--. \`._ )\`^-. "' / ( [_/( __,/-'
|
||||
'"' \\ " _\\ -_,--' ) /. (|
|
||||
| ,' _)_.\\\\._<> {} _,' / '
|
||||
\`. / [_/_'\` \`"( <'} )
|
||||
\\\\ .-. ) / \`-'"..' \`:._ _) '
|
||||
\` \\ ( \`( / \`:\\ > \\ ,-^. /' '
|
||||
\`._, "" | \\\`' \\| ?_) {\\
|
||||
\`=.---. \`._._ ,' "\` |' ,- '.
|
||||
| \`-._ | / \`:\`<_|=--._
|
||||
( > . | , \`=.__.\`-'\\
|
||||
\`. / | |{| ,-.,\\ .
|
||||
| ,' \\ / \`' ," \\
|
||||
| / |_' | __ /
|
||||
| | '-' \`-' \\.
|
||||
|/ " /
|
||||
\\. '
|
||||
|
||||
,/ ______._.--._ _..---.---------.
|
||||
__,-----"-..?----_/ )\\ . ,-'" " (__--/
|
||||
/__/\\/
|
||||
Reference in New Issue
Block a user