Browse Source

Add terrain icon next to weather (closes #4), update and cleanup code to handle it.

Replaced old terrain graphics with new b/w icons.
master
Skylar Ittner 6 years ago
parent
commit
466951bca5
  1. BIN
      res/screen/android/drawable-hdpi/logo.9.png
  2. BIN
      res/screen/android/drawable-mdpi/logo.9.png
  3. BIN
      res/screen/android/drawable-xhdpi/logo.9.png
  4. BIN
      res/screen/android/drawable-xxhdpi/logo.9.png
  5. BIN
      res/screen/android/drawable-xxxhdpi/logo.9.png
  6. BIN
      www/assets/terrain/-1.png
  7. BIN
      www/assets/terrain/0.png
  8. BIN
      www/assets/terrain/1.png
  9. BIN
      www/assets/terrain/10.png
  10. BIN
      www/assets/terrain/11.png
  11. BIN
      www/assets/terrain/12.png
  12. BIN
      www/assets/terrain/13.png
  13. BIN
      www/assets/terrain/2.png
  14. BIN
      www/assets/terrain/21.png
  15. BIN
      www/assets/terrain/22.png
  16. BIN
      www/assets/terrain/23.png
  17. BIN
      www/assets/terrain/24.png
  18. BIN
      www/assets/terrain/3.png
  19. BIN
      www/assets/terrain/31.png
  20. BIN
      www/assets/terrain/4.png
  21. BIN
      www/assets/terrain/41.png
  22. BIN
      www/assets/terrain/42.png
  23. BIN
      www/assets/terrain/43.png
  24. BIN
      www/assets/terrain/5.png
  25. BIN
      www/assets/terrain/52.png
  26. BIN
      www/assets/terrain/6.png
  27. BIN
      www/assets/terrain/7.png
  28. BIN
      www/assets/terrain/71.png
  29. BIN
      www/assets/terrain/8.png
  30. BIN
      www/assets/terrain/81.png
  31. BIN
      www/assets/terrain/82.png
  32. BIN
      www/assets/terrain/9.png
  33. BIN
      www/assets/terrain/90.png
  34. BIN
      www/assets/terrain/95.png
  35. 5
      www/css/main.css
  36. 39
      www/js/location.js
  37. 21
      www/js/user.js
  38. 5
      www/screens/home.html

BIN
res/screen/android/drawable-hdpi/logo.9.png

After

Width: 252  |  Height: 119  |  Size: 33 KiB

BIN
res/screen/android/drawable-mdpi/logo.9.png

After

Width: 169  |  Height: 80  |  Size: 20 KiB

BIN
res/screen/android/drawable-xhdpi/logo.9.png

After

Width: 336  |  Height: 158  |  Size: 51 KiB

BIN
res/screen/android/drawable-xxhdpi/logo.9.png

After

Width: 502  |  Height: 235  |  Size: 78 KiB

BIN
res/screen/android/drawable-xxxhdpi/logo.9.png

After

Width: 669  |  Height: 313  |  Size: 147 KiB

BIN
www/assets/terrain/-1.png

After

Width: 21  |  Height: 32  |  Size: 501 B

BIN
www/assets/terrain/0.png

Before

Width: 615  |  Height: 461  |  Size: 4.8 KiB

After

Width: 34  |  Height: 32  |  Size: 752 B

BIN
www/assets/terrain/1.png

After

Width: 36  |  Height: 32  |  Size: 773 B

BIN
www/assets/terrain/10.png

After

Width: 39  |  Height: 32  |  Size: 873 B

BIN
www/assets/terrain/11.png

Before

Width: 615  |  Height: 461  |  Size: 22 KiB

After

Width: 39  |  Height: 32  |  Size: 873 B

BIN
www/assets/terrain/12.png

Before

Width: 615  |  Height: 461  |  Size: 17 KiB

After

Width: 37  |  Height: 32  |  Size: 574 B

BIN
www/assets/terrain/13.png

After

Width: 29  |  Height: 32  |  Size: 453 B

BIN
www/assets/terrain/2.png

After

Width: 30  |  Height: 32  |  Size: 826 B

BIN
www/assets/terrain/21.png

Before

Width: 615  |  Height: 408  |  Size: 20 KiB

BIN
www/assets/terrain/22.png

Before

Width: 615  |  Height: 410  |  Size: 21 KiB

BIN
www/assets/terrain/23.png

Before

Width: 615  |  Height: 410  |  Size: 21 KiB

BIN
www/assets/terrain/24.png

Before

Width: 615  |  Height: 408  |  Size: 20 KiB

BIN
www/assets/terrain/3.png

After

Width: 36  |  Height: 32  |  Size: 773 B

BIN
www/assets/terrain/31.png

Before

Width: 615  |  Height: 461  |  Size: 21 KiB

BIN
www/assets/terrain/4.png

After

Width: 30  |  Height: 32  |  Size: 826 B

BIN
www/assets/terrain/41.png

Before

Width: 615  |  Height: 408  |  Size: 25 KiB

BIN
www/assets/terrain/42.png

Before

Width: 615  |  Height: 409  |  Size: 23 KiB

BIN
www/assets/terrain/43.png

Before

Width: 615  |  Height: 407  |  Size: 25 KiB

BIN
www/assets/terrain/5.png

After

Width: 33  |  Height: 32  |  Size: 807 B

BIN
www/assets/terrain/52.png

Before

Width: 600  |  Height: 400  |  Size: 12 KiB

BIN
www/assets/terrain/6.png

After

Width: 33  |  Height: 32  |  Size: 807 B

BIN
www/assets/terrain/7.png

After

Width: 32  |  Height: 32  |  Size: 740 B

BIN
www/assets/terrain/71.png

Before

Width: 615  |  Height: 410  |  Size: 24 KiB

BIN
www/assets/terrain/8.png

After

Width: 36  |  Height: 32  |  Size: 854 B

BIN
www/assets/terrain/81.png

Before

Width: 597  |  Height: 394  |  Size: 17 KiB

BIN
www/assets/terrain/82.png

Before

Width: 615  |  Height: 410  |  Size: 22 KiB

BIN
www/assets/terrain/9.png

After

Width: 36  |  Height: 32  |  Size: 854 B

BIN
www/assets/terrain/90.png

Before

Width: 615  |  Height: 461  |  Size: 26 KiB

BIN
www/assets/terrain/95.png

Before

Width: 615  |  Height: 461  |  Size: 26 KiB

5
www/css/main.css

@ -175,6 +175,11 @@ body {
float: right;
}
#terrainicon {
margin-top: -15px;
height: 20px;
}
#energybar-container {
position: absolute;
top: 30px;

