On 11/02/2011 20:59, WanMil wrote:
I tried to compile a complete europe map. It failed with the following
exception (sounds easy to fix...?-):

Exception in thread "main" java.lang.NullPointerException
at uk.me.parabola.imgfmt.app.mdr.Mdr23.sortRegions(Mdr23.java:54)

Easy to stop the exception perhaps ;) but how is it getting to be null?
All regions should have one of those set in the previous method.

Anyway I just compilled a complete UK extract and tried to upload
all the tiles and it failed with the usual error after a while. So a
complete Europe build might be a bit ambitious at this time.

..Steve

I think that happens in case the first region has an empty name "".
Then the region is set to null in Mdr28.buildFromRegions(..). I try to
change the lastName variable to another value. Maybe that works.

WanMil

Initializing lastName with null should do (?).
The patch initializes lastName with null in all Mdr classes. This seems to be a c&p problem that might happen with all names in lot's of Mdr classes.

Don't know if an empty name should be contained in map?!

WanMil
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr2x.java	(working copy)
@@ -32,7 +32,7 @@
 	 * @param writer Where to write it.
 	 */
 	public void writeSectData(ImgFileWriter writer) {
-		String lastName = "";
+		String lastName = null;
 
 		int size = getSizes().getStreetSizeFlagged();
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr22.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr22.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr22.java	(working copy)
@@ -64,7 +64,7 @@
 		int record = 0;
 
 		String lastCName = "";
-		String lastName = "";
+		String lastName = null;
 		int lastMapid = 0;
 		
 		for (SortKey<Mdr7Record> key : keys) {
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr28.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr28.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr28.java	(working copy)
@@ -39,7 +39,7 @@
 
 		int record = 0;
 		Mdr28Record mdr28 = null;
-		String lastName = "";
+		String lastName = null;
 		for (SortKey<Mdr13Record> key : keys) {
 			Mdr13Record region = key.getObject();
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr5.java	(working copy)
@@ -64,7 +64,7 @@
 		cities.clear();
 		int count = 0;
 		int lastMapId = 0;
-		String lastName = "";
+		String lastName = null;
 		for (SortKey<Mdr5Record> key : sortKeys) {
 			Mdr5Record c = key.getObject();
 			if (c.getMapIndex() != lastMapId || !c.getName().equals(lastName)) {
@@ -81,7 +81,7 @@
 	}
 
 	public void writeSectData(ImgFileWriter writer) {
-		String lastName = "";
+		String lastName = null;
 
 		int size20 = getSizes().getMdr20Size();
 		for (Mdr5Record city : cities) {
@@ -94,7 +94,7 @@
 			int region = city.getRegionIndex();
 
 			// Set flag only for a name that is different to the previous one
-			if (lastName.equals(city.getName()))
+			if (lastName == null || lastName.equals(city.getName()))
 				flag = 0;
 
 			lastName = city.getName();
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr21.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr21.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr21.java	(working copy)
@@ -60,7 +60,7 @@
 
 		Collections.sort(keys);
 
-		String lastName = "";
+		String lastName = null;
 		int lastMapid = 0;
 		int record = 0;
 		for (SortKey<Mdr7Record> key : keys) {
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr20.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr20.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr20.java	(working copy)
@@ -69,7 +69,7 @@
 
 		int[] mdr20 = new int[mdr5.getNumberOfItems() + 2];
 
-		String lastName = "";
+		String lastName = null;
 		int lastMapid = 0;
 		int record = 0;
 		for (SortKey<Mdr7Record> key : keys) {
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr29.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr29.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr29.java	(working copy)
@@ -38,7 +38,7 @@
 
 		// Sorted by name, for every new name we allocate a new 29 record and set the same one in every
 		// country with the same name.
-		String lastName = "";
+		String lastName = null;
 		Mdr29Record mdr29 = null;
 		for (SortKey<Mdr14Record> key : keys) {
 			Mdr14Record country = key.getObject();
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr24.java	(working copy)
@@ -42,7 +42,7 @@
 
 		Collections.sort(keys);
 
-		String lastName = "";
+		String lastName = null;
 		int lastMapIndex = 0;
 		int record = 0;
 		for (SortKey<Mdr14Record> key : keys) {
@@ -68,7 +68,7 @@
 	 * @param writer Where to write it.
 	 */
 	public void writeSectData(ImgFileWriter writer) {
-		String lastName = "";
+		String lastName = null;
 		for (Mdr14Record c : countries) {
 			putMapIndex(writer, c.getMapIndex());
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr25.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr25.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr25.java	(working copy)
@@ -47,7 +47,7 @@
 
 		Collections.sort(keys);
 
-		String lastName = "";
+		String lastName = null;
 		int record = 0;
 		for (SortKey<Mdr5Record> key : keys) {
 			record++;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr26.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr26.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr26.java	(working copy)
@@ -47,7 +47,7 @@
 	}
 
 	private void addToIndex(List<SortKey<Mdr28Record>> sortList) {
-		String lastName = "";
+		String lastName = null;
 		int record26 = 0;
 		for (SortKey<Mdr28Record> key : sortList) {
 			record26++;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr10.java	(working copy)
@@ -68,7 +68,7 @@
 			
 			Collections.sort(poiGroup);
 
-			String lastName = "";
+			String lastName = null;
 			for (Mdr10Record t : poiGroup) {
 
 				count++;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(working copy)
@@ -70,7 +70,7 @@
 	}
 
 	public void writeSectData(ImgFileWriter writer) {
-		String lastName = "";
+		String lastName = null;
 		for (Mdr7Record s : streets) {
 			addIndexPointer(s.getMapIndex(), s.getIndex());
 
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr27.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr27.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr27.java	(working copy)
@@ -50,7 +50,7 @@
 
 		Collections.sort(keys);
 
-		String lastName = "";
+		String lastName = null;
 		int record = 0;
 		for (SortKey<Mdr5Record> key : keys) {
 			record++;
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java	(revision 1845)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr23.java	(working copy)
@@ -41,7 +41,7 @@
 		List<SortKey<Mdr13Record>> keys = MdrUtils.sortList(sort, list);
 		Collections.sort(keys);
 
-		String lastName = "";
+		String lastName = null;
 		int lastMapIndex = 0;
 		int record = 0;
 		for (SortKey<Mdr13Record> key : keys) {
@@ -66,7 +66,7 @@
 	 * @param writer Where to write it.
 	 */
 	public void writeSectData(ImgFileWriter writer) {
-		String lastName = "";
+		String lastName = null;
 		for (Mdr13Record reg : regions) {
 			putMapIndex(writer, reg.getMapIndex());
 
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to