From 137b0ed137e631660233efe7d6d1e2063887ab40 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 15 Jul 2016 09:28:09 +0200 Subject: [PATCH] Update search location --- .../osmand/search/core/SearchCoreFactory.java | 28 +++++++++++++------ .../net/osmand/search/LocationSearchTest.java | 5 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index e4562b0f93..13dc585768 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -863,7 +863,8 @@ public class SearchCoreFactory { int jointNumbers = 0; int lastJoin = 0; int degSplit = -1; - int degType = -1; // 0 - degree, 1 - minutes, 2 - seconds + int degType = -1; // 0 - degree, 1 - minutes, 2 - seconds + boolean finishDegSplit = false; int northSplit = -1; int eastSplit = -1; for(int i = 1; i < all.size(); i++ ) { @@ -887,11 +888,22 @@ public class SearchCoreFactory { } else if (all.get(i).equals("″") || all.get(i).equals("\"")) { dg = 2; } - if (dg != -1 && degType != -2) { - if (degType < dg) { - degSplit = i + 1; + if (dg != -1) { + if (!finishDegSplit) { + if (degType < dg) { + degSplit = i + 1; + degType = dg; + } else { + finishDegSplit = true; + degType = dg; + } } else { - degType = -2; // finish search + if (degType < dg) { + degType = dg; + } else { + // reject delimiter + degSplit = -1; + } } } } @@ -901,11 +913,9 @@ public class SearchCoreFactory { } if(northSplit != -1 && northSplit < all.size() -1) { split = northSplit; - } - if(eastSplit != -1 && eastSplit < all.size() -1) { + } else if(eastSplit != -1 && eastSplit < all.size() -1) { split = eastSplit; - } - if(degSplit != -1 && degSplit < all.size() -1) { + } else if(degSplit != -1 && degSplit < all.size() -1) { split = degSplit; } diff --git a/OsmAnd-java/test/java/net/osmand/search/LocationSearchTest.java b/OsmAnd-java/test/java/net/osmand/search/LocationSearchTest.java index 5394b2b77a..eb099827b2 100644 --- a/OsmAnd-java/test/java/net/osmand/search/LocationSearchTest.java +++ b/OsmAnd-java/test/java/net/osmand/search/LocationSearchTest.java @@ -49,8 +49,8 @@ public class LocationSearchTest { search("5.445 3.523", new LatLon(5.445, 3.523)); search("5:1:1 3:1", new LatLon(5 + 1/60f + 1/3600f, 3 + 1/60f)); search("5:1#1 3#1", new LatLon(5 + 1/60f + 1/3600f, 3 + 1/60f)); - search("5'1'1 3'1", new LatLon(5 + 1/60f + 1/3600f, 3 + 1/60f)); search("5#1#1 3#1", new LatLon(5 + 1/60f + 1/3600f, 3 + 1/60f)); + search("5'1'1 3'1", new LatLon(5 + 1/60f + 1/3600f, 3 + 1/60f)); } @Test @@ -72,11 +72,12 @@ public class LocationSearchTest { @Test public void testArcgisSpaceSearch() throws IOException { + search("43°S 79°23′13.7″W", new LatLon(-43,-(79 + 23/60f + 13.7/3600f))); search("43°38′33.24″N 79°23′13.7″W", new LatLon(43 + 38/60f + 33.24/3600f,-(79 + 23/60f + 13.7/3600f))); search("45° 30'30\"W 3.0", new LatLon(45 + 0.5 + 1 / 120f, -3)); - search("43°S 79°23′13.7″W", new LatLon(-43,-(79 + 23/60f + 13.7/3600f))); search("43° 79°23′13.7″E", new LatLon(43,79 + 23/60f + 13.7/3600f)); search("43°38′ 79°23′13.7″E", new LatLon(43 + 38/60f,79 + 23/60f + 13.7/3600f)); + search("43°38′23\" 79°23′13.7″E", new LatLon(43 + 38/60f + 23/3600f,79 + 23/60f + 13.7/3600f)); }