Skip to content

Commit 056039b

Browse files
committed
Commit changes
1 parent 729b530 commit 056039b

40 files changed

Lines changed: 8703 additions & 61 deletions

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# MapMint4ME_final
2+
* I added the following methods which give more information regarding GPS satellites currently used to fix locations. Satellite information is required because MapMint4ME acquires data without internet
3+
* getPrn() method returns pseudo random number for satellite
4+
* getAzimuth() method returns azimuth of the satellite in degrees
5+
* getElevation() method returns elevation of the satellite in degrees
6+
* getSnr() method returns signal to noise ratio
7+
* usedInFix() method returns Returns true if the satellite was used by the GPS engine when calculating the most recent GPS fix
8+
* Currently all above methods give outputs on the android studio console.
9+
10+
11+
<img src = "output/output.png" />
12+

app/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.google.ar.sceneform.plugin'
44

55
android {
66
compileSdkVersion 27
7-
buildToolsVersion '28.0.3'
7+
88
defaultConfig {
99
applicationId "fr.geolabs.dev.mapmint4me"
1010
minSdkVersion 24
@@ -54,6 +54,10 @@ dependencies {
5454
implementation 'com.android.support:appcompat-v7:27.1.0'
5555
implementation 'com.android.support:design:27.1.0'
5656
implementation 'com.google.firebase:firebase-database:11.0.0'
57+
implementation 'org.greenrobot:eventbus:3.1.1'
58+
implementation 'com.android.support:preference-v7:27.0.0'
59+
implementation 'com.android.support:preference-v14:27.0.0'
60+
5761

5862
implementation 'de.javagl:obj:0.2.1'
5963
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {

app/src/main/AndroidManifest.xml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@
4444
android:allowBackup="true"
4545
android:icon="@mipmap/ic_launcher"
4646
android:label="@string/app_name"
47-
android:supportsRtl="true"
48-
android:theme="@style/AppTheme">
47+
android:theme="@style/AppTheme"
48+
android:name="Satellite.GPSApplication"
49+
50+
android:fullBackupContent="@xml/my_backup_rules"
51+
52+
android:networkSecurityConfig="@xml/network_security_config"
53+
android:supportsRtl="true">
4954
<activity
5055
android:name=".MapMint4ME"
5156
android:configChanges="orientation|keyboardHidden|screenSize"
@@ -91,14 +96,38 @@
9196

9297

9398
<activity android:name=".CloudAnchor"/>
99+
<activity android:name="Satellite.GPSActivity_sat"/>
100+
101+
<activity
102+
android:name="Satellite.GPSActivity"
103+
android:exported="true"
104+
android:label="GPS Satellite Information"
105+
android:launchMode="singleTask" >
106+
<intent-filter>
107+
<action android:name="android.intent.action.MAIN" />
108+
109+
<category android:name="android.intent.category.LAUNCHER" />
110+
</intent-filter>
111+
</activity>
112+
113+
114+
115+
116+
117+
94118

95119
<activity android:name="com.hl3hl3.arcoremeasure.ArMeasureActivity"/>
96120
<activity android:name="drawar.DrawAR"/>
121+
122+
123+
124+
97125
<meta-data android:name="com.google.ar.core" android:value="required" />
98126

99127

100128

101129

130+
102131
<meta-data android:name="com.google.android.ar.API_KEY" android:value="AIzaSyDTsutwy3QvhFRNGRbnRPa4pxdRoJNK61Q"/>
103132

104133
</application>

app/src/main/assets/content/edit.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
ARScale</a>
4848
</div>
4949

50+
</div><div class="col-xs-6 col-sm-3" style="margin-top: 15px;">
51+
<a class="btn btn-lg btn-default btn-block" href="#" onclick="loadWelcome5();" role="button">
52+
<center>
53+
<button class="btn btn-lg btn-warning btn-block btn-circle-lg">
54+
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
55+
</button>
56+
</center>
57+
58+
SatFinder</a>
59+
</div>
60+
61+
5062

5163
<script id="edit_list" type="text/template">
5264
<a id="tbl_[id]" class="list-group-item" href="#tbl[id]" data-id="[id]" data-name="[name]" data-title="[title]">
@@ -75,4 +87,5 @@
7587
<script src="scripts/gene.js"></script>
7688
<script src="scripts/gene2.js"></script>
7789
<script src="scripts/gene3.js"></script>
78-
<script src="scripts/generic.js"></script>
90+
<script src="scripts/generic.js"></script>
91+
<script src="scripts/gene4.js"></script>

app/src/main/assets/model.sfb

0 Bytes
Binary file not shown.

app/src/main/assets/scripts/gene4.js

Lines changed: 2461 additions & 0 deletions
Large diffs are not rendered by default.

app/src/main/java/Satellite/DatabaseHandler.java

Lines changed: 1087 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
2+
package Satellite;
3+
4+
5+
import android.util.Log;
6+
7+
import org.greenrobot.eventbus.EventBus;
8+
9+
import java.io.BufferedInputStream;
10+
import java.io.DataInputStream;
11+
import java.io.File;
12+
import java.io.FileInputStream;
13+
import java.io.FileNotFoundException;
14+
import java.io.FileOutputStream;
15+
import java.io.IOException;
16+
import java.io.InputStream;
17+
import java.io.OutputStream;
18+
19+
class EGM96 {
20+
21+
// ---------------------------------------------------------------------------- Singleton Class
22+
private static EGM96 instance = new EGM96();
23+
24+
private EGM96(){}
25+
26+
public static EGM96 getInstance(){
27+
return instance;
28+
}
29+
30+
31+
32+
private int BOUNDARY = 3; // The grid extensions (in each of the 4 sides) of the real 721 x 1440 grid
33+
private short[][] EGMGrid = new short[BOUNDARY + 1440 + BOUNDARY][BOUNDARY + 721 + BOUNDARY];
34+
private boolean isEGMGridLoaded = false;
35+
private boolean isEGMGridLoading = false;
36+
private boolean isEGMFileCopying = false;
37+
private String EGMFileName;
38+
private String EGMFileNameLocalCopy;
39+
40+
public double EGM96_VALUE_INVALID = -100000;
41+
42+
public void LoadGridFromFile(String FileName, String FileNameLocalCopy) {
43+
if (!isEGMGridLoaded && !isEGMGridLoading) {
44+
isEGMGridLoading = true;
45+
EGMFileName = FileName;
46+
EGMFileNameLocalCopy = FileNameLocalCopy;
47+
new Thread(new LoadEGM96Grid()).start();
48+
} else {
49+
if (isEGMGridLoading) Log.w("myApp", "[#] EGM96.java - Grid is already loading, please wait");
50+
if (isEGMGridLoaded) Log.w("myApp", "[#] EGM96.java - Grid already loaded");
51+
}
52+
}
53+
54+
/* public void UnloadGrid() {
55+
isEGMGridLoaded = false;
56+
isEGMGridLoading = false;
57+
//listener.onEGMGridLoaded(isEGMGridLoaded);
58+
EventBus.getDefault().post(EventBusMSG.UPDATE_FIX);
59+
EventBus.getDefault().post(EventBusMSG.UPDATE_TRACK);
60+
EventBus.getDefault().post(EventBusMSG.UPDATE_TRACKLIST);
61+
}
62+
*/
63+
public boolean isEGMGridLoaded() {
64+
return isEGMGridLoaded;
65+
}
66+
67+
public boolean isEGMGridLoading() {
68+
return isEGMGridLoading;
69+
}
70+
71+
public double getEGMCorrection(double Latitude, double Longitude) {
72+
// This function calculates and return the EGM96 altitude correction value of the input coordinates, in m;
73+
// Input coordinates are: -90 < Latitude < 90; -180 < Longitude < 360 (android range -180 < Longitude < 180);
74+
75+
if (isEGMGridLoaded) {
76+
double Lat = 90.0 - Latitude;
77+
double Lon = Longitude;
78+
if (Lon < 0) Lon += 360.0;
79+
80+
int ilon = (int) (Lon / 0.25) + BOUNDARY;
81+
int ilat = (int) (Lat / 0.25) + BOUNDARY;
82+
83+
try {
84+
// Creating points for interpolation
85+
short hc11 = EGMGrid[ilon][ilat];
86+
short hc12 = EGMGrid[ilon][ilat + 1];
87+
short hc21 = EGMGrid[ilon + 1][ilat];
88+
short hc22 = EGMGrid[ilon + 1][ilat + 1];
89+
90+
// Interpolation:
91+
// Latitude
92+
double hc1 = hc11 + (hc12 - hc11) * (Lat % 0.25) / 0.25;
93+
double hc2 = hc21 + (hc22 - hc21) * (Lat % 0.25) / 0.25;
94+
// Longitude
95+
//double hc = (hc1 + (hc2 - hc1) * (Lon % 0.25) / 0.25) / 100;
96+
//Log.w("myApp", "[#] EGM96.java - getEGMCorrection(" + Latitude + ", " + Longitude + ") = " + hc);
97+
98+
return ((hc1 + (hc2 - hc1) * (Lon % 0.25) / 0.25) / 100);
99+
} catch (ArrayIndexOutOfBoundsException e) {
100+
return EGM96_VALUE_INVALID;
101+
}
102+
}
103+
else return EGM96_VALUE_INVALID;
104+
}
105+
106+
private void copyFile(InputStream in, OutputStream out) throws IOException {
107+
byte[] buffer = new byte[1024];
108+
int read;
109+
while ((read = in.read(buffer)) != -1) {
110+
out.write(buffer, 0, read);
111+
}
112+
}
113+
114+
private void DeleteFile(String filename) {
115+
File file = new File(filename);
116+
if (file.exists ()) file.delete();
117+
}
118+
119+
120+
// The Thread that loads the grid in background ------------------------------------------------
121+
122+
private class LoadEGM96Grid implements Runnable {
123+
// Thread: Load EGM grid
124+
125+
@Override
126+
public void run() {
127+
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
128+
Log.w("myApp", "[#] EGM96.java - Start loading grid");
129+
130+
boolean islocalcopypresent = false;
131+
boolean issharedcopypresent = false;
132+
133+
File localfile = new File(EGMFileNameLocalCopy);
134+
if (localfile.exists() && (localfile.length() == 2076480)) islocalcopypresent = true;
135+
136+
File sharedfile = new File(EGMFileName);
137+
if (sharedfile.exists() && (sharedfile.length() == 2076480)) issharedcopypresent = true;
138+
139+
File file = new File(islocalcopypresent ? EGMFileNameLocalCopy : EGMFileName);
140+
if (islocalcopypresent || issharedcopypresent) {
141+
Log.w("myApp", "[#] EGM96.java - From file: " + file.getAbsolutePath());
142+
143+
FileInputStream fin;
144+
try {
145+
fin = new FileInputStream(file);
146+
} catch (FileNotFoundException e) {
147+
isEGMGridLoaded = false;
148+
isEGMGridLoading = false;
149+
Log.w("myApp", "[#] EGM96.java - FileNotFoundException");
150+
//Toast.makeText(getApplicationContext(), "Oops", Toast.LENGTH_SHORT).show();
151+
//e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
152+
return;
153+
}
154+
BufferedInputStream bin = new BufferedInputStream(fin);
155+
DataInputStream din = new DataInputStream(bin);
156+
int i;
157+
int i_lon = BOUNDARY;
158+
int i_lat = BOUNDARY;
159+
int count = (int) ((file.length() / 2));
160+
161+
for (i = 0; (i < count); i++) {
162+
try {
163+
EGMGrid[i_lon][i_lat] = din.readShort();
164+
i_lon++;
165+
if (i_lon >= (1440 + BOUNDARY)) {
166+
i_lat++;
167+
i_lon = BOUNDARY;
168+
}
169+
} catch (IOException e) {
170+
isEGMGridLoaded = false;
171+
isEGMGridLoading = false;
172+
Log.w("myApp", "[#] EGM96.java - IOException");
173+
return;
174+
//Toast.makeText(getApplicationContext(), "Oops", Toast.LENGTH_SHORT).show();
175+
//e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
176+
}
177+
}
178+
179+
if (BOUNDARY > 0) {
180+
// Fill boundaries with correct data, in order to speed up retrieving for interpolation;
181+
// fill left + right boundaries
182+
//Log.w("myApp", "[#] EGM96.java - LR BOUNDARIES");
183+
for (int ix = 0; (ix < BOUNDARY); ix++) {
184+
for (int iy = BOUNDARY; (iy < BOUNDARY + 721); iy++) {
185+
EGMGrid[ix][iy] = EGMGrid[ix + 1440][iy];
186+
EGMGrid[BOUNDARY + ix + 1440][iy] = EGMGrid[BOUNDARY + ix][iy];
187+
}
188+
}
189+
// fill top + bottom boundaries
190+
//Log.w("myApp", "[#] EGM96.java - TOP DOWN BOUNDARIES");
191+
for (int iy = 0; (iy < BOUNDARY); iy++) {
192+
for (int ix = 0; (ix < BOUNDARY + 1440 + BOUNDARY); ix++) {
193+
if (ix > 720) {
194+
EGMGrid[ix][iy] = EGMGrid[ix - 720][BOUNDARY + BOUNDARY - iy];
195+
EGMGrid[ix][BOUNDARY + iy + 721] = EGMGrid[ix - 720][BOUNDARY + 721-2 - iy];
196+
}
197+
else {
198+
EGMGrid[ix][iy] = EGMGrid[ix + 720][BOUNDARY + BOUNDARY - iy];
199+
EGMGrid[ix][BOUNDARY + iy + 721] = EGMGrid[ix + 720][BOUNDARY + 721-2 - iy];
200+
}
201+
}
202+
}
203+
}
204+
205+
isEGMGridLoading = false;
206+
isEGMGridLoaded = true;
207+
Log.w("myApp", "[#] EGM96.java - Grid Successfully Loaded: " + file.getAbsolutePath());
208+
//Toast.makeText(getApplicationContext(), "EGM96 correction grid loaded", Toast.LENGTH_SHORT).show();
209+
210+
if (issharedcopypresent) {
211+
if (!islocalcopypresent) new Thread(new CopyEGM96Grid()).start();
212+
else {
213+
DeleteFile(EGMFileName); // Delete the EGM file from the shared folder
214+
Log.w("myApp", "[#] EGM96.java - EGM File already present into FilesDir. File deleted from shared folder");
215+
}
216+
}
217+
218+
} else {
219+
isEGMGridLoading = false;
220+
isEGMGridLoaded = false;
221+
if (!file.exists()) { Log.w("myApp", "[#] EGM96.java - File not found"); }
222+
if (!file.canRead()) { Log.w("myApp", "[#] EGM96.java - Cannot read file"); }
223+
if (file.length() != 2076480) {
224+
Log.w("myApp", "[#] EGM96.java - File has invalid length: " + file.length());}
225+
//Toast.makeText(getApplicationContext(), "EGM96 correction not available", Toast.LENGTH_SHORT).show();
226+
}
227+
EventBus.getDefault().post(EventBusMSG.UPDATE_FIX);
228+
EventBus.getDefault().post(EventBusMSG.UPDATE_TRACK);
229+
EventBus.getDefault().post(EventBusMSG.UPDATE_TRACKLIST);
230+
//listener.onEGMGridLoaded(isEGMGridLoaded);
231+
}
232+
}
233+
234+
// The Thread that copies the EGM grid in FilesDir (in background) -----------------------------
235+
236+
private class CopyEGM96Grid implements Runnable {
237+
// Thread: Copy the EGM grid in FilesDir
238+
239+
@Override
240+
public void run() {
241+
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
242+
Log.w("myApp", "[#] EGM96.java - Copy EGM96 Grid into FilesDir");
243+
244+
if (isEGMFileCopying) return;
245+
246+
isEGMFileCopying = true;
247+
248+
File sd_cpy = new File(EGMFileNameLocalCopy);
249+
if (sd_cpy.exists()) sd_cpy.delete();
250+
251+
File sd_old = new File(EGMFileName);
252+
if (sd_old.exists()) {
253+
InputStream in = null;
254+
OutputStream out = null;
255+
try {
256+
in = new FileInputStream(EGMFileName);
257+
out = new FileOutputStream(EGMFileNameLocalCopy);
258+
copyFile(in, out);
259+
in.close();
260+
in = null;
261+
out.flush();
262+
out.close();
263+
out = null;
264+
Log.w("myApp", "[#] EGM96.java - EGM File copy completed");
265+
DeleteFile(EGMFileName); // Delete the EGM file from the shared folder
266+
Log.w("myApp", "[#] EGM96.java - EGM File deleted from shared folder");
267+
268+
} catch(Exception e) {
269+
Log.w("MyApp", "[#] EGM96.java - Unable to make local copy of EGM file: " + e.getMessage());
270+
}
271+
}
272+
273+
isEGMFileCopying = false;
274+
}
275+
}
276+
}

0 commit comments

Comments
 (0)