Skip to content

Commit

Permalink
WIP: error in parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva64 committed May 20, 2024
1 parent 15c4aa7 commit 10aa3ba
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 127 deletions.
244 changes: 127 additions & 117 deletions gen/go/proto/satellite/v1/satellite.pb.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions gen/openapiv2/proto/satellite/v1/satellite.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
"required": false,
"type": "number",
"format": "double"
},
{
"name": "velocity",
"in": "query",
"required": false,
"type": "number",
"format": "double"
}
],
"tags": [
Expand Down Expand Up @@ -157,6 +164,10 @@
"altitude": {
"type": "number",
"format": "double"
},
"velocity": {
"type": "number",
"format": "double"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ require (
require (
github.com/go-resty/resty/v2 v2.13.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/joshuaferrara/go-satellite v0.0.0-20220611180459-512638c64e5b
)

require (
github.com/pkg/errors v0.9.1 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/joshuaferrara/go-satellite v0.0.0-20220611180459-512638c64e5b h1:JlltDRgni6FuoFwluvoZCrE6cmpojccO4WsqeYlFJLE=
github.com/joshuaferrara/go-satellite v0.0.0-20220611180459-512638c64e5b/go.mod h1:msW2QeN9IsnRyvuK8OBAzBwn6DHwXpiAiqBk8dbLfrU=
github.com/onsi/ginkgo v1.2.1-0.20160509182050-5437a97bf824 h1:MbMqwlWoESqhGm4Sslfdyeq7Ww8R9ppeKS5DcO3xDI0=
github.com/onsi/ginkgo v1.2.1-0.20160509182050-5437a97bf824/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v0.0.0-20160516222431-c73e51675ad2 h1:38zSYUaJJkzreBjLz7tx4AUTVjnFI7EQBnlRoWt4QFA=
github.com/onsi/gomega v0.0.0-20160516222431-c73e51675ad2/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down Expand Up @@ -76,6 +84,8 @@ google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLp
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.0.0-20160301204022-a83829b6f129 h1:RBgb9aPUbZ9nu66ecQNIBNsA7j3mB5h8PNDIfhPjaJg=
gopkg.in/yaml.v2 v2.0.0-20160301204022-a83829b6f129/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 1 addition & 0 deletions proto/satellite/v1/satellite.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ message Satellite {
double lat = 2;
double lon = 3;
double altitude = 4;
double velocity = 5;
}


Expand Down
46 changes: 36 additions & 10 deletions service/satelliteservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package service
import (
"context"
"github.com/go-resty/resty/v2"
"github.com/joshuaferrara/go-satellite"
log "github.com/sirupsen/logrus"
"github.com/tsukoyachi/react-flight-tracker-satellite/gen/go/proto/satellite/v1"
"github.com/tsukoyachi/react-flight-tracker-satellite/spacetrack"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
_ "google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"
"os"
"time"
)

type SatelliteService struct {
Expand Down Expand Up @@ -106,16 +109,39 @@ func (api SatelliteService) GetSatelliteDetail(ctx context.Context, req *v1.Sate
}

func (api SatelliteService) GetSatellitePositions(ctx context.Context, req *v1.GetSatellitePositionsRequest) (*v1.GetSatellitePositionsResponse, error) {
// print("GetSatellitePositions")
log.Info(req.GetTime())
calculatedPositions := make([]*v1.Satellite, 0)
reqTime := req.GetTime()
if reqTime == nil {
reqTime = &timestamppb.Timestamp{
Seconds: time.Now().Unix(),
Nanos: 0,
}
}
// iterate over api.data
for id, data := range api.data {
log.Info("Calculating position for satellite", id)
log.Info(data.TLE_LINE1, data.TLE_LINE2)
goSat := satellite.TLEToSat(data.TLE_LINE1, data.TLE_LINE2, satellite.GravityWGS84)
// propagate the satellite position
t := time.Unix(reqTime.Seconds, int64(reqTime.Nanos))

log.Info(goSat.ErrorStr, goSat.Error)
log.Info(t)
pos, vec := satellite.Propagate(goSat, t.Year(), int(t.Month()), t.Day(), t.Hour(), t.Minute(), t.Second())
log.Info(pos, vec)
gst := satellite.GSTimeFromDate(t.Year(), int(t.Month()), t.Day(), t.Hour(), t.Minute(), t.Second())

// convert Earth Centered Inertial coordinates to Lat/Long
altitude, velocity, ret := satellite.ECIToLLA(pos, gst)
calculatedPositions = append(calculatedPositions, &v1.Satellite{
Id: id,
Lat: ret.Latitude,
Lon: ret.Longitude,
Altitude: altitude,
Velocity: velocity,
})
}
return &v1.GetSatellitePositionsResponse{
Satellites: []*v1.Satellite{
{
Id: "1",
Lat: 0,
Lon: 0,
Altitude: float64(req.GetTime().GetSeconds()),
},
},
Satellites: calculatedPositions,
}, nil
}

0 comments on commit 10aa3ba

Please sign in to comment.