Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alexander Lapshin
common
Commits
15d98c3b
Commit
15d98c3b
authored
Sep 21, 2019
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
22ec10db
Changes
16
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
350 additions
and
348 deletions
+350
-348
json_functions.h
json/json_functions.h
+44
-33
Converter.h
utils/Converter.h
+59
-20
TextFunctions.h
utils/TextFunctions.h
+8
-0
TimeFunctions.h
utils/TimeFunctions.h
+7
-1
XMLFunctions.h
utils/XMLFunctions.h
+10
-9
ephi.h
utils/ephi.h
+14
-54
ephinterp.cpp
utils/ephinterp.cpp
+39
-17
interpolate.cpp
utils/interpolate.cpp
+71
-158
interpolate.h
utils/interpolate.h
+6
-8
ires.cpp
utils/ires.cpp
+3
-3
ires.h
utils/ires.h
+3
-5
orbBlock.cpp
utils/orbBlock.cpp
+44
-4
orbBlock.h
utils/orbBlock.h
+5
-6
orbBlocks.cpp
utils/orbBlocks.cpp
+30
-25
orbBlocks.h
utils/orbBlocks.h
+6
-4
orb_date.cpp
utils/orb_date.cpp
+1
-1
No files found.
json/json_functions.h
View file @
15d98c3b
This diff is collapsed.
Click to expand it.
utils/Converter.h
View file @
15d98c3b
...
...
@@ -3,36 +3,72 @@
#include <string>
#include <sstream>
class
Converter
{
// enum STR2INT_ERROR { XSUCCESS, XOVERFLOW, XUNDERFLOW, XINCONVERTIBLE };
//
// STR2INT_ERROR str2int(int& i, char const* s, int base = 0)
// {
// char* end;
// long l;
// errno = 0;
// l = strtol(s, &end, base);
// if ((errno == ERANGE && l == LONG_MAX) || l > INT_MAX) {
// return XOVERFLOW;
// }
// if ((errno == ERANGE && l == LONG_MIN) || l < INT_MIN) {
// return XUNDERFLOW;
// }
// if (*s == '\0' || *end != '\0') {
// return XINCONVERTIBLE;
// }
// i = l;
// return XSUCCESS;
// }
class
Converter
{
public
:
static
bool
ToNumber
(
const
std
::
string
&
str
,
unsigned
short
int
&
val
)
{
std
::
istringstream
ss
(
str
);
ss
>>
val
;
return
!
ss
.
fail
();
// std::istringstream ss(str);
// ss >> val;
// return !ss.fail();
// int ival;
// bool res = str2int(ival, str.c_str()) == XSUCCESS;
// val = ival;
val
=
std
::
stoi
(
str
,
nullptr
);
return
true
;
}
static
bool
ToNumber
(
const
std
::
string
&
str
,
int
&
val
)
{
std
::
istringstream
ss
(
str
);
ss
>>
val
;
return
!
ss
.
fail
();
//std::istringstream ss(str);
//ss >> val;
//return !ss.fail();
val
=
std
::
stoi
(
str
,
nullptr
);
return
true
;
}
static
bool
ToNumber
(
const
std
::
string
&
str
,
double
&
val
)
{
std
::
istringstream
ss
(
str
);
ss
>>
val
;
return
!
ss
.
fail
();
// std::istringstream ss(str);
// ss >> val;
// return !ss.fail();
val
=
std
::
stod
(
str
,
nullptr
);
return
true
;
}
static
bool
ToNumber
(
const
std
::
string
&
str
,
float
&
val
)
{
std
::
istringstream
ss
(
str
);
ss
>>
val
;
return
!
ss
.
fail
();
// std::istringstream ss(str);
// ss >> val;
// return !ss.fail();
val
=
std
::
stof
(
str
,
nullptr
);
return
true
;
}
static
bool
ToNumber
(
const
std
::
string
&
str
,
bool
&
val
)
...
...
@@ -41,14 +77,17 @@ public:
val
=
false
;
return
true
;
}
else
if
(
str
==
"true"
||
str
==
"TRUE"
)
{
if
(
str
==
"true"
||
str
==
"TRUE"
)
{
val
=
true
;
return
true
;
}
else
{
std
::
istringstream
ss
(
str
);
ss
>>
val
;
return
!
ss
.
fail
();
}
//std::istringstream ss(str);
//ss >> val;
//return !ss.fail();
val
=
std
::
stoi
(
str
,
nullptr
);
return
true
;
}
};
utils/TextFunctions.h
View file @
15d98c3b
...
...
@@ -356,3 +356,11 @@ std::string implode(std::string delim, const std::vector<T>& vec)
return
ss
.
str
();
}
template
<
typename
T
>
bool
in_array
(
const
std
::
vector
<
T
>&
src
,
T
subject
)
{
return
std
::
find
(
std
::
begin
(
src
),
std
::
end
(
src
),
subject
)
!=
std
::
end
(
src
);
}
utils/TimeFunctions.h
View file @
15d98c3b
...
...
@@ -2,7 +2,6 @@
#include "Converter.h"
#include "TM.h"
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
...
...
@@ -91,6 +90,13 @@ static bool StrToDate(const std::string& date, TimeGD& gd)
}
}
static
TimeJD
StrToDate
(
const
std
::
string
&
sdate
)
{
TimeGD
date
;
StrToDate
(
sdate
,
date
);
return
date
;
}
static
int
isleap
(
int
year
)
{
return
(
year
%
4
==
0
&&
year
%
100
!=
0
)
||
(
year
%
400
==
0
);
...
...
utils/XMLFunctions.h
View file @
15d98c3b
#ifndef XMLFUNCTIONS_H
#define XMLFUNCTIONS_H
#pragma once
#include <myXML_Document.hpp>
#include "MException.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "TM.h"
...
...
@@ -18,7 +15,6 @@ bool FindFirstContainer(myXML::Contain* parent, const std::string& path, myXML::
bool
FindXMLContainer
(
const
std
::
map
<
std
::
string
,
myXML
::
Contain
*>&
items
,
const
std
::
string
&
name
,
myXML
::
Contain
*&
result
);
bool
FindXMLContainer
(
myXML
::
Contain
*
parent
,
const
std
::
string
&
path
,
myXML
::
Contain
*&
result
);
template
<
typename
T
>
void
ReadXML
(
T
storage
,
TimeGD
&
result
);
template
<
typename
T
>
...
...
@@ -36,7 +32,6 @@ void ReadXML(T storage, std::string subname, std::vector<T2>& result);
template
<
typename
T
,
typename
T2
,
typename
T3
>
void
ReadXML
(
T
storage
,
std
::
string
subname
,
std
::
map
<
T2
,
T3
>&
result
);
template
<
typename
T
>
void
ReadXMLVector
(
myXML
::
Contain
*
con
,
std
::
string
subname
,
std
::
vector
<
T
>&
result
)
{
...
...
@@ -364,6 +359,14 @@ void PutValue(std::ostream& ss, std::string conName, const T& object)
ss
<<
"</"
<<
conName
<<
">"
;
}
template
<
typename
T
>
void
PutValue
(
std
::
ostream
&
ss
,
std
::
string
conName
,
const
T
*
object
)
{
ss
<<
"<"
<<
conName
<<
">"
;
object
->
ToXml
(
ss
);
ss
<<
"</"
<<
conName
<<
">"
;
}
template
<
typename
T
>
void
PutValueAttr
(
std
::
ostream
&
ss
,
std
::
string
conName
,
const
T
&
object
)
{
...
...
@@ -432,8 +435,7 @@ static void PutValue(std::ostream& ss, std::string conName, std::string subName,
static
void
PutValue
(
std
::
ostream
&
ss
,
const
std
::
string
&
conName
,
const
double
value
,
const
std
::
string
&
attributes
=
""
)
{
int
precision
=
15
;
ss
<<
std
::
setprecision
(
precision
);
ss
<<
std
::
setprecision
(
std
::
numeric_limits
<
double
>::
digits10
+
2
);
if
(
attributes
.
empty
())
{
ss
<<
"<"
<<
conName
<<
">"
<<
value
<<
"</"
<<
conName
<<
">"
;
}
...
...
@@ -466,4 +468,3 @@ static void LoadXmlString(const std::string& str, myXML::Document& doc)
}
}
#endif
utils/ephi.h
View file @
15d98c3b
#pragma once
struct
eh
{
double
prf
;
double
xpond_xmit_delay
;
double
xpond_utc_off
;
double
xpond_osc_drift
;
double
cofm_corr
;
int
cospar_id
;
int
sic
;
int
norad
;
int
eph_seq
;
int
sttpyear
;
int
sttpmonth
;
int
sttpday
;
int
sttphour
;
int
sttpmin
;
int
sttpsec
;
int
endpyear
;
int
endpmonth
;
int
endpday
;
int
endphour
;
int
endpmin
;
int
endpsec
;
int
ephsep
;
int
compat
;
int
version
;
int
epyear
;
int
epmon
;
int
epday
;
int
ephour
;
int
tar_type
;
int
ref_frame
;
int
rot_type
;
int
cofm_app
;
int
ltcorr
;
int
atrk_ro_0
;
int
xtrk_ro_0
;
int
rtrk_ro_0
;
int
atrk_ro_1
;
int
xtrk_ro_1
;
int
rtrk_ro_1
;
int
atrk_ro_2
;
int
xtrk_ro_2
;
int
rtrk_ro_2
;
char
eph_source
[
4
];
char
tar_name
[
10
];
char
eph_notes
[
10
];
};
// class export_ei {
// std::string jds;
// std::string x;
// std::string y;
// std::string z;
// std::string vx;
// std::string vy;
// std::string vz;
// };
struct
ei
class
ei
{
public
:
ei
();
~
ei
();
double
*
jdi
;
double
*
jdf
;
double
*
outv
[
6
];
double
*
c12
;
double
*
c23
;
int
*
leapflag
;
double
*
jds
;
int
nv
;
};
int
cephinit
(
char
*
str
);
int
cinterp_pvac
(
ei
&
ephi
,
double
jdint
,
double
seceph
,
double
outvec
[
6
],
int
fvel
,
int
*
ircode
);
int
cinterp_pvac
(
const
ei
&
ephi
,
double
jdint
,
double
seceph
,
double
outvec
[
6
],
int
fvel
,
int
*
ircode
);
utils/ephinterp.cpp
View file @
15d98c3b
#include <stdio.h>
#include <math.h>
#include <cmath>
#include "ephi.h"
int
debug
=
0
;
int
bs_lower_bound
(
double
a
[],
int
n
,
double
x
)
{
int
bs_lower_bound
(
const
double
a
[],
const
int
n
,
const
double
x
)
{
int
l
=
0
;
int
h
=
n
;
// Not n - 1
while
(
l
<
h
)
{
int
mid
=
(
l
+
h
)
/
2
;
const
int
mid
=
(
l
+
h
)
/
2
;
if
(
x
<=
a
[
mid
])
{
h
=
mid
;
}
...
...
@@ -21,6 +21,30 @@ int bs_lower_bound(double a[], int n, double x) {
void
hermite
(
int
index
,
int
ityp
,
const
double
*
x
,
const
double
*
y
,
const
double
*
z
,
int
nmax
,
int
nval
,
double
xp
,
double
*
yp
,
double
*
zp
,
int
*
ircode
);
ei
::
ei
()
:
jdi
(
nullptr
),
jdf
(
nullptr
),
outv
(),
jds
(
nullptr
),
nv
(
-
1
)
{
for
(
auto
&
el
:
outv
)
{
el
=
nullptr
;
}
}
ei
::~
ei
()
{
delete
[]
jdi
;
delete
[]
jdf
;
delete
[]
jds
;
for
(
auto
&
el
:
outv
)
{
delete
[]
el
;
}
}
/*-----------------------------------------------------------------------
void cinterp_pvac (jdint, seceph, outvec, backvec,
aberout,aberback, corr12, corr23, ircode)
...
...
@@ -43,22 +67,21 @@ Date: 1 May, 2003
History:
-----------------------------------------------------------------------*/
int
cinterp_pvac
(
ei
&
ephi
,
const
ei
&
ephi
,
double
jdint
,
double
seceph
,
double
outvec
[
6
],
int
fvel
,
const
int
fvel
,
int
*
ircode
)
{
double
itime
,
z
,
vz
;
/* z is dummy for derivative field */
int
j
;
double
z
,
vz
;
/* z is dummy for derivative field */
itime
=
((
seceph
/
86400.e0
-
ephi
.
jdf
[
0
])
+
(
jdint
-
ephi
.
jdi
[
0
]))
*
86400.e0
;
const
double
itime
=
((
seceph
/
86400.e0
-
ephi
.
jdf
[
0
])
+
(
jdint
-
ephi
.
jdi
[
0
]))
*
86400.e0
;
/* 3 or 6 elements? Handle velocity if present */
int
pindex
=
bs_lower_bound
((
double
*
)
ephi
.
jds
,
ephi
.
nv
,
itime
);
const
int
pindex
=
bs_lower_bound
((
double
*
)
ephi
.
jds
,
ephi
.
nv
,
itime
);
for
(
j
=
0
;
j
<
6
;
j
++
)
{
for
(
int
j
=
0
;
j
<
6
;
j
++
)
{
/* Out */
/* Position */
if
(
j
<
3
)
{
...
...
@@ -84,4 +107,3 @@ int cinterp_pvac(
return
0
;
}
utils/interpolate.cpp
View file @
15d98c3b
This diff is collapsed.
Click to expand it.
utils/interpolate.h
View file @
15d98c3b
...
...
@@ -12,21 +12,19 @@ class XInterpolator
public
:
XInterpolator
();
XInterpolator
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
);
~
XInterpolator
();
Vect6
get_pos
(
const
TimeJD
&
date
)
const
;
int
get_size
()
const
{
return
m_positions
.
size
();
}
XInterpolator
(
const
std
::
vector
<
IRes
>&
vec
);
Vect6
get_pos
(
const
TimeJD
&
date
,
bool
tks
=
false
)
const
;
TimeJD
get_beg
()
const
{
return
m_beg
;
}
TimeJD
get_end
()
const
{
return
m_end
;
}
const
SInitOrbit
&
get_orbit
()
const
{
return
m_orbit
;
}
static
void
calc_positions
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
std
::
vector
<
IRes
>&
result
);
void
export_data
()
const
;
std
::
vector
<
IRes
>
m_positions
;
private
:
void
create
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
);
void
create
(
const
std
::
vector
<
IRes
>&
positions
);
static
void
propagate
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
int
dir
,
std
::
vector
<
IRes
>&
result
);
static
void
propagate_dir
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
int
dir
,
std
::
vector
<
IRes
>&
result
);
TimeJD
m_beg
;
TimeJD
m_end
;
ei
*
m_ephi
;
std
::
vector
<
IRes
>
m_positions
;
SInitOrbit
m_orbit
;
ei
m_ephi
;
};
utils/ires.cpp
View file @
15d98c3b
#include "ires.h"
#include <utility>
IRes
::
IRes
(
Vect6
vec
,
const
TimeJD
&
date
,
int
step
,
double
age
,
TOrbitId
orbitid
,
bool
addon
)
IRes
::
IRes
(
const
Vect6
&
vec
,
const
TimeJD
&
date
,
const
double
age
,
std
::
string
orbitid
,
const
bool
addon
)
:
m_orbitid
(
std
::
move
(
orbitid
)),
m_vec
(
vec
),
m_date
(
date
),
m_step
(
step
),
m_age
(
age
),
m_orbitid
(
orbitid
),
m_addon
(
addon
)
{
}
utils/ires.h
View file @
15d98c3b
...
...
@@ -2,7 +2,7 @@
#include "DVectors.h"
#include "TM.h"
#include
"OrbitId.h"
#include
<string>
class
IRes
{
...
...
@@ -10,17 +10,15 @@ public:
IRes
()
{
};
IRes
(
Vect6
vec
,
const
TimeJD
&
date
,
int
step
,
double
age
,
TOrbitId
orbitid
,
bool
addon
=
false
);
IRes
(
const
Vect6
&
vec
,
const
TimeJD
&
date
,
double
age
,
std
::
string
orbitid
,
bool
addon
=
false
);
TimeJD
get_date
()
const
{
return
m_date
;
}
Vect6
get_pos
()
const
{
return
m_vec
;
}
int
get_step
()
const
{
return
m_step
;
}
bool
is_addon
()
const
{
return
m_addon
;
}
double
get_age
()
const
{
return
m_age
;
}
private
:
TOrbitId
m_orbitid
;
std
::
string
m_orbitid
;
Vect6
m_vec
;
TimeJD
m_date
;
int
m_step
;
double
m_age
;
bool
m_addon
;
};
utils/orbBlock.cpp
View file @
15d98c3b
#include "orbBlock.h"
#include <utility>
#include "TextFunctions.h"
OrbBlock
::
OrbBlock
()
:
m_ip
(
nullptr
)
{
}
OrbBlock
::
OrbBlock
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
...
...
@@ -23,16 +30,16 @@ OrbBlock::OrbBlock(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
double
mind
,
const
std
::
string
&
next_orbitid
const
double
mind
,
std
::
string
next_orbitid
)
:
m_orbit
(
orbit
),
m_beg
(
beg
),
m_end
(
end
),
m_mind
(
mind
),
m_next_orbitid
(
next_orbitid
),
m_ip
(
0
)
m_next_orbitid
(
std
::
move
(
next_orbitid
)
),
m_ip
(
nullptr
)
{
#ifdef _DEBUG
m_beg_s
=
DateToStr
(
beg
);
...
...
@@ -49,3 +56,36 @@ void OrbBlock::interpolate(const TimeJD& beg, const TimeJD& end)
{
m_ip
=
new
XInterpolator
(
m_orbit
,
beg
,
end
);
}
void
OrbBlock
::
load
(
const
jsonval
&
parent
)
{
std
::
string
orbitid
;
loadjson
(
parent
,
"id"
,
orbitid
);
loadjson
(
parent
,
"beg"
,
m_beg
);
loadjson
(
parent
,
"end"
,
m_end
);
loadjson
(
parent
,
"mind_km"
,
m_mind
,
false
);
std
::
string
vecs
;
loadjson
(
parent
,
"vecs"
,
vecs
,
false
);
static
std
::
vector
<
std
::
string
>
arr
=
splitstr
(
vecs
,
","
);
std
::
vector
<
IRes
>
vres
;
for
(
size_t
i
=
0
;
i
<
arr
.
size
();
i
+=
8
)
{
int
days
;
Converter
::
ToNumber
(
arr
[
i
],
days
);
double
fraction
;
Converter
::
ToNumber
(
arr
[
i
+
1
],
fraction
);
double
x
,
y
,
z
,
vx
,
vy
,
vz
;
Converter
::
ToNumber
(
arr
[
i
+
2
],
x
);
Converter
::
ToNumber
(
arr
[
i
+
3
],
y
);
Converter
::
ToNumber
(
arr
[
i
+
4
],
z
);
Converter
::
ToNumber
(
arr
[
i
+
5
],
vx
);
Converter
::
ToNumber
(
arr
[
i
+
6
],
vy
);
Converter
::
ToNumber
(
arr
[
i
+
7
],
vz
);
vres
.
emplace_back
(
Vect6
(
x
,
y
,
z
,
vx
,
vy
,
vz
),
TimeJD
(
days
,
fraction
),
0
,
orbitid
);
}
}
utils/orbBlock.h
View file @
15d98c3b
...
...
@@ -3,15 +3,13 @@
#include "TM.h"
#include "StateVector.h"
#include "interpolate.h"
#include "json_functions.h"
class
OrbBlock
{
class
OrbBlock
{
public
:
OrbBlock
()
{
};
OrbBlock
();;
OrbBlock
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
);
OrbBlock
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
double
mind
,
const
std
::
string
&
next_orbitid
);
OrbBlock
(
const
SInitOrbit
&
orbit
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
double
mind
,
std
::
string
next_orbitid
);
~
OrbBlock
();
TimeJD
get_beg
()
const
{
return
m_beg
;
}
...
...
@@ -21,6 +19,7 @@ public:
std
::
string
get_next_orbitid
()
const
{
return
m_next_orbitid
;
}
void
interpolate
(
const
TimeJD
&
beg
,
const
TimeJD
&
end
);
const
XInterpolator
*
get_interpolator
()
const
{
return
m_ip
;
}
void
load
(
const
jsonval
&
parent
);
private
:
SInitOrbit
m_orbit
;
TimeJD
m_beg
;
...
...
utils/orbBlocks.cpp
View file @
15d98c3b
#include "orbBlocks.h"
#include "TimeFunctions.h"
#include "Propagator.h"
#include "xalgorithm.h"
#include "orb_date.h"
...
...
@@ -18,13 +17,12 @@ void OrbBlocksStore::init(
{
SInitOrbits
sordet_orbits
=
orbits
;
std
::
sort
(
sordet_orbits
.
begin
(),
sordet_orbits
.
end
(),
[](
const
SInitOrbit
&
a
,
const
SInitOrbit
&
b
)
{
std
::
sort
(
sordet_orbits
.
begin
(),
sordet_orbits
.
end
(),
[](
const
SInitOrbit
&
a
,
const
SInitOrbit
&
b
)
{
return
a
.
GetDate
()
<
b
.
GetDate
();
});
m_beg_before_filter
=
beg
?
*
beg
:
sordet_orbits
.
front
().
GetDate
();
m_end_before_filter
=
end
?
*
end
:
sordet_orbits
.
back
().
GetDate
();
//
m_beg_before_filter = beg ? *beg : sordet_orbits.front().GetDate();
//
m_end_before_filter = end ? *end : sordet_orbits.back().GetDate();
if
(
filter_orbits
)
{
sordet_orbits
=
filter
(
sordet_orbits
);
...
...
@@ -103,6 +101,16 @@ SInitOrbits OrbBlocksStore::filter(const SInitOrbits& orbits) const
return
result
;
}
void
loadjson
(
const
jsonval
&
parent
,
OrbBlock
&
item
)
{
item
.
load
(
parent
);
}
void
OrbBlocksStore
::
load
(
const
jsonval
&
parent
)
{
loadjson
(
parent
,
"records"
,
m_blocks
);
}
void
OrbBlocksStore
::
init_min_dist
(
const
SInitOrbits
&
orbits
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
bool
forced
)
{
TimeJD
left
=
beg
;
...
...
@@ -113,7 +121,7 @@ void OrbBlocksStore::init_min_dist(const SInitOrbits& orbits, const TimeJD& beg,
const
SInitOrbit
&
orb1
=
orbits
[
i
];
if
(
i
==
orbits
.
size
()
-
1
)
{
m_blocks
.
push_back
(
OrbBlock
(
orb1
,
left
,
end
)
);
m_blocks
.
emplace_back
(
orb1
,
left
,
end
);
break
;
}
...
...
@@ -132,7 +140,7 @@ void OrbBlocksStore::init_min_dist(const SInitOrbits& orbits, const TimeJD& beg,
//no intersection
if
(
orb2beg
<
left
)
{
//orbit1 if out of left and orbit2 has left border inside, so orbit1 no longer needed
throw
(
Exp
()
<<
"assert point 0"
)
;
throw
Exp
()
<<
"assert point 0"
;
}
TimeJD
right
;
...
...
@@ -172,13 +180,12 @@ void OrbBlocksStore::init_min_dist(const SInitOrbits& orbits, const TimeJD& beg,
}
}
class
MinDistEvaluator
{
class
MinDistEvaluator
{
public
:
MinDistEvaluator
(
const
XInterpolator
&
ip1
,
const
XInterpolator
&
ip2
,
const
TimeJD
&
base
)
:
m_base
(
base
),
m_ip1
(
ip1
),
m_ip2
(
ip2
),
m_base
(
base
)
m_ip2
(
ip2
)
{
}
...
...
@@ -186,8 +193,8 @@ public:
{
TimeJD
date
=
ShiftDate
(
m_base
,
time
*
86400
);
Vect6
p1
=
m_ip1
.
get_pos
(
date
);
Vect6
p2
=
m_ip2
.
get_pos
(
date
);
const
Vect6
p1
=
m_ip1
.
get_pos
(
date
);
const
Vect6
p2
=
m_ip2
.
get_pos
(
date
);
return
sqrt
(
sqr
(
p1
.
x
-
p2
.
x
)
+
...
...
@@ -201,8 +208,7 @@ private:
const
XInterpolator
&
m_ip2
;
};
void
OrbBlocksStore
::
calc_min_dist
(
const
SInitOrbit
&
orb1
,
const
SInitOrbit
&
orb2
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
TimeJD
&
result_jd
,
double
&
result_dist
)
const
void
OrbBlocksStore
::
calc_min_dist
(
const
SInitOrbit
&
orb1
,
const
SInitOrbit
&
orb2
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
TimeJD
&
result_jd
,
double
&
result_dist
)
const
{
XInterpolator
ip1
(
orb1
,
beg
,
end
);
XInterpolator
ip2
(
orb2
,
beg
,
end
);
...
...
@@ -242,30 +248,29 @@ void OrbBlocksStore::calc_min_dist(const SInitOrbit& orb1, const SInitOrbit& orb
Vect6
OrbBlocksStore
::
get_pos
(
const
TimeJD
&
date
)
const
{
for
(
OrbBlocks
::
const_iterator
it
=
m_blocks
.
begin
();
it
!=
m_blocks
.
end
();
++
it
)
{
if
(
date
>=
it
->
get_beg
()
&&
date
<=
it
->
get_end
())
{
return
it
->
get_interpolator
()
->
get_pos
(
date
);
for
(
const
auto
&
block
:
m_blocks
)
{
if
(
date
>=
block
.
get_beg
()
&&
date
<=
block
.
get_end
())
{
return
block
.
get_interpolator
()
->
get_pos
(
date
);
}
}
throw
(
Exp
()
<<
"no orbit found"
)
;
throw
Exp
()
<<
"no orbit found"
;
}
const
SInitOrbit
&
OrbBlocksStore
::
get_orbit
(
const
TimeJD
&
date
)
const
{
for
(
OrbBlocks
::
const_iterator
it
=
m_blocks
.
begin
();
it
!=
m_blocks
.
end
();
++
it
)
{
if
(
date
>=
it
->
get_beg
()
&&
date
<=
it
->
get_end
())
{
return
it
->
get_interpolator
()
->
get_orbit
();
for
(
const
auto
&
block
:
m_blocks
)
{
if
(
date
>=
block
.
get_beg
()
&&
date
<=
block
.
get_end
())
{
return
block
.
get_orbit
();
}
}
throw
(
Exp
()
<<
"no orbit found"
)
;
throw
Exp
()
<<
"no orbit found"
;
}
SInitOrbits
OrbBlocksStore
::
calc_orbits
(
std
::
vector
<
TimeJD
>
dates
,
bool
variates
)
const
{
std
::
sort
(
dates
.
begin
(),
dates
.
end
(),
[](
const
TimeJD
&
a
,
const
TimeJD
&
b
)
{
std
::
sort
(
dates
.
begin
(),
dates
.
end
(),
[](
const
TimeJD
&
a
,
const
TimeJD
&
b
)
{
return
a
<
b
;
});
...
...
utils/orbBlocks.h
View file @
15d98c3b
...
...
@@ -4,6 +4,7 @@
#include <vector>
#include "orbBlock.h"
#include "StateVector.h"
#include "json_functions.h"
typedef
std
::
vector
<
OrbBlock
>
OrbBlocks
;
...
...
@@ -18,13 +19,14 @@ public:
const
SInitOrbit
&
get_orbit
(
const
TimeJD
&
date
)
const
;
const
OrbBlocks
&
get_blocks
()
const
{
return
m_blocks
;
}
OrbBlocks
&
get_blocks
()
{
return
m_blocks
;
}
const
TimeJD
&
get_beg_before_filter
()
const
{
return
m_beg_before_filter
;
}
const
TimeJD
&
get_end_before_filter
()
const
{
return
m_end_before_filter
;
}
//const TimeJD& get_beg_before_filter() const { return m_beg_before_filter; }
//const TimeJD& get_end_before_filter() const { return m_end_before_filter; }
void
load
(
const
jsonval
&
parent
);
private
:
void
init_min_dist
(
const
SInitOrbits
&
orbits
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
bool
forced
);
void
calc_min_dist
(
const
SInitOrbit
&
orb1
,
const
SInitOrbit
&
orb2
,
const
TimeJD
&
beg
,
const
TimeJD
&
end
,
TimeJD
&
result_jd
,
double
&
result_dist
)
const
;
SInitOrbits
filter
(
const
SInitOrbits
&
orbits
)
const
;
OrbBlocks
m_blocks
;
TimeJD
m_beg_before_filter
;
TimeJD
m_end_before_filter
;
//
TimeJD m_beg_before_filter;
//
TimeJD m_end_before_filter;
};
utils/orb_date.cpp
View file @
15d98c3b
...
...
@@ -62,7 +62,7 @@ void propagate_date(Propagator& prop, const TimeJD& date, IRes& result)
{
PhasePoint6D
pos
;
prop
.
Propagate
(
date
,
pos
);
result
=
IRes
(
pos
.
CoordsVel
,
date
,
0
,
DaysInterval
(
prop
.
GetInitOrbit
().
GetDate
(),
date
),
prop
.
GetInitOrbit
().
GetId
());
result
=
IRes
(
pos
.
CoordsVel
,
date
,
DaysInterval
(
prop
.
GetInitOrbit
().
GetDate
(),
date
),
prop
.
GetInitOrbit
().
GetId
());
}
void
propagate_date
(
Propagator
&
prop
,
const
TimeJD
&
date
,
SInitOrbit
&
result
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment