Skip to content

Commit 41fc0da

Browse files
authored
Merge pull request #132 from mahomaps/sym3mod-satellite-data
Obtain satellite data from modded extra params (Symbian^3)
2 parents 280b4e6 + 9337791 commit 41fc0da

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

src/mahomaps/map/GeoUpdateThread.java

+38-23
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,46 @@ class LocationAPIListener implements LocationListener {
191191

192192
public void locationUpdated(LocationProvider provider, Location location) {
193193
// определение кол-ва спутников
194-
String nmea = location.getExtraInfo("application/X-jsr179-location-nmea");
195-
if (nmea != null) {
196-
String[] sequence = split(nmea, '$');
197-
int s1 = -1;
198-
int s2 = -1;
199-
for (int i = sequence.length - 1; i >= 0; i--) {
200-
String[] sentence = split(sequence[i], ',');
201-
if (sentence[0].endsWith("GGA")) {
202-
try {
203-
s1 = Integer.parseInt(sentence[7]);
204-
} catch (Exception e) {
205-
s1 = -1;
206-
}
207-
s2 = Math.max(s2, s1);
208-
} else if (sentence[0].endsWith("GSV")) {
209-
try {
210-
s2 = Math.max(s2, Integer.parseInt(sentence[3]));
211-
} catch (Exception e) {
194+
satellites: {
195+
// парамы из патча для symbian^3 https://github.com/shinovon/Symbian3JSR179Mod
196+
try {
197+
String s1 = location.getExtraInfo("satelliteNumInView");
198+
String s2 = location.getExtraInfo("satelliteNumUsed");
199+
if (s1 != null && s2 != null) {
200+
totalSattelitesInView = Integer.parseInt(s1);
201+
sattelites = Integer.parseInt(s2);
202+
break satellites;
203+
}
204+
} catch (Exception e) {}
205+
// парс сырых nmea данных
206+
String nmea = location.getExtraInfo("application/X-jsr179-location-nmea");
207+
if (nmea != null) {
208+
String[] sequence = split(nmea, '$');
209+
int s1 = -1;
210+
int s2 = -1;
211+
for (int i = sequence.length - 1; i >= 0; i--) {
212+
String s = sequence[i];
213+
if (s.indexOf('*') != -1) s = s.substring(0, s.lastIndexOf('*'));
214+
String[] sentence = split(s, ',');
215+
if (sentence[0].endsWith("GGA")) {
216+
try {
217+
s1 = Integer.parseInt(sentence[7]);
218+
} catch (Exception e) {
219+
s1 = -1;
220+
}
221+
s2 = Math.max(s2, s1);
222+
} else if (sentence[0].endsWith("GSV")) {
223+
try {
224+
s2 = Math.max(s2, Integer.parseInt(sentence[3]));
225+
} catch (Exception e) {
226+
}
212227
}
213228
}
229+
sattelites = s1;
230+
totalSattelitesInView = s2;
231+
} else {
232+
totalSattelitesInView = sattelites = -1;
214233
}
215-
sattelites = s1;
216-
totalSattelitesInView = s2;
217-
} else {
218-
totalSattelitesInView = sattelites = -1;
219234
}
220235
String s = "";
221236
int t = location.getLocationMethod();
@@ -263,7 +278,7 @@ public void locationUpdated(LocationProvider provider, Location location) {
263278
positionPoint.lon = coordinates.getLongitude();
264279
positionPoint.color = Geopoint.COLOR_RED;
265280
state = STATE_OK;
266-
lastUpdateTime = System.currentTimeMillis();
281+
lastUpdateTime = location.getTimestamp();
267282
MahoMapsApp.GetCanvas().requestRepaint();
268283
} else {
269284
state = STATE_UNAVAILABLE;

src/mahomaps/screens/MapCanvas.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private Vector GetGeoInfo() {
294294
v.addElement(MahoMapsApp.text[GeoUpdateThread.states[geo.state]]);
295295
v.addElement(MahoMapsApp.text[83] + passed + MahoMapsApp.text[84]);
296296
} else if (passed >= 5) {
297-
v.addElement(MahoMapsApp.text[85] + passed + MahoMapsApp.text[86]);
297+
v.addElement(MahoMapsApp.text[85] + (passed < 24 * 60 * 60 ? passed + MahoMapsApp.text[86] : ""));
298298
}
299299

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

0 commit comments

Comments
 (0)