Skip to content

Commit

Permalink
Merge pull request #132 from mahomaps/sym3mod-satellite-data
Browse files Browse the repository at this point in the history
Obtain satellite data from modded extra params (Symbian^3)
  • Loading branch information
Feodor0090 authored Jan 6, 2024
2 parents 280b4e6 + 9337791 commit 41fc0da
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
61 changes: 38 additions & 23 deletions src/mahomaps/map/GeoUpdateThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,31 +191,46 @@ class LocationAPIListener implements LocationListener {

public void locationUpdated(LocationProvider provider, Location location) {
// определение кол-ва спутников
String nmea = location.getExtraInfo("application/X-jsr179-location-nmea");
if (nmea != null) {
String[] sequence = split(nmea, '$');
int s1 = -1;
int s2 = -1;
for (int i = sequence.length - 1; i >= 0; i--) {
String[] sentence = split(sequence[i], ',');
if (sentence[0].endsWith("GGA")) {
try {
s1 = Integer.parseInt(sentence[7]);
} catch (Exception e) {
s1 = -1;
}
s2 = Math.max(s2, s1);
} else if (sentence[0].endsWith("GSV")) {
try {
s2 = Math.max(s2, Integer.parseInt(sentence[3]));
} catch (Exception e) {
satellites: {
// парамы из патча для symbian^3 https://github.com/shinovon/Symbian3JSR179Mod
try {
String s1 = location.getExtraInfo("satelliteNumInView");
String s2 = location.getExtraInfo("satelliteNumUsed");
if (s1 != null && s2 != null) {
totalSattelitesInView = Integer.parseInt(s1);
sattelites = Integer.parseInt(s2);
break satellites;
}
} catch (Exception e) {}
// парс сырых nmea данных
String nmea = location.getExtraInfo("application/X-jsr179-location-nmea");
if (nmea != null) {
String[] sequence = split(nmea, '$');
int s1 = -1;
int s2 = -1;
for (int i = sequence.length - 1; i >= 0; i--) {
String s = sequence[i];
if (s.indexOf('*') != -1) s = s.substring(0, s.lastIndexOf('*'));
String[] sentence = split(s, ',');
if (sentence[0].endsWith("GGA")) {
try {
s1 = Integer.parseInt(sentence[7]);
} catch (Exception e) {
s1 = -1;
}
s2 = Math.max(s2, s1);
} else if (sentence[0].endsWith("GSV")) {
try {
s2 = Math.max(s2, Integer.parseInt(sentence[3]));
} catch (Exception e) {
}
}
}
sattelites = s1;
totalSattelitesInView = s2;
} else {
totalSattelitesInView = sattelites = -1;
}
sattelites = s1;
totalSattelitesInView = s2;
} else {
totalSattelitesInView = sattelites = -1;
}
String s = "";
int t = location.getLocationMethod();
Expand Down Expand Up @@ -263,7 +278,7 @@ public void locationUpdated(LocationProvider provider, Location location) {
positionPoint.lon = coordinates.getLongitude();
positionPoint.color = Geopoint.COLOR_RED;
state = STATE_OK;
lastUpdateTime = System.currentTimeMillis();
lastUpdateTime = location.getTimestamp();
MahoMapsApp.GetCanvas().requestRepaint();
} else {
state = STATE_UNAVAILABLE;
Expand Down
2 changes: 1 addition & 1 deletion src/mahomaps/screens/MapCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private Vector GetGeoInfo() {
v.addElement(MahoMapsApp.text[GeoUpdateThread.states[geo.state]]);
v.addElement(MahoMapsApp.text[83] + passed + MahoMapsApp.text[84]);
} else if (passed >= 5) {
v.addElement(MahoMapsApp.text[85] + passed + MahoMapsApp.text[86]);
v.addElement(MahoMapsApp.text[85] + (passed < 24 * 60 * 60 ? passed + MahoMapsApp.text[86] : ""));
}

// метод и спутники
Expand Down

0 comments on commit 41fc0da

Please sign in to comment.