diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-08-19 22:20:31 +0400 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-08-19 22:20:31 +0400 |
commit | 22a8d46522824151f71c53f3fcab5e3b0d72f608 (patch) | |
tree | 3bb059be22e928839ff2dd4171eb9c4205d8ac51 /src/org/traccar | |
parent | b0b93983f5411ceffc649d44d55093b04ddf802a (diff) | |
parent | e7660ab714ee237ce080eaf14f5ab7f1997bea3f (diff) | |
download | trackermap-server-22a8d46522824151f71c53f3fcab5e3b0d72f608.tar.gz trackermap-server-22a8d46522824151f71c53f3fcab5e3b0d72f608.tar.bz2 trackermap-server-22a8d46522824151f71c53f3fcab5e3b0d72f608.zip |
Merge branch 'williamchitto-master'
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/geocode/GoogleReverseGeocoder.java | 8 | ||||
-rw-r--r-- | src/org/traccar/protocol/ST210ProtocolDecoder.java | 19 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/org/traccar/geocode/GoogleReverseGeocoder.java b/src/org/traccar/geocode/GoogleReverseGeocoder.java index 724c60e50..a25f60d66 100644 --- a/src/org/traccar/geocode/GoogleReverseGeocoder.java +++ b/src/org/traccar/geocode/GoogleReverseGeocoder.java @@ -19,6 +19,8 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.Charset; + import org.traccar.helper.Log; /** @@ -36,8 +38,10 @@ public class GoogleReverseGeocoder implements ReverseGeocoder { try { URL url = new URL("http://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude + "," + longitude + "&sensor=false"); URLConnection connection = url.openConnection(); - BufferedReader reader = new BufferedReader( - new InputStreamReader(connection.getInputStream())); + + connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),Charset.forName("UTF-8"))); // Find address line String line; diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java index f503fead6..d41a78da5 100644 --- a/src/org/traccar/protocol/ST210ProtocolDecoder.java +++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java @@ -23,8 +23,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { } private enum ST210FIELDS { - HDR_STATUS("SA200STT;", - "Status Report"), + HDR_STATUS("SA200STT;","Status Report"), HDR_EMERGENCY("SA200EMG;","Emergency Report"), HDR_EVENT("SA200EVT;", "Event Report"), HDR_ALERT("SA200ALT;","Alert Report"), @@ -33,7 +32,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { SW_VER("(\\d{3});", "Software Release Version"), DATE("(\\d+);","GPS date (yyyymmdd) Year + Month + Day"), TIME("(\\d{2}:\\d{2}:\\d{2});","GPS time (hh:mm:ss) Hour : Minute : Second"), - CELL("(\\d{2}\\w\\d{2});","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"), + CELL("(\\w+);","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"), LAT("(-\\d{2}.\\d+);", "Latitude (+/-xx.xxxxxx)"), LON("(-\\d{3}.\\d+);", "Longitude (+/-xxx.xxxxxx)"), SPD("(\\d{3}.\\d{3});","Speed in km/h - This value returns to 0 when it is over than 200,000Km"), @@ -44,8 +43,8 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { PWR_VOLT("(\\d+.\\d{2});","Voltage value of main power"), IO("(\\d+);","Current I/O status of inputs and outputs."), MODE("(\\d);","1 = Idle mode (Parking)\n" + "2 = Active Mode (Driving)"), - MSG_NUM("(\\d{4})","Message number - After 9999 is reported, message number returns to 0000"), - EMG_ID("(\\d)", "Emergency type"), + MSG_NUM("(\\d{4});","Message number - After 9999 is reported, message number returns to 0000"), + EMG_ID("(\\d);", "Emergency type"), EVT_ID("(\\d);", "Event type"), ALERT_ID("(\\d);", "Alert type"); @@ -488,6 +487,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { patternStr += field.getPattern(); } + if(patternStr.endsWith(";")){ + patternStr = patternStr.substring(0, patternStr.length()-1); + } + return Pattern.compile(patternStr); } @@ -611,7 +614,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { Log.info("MESSAGE DECODED WITH SUCCESS!"); } catch(Exception e){ - Log.info("ERROR WHILE DECODING MESSAGE: " + e.getMessage()); + Log.severe("ERROR WHILE DECODING MESSAGE: " + e.getMessage()); } return position; @@ -631,6 +634,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { throw new Exception("Pattern no match: " + protocolPattern.toString()); } + if(report.equals(ST210REPORTS.ALIVE)){ + return null; + } + // Create new position Position position = new Position(); |