Hi Gerd

Here are some fixes to warnings I get when I build with options
  -XLint:all -Xlint:-serial -Xlint:-path

also an improvement to where city/zip/highway/exitFac ptr sizes are
calculated when POIs are written

Ticker
Index: src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java	(revision 4531)
+++ src/uk/me/parabola/imgfmt/app/lbl/POIRecord.java	(working copy)
@@ -18,7 +18,6 @@
 
 import java.util.List;
 
-import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.imgfmt.app.Exit;
 import uk.me.parabola.imgfmt.app.ImgFileWriter;
 import uk.me.parabola.imgfmt.app.Label;
@@ -106,7 +105,7 @@
 	}
 
 	void write(ImgFileWriter writer, int POIGlobalFlags, int realofs,
-		   long numCities, long numZips, long numHighways, long numExitFacilities) {
+		   int cityPtrSize, int zipPtrSize, int highwayPtrSize, int exitFacilityPtrSize) {
 		assert offset == realofs : "offset = " + offset + " realofs = " + realofs;
 		int ptr = poiName.getOffset();
 		if (POIGlobalFlags != getPOIFlags())
@@ -130,10 +129,10 @@
 			writer.put3u(streetName.getOffset());
 
 		if (city != null)
-			writer.putNu(Utils.numberToPointerSize((int)numCities), city.getIndex());
+			writer.putNu(cityPtrSize, city.getIndex());
 
 		if (zip != null)
-			writer.putNu(Utils.numberToPointerSize((int)numZips), zip.getIndex());
+			writer.putNu(zipPtrSize, zip.getIndex());
 
 		if (complexPhoneNumber != null)
 		{
@@ -163,11 +162,11 @@
 			writer.put3u(val);
 
 			int highwayIndex = exit.getHighway().getIndex();
-			writer.putNu(Utils.numberToPointerSize((int)numHighways), highwayIndex);
+			writer.putNu(highwayPtrSize, highwayIndex);
 
 			if(ef != null) {
 				int exitFacilityIndex = ef.getIndex();
-				writer.putNu(Utils.numberToPointerSize((int)numExitFacilities), exitFacilityIndex);
+				writer.putNu(exitFacilityPtrSize, exitFacilityIndex);
 			}
 		}
 	}
@@ -179,9 +178,9 @@
 		if (simpleStreetNumber.isUsed() || streetNumberName != null)
 			b |= HAS_STREET_NUM;
 		if (city != null)
-		        b |= HAS_CITY;
+			b |= HAS_CITY;
 		if (zip != null)
-		        b |= HAS_ZIP;
+			b |= HAS_ZIP;
 		if (simplePhoneNumber.isUsed() || complexPhoneNumber != null)
 			b |= HAS_PHONE;
 		if (exit != null)
@@ -214,7 +213,7 @@
 		}
 
 		flag |= 0x80; // gpsmapedit asserts for this bit set
-	    
+
 		return flag;
 	}
 
@@ -223,14 +222,14 @@
 	 *
 	 * @return Number of bytes needed by this entry
 	 */
-	int calcOffset(int ofs, int POIGlobalFlags, long numCities, long numZips, long numHighways, long numExitFacilities) {
+	int calcOffset(int ofs, int POIGlobalFlags, int cityPtrSize, int zipPtrSize, int highwayPtrSize, int exitFacilityPtrSize) {
 		offset = ofs;
 		int size = 3;
 		if (exit != null) {
 			size += 3;
-			size += Utils.numberToPointerSize((int)numHighways);
+			size += highwayPtrSize;
 			if(!exit.getFacilities().isEmpty())
-				size += Utils.numberToPointerSize((int)numExitFacilities);
+				size += exitFacilityPtrSize;
 		}
 		if (POIGlobalFlags != getPOIFlags())
 			size += 1;
@@ -244,18 +243,10 @@
 			size += 3;			
 		if (streetName != null)
 			size += 3;	
-		if (city != null) 
-		{
-			/*
-			  depending on how many cities are in the LBL block we have
-			  to write one to three bytes 
-			*/
-			size += Utils.numberToPointerSize((int)numCities);
-		}
-		if (zip != null) {
-			// depending on how many zips are in the LBL block we have to write one to three bytes
-			size += Utils.numberToPointerSize((int)numZips);
-		}
+		if (city != null)
+			size += cityPtrSize;
+		if (zip != null)
+			size += zipPtrSize;
 		return size;
 	}
 
Index: src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java	(revision 4531)
+++ src/uk/me/parabola/imgfmt/app/lbl/PlacesFile.java	(working copy)
@@ -24,6 +24,7 @@
 import java.util.Random;
 import java.util.TreeMap;
 
+import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.imgfmt.app.Exit;
 import uk.me.parabola.imgfmt.app.ImgFileWriter;
 import uk.me.parabola.imgfmt.app.Label;
@@ -104,9 +105,13 @@
 
 		int poistart = writer.position();
 		int poiglobalflags = placeHeader.getPOIGlobalFlags();
+		final int cityPtrSize = Utils.numberToPointerSize(cityList.size());
+		final int zipPtrSize = Utils.numberToPointerSize(postalCodes.size());
+		final int highwayPtrSize = Utils.numberToPointerSize(highways.size());
+		final int exitFacilityPtrSize = Utils.numberToPointerSize(exitFacilities.size());
 		for (POIRecord p : pois)
 			p.write(writer, poiglobalflags,
-				writer.position() - poistart, cityList.size(), postalCodes.size(), highways.size(), exitFacilities.size());
+				writer.position() - poistart, cityPtrSize, zipPtrSize, highwayPtrSize, exitFacilityPtrSize);
 		placeHeader.endPOI(writer.position());
 
 		int numPoiIndexEntries = 0;
