logo separator

[mkgmap-dev] multi-word street search

From Andrzej Popowski popej at poczta.onet.pl on Thu Dec 11 22:08:45 GMT 2014

Hi,

I have made some minor changes to mixed-index branch, patch is attached. 
Like I said before, I think this is workable solution. See pictures from 
Mapsource and nuvi.

I have created jar for tests:
http://files.mkgmap.org.uk/download/239/mkgmap.jar

The only feature I have added is a break at opening parenthesis "(", so 
text after parenthesis is not added to multi-word index.

-- 
Best regards,
Andrzej
-------------- next part --------------
--- mixed-index/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	Tue Dec 09 22:02:56 2014
+++ mixed-index/src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	Thu Dec 11 22:25:37 2014
@@ -51,10 +51,11 @@
 		st.setMapIndex(mapId);
 		st.setLabelOffset(lblOffset);
 		st.setStringOffset(strOff);
 		st.setName(name);
 		st.setCity(mdrCity);
+		st.setNameOffset(0);
 		allStreets.add(st);
 
 		// XXX Quick test...
 		//int nameOffset = name.indexOf(' ');
 		//if (nameOffset > 0) {
@@ -66,18 +67,25 @@
 		//	st.setCity(mdrCity);
 		//	st.setNameOffset(nameOffset+1);
 		//	allStreets.add(st);
 		//}
 
-		boolean start = true;
+		int nameOffset = 0;
+		for (; nameOffset < name.length() -2; nameOffset++) {
+			if (!Character.isWhitespace(name.charAt(nameOffset)))
+				break;
+		}
 
-		for (int nameOffset = 0; nameOffset < name.length(); nameOffset++) {
+		boolean start = true;
+		for (; nameOffset < name.length() -2; nameOffset++) {
 			char c = name.charAt(nameOffset);
 			if (Character.isWhitespace(c)) {
 				start = true;
 				continue;
 			}
+			if (c == '(')
+				break;
 			if (!Character.isLetterOrDigit(c)) {
 				start = true;
 				continue;
 			}
 
@@ -87,19 +95,14 @@
 				st.setLabelOffset(lblOffset);
 				st.setStringOffset(strOff);
 				st.setName(name);
 				st.setCity(mdrCity);
 				st.setNameOffset(nameOffset);
-				if (st.getPartialName().startsWith("CALLE"))
-					continue;
 				allStreets.add(st);
-				String part = st.getPartialName();
-				//System.out.println("adding: " + part);
 				start = false;
 			}
 		}
-
 	}
 
 	/**
 	 * Since we change the number of records by removing some after sorting,
 	 * we sort and de-duplicate here.
@@ -108,12 +111,11 @@
 		//createPartials();
 
 		Sort sort = getConfig().getSort();
 		List<SortKey<Mdr7Record>> sortedStreets = new ArrayList<SortKey<Mdr7Record>>(allStreets.size());
 		for (Mdr7Record m : allStreets) {
-			SortKey<Mdr7Record> sortKey = sort.createSortKey(m, m.getPartialName(),
-					m.getMapIndex());
+			SortKey<Mdr7Record> sortKey = sort.createSortKey(m, m.getPartialName(),	m.getMapIndex());
 			sortedStreets.add(sortKey);
 		}
 		Collections.sort(sortedStreets);
 
 		// De-duplicate the street names so that there is only one entry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dudka_mapsource.png
Type: image/png
Size: 7411 bytes
Desc: not available
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20141211/de1a98ca/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dudka_nuvi.png
Type: image/png
Size: 9998 bytes
Desc: not available
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20141211/de1a98ca/attachment-0003.png>


More information about the mkgmap-dev mailing list