package main

import (
"fmt"
"math"
"go_sat_test/satellite"
"io/ioutil"
"strings"
"time"
)

func readlines(file string) []string {

	content, _ := ioutil.ReadFile(file)
    str := string(content)
    lines := strings.Split(str, "\n")
	return lines
	
}


func main() {

	tle1 := "1 25544U 98067A   24305.51614734  .00033924  00000-0  58068-3 0  9996"
	tle2 := "2 25544  51.6393   0.0913 0008954 121.9734 238.2127 15.50881146479694"
			 
	location := satellite.LatLong{
		Latitude:  41.918824 * math.Pi / 180,
		Longitude: 29.316443 * math.Pi / 180,
	}
	altitude := 50.0
	
	var ts = time.Now()
	ts = ts.UTC()
	year, month, day, hour, minute, second := ts.Year(),
		int(ts.Month()),
		ts.Day(),
		ts.Hour(),
		ts.Minute(),
		ts.Second()
	// initialize satellite
	sat := satellite.TLEToSat(tle1, tle2, "wgs84")
	// get the satellite position
	position, _ := satellite.Propagate(
		sat, year, month, day,
		hour, minute, second,
	)
	// convert the current time to Galileo system time (GST)
	gst := satellite.GSTimeFromDate(
		year, month, day,
		hour, minute, second,
	)
	// get satellite coordinates in radians
	_, _, latlng := satellite.ECIToLLA(position, gst)
	
	obs := satellite.ECIToLookAngles(
		position, location, altitude,
		// get Julian date
		satellite.JDay(
			year, month, day,
			hour, minute, second,
		),
	)
	// print satellite coordinates in angles
	fmt.Printf("Sat pos: %f %f\n", latlng.Latitude*180/math.Pi, latlng.Longitude*180/math.Pi)
	// print my observation azimuth in angle
	fmt.Printf("Azimuth:  %.2f\n", obs.Az*180/math.Pi)
	fmt.Printf("Elevation %.2f\n", obs.El*180/math.Pi)
        


}