Index: /trunk/import/osm2pgsql/output-pgsql.c
===================================================================
--- /trunk/import/osm2pgsql/output-pgsql.c (revision 11)
+++ /trunk/import/osm2pgsql/output-pgsql.c (revision 48)
@@ -299,4 +305,22 @@
 
 
+static void escape_type(char *sql, int len, const char *value, const char *type) {
+    int items, from, to;
+
+    if ( !strcmp(type, "int4") ) {
+        items = sscanf(value, "%d-%d", &from, &to);
+        if ( items == 1 ) {
+            sprintf(sql, "%d", from);
+        } else if ( items == 2 ) {
+            sprintf(sql, "%d", (from + to) / 2);
+        } else {
+            sprintf(sql, "\\N");
+        }
+    } else {
+        escape(sql, len, value);
+    }
+}
+
+
 /* example from: pg_dump -F p -t planet_osm gis
 COPY planet_osm (osm_id, name, place, landuse, leisure, "natural", man_made, waterway, highway, railway, amenity, tourism, learning, building, bridge, layer, way) FROM stdin;
@@ -335,5 +359,5 @@
     for (i=0; i < numTags; i++) {
         if ((v = getItem(tags, exportTags[i].name)))
-            escape(sql, sizeof(sql), v);
+            escape_type(sql, sizeof(sql), v, exportTags[i].type);
         else
             sprintf(sql, "\\N");
@@ -363,5 +387,5 @@
     for (j=0; j < numTags; j++) {
 	    if ((v = getItem(tags, exportTags[j].name)))
-		    escape(sql, sizeof(sql), v);
+		    escape_type(sql, sizeof(sql), v, exportTags[j].type);
 	    else
 		    sprintf(sql, "\\N");
