Update search location

This commit is contained in:
Victor Shcherb 2016-07-15 09:28:09 +02:00
parent 4652763b95
commit 137b0ed137
2 changed files with 22 additions and 11 deletions

View file

@ -864,6 +864,7 @@ public class SearchCoreFactory {
int lastJoin = 0;
int degSplit = -1;
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 (dg != -1) {
if (!finishDegSplit) {
if (degType < dg) {
degSplit = i + 1;
degType = dg;
} else {
degType = -2; // finish search
finishDegSplit = true;
degType = dg;
}
} else {
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;
}

View file

@ -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°2313.7″W", new LatLon(-43,-(79 + 23/60f + 13.7/3600f)));
search("43°3833.24″N 79°2313.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°2313.7″W", new LatLon(-43,-(79 + 23/60f + 13.7/3600f)));
search("43° 79°2313.7″E", new LatLon(43,79 + 23/60f + 13.7/3600f));
search("43°38 79°2313.7″E", new LatLon(43 + 38/60f,79 + 23/60f + 13.7/3600f));
search("43°3823\" 79°2313.7″E", new LatLon(43 + 38/60f + 23/3600f,79 + 23/60f + 13.7/3600f));
}