@@ -287,8 +292,12 @@
 		placeHeader.setPOIGlobalFlags(poiFlags);
 
 		int ofs = 0;
+		final int cityPtrSize = Utils.numberToPointerSize(cityList.size());
+		final int zipPtrSize = Utils.numberToPointerSize(postalCodes.size());
+		final int highwayPtrSize = Utils.numberToPointerSize(highways.size());
+		final int exitFacilityPtrSize = Utils.numberToPointerSize(exitFacilities.size());
 		for (POIRecord p : pois)
-			ofs += p.calcOffset(ofs, poiFlags, cityList.size(), postalCodes.size(), highways.size(), exitFacilities.size());
+			ofs += p.calcOffset(ofs, poiFlags, cityPtrSize, zipPtrSize, highwayPtrSize, exitFacilityPtrSize);
 	}
 
 	/**
Index: src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(revision 4531)
+++ src/uk/me/parabola/imgfmt/app/mdr/Mdr7.java	(working copy)
@@ -363,7 +363,7 @@
 
 
 	public List<Mdr7Record> getStreets() {
-		return Collections.unmodifiableList((ArrayList<Mdr7Record>) allStreets);
+		return Collections.unmodifiableList(allStreets);
 	}
 	
 	public List<Mdr7Record> getSortedStreets() {
Index: src/uk/me/parabola/imgfmt/app/net/RouteArc.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RouteArc.java	(revision 4531)
+++ src/uk/me/parabola/imgfmt/app/net/RouteArc.java	(working copy)
@@ -317,7 +317,7 @@
 
 		// We write this big endian
 		if(log.isDebugEnabled())
-			log.debug("val is", Integer.toHexString((int)val));
+			log.debug("val is", Integer.toHexString(val));
 		writer.put1u(val >> 8);
 		writer.put1u(val & 0xff);
 	}
Index: src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java	(revision 4531)
+++ src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java	(working copy)
@@ -183,7 +183,7 @@
 		for (Country c : countries) {
 			if (c != null) {
 				Mdr14Record record = mdrFile.addCountry(c);
-				countryMap.put((int) c.getIndex(), record);
+				countryMap.put(c.getIndex(), record);
 			}
 		}
 		return countryMap;
@@ -195,9 +195,9 @@
 		List<Region> regions = mr.getRegions();
 		for (Region region : regions) {
 			if (region != null) {
-				Mdr14Record mdr14 = maps.countries.get((int) region.getCountry().getIndex());
+				Mdr14Record mdr14 = maps.countries.get(region.getCountry().getIndex());
 				Mdr13Record record = mdrFile.addRegion(region, mdr14);
-				regionMap.put((int) region.getIndex(), record);
+				regionMap.put(region.getIndex(), record);
 			}
 		}
 		return regionMap;
Index: src/uk/me/parabola/mkgmap/osmstyle/PrefixSuffixFilter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/PrefixSuffixFilter.java	(revision 4531)
+++ src/uk/me/parabola/mkgmap/osmstyle/PrefixSuffixFilter.java	(working copy)
@@ -167,7 +167,6 @@
 			}
 			countryLanguageMap .put(iso, langs);
 			languages.addAll(langs);
-		default:
 			break;
 		}
 	}
Index: src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java	(revision 4531)
+++ src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundaryMerger.java	(working copy)
@@ -42,8 +42,6 @@
 		try (FileChannel in = (new FileInputStream(file)).getChannel();
 				FileChannel out = (new FileOutputStream(new File(to, filename))).getChannel()) {
 			in.transferTo(0, file.length(), out);
-			in.close();
-			out.close();
 		} catch (IOException exp) {
 			System.err.println(exp);
 		}
Index: src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundarySaver.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundarySaver.java	(revision 4531)
+++ src/uk/me/parabola/mkgmap/reader/osm/boundary/BoundarySaver.java	(working copy)
@@ -378,6 +378,7 @@
 	 * @param area the area (can be non-singular)
 	 * @throws IOException
 	 */
+	@SuppressWarnings("fallthrough")
 	public static void writeArea(DataOutputStream dos, Shape area) throws IOException{
 		double[] res = new double[6];
 		double[] lastRes = new double[2];
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to