From 7ac4af771d29c5e868b79b0161a4d30e3108e094 Mon Sep 17 00:00:00 2001 From: Apoorva Srinivas Appadoo Date: Wed, 22 May 2024 23:38:24 +0200 Subject: [PATCH] feat: mark space track data --- celestrack/client.go | 7 +- celestrack/client_test.go | 2 +- gen/go/proto/satellite/v1/satellite.pb.go | 159 +++++++++--------- .../proto/satellite/v1/satellite.swagger.json | 6 + proto/satellite/v1/satellite.proto | 1 + service/satelliteservice.go | 19 ++- 6 files changed, 115 insertions(+), 79 deletions(-) diff --git a/celestrack/client.go b/celestrack/client.go index 3734b6a..0c59928 100644 --- a/celestrack/client.go +++ b/celestrack/client.go @@ -9,10 +9,13 @@ import ( ) func extractNoradIdFromTle(line2 string) string { - return strings.Split(line2, " ")[1] + // remove the 0 in the beginning + dirtyNorad := strings.Split(line2, " ")[1] + return strings.TrimLeft(dirtyNorad, "0") + } -func scrap() (map[string]spacetrack.TLE, error) { +func Scrap() (map[string]spacetrack.TLE, error) { url := "https://celestrak.org/NORAD/elements/" // Get the HTML client := resty.New() diff --git a/celestrack/client_test.go b/celestrack/client_test.go index 47d3edc..b1e0575 100644 --- a/celestrack/client_test.go +++ b/celestrack/client_test.go @@ -6,7 +6,7 @@ import ( ) func Test_scrap(t *testing.T) { - m, err := scrap() + m, err := Scrap() if err != nil { return } diff --git a/gen/go/proto/satellite/v1/satellite.pb.go b/gen/go/proto/satellite/v1/satellite.pb.go index 5a87005..402445b 100644 --- a/gen/go/proto/satellite/v1/satellite.pb.go +++ b/gen/go/proto/satellite/v1/satellite.pb.go @@ -106,46 +106,47 @@ type SatelliteDetail struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CcsdsOmmVers string `protobuf:"bytes,1,opt,name=ccsds_omm_vers,json=ccsdsOmmVers,proto3" json:"ccsds_omm_vers,omitempty"` - Comment string `protobuf:"bytes,2,opt,name=comment,proto3" json:"comment,omitempty"` - CreationDate string `protobuf:"bytes,3,opt,name=creation_date,json=creationDate,proto3" json:"creation_date,omitempty"` - Originator string `protobuf:"bytes,4,opt,name=originator,proto3" json:"originator,omitempty"` - ObjectName string `protobuf:"bytes,5,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` - ObjectId string `protobuf:"bytes,6,opt,name=object_id,json=objectId,proto3" json:"object_id,omitempty"` - CenterName string `protobuf:"bytes,7,opt,name=center_name,json=centerName,proto3" json:"center_name,omitempty"` - RefFrame string `protobuf:"bytes,8,opt,name=ref_frame,json=refFrame,proto3" json:"ref_frame,omitempty"` - TimeSystem string `protobuf:"bytes,9,opt,name=time_system,json=timeSystem,proto3" json:"time_system,omitempty"` - MeanElementTheory string `protobuf:"bytes,10,opt,name=mean_element_theory,json=meanElementTheory,proto3" json:"mean_element_theory,omitempty"` - Epoch string `protobuf:"bytes,11,opt,name=epoch,proto3" json:"epoch,omitempty"` - MeanMotion string `protobuf:"bytes,12,opt,name=mean_motion,json=meanMotion,proto3" json:"mean_motion,omitempty"` - Eccentricity string `protobuf:"bytes,13,opt,name=eccentricity,proto3" json:"eccentricity,omitempty"` - Inclination string `protobuf:"bytes,14,opt,name=inclination,proto3" json:"inclination,omitempty"` - RaOfAscNode string `protobuf:"bytes,15,opt,name=ra_of_asc_node,json=raOfAscNode,proto3" json:"ra_of_asc_node,omitempty"` - ArgOfPericenter string `protobuf:"bytes,16,opt,name=arg_of_pericenter,json=argOfPericenter,proto3" json:"arg_of_pericenter,omitempty"` - MeanAnomaly string `protobuf:"bytes,17,opt,name=mean_anomaly,json=meanAnomaly,proto3" json:"mean_anomaly,omitempty"` - EphemerisType string `protobuf:"bytes,18,opt,name=ephemeris_type,json=ephemerisType,proto3" json:"ephemeris_type,omitempty"` - ClassificationType string `protobuf:"bytes,19,opt,name=classification_type,json=classificationType,proto3" json:"classification_type,omitempty"` - NoradCatId string `protobuf:"bytes,20,opt,name=norad_cat_id,json=noradCatId,proto3" json:"norad_cat_id,omitempty"` - ElementSetNo string `protobuf:"bytes,21,opt,name=element_set_no,json=elementSetNo,proto3" json:"element_set_no,omitempty"` - RevAtEpoch string `protobuf:"bytes,22,opt,name=rev_at_epoch,json=revAtEpoch,proto3" json:"rev_at_epoch,omitempty"` - Bstar string `protobuf:"bytes,23,opt,name=bstar,proto3" json:"bstar,omitempty"` - MeanMotionDot string `protobuf:"bytes,24,opt,name=mean_motion_dot,json=meanMotionDot,proto3" json:"mean_motion_dot,omitempty"` - MeanMotionDdot string `protobuf:"bytes,25,opt,name=mean_motion_ddot,json=meanMotionDdot,proto3" json:"mean_motion_ddot,omitempty"` - SemimajorAxis string `protobuf:"bytes,26,opt,name=semimajor_axis,json=semimajorAxis,proto3" json:"semimajor_axis,omitempty"` - Period string `protobuf:"bytes,27,opt,name=period,proto3" json:"period,omitempty"` - Apoapsis string `protobuf:"bytes,28,opt,name=apoapsis,proto3" json:"apoapsis,omitempty"` - Periapsis string `protobuf:"bytes,29,opt,name=periapsis,proto3" json:"periapsis,omitempty"` - ObjectType string `protobuf:"bytes,30,opt,name=object_type,json=objectType,proto3" json:"object_type,omitempty"` - RcsSize string `protobuf:"bytes,31,opt,name=rcs_size,json=rcsSize,proto3" json:"rcs_size,omitempty"` - CountryCode string `protobuf:"bytes,32,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"` - LaunchDate string `protobuf:"bytes,33,opt,name=launch_date,json=launchDate,proto3" json:"launch_date,omitempty"` - Site string `protobuf:"bytes,34,opt,name=site,proto3" json:"site,omitempty"` - DecayDate string `protobuf:"bytes,35,opt,name=decay_date,json=decayDate,proto3" json:"decay_date,omitempty"` - File string `protobuf:"bytes,36,opt,name=file,proto3" json:"file,omitempty"` - GpId string `protobuf:"bytes,37,opt,name=gp_id,json=gpId,proto3" json:"gp_id,omitempty"` - TleLine0 string `protobuf:"bytes,38,opt,name=tle_line0,json=tleLine0,proto3" json:"tle_line0,omitempty"` - TleLine1 string `protobuf:"bytes,39,opt,name=tle_line1,json=tleLine1,proto3" json:"tle_line1,omitempty"` - TleLine2 string `protobuf:"bytes,40,opt,name=tle_line2,json=tleLine2,proto3" json:"tle_line2,omitempty"` + CcsdsOmmVers string `protobuf:"bytes,1,opt,name=ccsds_omm_vers,json=ccsdsOmmVers,proto3" json:"ccsds_omm_vers,omitempty"` + Comment string `protobuf:"bytes,2,opt,name=comment,proto3" json:"comment,omitempty"` + CreationDate string `protobuf:"bytes,3,opt,name=creation_date,json=creationDate,proto3" json:"creation_date,omitempty"` + Originator string `protobuf:"bytes,4,opt,name=originator,proto3" json:"originator,omitempty"` + ObjectName string `protobuf:"bytes,5,opt,name=object_name,json=objectName,proto3" json:"object_name,omitempty"` + ObjectId string `protobuf:"bytes,6,opt,name=object_id,json=objectId,proto3" json:"object_id,omitempty"` + CenterName string `protobuf:"bytes,7,opt,name=center_name,json=centerName,proto3" json:"center_name,omitempty"` + RefFrame string `protobuf:"bytes,8,opt,name=ref_frame,json=refFrame,proto3" json:"ref_frame,omitempty"` + TimeSystem string `protobuf:"bytes,9,opt,name=time_system,json=timeSystem,proto3" json:"time_system,omitempty"` + MeanElementTheory string `protobuf:"bytes,10,opt,name=mean_element_theory,json=meanElementTheory,proto3" json:"mean_element_theory,omitempty"` + Epoch string `protobuf:"bytes,11,opt,name=epoch,proto3" json:"epoch,omitempty"` + MeanMotion string `protobuf:"bytes,12,opt,name=mean_motion,json=meanMotion,proto3" json:"mean_motion,omitempty"` + Eccentricity string `protobuf:"bytes,13,opt,name=eccentricity,proto3" json:"eccentricity,omitempty"` + Inclination string `protobuf:"bytes,14,opt,name=inclination,proto3" json:"inclination,omitempty"` + RaOfAscNode string `protobuf:"bytes,15,opt,name=ra_of_asc_node,json=raOfAscNode,proto3" json:"ra_of_asc_node,omitempty"` + ArgOfPericenter string `protobuf:"bytes,16,opt,name=arg_of_pericenter,json=argOfPericenter,proto3" json:"arg_of_pericenter,omitempty"` + MeanAnomaly string `protobuf:"bytes,17,opt,name=mean_anomaly,json=meanAnomaly,proto3" json:"mean_anomaly,omitempty"` + EphemerisType string `protobuf:"bytes,18,opt,name=ephemeris_type,json=ephemerisType,proto3" json:"ephemeris_type,omitempty"` + ClassificationType string `protobuf:"bytes,19,opt,name=classification_type,json=classificationType,proto3" json:"classification_type,omitempty"` + NoradCatId string `protobuf:"bytes,20,opt,name=norad_cat_id,json=noradCatId,proto3" json:"norad_cat_id,omitempty"` + ElementSetNo string `protobuf:"bytes,21,opt,name=element_set_no,json=elementSetNo,proto3" json:"element_set_no,omitempty"` + RevAtEpoch string `protobuf:"bytes,22,opt,name=rev_at_epoch,json=revAtEpoch,proto3" json:"rev_at_epoch,omitempty"` + Bstar string `protobuf:"bytes,23,opt,name=bstar,proto3" json:"bstar,omitempty"` + MeanMotionDot string `protobuf:"bytes,24,opt,name=mean_motion_dot,json=meanMotionDot,proto3" json:"mean_motion_dot,omitempty"` + MeanMotionDdot string `protobuf:"bytes,25,opt,name=mean_motion_ddot,json=meanMotionDdot,proto3" json:"mean_motion_ddot,omitempty"` + SemimajorAxis string `protobuf:"bytes,26,opt,name=semimajor_axis,json=semimajorAxis,proto3" json:"semimajor_axis,omitempty"` + Period string `protobuf:"bytes,27,opt,name=period,proto3" json:"period,omitempty"` + Apoapsis string `protobuf:"bytes,28,opt,name=apoapsis,proto3" json:"apoapsis,omitempty"` + Periapsis string `protobuf:"bytes,29,opt,name=periapsis,proto3" json:"periapsis,omitempty"` + ObjectType string `protobuf:"bytes,30,opt,name=object_type,json=objectType,proto3" json:"object_type,omitempty"` + RcsSize string `protobuf:"bytes,31,opt,name=rcs_size,json=rcsSize,proto3" json:"rcs_size,omitempty"` + CountryCode string `protobuf:"bytes,32,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"` + LaunchDate string `protobuf:"bytes,33,opt,name=launch_date,json=launchDate,proto3" json:"launch_date,omitempty"` + Site string `protobuf:"bytes,34,opt,name=site,proto3" json:"site,omitempty"` + DecayDate string `protobuf:"bytes,35,opt,name=decay_date,json=decayDate,proto3" json:"decay_date,omitempty"` + File string `protobuf:"bytes,36,opt,name=file,proto3" json:"file,omitempty"` + GpId string `protobuf:"bytes,37,opt,name=gp_id,json=gpId,proto3" json:"gp_id,omitempty"` + TleLine0 string `protobuf:"bytes,38,opt,name=tle_line0,json=tleLine0,proto3" json:"tle_line0,omitempty"` + TleLine1 string `protobuf:"bytes,39,opt,name=tle_line1,json=tleLine1,proto3" json:"tle_line1,omitempty"` + TleLine2 string `protobuf:"bytes,40,opt,name=tle_line2,json=tleLine2,proto3" json:"tle_line2,omitempty"` + Groups []string `protobuf:"bytes,41,rep,name=groups,proto3" json:"groups,omitempty"` } func (x *SatelliteDetail) Reset() { @@ -460,6 +461,13 @@ func (x *SatelliteDetail) GetTleLine2() string { return "" } +func (x *SatelliteDetail) GetGroups() []string { + if x != nil { + return x.Groups + } + return nil +} + type GetSatellitePositionsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -571,7 +579,7 @@ var file_proto_satellite_v1_satellite_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x6c, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x61, 0x6c, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x76, 0x65, 0x6c, 0x6f, 0x63, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, - 0x52, 0x08, 0x76, 0x65, 0x6c, 0x6f, 0x63, 0x69, 0x74, 0x79, 0x22, 0xaa, 0x0a, 0x0a, 0x0f, 0x53, + 0x52, 0x08, 0x76, 0x65, 0x6c, 0x6f, 0x63, 0x69, 0x74, 0x79, 0x22, 0xc2, 0x0a, 0x0a, 0x0f, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, 0x0e, 0x63, 0x63, 0x73, 0x64, 0x73, 0x5f, 0x6f, 0x6d, 0x6d, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x63, 0x73, 0x64, 0x73, 0x4f, 0x6d, 0x6d, @@ -654,40 +662,41 @@ var file_proto_satellite_v1_satellite_proto_rawDesc = []byte{ 0x09, 0x74, 0x6c, 0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x31, 0x18, 0x27, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x6c, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x31, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6c, 0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x32, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, - 0x6c, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x32, 0x22, 0x4e, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x53, 0x61, - 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x58, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x53, 0x61, - 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x73, 0x61, 0x74, 0x65, - 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, - 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, 0x74, 0x65, - 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x52, 0x0a, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, - 0x73, 0x32, 0x97, 0x02, 0x0a, 0x10, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x91, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x61, - 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x2a, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x73, - 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, - 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x19, 0x12, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, - 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x6f, 0x0a, 0x12, 0x47, 0x65, - 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x12, 0x17, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x1a, 0x1d, 0x2e, 0x73, 0x61, 0x74, 0x65, - 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, - 0x74, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, - 0x12, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2f, - 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0x40, 0x5a, 0x3e, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x73, 0x75, 0x6b, 0x6f, 0x79, - 0x61, 0x63, 0x68, 0x69, 0x2f, 0x72, 0x65, 0x61, 0x63, 0x74, 0x2d, 0x66, 0x6c, 0x69, 0x67, 0x68, - 0x74, 0x2d, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x2d, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, - 0x69, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x65, 0x4c, 0x69, 0x6e, 0x65, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x73, 0x18, 0x29, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x22, + 0x4e, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, + 0x58, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x37, 0x0a, 0x0a, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x52, 0x0a, 0x73, + 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x73, 0x32, 0x97, 0x02, 0x0a, 0x10, 0x53, 0x61, + 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x91, + 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2a, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, + 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, + 0x6c, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x73, + 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x6f, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, + 0x74, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, + 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, + 0x65, 0x1a, 0x1d, 0x2e, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x61, + 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2f, 0x7b, + 0x69, 0x64, 0x7d, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x54, 0x73, 0x75, 0x6b, 0x6f, 0x79, 0x61, 0x63, 0x68, 0x69, 0x2f, 0x72, 0x65, 0x61, + 0x63, 0x74, 0x2d, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2d, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x65, + 0x72, 0x2d, 0x73, 0x61, 0x74, 0x65, 0x6c, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/openapiv2/proto/satellite/v1/satellite.swagger.json b/gen/openapiv2/proto/satellite/v1/satellite.swagger.json index e6a1f12..486a1ed 100644 --- a/gen/openapiv2/proto/satellite/v1/satellite.swagger.json +++ b/gen/openapiv2/proto/satellite/v1/satellite.swagger.json @@ -293,6 +293,12 @@ }, "tleLine2": { "type": "string" + }, + "groups": { + "type": "array", + "items": { + "type": "string" + } } } } diff --git a/proto/satellite/v1/satellite.proto b/proto/satellite/v1/satellite.proto index c9676c4..2f509ab 100644 --- a/proto/satellite/v1/satellite.proto +++ b/proto/satellite/v1/satellite.proto @@ -55,6 +55,7 @@ message SatelliteDetail { string tle_line0 = 38; string tle_line1 = 39; string tle_line2 = 40; + repeated string groups = 41; } message GetSatellitePositionsRequest { diff --git a/service/satelliteservice.go b/service/satelliteservice.go index 5da2159..e2fbf29 100644 --- a/service/satelliteservice.go +++ b/service/satelliteservice.go @@ -5,6 +5,7 @@ import ( "github.com/go-resty/resty/v2" "github.com/joshuaferrara/go-satellite" log "github.com/sirupsen/logrus" + "github.com/tsukoyachi/react-flight-tracker-satellite/celestrack" "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" @@ -36,7 +37,6 @@ func NewSatelliteService() *SatelliteService { if err != nil { log.Error(err) } - log.Println(len(data)) calculatedMap := make(map[string]spacetrack.TLE) for _, tle := range data { @@ -51,6 +51,22 @@ func NewSatelliteService() *SatelliteService { } + // fetch from celestrak + celestrakData, err := celestrack.Scrap() + if err != nil { + log.Error(err) + } + for k, v := range celestrakData { + sat, ok := calculatedMap[k] + if !ok { + calculatedMap[k] = v + log.Info("Added ", k) + continue + } + sat.Group = append(sat.Group, v.Group...) + calculatedMap[k] = sat + } + log.Info("Total satellites: ", len(calculatedMap)) return &SatelliteService{ data: calculatedMap, } @@ -105,6 +121,7 @@ func (api SatelliteService) GetSatelliteDetail(ctx context.Context, req *v1.Sate TleLine0: tle.TLE_LINE0, TleLine1: tle.TLE_LINE1, TleLine2: tle.TLE_LINE2, + Groups: tle.Group, }, nil }