Index: src/uk/me/parabola/mkgmap/build/MapBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/build/MapBuilder.java	(revision 4097)
+++ src/uk/me/parabola/mkgmap/build/MapBuilder.java	(working copy)
@@ -14,7 +14,6 @@
 package uk.me.parabola.mkgmap.build;
 
 import java.awt.geom.Path2D;
-import java.awt.geom.Rectangle2D;
 import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -34,7 +33,6 @@
 import uk.me.parabola.imgfmt.ExitException;
 import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.Utils;
-import uk.me.parabola.imgfmt.app.Area;
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.imgfmt.app.Exit;
 import uk.me.parabola.imgfmt.app.Label;
@@ -102,7 +100,6 @@
 import uk.me.parabola.mkgmap.reader.overview.OverviewMapDataSource;
 import uk.me.parabola.util.Configurable;
 import uk.me.parabola.util.EnhancedProperties;
-import uk.me.parabola.util.Java2DConverter;
 import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
 
 /**
@@ -166,7 +163,6 @@
 	private String pathToHGT;
 	private List<Integer> demDists;
 	private short demOutsidePolygonHeight;
-	private java.awt.geom.Area demPolygon;
 	private HGTConverter.InterpolationMethod demInterpolationMethod;
 	
 
@@ -215,10 +211,6 @@
 		pathToHGT = props.getProperty("dem", null);
 		demDists = parseDemDists(props.getProperty("dem-dists", "-1"));
 		demOutsidePolygonHeight = (short) props.getProperty("dem-outside-polygon", HGTReader.UNDEF);
-		String demPolygonFile = props.getProperty("dem-poly", null);
-		if (demPolygonFile != null) {
-			demPolygon = Java2DConverter.readPolyFile(demPolygonFile);
-		}
 		String ipm = props.getProperty("dem-interpolation", "auto");
 		switch (ipm) {
 		case "auto": 
@@ -322,14 +314,6 @@
 			try{
 				long t1 = System.currentTimeMillis();
 				java.awt.geom.Area  demArea = null;
-				if (demPolygon != null) {
-					Area bbox = src.getBounds();
-					// the rectangle is a bit larger to avoid problems at tile boundaries
-					Rectangle2D r = new Rectangle2D.Double(bbox.getMinLong() - 2, bbox.getMinLat() - 2,
-							bbox.getWidth() + 4, bbox.getHeight() + 4);
-					demArea = new java.awt.geom.Area(r);
-					demArea.intersect(demPolygon);
-				} 
 				if (demArea == null && src instanceof OverviewMapDataSource) {
 					Path2D demPoly = ((OverviewMapDataSource) src).getTileAreaPath();
 					if (demPoly != null) {
Index: src/uk/me/parabola/mkgmap/combiners/OverviewBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/OverviewBuilder.java	(revision 4097)
+++ src/uk/me/parabola/mkgmap/combiners/OverviewBuilder.java	(working copy)
@@ -42,6 +42,7 @@
 import uk.me.parabola.mkgmap.reader.overview.OverviewMapDataSource;
 import uk.me.parabola.mkgmap.srt.SrtTextReader;
 import uk.me.parabola.util.EnhancedProperties;
+import uk.me.parabola.util.Java2DConverter;
 
 /**
  * Build the overview map.  This is a low resolution map that covers the whole
@@ -392,10 +393,32 @@
 	 */
 	private void addMapCoverageArea(FileInfo finfo) {
 		Area bounds = finfo.getBounds();
+		String demPolygonFile = demProps.getProperty("dem-poly", null); 
+		if (demPolygonFile != null) {
+			java.awt.geom.Area demPolygon = Java2DConverter.readPolyFile(demPolygonFile);
+			java.awt.geom.Area backgroundArea = Java2DConverter.createBoundsArea(finfo.getBounds());
+			backgroundArea.intersect(demPolygon);
+			List<List<Coord>> shapes = Java2DConverter.areaToShapes(backgroundArea);
+			for (List<Coord> shape : shapes) {
+				for (Coord co: shape){
+					overviewSource.addToBounds(co);
+				}
+
+				MapShape bg = new MapShape();
+				bg.setType(0x4a);
+				bg.setPoints(shape);
+				bg.setMinResolution(0);
+				bg.setName(finfo.getDescription() + '\u001d' + finfo.getMapname());
+				overviewSource.addShape(bg); 
+			}
+			return;
+		}
+		
 		List<Coord> points = bounds.toCoords();
 		for (Coord co: points){
 			overviewSource.addToBounds(co);
 		}
+
 		// Create the tile coverage rectangle
 		MapShape bg = new MapShape();
 		bg.setType(0x4a);
Index: src/uk/me/parabola/mkgmap/reader/MapperBasedMapDataSource.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/MapperBasedMapDataSource.java	(revision 4097)
+++ src/uk/me/parabola/mkgmap/reader/MapperBasedMapDataSource.java	(working copy)
@@ -30,6 +30,7 @@
 import uk.me.parabola.imgfmt.app.net.RoadNetwork;
 import uk.me.parabola.util.Configurable;
 import uk.me.parabola.util.EnhancedProperties;
+import uk.me.parabola.util.Java2DConverter;
 
 /**
  * A convenient base class for all map data that is based on the MapDetails
@@ -104,6 +105,22 @@
 	 * We add the background polygons if the map is not transparent.
 	 */
 	public void addBackground() {
+		String demPolygonFile = configProps.getProperty("dem-poly", null);
+		if (demPolygonFile != null) {
+			java.awt.geom.Area demPolygon = Java2DConverter.readPolyFile(demPolygonFile);
+			java.awt.geom.Area backgroundArea = Java2DConverter.createBoundsArea(mapper.getBounds());
+			backgroundArea.intersect(demPolygon);
+			List<List<Coord>> shapes = Java2DConverter.areaToShapes(backgroundArea);
+			for (List<Coord> shape : shapes) {
+				MapShape background = new MapShape();
+				background.setPoints(shape);
+				background.setType(0x4b); // background type
+				background.setMinResolution(0); // On all levels
+				mapper.addShape(background);
+			}
+			return;
+		}
+
 		MapShape background = new MapShape();
 		background.setPoints(mapper.getBounds().toCoords());
 		background.setType(0x4b); // background type
