gps distance correction when Overlay is not /

This commit is contained in:
richonguzman 2023-08-15 11:51:17 -04:00
parent 09eacd652d
commit 970fface06
2 changed files with 11 additions and 6 deletions

View file

@ -20,7 +20,7 @@
Configuration Config;
WiFiClient espClient;
String versionDate = "2023.08.05";
String versionDate = "2023.08.15";
int myWiFiAPIndex = 0;
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];

View file

@ -108,7 +108,7 @@ double calculateDistanceTo(double latitude, double longitude) {
}
String decodeEncodedGPS(String packet) {
String GPSPacket = packet.substring(packet.indexOf(":!/")+3);
String GPSPacket = packet.substring(packet.indexOf(":!")+3);
String encodedLatitude = GPSPacket.substring(0,4);
String encodedLongtitude = GPSPacket.substring(4,8);
@ -160,10 +160,15 @@ String getReceivedGPS(String packet) {
}
String getDistance(String packet) {
int gpsIndexEx = packet.indexOf(":!");
int gpsIndexEq = packet.indexOf(":=");
if (gpsIndexEx > 10 || gpsIndexEq > 10) {
if ((gpsIndexEx + 15 == packet.indexOf("G")) || (gpsIndexEx + 15 == packet.indexOf("Q")) || (gpsIndexEq + 15 == packet.indexOf("G")) || (gpsIndexEq + 15 == packet.indexOf("Q"))) {
int encodedBytePosition = 0;
if (packet.indexOf(":!") > 10) {
encodedBytePosition = packet.indexOf(":!") + 14;
}
if (packet.indexOf(":=") > 10) {
encodedBytePosition = packet.indexOf(":=") + 14;
}
if (encodedBytePosition != 0) {
if (String(packet[encodedBytePosition]) == "G" || String(packet[encodedBytePosition]) == "Q") {
return decodeEncodedGPS(packet);
} else {
return getReceivedGPS(packet);