Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Orekit
Stavor
Commits
57a2f368
Commit
57a2f368
authored
Sep 05, 2014
by
Xavier
Browse files
BUGFIX: FOV including Poles
parent
e039c03d
Changes
6
Hide whitespace changes
Inline
Side-by-side
assets/www/map/Fov.js
View file @
57a2f368
...
...
@@ -2,58 +2,6 @@ function drawFov(){
if
(
show_fov
){
sc_layer
.
removeAllFeatures
();
//NORMAL CASE
var
fovPointsA
=
[];
var
fovPointsB
=
[];
var
fov_tmp_long
=
0
,
fov_tmp_lat
=
0
;
var
first
=
true
;
for
(
var
i
in
fov
)
{
var
point
=
new
OpenLayers
.
Geometry
.
Point
(
fov
[
i
].
longitude
,
fov
[
i
].
latitude
);
// transform from WGS 1984 to Spherical Mercator
point
.
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
());
if
((
i
!=
0
)
&&
((
fov
[
i
].
longitude
*
fov_tmp_long
)
<
0
)
&&
(
Math
.
abs
(
fov
[
i
].
longitude
)
+
Math
.
abs
(
fov_tmp_long
)
>
180.0
)){
var
avg_lat
=
(
fov
[
i
].
latitude
+
fov_tmp_lat
)
/
2
;
if
(
fov
[
i
].
longitude
>
0
)
var
new_lon
=
-
179.999999
;
else
var
new_lon
=
179.999999
;
if
(
first
){
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsB
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
first
=
false
;
}
else
{
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsB
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
+
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
first
=
true
;
}
}
fov_tmp_lat
=
fov
[
i
].
latitude
;
fov_tmp_long
=
fov
[
i
].
longitude
;
if
(
first
){
fovPointsA
.
push
(
point
);
}
else
{
fovPointsB
.
push
(
point
);
}
}
if
(
fovPointsA
.
length
>
0
){
fovPointsA
.
push
(
fovPointsA
[
0
]);
var
linearRing
=
new
OpenLayers
.
Geometry
.
LinearRing
(
fovPointsA
);
var
geometry
=
new
OpenLayers
.
Geometry
.
Polygon
([
linearRing
]);
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
if
(
fovPointsB
.
length
>
0
){
fovPointsB
.
push
(
fovPointsB
[
0
]);
var
linearRing
=
new
OpenLayers
.
Geometry
.
LinearRing
(
fovPointsB
);
var
geometry
=
new
OpenLayers
.
Geometry
.
Polygon
([
linearRing
]);
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
//WHOLE EARTH CASE
if
(
typeof
fov_terminator
!=
"
undefined
"
&&
fov_terminator
.
length
>
0
){
var
fovPoints
=
[];
...
...
@@ -116,8 +64,109 @@ function drawFov(){
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
}
else
{
//Normal FOVs
if
(
fov_type
==
0
)
paintFovClosedArea
();
else
paintFovOpenArea
();
}
}
}
function
paintFovClosedArea
(){
//NORMAL CASE
var
fovPointsA
=
[];
var
fovPointsB
=
[];
var
fov_tmp_long
=
0
,
fov_tmp_lat
=
0
;
var
first
=
true
;
for
(
var
i
in
fov
)
{
var
point
=
new
OpenLayers
.
Geometry
.
Point
(
fov
[
i
].
longitude
,
fov
[
i
].
latitude
);
// transform from WGS 1984 to Spherical Mercator
point
.
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
());
if
((
i
!=
0
)
&&
((
fov
[
i
].
longitude
*
fov_tmp_long
)
<
0
)
&&
(
Math
.
abs
(
fov
[
i
].
longitude
)
+
Math
.
abs
(
fov_tmp_long
)
>
180.0
)){
var
avg_lat
=
(
fov
[
i
].
latitude
+
fov_tmp_lat
)
/
2
;
if
(
fov
[
i
].
longitude
>
0
)
var
new_lon
=
-
179.999999
;
else
var
new_lon
=
179.999999
;
if
(
first
){
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsB
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
first
=
false
;
}
else
{
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsB
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
+
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
first
=
true
;
}
}
fov_tmp_lat
=
fov
[
i
].
latitude
;
fov_tmp_long
=
fov
[
i
].
longitude
;
if
(
first
){
fovPointsA
.
push
(
point
);
}
else
{
fovPointsB
.
push
(
point
);
}
}
if
(
fovPointsA
.
length
>
0
){
fovPointsA
.
push
(
fovPointsA
[
0
]);
var
linearRing
=
new
OpenLayers
.
Geometry
.
LinearRing
(
fovPointsA
);
var
geometry
=
new
OpenLayers
.
Geometry
.
Polygon
([
linearRing
]);
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
if
(
fovPointsB
.
length
>
0
){
fovPointsB
.
push
(
fovPointsB
[
0
]);
var
linearRing
=
new
OpenLayers
.
Geometry
.
LinearRing
(
fovPointsB
);
var
geometry
=
new
OpenLayers
.
Geometry
.
Polygon
([
linearRing
]);
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
}
function
paintFovOpenArea
(){
//Poles CASE
var
fovPointsA
=
[];
var
fov_tmp_long
=
0
,
fov_tmp_lat
=
0
;
var
first
=
true
;
for
(
var
i
in
fov
)
{
var
point
=
new
OpenLayers
.
Geometry
.
Point
(
fov
[
i
].
longitude
,
fov
[
i
].
latitude
);
// transform from WGS 1984 to Spherical Mercator
point
.
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
());
if
((
i
!=
0
)
&&
((
fov
[
i
].
longitude
*
fov_tmp_long
)
<
0
)
&&
(
Math
.
abs
(
fov
[
i
].
longitude
)
+
Math
.
abs
(
fov_tmp_long
)
>
180.0
)){
var
avg_lat
=
(
fov
[
i
].
latitude
+
fov_tmp_lat
)
/
2
;
if
(
fov
[
i
].
longitude
>
0
)
var
new_lon
=
-
179.999999
;
else
var
new_lon
=
179.999999
;
if
(
fov_type
==
1
)
var
new_lat
=
90.0
;
else
var
new_lat
=
-
90.0
;
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
new_lon
,
new_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
new_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
fovPointsA
.
push
(
new
OpenLayers
.
Geometry
.
Point
(
-
new_lon
,
avg_lat
).
transform
(
new
OpenLayers
.
Projection
(
"
EPSG:4326
"
),
map
.
getProjectionObject
()));
}
fov_tmp_lat
=
fov
[
i
].
latitude
;
fov_tmp_long
=
fov
[
i
].
longitude
;
fovPointsA
.
push
(
point
);
}
if
(
fovPointsA
.
length
>
0
){
fovPointsA
.
push
(
fovPointsA
[
0
]);
var
linearRing
=
new
OpenLayers
.
Geometry
.
LinearRing
(
fovPointsA
);
var
geometry
=
new
OpenLayers
.
Geometry
.
Polygon
([
linearRing
]);
var
polygonFeature
=
new
OpenLayers
.
Feature
.
Vector
(
geometry
,
null
,
sc_style
);
sc_layer
.
addFeatures
([
polygonFeature
]);
}
}
assets/www/map/Stations.js
View file @
57a2f368
...
...
@@ -26,9 +26,7 @@ function drawStationsAreas(){
function
paintOpenArea
(
arrayIndex
,
type
){
var
areaFirst
=
[];
var
areaSecond
=
[];
var
area_tmp_long
=
0
,
area_tmp_lat
=
0
;
var
first
=
true
;
for
(
var
i
in
station_areas
[
arrayIndex
].
points
)
{
var
coord
=
station_areas
[
arrayIndex
].
points
[
i
];
var
point
=
new
OpenLayers
.
Geometry
.
Point
(
...
...
assets/www/map/index.html
View file @
57a2f368
...
...
@@ -54,6 +54,7 @@
//DYNAMIC PARAMS
var
follow_sc
=
false
;
var
fov
=
new
Array
();
var
fov_type
=
0
;
var
fov_terminator
=
new
Array
();
var
sun_lat
=
0
;
var
sun_lon
=
0
;
...
...
assets/www/map/interface.js
View file @
57a2f368
...
...
@@ -11,6 +11,7 @@ function updateModelState(new_state){
sun_lon
=
state
.
sun_lon
;
//In degrees
station_areas
=
state
.
stations
;
fov
=
state
.
fov
;
fov_type
=
state
.
fov_type
;
fov_terminator
=
state
.
fov_terminator
;
solarTerminator
=
state
.
terminator
;
//console.log("interface: ".concat(String(state.point.latitude)));
...
...
src/cs/si/stavor/model/ModelSimulation.java
View file @
57a2f368
...
...
@@ -7,8 +7,6 @@ import org.apache.commons.math3.geometry.euclidean.threed.Line;
import
org.apache.commons.math3.geometry.euclidean.threed.Rotation
;
import
org.apache.commons.math3.geometry.euclidean.threed.RotationOrder
;
import
org.apache.commons.math3.geometry.euclidean.threed.Vector3D
;
import
org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet
;
import
org.apache.commons.math3.geometry.euclidean.twod.Vector2D
;
import
org.apache.commons.math3.geometry.partitioning.Region.Location
;
import
org.apache.commons.math3.geometry.spherical.twod.S2Point
;
import
org.apache.commons.math3.geometry.spherical.twod.SphericalPolygonsSet
;
...
...
@@ -27,7 +25,6 @@ import org.orekit.utils.Constants;
import
android.content.SharedPreferences
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
android.view.View
;
import
android.webkit.WebView
;
import
android.widget.ProgressBar
;
...
...
@@ -296,7 +293,7 @@ public class ModelSimulation {
double
angle
=
0
;
ArrayList
<
LatLon
>
fov
=
new
ArrayList
<
LatLon
>();
ArrayList
<
S2Point
>
fov2d
=
new
ArrayList
<
S2Point
>();
int
type
=
0
;
//0 no poles, 1 north pole, 2 south pole
int
fov_
type
=
0
;
//0 no poles, 1 north pole, 2 south pole
for
(
int
j
=
0
;
j
<
Parameters
.
Map
.
satellite_fov_points
;
j
++){
Rotation
r_circle
=
new
Rotation
(
axis
,
angle
);
Vector3D
dir
=
r_circle
.
applyTo
(
start
);
...
...
@@ -307,9 +304,10 @@ public class ModelSimulation {
//Vector3D p3d = earth.transform(intersec);
try
{
double
azim
=
intersec
.
getLongitude
();
if
(
azim
<
0
)
azim
=
(
2
*
FastMath
.
PI
)
-
azim
;
/*
if(azim < 0)
azim = (2*FastMath.PI) - azim;
*/
fov2d
.
add
(
new
S2Point
(
azim
,(
FastMath
.
PI
/
2
)-
intersec
.
getLatitude
()));
//Log.d("INSIDE","azim: "+azim+" , lat: "+((FastMath.PI/2)-intersec.getLatitude()));
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
...
...
@@ -321,14 +319,18 @@ public class ModelSimulation {
if
(
fov2d
.
size
()>
1
){
try
{
S2Point
[]
vec
=
fov2d
.
toArray
(
new
S2Point
[
fov2d
.
size
()]);
SphericalPolygonsSet
zone
=
new
SphericalPolygonsSet
(
0.01
,
vec
);
SphericalPolygonsSet
zone
=
new
SphericalPolygonsSet
(
0.
00
01
,
vec
);
Location
loc
=
zone
.
checkPoint
(
new
S2Point
(
0
,
0
));
if
(
loc
.
equals
(
Location
.
IN
SIDE
)){
type
=
1
;
if
(
loc
.
equals
(
Location
.
OUT
SIDE
)){
//Outside because the order of the points is the oposite
fov_
type
=
1
;
}
Log
.
d
(
"INSIDE"
,
loc
.
toString
()+
"-------------------------"
);
loc
=
zone
.
checkPoint
(
new
S2Point
(
0
,
FastMath
.
PI
));
if
(
loc
.
equals
(
Location
.
OUTSIDE
)){
//Outside because the order of the points is the oposite
fov_type
=
2
;
}
//Log.d("INSIDE",loc.toString()+"-------------------------");
}
catch
(
Exception
e
){
Log
.
d
(
"INSIDE"
,
"EXCEPTION"
);
//
Log.d("INSIDE","EXCEPTION");
}
}
...
...
@@ -368,7 +370,7 @@ public class ModelSimulation {
}
updateState
(
new
ModelStateMap
(
getMapPathBufferLast
(),
solarTerminator
.
toArray
(
new
LatLon
[
solarTerminator
.
size
()]),
fov
.
toArray
(
new
LatLon
[
fov
.
size
()]),
fovTerminator
.
toArray
(
new
LatLon
[
fovTerminator
.
size
()]),
stations
.
toArray
(
new
StationArea
[
stations
.
size
()]),
sun_lat
,
sun_lon
));
updateState
(
new
ModelStateMap
(
getMapPathBufferLast
(),
solarTerminator
.
toArray
(
new
LatLon
[
solarTerminator
.
size
()]),
fov
.
toArray
(
new
LatLon
[
fov
.
size
()]),
fov_type
,
fovTerminator
.
toArray
(
new
LatLon
[
fovTerminator
.
size
()]),
stations
.
toArray
(
new
StationArea
[
stations
.
size
()]),
sun_lat
,
sun_lon
));
ModelInfo
new_info
=
new
ModelInfo
();
...
...
src/cs/si/stavor/model/ModelStateMap.java
View file @
57a2f368
...
...
@@ -14,17 +14,19 @@ import cs.si.stavor.station.StationArea;
public
class
ModelStateMap
implements
Serializable
{
public
MapPoint
point
;
public
LatLon
[]
fov
,
fov_terminator
,
terminator
;
public
int
fov_type
=
0
;
public
double
sun_lat
=
0
,
sun_lon
=
0
;
public
StationArea
[]
stations
;
public
ModelStateMap
(
MapPoint
mapPathBufferLast
,
LatLon
[]
terminator
,
LatLon
[]
fov
,
LatLon
[]
fov_terminator
,
StationArea
[]
stations
,
double
sun_lat
,
public
ModelStateMap
(
MapPoint
mapPathBufferLast
,
LatLon
[]
terminator
,
LatLon
[]
fov
,
int
fov_type
,
LatLon
[]
fov_terminator
,
StationArea
[]
stations
,
double
sun_lat
,
double
sun_lon
)
{
this
.
point
=
mapPathBufferLast
;
this
.
sun_lat
=
sun_lat
;
this
.
sun_lon
=
sun_lon
;
this
.
stations
=
stations
;
this
.
fov
=
fov
;
this
.
fov_type
=
fov_type
;
this
.
fov_terminator
=
fov_terminator
;
this
.
terminator
=
terminator
;
}
...
...
Write
Preview
Supports
Markdown
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