Fixed MGRS decoding when still containing spaces.
This commit is contained in:
parent
436630c1e2
commit
3f7a4ea568
3 changed files with 14 additions and 5 deletions
|
@ -108,6 +108,15 @@ public class MGRSPoint extends ZonedUTMPoint {
|
|||
* an UPPERCASE coordinate string is expected.
|
||||
*/
|
||||
protected void decode(String mgrsString) throws NumberFormatException {
|
||||
if (mgrsString.contains(" ")) {
|
||||
String[] parts = mgrsString.split(" ");
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (String i : parts) {
|
||||
s.append(i);
|
||||
}
|
||||
mgrsString = s.toString();
|
||||
}
|
||||
|
||||
if (mgrsString == null || mgrsString.length() == 0) {
|
||||
throw new NumberFormatException("MGRSPoint coverting from nothing");
|
||||
}
|
||||
|
|
|
@ -140,11 +140,7 @@ public class LocationParser {
|
|||
//detect MGRS
|
||||
if (all.size() >= 3 && (d.size() == 2 || d.size() == 3) && all.get(1) instanceof String) {
|
||||
try {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (String i : strings) {
|
||||
s.append(i);
|
||||
}
|
||||
MGRSPoint mgrsPoint = new MGRSPoint(s.toString());
|
||||
MGRSPoint mgrsPoint = new MGRSPoint(locPhrase);
|
||||
LatLonPoint ll = mgrsPoint.toLatLonPoint();
|
||||
return validateAndCreateLatLon(ll.getLatitude(), ll.getLongitude());
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
|
@ -610,6 +610,10 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os
|
|||
if (latLon != null) {
|
||||
MGRSPoint pnt = new MGRSPoint(new LatLonPoint(latLon.getLatitude(), latLon.getLongitude()));
|
||||
mgrsEdit.setText(pnt.toFlavoredString(5));
|
||||
} else if (prevFormat == PointDescription.UTM_FORMAT) {
|
||||
mgrsEdit.setText(zoneEdit.getText());
|
||||
} else if (prevFormat == PointDescription.OLC_FORMAT) {
|
||||
mgrsEdit.setText(olcEdit.getText());
|
||||
} else {
|
||||
mgrsEdit.setText(latEdit.getText());
|
||||
|
||||
|
|
Loading…
Reference in a new issue