This commit is contained in:
Ren Juan 2021-08-20 08:41:16 +00:00
parent 5ebbf6bc20
commit 16b5d0d30d
8 changed files with 46 additions and 117 deletions

View File

@ -1,16 +1,15 @@
import 'react-native-gesture-handler';
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from 'react';
import { Platform, Text, View, Switch, StyleSheet } from 'react-native';
import { Text } from 'react-native';
import * as Location from 'expo-location';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import useCachedResources from './hooks/useCachedResources';
import useColorScheme from './hooks/useColorScheme';
import Navigation from './navigation';
export var debug:boolean = false;
import { GT2 } from './GT2';
export var debug:boolean = true;
export var expoGeoState:any;
export var tripInProgress:boolean = true;
export default function App() {
const isLoadingComplete = useCachedResources();
@ -60,5 +59,3 @@ export default function App() {
);
}
}
export function toggleTripInProgress() {tripInProgress = !tripInProgress;}

View File

@ -1,77 +1,27 @@
/** Class for handling coordinates original by Linus Helgesson */
export class Coordinate {
mLatitude:number = 0.0;
mLongitude:number = 0.0;
mResults:any = [0, 0];
PI_OVER_180:number = 0.017453292519943295769236907684886;
EARTH_RADIUS:number = 6371009;
/* Generated from Java with JSweet 3.0.0 - http://www.jsweet.org */
/**
* Constructor taking a longitude and a latitude
*
* @param {number} longitude
* @param {number} latitude
* @class
* @author Linus Helgesson
*/
var Coordinate = /** @class */ (function () {
function Coordinate(longitude, latitude) {
if (((typeof longitude === 'number') || longitude === null) && ((typeof latitude === 'number') || latitude === null)) {
var __args = arguments;
this.mLongitude = 0;
this.mLatitude = 0;
this.mResults = [0, 0];
constructor (longitude:number, latitude:number) {
this.mLongitude = longitude;
this.mLatitude = latitude;
}
else if (longitude === undefined && latitude === undefined) {
var __args = arguments;
this.mLongitude = 0;
this.mLatitude = 0;
this.mResults = [0, 0];
}
else
throw new Error('invalid overload');
}
getLongitude() { return this.mLongitude; }
setLongitude(longitude:number) { this.mLongitude = longitude; }
getLatitude() { return this.mLatitude; }
setLatitude(latitude:number) { this.mLatitude = latitude; }
/**
* Get the longitude part of this coordinate
*
* @return {number} The longitude part of this coordinate
*/
Coordinate.prototype.getLongitude = function () {
return this.mLongitude;
};
/**
* Set the longitude part of this coordinate
*
* @param {number} longitude The longitude part of this coordinate
*/
Coordinate.prototype.setLongitude = function (longitude) {
this.mLongitude = longitude;
};
/**
* Get the latitude part of this coordinate
*
* @return {number} The latitude part of this coordinate
*/
Coordinate.prototype.getLatitude = function () {
return this.mLatitude;
};
/**
* Set the latitude part of this coordinate
*
* @param {number} latitude The latitude part of this coordinate
*/
Coordinate.prototype.setLatitude = function (latitude) {
this.mLatitude = latitude;
};
/**
* Calculates a bounding box of a certain size arund a coordinate. This is mainly used for a quick check
* in the database for cameras that are close to a coordinate. This function takes a size ion meters as
* Calculates a bounding box of a certain size arund a coordinate.This function takes a size in meters as
* a parameter and returns an array of two Coordinate objects. The first Coordinate is the upper left corner
* while the last coordinate is the bottom right corner.
*
* @param {number} side The length of the square side in meters
*
* @return {Coordinate[]} Two cordinates where the first is smaller than the second.
* while the last coordinate is the bottom right corner.er than the second.
*/
Coordinate.prototype.getBoundingBox = function (side: number) {
var ret = [null, null];
getBoundingBox(side: number) {
var ret:any = [Coordinate, Coordinate];
var degLatM:number , degLatM:number, degLongM:number, deltaLat:number, deltaLong:number;
@ -87,18 +37,12 @@
};
/**
* Calculates the distance between two Coordinate objects using the Spherical law of cosines found at:
*
* http://www.movable-type.co.uk/scripts/latlong.html
*
* @param coordinate The coordinate to measure the distance to.
* @return {number} the distance in meters
* @param {Coordinate} dest
*/
Coordinate.prototype.distanceTo = function (dest) {
Coordinate.computeDistanceAndBearing(this.mLatitude, this.mLongitude, dest.getLatitude(), dest.getLongitude(), this.mResults);
distanceTo(dest:Coordinate) {
this.computeDistanceAndBearing(this.mLatitude, this.mLongitude, dest.getLatitude(), dest.getLongitude(), this.mResults);
return this.mResults[0];
};
/*private*/ Coordinate.computeDistanceAndBearing = function (lat1, lon1, lat2, lon2, results) {
computeDistanceAndBearing(lat1:number, lon1:number, lat2:number, lon2:number, results:any) {
var MAXITERS = 20;
lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0;
@ -168,8 +112,8 @@
}
}
};
Coordinate.PI_OVER_180 = 0.017453292;
Coordinate.EARTH_RADIUS = 6371009;
return Coordinate;
}());
Coordinate["__class"] = "Coordinate";
}

View File

@ -1,8 +1,8 @@
{
"expo": {
"name": "Ejectable",
"name": "Green Travel Carbon Calculator",
"slug": "Ejectable",
"version": "1.0.0",
"version": "2.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "myapp",

View File

@ -70,7 +70,7 @@ function SplashNavigator() {
);
}
const TripStack = createStackNavigator<TripParamList>();
export const TripStack = createStackNavigator<TripParamList>();
function TripNavigator() {
return (

View File

@ -14,17 +14,17 @@ export default {
screens: {
Splash: {
screens: {
SplashScreen: 'one',
SplashScreen: 'home',
},
},
Trip: {
screens: {
TripScreen: 'two',
TripScreen: 'trip',
},
},
Settings: {
screens: {
SettingsScreen: 'three',
SettingsScreen: 'settings',
},
},
},

View File

@ -13006,9 +13006,9 @@
}
},
"react-devtools-core": {
"version": "4.15.0",
"resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-4.15.0.tgz",
"integrity": "sha512-Y1NwrWSKRg4TtwcES2upzXFDmccAW9jrGQG2D8EGQrZhK+0hmuhgFnSdKpFc3z04CSeDT5t83RMXcmX5TkR1dA==",
"version": "4.16.0",
"resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-4.16.0.tgz",
"integrity": "sha512-fqyVbp+wVVey6O4uVBk5s3J/vTiPludp7lulr6a8asTBm7DIA0vLBbjmAOLCnOlkWcgdy4mjsqOgNCbu8uICWw==",
"requires": {
"shell-quote": "^1.6.1",
"ws": "^7"

View File

@ -1,14 +1,9 @@
import * as React from 'react';
import { Component } from 'react';
import { Button, StyleSheet, Alert } from 'react-native';
import { Text, View } from '../components/Themed';
import { ScreenInfo2 } from '../components/ScreenInfo';
import { geocodeAsync } from 'expo-location';
import * as GT2 from '../App';
import * as Nav from '../navigation/BottomTabNavigator';
import Navigation from '../navigation';
var elapsed:number, lat:number, long:number, ds:number, v:number;
import { thisTrip } from '../GT2';
import { TripStack } from '../navigation/BottomTabNavigator';
const styles = StyleSheet.create({
tripText: {
@ -43,16 +38,8 @@ const styles = StyleSheet.create({
function startTrip() {
GT2.toggleTripInProgress();
elapsed = 0.0;
lat = 0.0;
long = 0.0;
ds = 0.0;
v = 0.0;
thisTrip.start();
Alert.alert('Trip Started');
}
@ -63,13 +50,14 @@ function pauseTrip() {
function endTrip() {
GT2.toggleTripInProgress();
thisTrip.end();
Alert.alert('Trip Ended');
}
export default function TripScreen() {
if (!GT2.tripInProgress)
if (!thisTrip.inProgress)
return (
<View style={styles.container}>
<Text style={styles.title}>Trip Control</Text>
@ -112,9 +100,9 @@ export default function TripScreen() {
</View>
<View>
<Text style={styles.tripText}>
{'Elapsed: '}{elapsed}{'\n'}
{'Geo: '}{lat}{long}{'\n'}
{'Vector: '}{ds}{v}{'\n'}
{'Elapsed - '}{thisTrip.elapsed}{' seconds\n'}
{'Geo: '}{'lat: '}{thisTrip.loc.mLatitude}{' long: '}{thisTrip.loc.mLatitude}{'\n'}
{'Vector: '}{'distance: '}{thisTrip.distance}{' velocity: '}{thisTrip.v}{'\n'}
</Text>
</View>
</View>

View File

@ -1,4 +1,4 @@
{
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true