39
www/js/location.js

@ -18,16 +18,15 @@
//////////////////////////////////////////////
// GPS and terrain stuff
// GPS and map stuff
//////////////////////////////////////////////
/**
* Handles GPS and terrain data.
* Handles GPS and map data.
*/
// Globals
var lockGot = false;
var terrainGot = false;
var latitude = 0.0000;
var longitude = 0.0000;
var gpsaccuracy = 9999;
@ -36,7 +35,6 @@ var requiredaccuracy = 40;
var fetchplacecounter = 0;
var lastgpstime = 0;
var terraintypeid = 0;
var map = L.map('map');
var tileurl = "http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg";
map.setZoom(17);
@ -176,8 +174,9 @@ function openPlace(feature) {
* Hide the loading overlay if everything is loaded, otherwise do nothing
*/
function hideLoading() {
if (lockGot && terrainGot && gpsaccuracy < requiredaccuracy && $('#loading').css('display') !== 'none') {
if (lockGot && gpsaccuracy < requiredaccuracy && $('#loading').css('display') !== 'none') {
getWeather();
getTerrain();
$('#loading').fadeOut('slow', function () {
$('#loading').css('display', 'none');
updateStatusBarColor();
@ -197,25 +196,6 @@ var updatePosition = function (position) {
}
mapPos(latitude, longitude);
};
var updateTerrain = function (position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
lastgpstime = position.timestamp;
gpsaccuracy = position.coords.accuracy;
var rasterurl = "http://earth.apis.netsyms.net/terrain.php?format=json&lat="
+ latitude + "&long=" + longitude;
$.get(rasterurl, function (data) {
if (data.status === 'OK') {
terraintypeid = data.typeid;
terraintypename = data.typename;
$('#terrain-image').attr('src', 'assets/terrain/' + terraintypeid + '.png');
terrainGot = true;
hideLoading();
}
}, "json").fail(function (err) {
$('#terrain-image').attr('src', 'assets/terrain/0.png');
});
};
function pingServer() {
if (lockGot && gpsaccuracy < requiredaccuracy) {
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
@ -231,22 +211,21 @@ function popDiagData() {
"\nLongitude: " + longitude +
"\nAccuracy: " + gpsaccuracy +
"\nWeather: " + rawWeatherData.temperature + " F, " + rawWeatherData.summary + ", " + rawWeatherData.windSpeed + " mph" +
"\nTerrain: " + terraintypename + " (" + terraintypeid + ")",
"\nTerrain: " + terrainName + " (" + terrainType + ")",
null,
"Information",
"World Info",
"Close");
}
// Initial GPS position and stuff
navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true});
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true});
// Update position
setInterval(function () {
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true});
}, 1000);
// Update position + terrain
// Update places
setInterval(function () {
navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true});
loadPlaces(latitude, longitude);
}, 1000 * 20);
}, 1000 * 15);
// Ping the server with coordinates
setInterval(pingServer, 5000);
// Show error if it's taking too long

21
www/js/user.js

@ -21,6 +21,8 @@
//////////////////////////////////////////////
var rawWeatherData = [];
var terrainType = -1;
var terrainName = "Other";
/*
* Handles general server communication.
@ -82,6 +84,24 @@ function getWeather() {
var currently = data.currently;
rawWeatherData = currently;
skycons.set("weathericon", currently.icon);
skycons.play();
});
}
function getTerrain() {
$.getJSON(mkApiUrl('getterrain'), {
lat: latitude,
long: longitude
}, function (data) {
var terrainid = -1;
var terrainstr = "Other";
if (data.status === "OK") {
terrainid = data.type;
terrainstr = data.name;
}
$('#terrainicon').attr('src', 'assets/terrain/' + terrainid + '.png');
terrainType = terrainid;
terrainName = terrainstr;
});
}
@ -104,6 +124,7 @@ setInterval(function () {
}, 3000);
setInterval(function () {
getWeather();
getTerrain();
}, 30 * 1000);
// Send chat messages
$("#chatsendform").submit(function (event) {

5
www/screens/home.html

@ -43,7 +43,10 @@
<div id="overlay-top">
<p id="topbar">
<span id="namedisp" onclick="openMenu('profile')"></span>
<span id="worldinfo" onclick="popDiagData()"><canvas id="weathericon" width="22" height="22"></canvas></span>
<span id="worldinfo" onclick="popDiagData()">
<canvas id="weathericon" width="22" height="22"></canvas>
<img id="terrainicon" src="assets/terrain/-1.png" />
</span>
</p>
<div class="progress" id="energybar-container">
<div id="energybar" class="progress-bar" role="progressbar" >