Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtain satellite data from modded extra params (Symbian^3) #132

Merged
merged 3 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading