Index: ps/ps.map/get_scalebar.c
===================================================================
--- ps/ps.map/get_scalebar.c	(revision 30281)
+++ ps/ps.map/get_scalebar.c	(working copy)
@@ -40,6 +40,7 @@
    sb.x = PS.page_width/2.;
    sb.y = 2.;
    sb.bgcolor = 1; /* default is "on" [white|none] (TODO: multi-color) */
+   sb.scaleunits = 1; /* scale units e.g. meters to Kilometers */
 
 
     while (input(2, buf, help))
@@ -119,6 +120,26 @@
 		continue;
 	}
 
+        if (KEY("scaleunits"))
+	        {
+	    	
+            if (sscanf(data, "%lf", &sb.scaleunits) != 1 || sb.scaleunits <= 0. )
+	        {
+                       error(key, data, "illegal scaleunits request");
+	        }
+                else continue;
+        }
+
+	if (KEY("unitslabel"))
+	        {
+	        sscanf(data, "%s", &sb.unitslabel); 
+	        continue;
+	}
+
+	
+	     
+	 
+
 	error(key, data, "illegal request (scalebar)");
 	
      }
Index: ps/ps.map/description.html
===================================================================
--- ps/ps.map/description.html	(revision 30281)
+++ ps/ps.map/description.html	(working copy)
@@ -1031,6 +1031,8 @@
 	<B>numbers</B> #
 	<B>fontsize</B> font size
 	<B>background</B> [Y|n]
+	<B>scaleunits</B> scale units by this factor
+	<B>unitslabel</B> label for units
 	<B>end</B>
 </PRE>
 Draw one of two types of scale bar.
@@ -1050,8 +1052,8 @@
 <P>
 NOTE: The scalebar is centered on the location given.
 <P>
-This example draws a simple scalebar 1000 meters (for a metered database, like UTM) long,
-with tics every 200 meters, labeled every second tic. The scalebar is drawn 5 inches from the top and 4 inches from the left and is 0.25 inches high.
+This example draws a simple scalebar 1000 meters (for a metered database, like UTM) long, with tics every 200 meters, labeled every second tic. The scalebar is drawn 5 inches from the top and 4 inches from the left and is 0.25 inches high.
+Under the scalebar a label shows the name of the unit (Meters).
 <PRE>
 EXAMPLE:
 	<B>scalebar</B> s
@@ -1060,6 +1062,7 @@
 	<B>height</B> 0.25
 	<B>segment</B> 5
 	<B>numbers</B> 2
+	<B>unitslabel</B> meters
 	<B>end</B>
 </PRE>
 
Index: ps/ps.map/do_scalebar.c
===================================================================
--- ps/ps.map/do_scalebar.c	(revision 30281)
+++ ps/ps.map/do_scalebar.c	(working copy)
@@ -75,7 +75,7 @@
 
 	    /* do text */
 	    if (i == 0 || lab == sb.numbers) {
-		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));
+		sprintf(num, "%s", nice_number(((sb.length / sb.segment) * i ) / sb.scaleunits));
 		text_box_path(x1, y2 + margin, CENTER, LOWER, num, sb.fontsize, 0);
 		if(sb.bgcolor) { /* TODO: take bg color, not just [white|none] */
 		    set_rgb_color(WHITE);
@@ -88,7 +88,7 @@
 
 	    if ((lab > 0 && i == seg - 1) || (sb.numbers == 1 && i == seg - 1)) {
 		/* special case for last label */
-		sprintf(num, "%s", nice_number(sb.length));
+		sprintf(num, "%s", nice_number(sb.length / sb.scaleunits));
 		text_box_path(x2, y2 + margin, CENTER, LOWER, num, sb.fontsize, 0);
 		if(sb.bgcolor) {
 		    set_rgb_color(WHITE);
@@ -134,7 +134,7 @@
 	fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);
 
 	/* draw label */
-	sprintf(num, "%s", nice_number(sb.length));
+	sprintf(num, "%s", nice_number(sb.length / sb.scaleunits));
 	text_box_path(x1, y2 + margin, CENTER, LOWER, num, sb.fontsize, 0);
 	if(sb.bgcolor) {
 	    set_rgb_color(WHITE);
@@ -157,7 +157,7 @@
 
 	    /* do text */
 	    if (lab == sb.numbers) {
-		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));
+		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i / sb.scaleunits));
 
 		text_box_path(x1, y3 + margin, CENTER, LOWER, num, sb.fontsize, 0);
 		if(sb.bgcolor) {
@@ -169,10 +169,15 @@
 		lab = 0;
 	    }
 
+
 	}
     }
 
+    sprintf(num, "%s", sb.unitslabel);
+    text_box_path( 72.0 * ( x + length / 2) , 72.0 * (PS.page_height - sb.y), CENTER, UPPER, num, sb.fontsize, 0);
+    fprintf(PS.fp, "TIB\n");
 
+
     return 0;
 }
 
Index: ps/ps.map/decorate.h
===================================================================
--- ps/ps.map/decorate.h	(revision 30281)
+++ ps/ps.map/decorate.h	(working copy)
@@ -14,6 +14,8 @@
 	double width;
 	int fontsize;
 	int color, bgcolor;
+	double scaleunits;
+	char unitslabel[32];
 };
 
 #ifdef MAIN
