diff --git a/client/Nightr/package-lock.json b/client/Nightr/package-lock.json
index 6091599..10dcff8 100644
--- a/client/Nightr/package-lock.json
+++ b/client/Nightr/package-lock.json
@@ -3784,6 +3784,11 @@
"nativescript-permissions": "^1.2.3"
}
},
+ "nativescript-checkbox": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/nativescript-checkbox/-/nativescript-checkbox-3.0.3.tgz",
+ "integrity": "sha1-H5oC4BvPi9fSd79IW8CvMa3jdcs="
+ },
"nativescript-dev-typescript": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/nativescript-dev-typescript/-/nativescript-dev-typescript-0.9.0.tgz",
diff --git a/client/Nightr/package.json b/client/Nightr/package.json
index f583598..ea733d8 100644
--- a/client/Nightr/package.json
+++ b/client/Nightr/package.json
@@ -23,6 +23,7 @@
"@angular/router": "~7.2.0",
"nativescript-angular": "~7.2.0",
"nativescript-camera": "^4.4.0",
+ "nativescript-checkbox": "^3.0.3",
"nativescript-geolocation": "^5.0.0",
"nativescript-powerinfo": "^1.0.7",
"nativescript-theme-core": "~1.0.4",
diff --git a/client/Nightr/src/app/app.module.ts b/client/Nightr/src/app/app.module.ts
index 46046e5..6185091 100644
--- a/client/Nightr/src/app/app.module.ts
+++ b/client/Nightr/src/app/app.module.ts
@@ -6,8 +6,6 @@ import { AppComponent } from "./app.component";
import { HomePageComponent } from "./home-page/home-page.component";
import { MyButtonComponent } from './component/my-button/my-button.component';
import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";
-import { MyLocationButtonComponent } from './component/locationButton/locationButton.component';
-import { CameraButtonComponent } from './component/camera-button/camera-button.component';
import { ResultPageComponent } from './result-page/result-page.component';
// Uncomment and add to NgModule imports if you need to use two-way binding
@@ -32,9 +30,7 @@ import { ResultPageComponent } from './result-page/result-page.component';
],
declarations: [
AppComponent,
- MyLocationButtonComponent,
MyButtonComponent,
- CameraButtonComponent,
ResultPageComponent,
HomePageComponent,
],
diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.css b/client/Nightr/src/app/component/camera-button/camera-button.component.css
deleted file mode 100644
index bcd4764..0000000
--- a/client/Nightr/src/app/component/camera-button/camera-button.component.css
+++ /dev/null
@@ -1 +0,0 @@
-/* Add mobile styles for the component here. */
diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.html b/client/Nightr/src/app/component/camera-button/camera-button.component.html
deleted file mode 100644
index 4fe4caf..0000000
--- a/client/Nightr/src/app/component/camera-button/camera-button.component.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/client/Nightr/src/app/component/camera-button/camera-button.component.ts b/client/Nightr/src/app/component/camera-button/camera-button.component.ts
deleted file mode 100644
index d3bd803..0000000
--- a/client/Nightr/src/app/component/camera-button/camera-button.component.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-import { MyCameraService } from '../../services/my-camera-service';
-
-@Component({
- selector: 'ns-camera-button',
- templateUrl: './camera-button.component.html',
- styleUrls: ['./camera-button.component.css'],
- moduleId: module.id,
-})
-export class CameraButtonComponent implements OnInit {
-
- camera:MyCameraService = new MyCameraService();
- constructor() { }
-
- ngOnInit() {
- }
-
- onTap() {
- this.camera.takePicture().then(
- (res) => {console.log(res)}, () => {}
- );
-}
-
-}
diff --git a/client/Nightr/src/app/component/locationButton/locationButton.component.css b/client/Nightr/src/app/component/locationButton/locationButton.component.css
deleted file mode 100644
index bcd4764..0000000
--- a/client/Nightr/src/app/component/locationButton/locationButton.component.css
+++ /dev/null
@@ -1 +0,0 @@
-/* Add mobile styles for the component here. */
diff --git a/client/Nightr/src/app/component/locationButton/locationButton.component.html b/client/Nightr/src/app/component/locationButton/locationButton.component.html
deleted file mode 100644
index 9fe4bc3..0000000
--- a/client/Nightr/src/app/component/locationButton/locationButton.component.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/client/Nightr/src/app/component/locationButton/locationButton.component.ts b/client/Nightr/src/app/component/locationButton/locationButton.component.ts
deleted file mode 100644
index d28c873..0000000
--- a/client/Nightr/src/app/component/locationButton/locationButton.component.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Component, EventEmitter, OnInit, Output } from '@angular/core';
-import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures'
-import { MyGeoLocationService} from '../../services/my-geo-location.service';
-@Component({
- selector: 'ns-locationButton',
- templateUrl: './locationButton.component.html',
- styleUrls: ['./locationButton.component.css'],
- moduleId: module.id,
-})
-export class MyLocationButtonComponent implements OnInit {
- title = "Click to get location!";
- lat = "start";
- geoLocationService = new MyGeoLocationService();
-
- @Output() tap: EventEmitter = new EventEmitter();
-
- constructor() {
- }
- ngOnInit() {
- }
-
- onTap(args: GestureEventData): any {
- this.tap.emit(args);
- this.geoLocationService.getLocation().then(location => {
- this.lat = ""+location.latitude;
- }).catch(error => {
- });
- }
-}
diff --git a/client/Nightr/src/app/home-page/home-page.component.html b/client/Nightr/src/app/home-page/home-page.component.html
index 34a9045..2b37e97 100644
--- a/client/Nightr/src/app/home-page/home-page.component.html
+++ b/client/Nightr/src/app/home-page/home-page.component.html
@@ -1,14 +1,15 @@
-
+
+
+
+
+
+
+
-
-
-
-
-
diff --git a/client/Nightr/src/app/home-page/home-page.component.ts b/client/Nightr/src/app/home-page/home-page.component.ts
index 329ff98..f239bd7 100644
--- a/client/Nightr/src/app/home-page/home-page.component.ts
+++ b/client/Nightr/src/app/home-page/home-page.component.ts
@@ -1,12 +1,12 @@
import { Component, OnInit } from "@angular/core";
-import * as dialogs from "tns-core-modules/ui/dialogs";
import { RouterExtensions } from "nativescript-angular/router";
-import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures'
+import { GestureEventData } from 'tns-core-modules/ui/gestures'
+import { Switch } from "tns-core-modules/ui/switch";
+import * as appSettings from "tns-core-modules/application-settings";
+
import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation";
-
import { MyHttpPostService } from '../services/my-http-post-service';
-
@Component({
selector: "home-page",
moduleId: module.id,
@@ -15,29 +15,44 @@ import { MyHttpPostService } from '../services/my-http-post-service';
providers: [MyHttpPostService]
})
export class HomePageComponent implements OnInit {
- returnMessage: string = "";
- myReturnJSON: Object;
- locationData: Location;
- myPicture: String;
- image: any;
- flat_earth: boolean;
- in_australia: boolean;
- changeYes: boolean;
-
+ public toggleFlatEarthState = "Is the earth flat?";
+ public toggleIsAustraliaState = "Are you in Australia?";
+ isEarthFlat: boolean;
+ inAustralia: boolean;
constructor(private routerExtensions: RouterExtensions,
) { }
ngOnInit(): void {
}
- public changeGenderMale(){
- if(this.changeYes == true)
- this.changeYes = false;
- else
- this.changeYes = true;
- }
+ public toggleFlatEarth(args) {
+ let firstSwitch = args.object;
+ if (firstSwitch.checked) {
+ this.isEarthFlat = true;
+ appSettings.setBoolean("applicationIsEarthFlat", true);
+ } else {
+ this.isEarthFlat = false;
+ appSettings.setBoolean("applicationIsEarthFlat", false);
+ }
+ }
+
+ public toggleIsAustralia(args) {
+ let secondSwitch = args.object;
+ if (secondSwitch.checked) {
+ this.inAustralia = true;
+ appSettings.setBoolean("applicationinAustralia", true);
+ } else {
+ this.inAustralia = false;
+ appSettings.setBoolean("applicationinAustralia", false);
+ }
+ }
public onTap(args: GestureEventData): void {
- this.routerExtensions.navigateByUrl("/result-page");
+ let navigationExtras = {
+ queryParams: {
+ isEarthFlat: this.isEarthFlat,
+ inAustralia: this.inAustralia }
+ }
+ this.routerExtensions.navigateByUrl("/result-page"), navigationExtras;
}
}
diff --git a/client/Nightr/src/app/result-page/result-page.component.css b/client/Nightr/src/app/result-page/result-page.component.css
index 7b3ead4..dddc019 100644
--- a/client/Nightr/src/app/result-page/result-page.component.css
+++ b/client/Nightr/src/app/result-page/result-page.component.css
@@ -1,11 +1,26 @@
-.title-container
+.h2
{
font-family: sans-serif;
- font-size: 30px;
- padding: 5px;
+ font-size: 35px;
color: white;
text-align: center;
}
+ .h1
+ {
+ font-family: sans-serif;
+ font-size: 100px;
+ color: white;
+ text-align: center;
+ }
+ .h3
+ {
+ font-family: sans-serif;
+ font-style: italic;
+ font-size: 20px;
+ color: white;
+ text-align: center;
+ }
+
.page {
background-color: lightskyblue;
}
diff --git a/client/Nightr/src/app/result-page/result-page.component.html b/client/Nightr/src/app/result-page/result-page.component.html
index 7f4c484..56dba69 100644
--- a/client/Nightr/src/app/result-page/result-page.component.html
+++ b/client/Nightr/src/app/result-page/result-page.component.html
@@ -1,11 +1,12 @@
-
-
+
-
-
-
+
+
+
+
+
-
+
@@ -16,3 +17,4 @@
+
diff --git a/client/Nightr/src/app/result-page/result-page.component.ts b/client/Nightr/src/app/result-page/result-page.component.ts
index f447ffb..b19dd1c 100644
--- a/client/Nightr/src/app/result-page/result-page.component.ts
+++ b/client/Nightr/src/app/result-page/result-page.component.ts
@@ -1,11 +1,12 @@
import { Component, OnInit } from '@angular/core';
-import { MyHttpPostService } from '../services/my-http-post-service'
+import { MyHttpPostService } from '../services/my-http-post-service';
import { MyGeoLocationService} from '../services/my-geo-location.service';
import { MyBatteryInfoService } from '../services/my-battery-info.service';
-import { MyCameraService } from '../services/my-camera-service'
+import { MyCameraService } from '../services/my-camera-service';
import { RouterExtensions } from 'nativescript-angular/router';
import { Location } from 'nativescript-geolocation';
+import * as appSettings from "tns-core-modules/application-settings";
class Reason {
constructor(public str: string, public causestring: string) {
@@ -18,9 +19,11 @@ class Reason {
templateUrl: './result-page.component.html',
styleUrls: ['./result-page.component.css'],
moduleId: module.id,
+ providers: [MyHttpPostService]
})
export class ResultPageComponent implements OnInit {
returnMessage: string = "";
+ isBusy: boolean;
myReturnJSON: Object;
locationData: Location;
myPicture: String;
@@ -28,21 +31,25 @@ export class ResultPageComponent implements OnInit {
flat_earth: boolean;
in_australia: boolean;
night: string = "";
- percentage: string = "";
+ percentage: string = "Calculating...";
+ hereswhy: string = "";
+ itis: string = "";
+ reasons: Array;
JSONObject;
- public reasons: Array;
+
constructor(private myHttpPostSerivce: MyHttpPostService,
- private routerExtensions: RouterExtensions,
- private geoLocationService: MyGeoLocationService,
- private batterInfoService: MyBatteryInfoService,
- private cameraService: MyCameraService,){ }
+ private routerExtensions: RouterExtensions,
+ private geoLocationService: MyGeoLocationService,
+ private batterInfoService: MyBatteryInfoService,
+ private cameraService: MyCameraService,){ }
ngOnInit(): Promise {
+ this.isBusy = true;
+ this.reasons = new Array();
return this.cameraService.takePicture().
then(picture => {
this.image = JSON.stringify(picture);
- //console.log('this is picture in json', JSON.stringify(picture));
this.getLocation();
})
}
@@ -50,7 +57,6 @@ export class ResultPageComponent implements OnInit {
public getLocation(): any {
this.geoLocationService.getLocation().then(location => {
this.locationData = location;
- //console.log('this is locationData', this.locationData);
this.submit();
}).catch(error => {
});
@@ -60,30 +66,34 @@ public submit(): void {
}
private makePostRequest(): void {
+ this.isBusy = true;
this.myHttpPostSerivce
- .postData({ position: this.locationData, image: this.image, flat_earth: true, in_australia: true, })
+ .postData({ position: this.locationData, image: this.image,
+ flat_earth: appSettings.getBoolean("applicationIsEarthFlat", false),
+ in_australia: appSettings.getBoolean("applicationinAustralia", false), })
.subscribe(res => {
- //console.log('This is res', res);
this.JSONObject = res;
+ this.isBusy = false;
this.addToArray();
- //console.log('THis is myreturnJSON', this.myReturnJSON);
});
}
public addToArray(): void {
if (this.JSONObject.night) {
- this.night = "It is night";
+ this.night = "NIGHT";
} else {
- this.night = "It is day";
+ this.night = "DAY";
}
- this.percentage = "At least we are "+Math.floor(this.JSONObject.weighted_probabilities_mean*100)+"% sure, here's why"
+ this.percentage = "At least we are "+Math.floor(this.JSONObject.weighted_probabilities_mean*100)+"% sure"
for (let i = 0; i < this.JSONObject.predictions.length; i++) {
var causestring = ""
for (let j = 0; j < this.JSONObject.predictions[i].reasons.length; j++) {
causestring = causestring + " - " + this.JSONObject.predictions[i].reasons[j] + "\n";
}
+ this.itis = "It is"
+ this.hereswhy = "Here's why:"
this.reasons.push(new Reason(""+Math.round(this.JSONObject.predictions[i].contribution*100)+"% - " + this.JSONObject.predictions[i].name, causestring));
}
}
diff --git a/server/nightr/strategies/miloStrats.py b/server/nightr/strategies/miloStrats.py
index afe5af5..2b7903d 100644
--- a/server/nightr/strategies/miloStrats.py
+++ b/server/nightr/strategies/miloStrats.py
@@ -35,12 +35,20 @@ def australiaStrat(context : Context) -> Prediction:
hour = t.hour
p = Prediction()
- if hour > 22 or hour < 6:
- p.probability = 0.0
- p.reasons.append('It\'s night-time in Australia, so it must be day-time here.')
+ if context.in_australia:
+ if hour > 22 or hour < 6:
+ p.probability = 1.0
+ p.reasons.append('It\'s night-time in Australia, and that\'s where we\'re at.')
+ else:
+ p.probability = 0.0
+ p.reasons.append('It\'s day-time in Australia, and that\'s where we\'re at.')
else:
- p.probability = 1.0
- p.reasons.append('It\'s day-time in Australia, so it must be night-time here.')
+ if hour > 22 or hour < 6:
+ p.probability = 0.0
+ p.reasons.append('It\'s night-time in Australia, so it must be day-time here.')
+ else:
+ p.probability = 1.0
+ p.reasons.append('It\'s day-time in Australia, so it must be night-time here.')
return p
diff --git a/server/nightr/util.py b/server/nightr/util.py
index 82725a1..5985465 100644
--- a/server/nightr/util.py
+++ b/server/nightr/util.py
@@ -1,4 +1,5 @@
import base64
+import random
from dataclasses import dataclass, field
from pathlib import Path
from typing import List, Dict
@@ -9,7 +10,7 @@ import numpy as np
@dataclass
class Context:
- battery: int = 55
+ battery: int = field(default_factory=lambda: random.randint(0, 100))
position: Dict[str, float] = field(default_factory=lambda: {'latitude': 53.0, 'longitude': 9.0}) # Denmark somewhere
image: np.ndarray = None