Skip to content

Commit

Permalink
Improved responsiveness - Resolved #5
Browse files Browse the repository at this point in the history
  • Loading branch information
clodomir vianna da silva neto committed Apr 30, 2024
1 parent 194eab0 commit ab69bc7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
1 change: 0 additions & 1 deletion components/Interface/ViewPanel/ViewPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ app.component('view-panel', {
]
}
},

props: {
tracking: {
type: Boolean,
Expand Down
22 changes: 14 additions & 8 deletions components/Interface/ViewPanel/components/Map2DTab/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ function setFootprintCircleRadius(){
longitudinal_length = 2 * Math.PI * earth_radius * Math.cos(current_latitude*Math.PI/180);
earth_meridional_length = 40074;

map_width = document.getElementById('map2D-img').offsetWidth;
map_height = document.getElementById('map2D-img').offsetHeight;
let map_width = document.getElementById('map2D-img').offsetWidth;
let map_height = document.getElementById('map2D-img').offsetHeight;

document.getElementById('footprint-radius').style.width = map_width * (footprint_radius/longitudinal_length) + 'px';
document.getElementById('footprint-radius').style.height = map_height * (footprint_radius/earth_meridional_length) + 'px';
Expand All @@ -196,15 +196,18 @@ function updateObjectPosition(object_path){
latitude = object_path[object_path.length-1]['latitude'];
longitude = object_path[object_path.length-1]['longitude'];

let map_width = document.getElementById('map2D-img').offsetWidth;
let map_height = document.getElementById('map2D-img').offsetHeight;

//Unit conversions, scaling and positional adjustments:
satellite_picture_width = Number(document.getElementById("satellite").offsetWidth);
satY = (Number(latitude) - 90)*(-2.2222) - satellite_picture_width/2;
satX = (Number(longitude) + 180)*(2.2222) - satellite_picture_width/2;
satY = (Number(latitude) - 90)*(-map_height/180) - satellite_picture_width/2;
satX = (Number(longitude) + 180)*(map_width/360) - satellite_picture_width/2;

visibility_radius_width = Number(document.getElementById("footprint-radius").offsetWidth);
visibility_radius_height = Number(document.getElementById("footprint-radius").offsetHeight);
radiusY = (Number(latitude) - 90)*(-2.2222) - visibility_radius_height/2;
radiusX = (Number(longitude) + 180)*(2.2222) - visibility_radius_width/2;
radiusY = (Number(latitude) - 90)*(-map_height/180) - visibility_radius_height/2;
radiusX = (Number(longitude) + 180)*(map_width/360) - visibility_radius_width/2;

document.getElementById("satellite").style.transform = "translate(" + satX + "px, " + satY + "px)";
document.getElementById("footprint-radius").style.transform = "translate(" + radiusX + "px, " + radiusY + "px)";
Expand All @@ -220,6 +223,9 @@ function updateNationalFlagPosition(object_path){
latitude = object_path[object_path.length-1]['latitude'];
longitude = object_path[object_path.length-1]['longitude'];

let map_width = document.getElementById('map2D-img').offsetWidth;
let map_height = document.getElementById('map2D-img').offsetHeight;

// https://secure.geonames.org/countryCodeJSON?formatted=true&lat=47.03&lng=10.2&username=clodolinus&style=full
fetch("https://secure.geonames.org/countryCodeJSON?formatted=true&lat=" + latitude + "&lng=" + longitude + "&username=clodolinus&style=full")
.then((response) => response.json())
Expand All @@ -235,8 +241,8 @@ function updateNationalFlagPosition(object_path){
document.getElementById("satellite-location-flag").src = flagURL;

satellite_picture_width = Number(document.getElementById("satellite").offsetWidth);
positionY = (Number(latitude) - 90)*(-2.2222);
positionX = (Number(longitude) + 180)*(2.2222);
positionY = (Number(latitude) - 90)*(-map_height/180);
positionX = (Number(longitude) + 180)*(map_width/360);

document.getElementById("satellite-location-flag").style.transform = "translate(" + (positionX - satellite_picture_width/2 -5) + "px, " + (positionY - satellite_picture_width/2 - 5) + "px)";
document.getElementById("satellite-location-name").style.transform = "translate(" + (positionX + 10) + "px, " + (positionY + 10) + "px)";
Expand Down
2 changes: 1 addition & 1 deletion components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ app.component('header-vue', {

// Letting celestrck direct link makes each user responsible by the use of this resource, since it is its own IP in use for these requests.
// Differently from the N2YO plataform, Celestrak allows that approach.
fetch(skyvue_php_source)
fetch(celestrack_URL)
.then((response => response.text()))
.then((body) => {

Expand Down
26 changes: 17 additions & 9 deletions responsiveness.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
align-items: center;

row-gap: 100px;

}

.interface {
Expand Down Expand Up @@ -179,16 +178,25 @@
}

#satbot-container {
position: fixed;
z-index: 2;
right: 0;
top: 0;
bottom: none;

width: fit-content;
height: 400px;
max-height: 100%;

max-height: 40%;

}

#view-labels {
flex-wrap: wrap;
}

.sky-status {

width: 100%;
margin: 0;
}

.sky-status-field-value {
padding: 0;
min-width: 6vw;
}
}

11 changes: 7 additions & 4 deletions scripts/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,14 @@ function fetchUserLocation(){
let altitude = position.coords.altitude;

mountedApp.user_location = [latitude, longitude, altitude];

let map_width = document.getElementById('map2D-img').offsetWidth;
let map_height = document.getElementById('map2D-img').offsetHeight;

//Unit conversions, scaling and positional adjustments:
let user_picture_width = Number(document.getElementById("user-location").offsetWidth);
let userY = (Number(latitude) - 90)*(-2.2222) - user_picture_width/2;
let userX = (Number(longitude) + 180)*(2.2222) - user_picture_width/2;
let userY = (Number(latitude) - 90)*(-map_height/180) - user_picture_width/2;
let userX = (Number(longitude) + 180)*(map_width/360) - user_picture_width/2;

document.getElementById("user-location").style.transform = "translate(" + userX + "px, " + userY + "px)";
document.getElementById("user-location").style.opacity = 1;
Expand All @@ -230,8 +233,8 @@ function fetchUserLocation(){
document.getElementById("user-location-flag").src = flagURL;

let user_picture_width = Number(document.getElementById("user-location").offsetWidth);
let positionY = (Number(latitude) - 90)*(-2.2222);
let positionX = (Number(longitude) + 180)*(2.2222);
let positionY = (Number(latitude) - 90)*(-map_height/180);
let positionX = (Number(longitude) + 180)*(map_width/360);

document.getElementById("user-location-flag").style.transform = "translate(" + (positionX - user_picture_width/2 -8) + "px, " + (positionY - user_picture_width/2 - 10) + "px)";
document.getElementById("user-location-name").style.transform = "translate(" + (positionX + 10) + "px, " + (positionY + 10) + "px)";
Expand Down

0 comments on commit ab69bc7

Please sign in to comment.