Index: trunk/src/org/openstreetmap/josm/data/Bounds.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Bounds.java	(revision 4177)
+++ trunk/src/org/openstreetmap/josm/data/Bounds.java	(revision 4178)
@@ -215,4 +215,27 @@
     }
 
+    public boolean isOutOfTheWorld() {
+        return
+        minLat < -90 || minLat > 90 ||
+        maxLat < -90 || maxLat > 90 ||
+        minLon < -180 || minLon > 180 ||
+        maxLon < -180 || maxLon > 180;
+    }
+
+    private double toInterval(double value, double min, double max) {
+        if (value < min)
+            return min;
+        if (value > max)
+            return max;
+        return value;
+    }
+
+    public void normalize() {
+        minLat = toInterval(minLat, -90, 90);
+        maxLat = toInterval(maxLat, -90, 90);
+        minLon = toInterval(minLon, -180, 180);
+        maxLon = toInterval(maxLon, -180, 180);
+    }
+
     @Override
     public int hashCode() {
Index: trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 4177)
+++ trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 4178)
@@ -731,5 +731,5 @@
             // search spot can not cover the current
             // search
-            while (!search_cache.bbox().bounds(search_bbox)) {
+            while (search_cache != null && !search_cache.bbox().bounds(search_bbox)) {
                 if (debug) {
                     out("bbox: " + search_bbox);
@@ -743,4 +743,9 @@
                     out("new search_cache: " + search_cache);
                 }
+            }
+
+            if (search_cache == null) {
+                search_cache = root;
+                out("bbox: " + search_bbox + " is out of the world");
             }
         } else {
Index: trunk/src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 4177)
+++ trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 4178)
@@ -151,6 +151,11 @@
                         }
                         Bounds bounds = new Bounds(
-                                new LatLon(Double.parseDouble(minlat), Double.parseDouble(minlon)),
-                                new LatLon(Double.parseDouble(maxlat), Double.parseDouble(maxlon)));
+                                Double.parseDouble(minlat), Double.parseDouble(minlon),
+                                Double.parseDouble(maxlat), Double.parseDouble(maxlon));
+                        if (bounds.isOutOfTheWorld()) {
+                            Bounds copy = new Bounds(bounds);
+                            bounds.normalize();
+                            System.out.println("Bbox " + copy + " is out of the world, normalized to " + bounds);
+                        }
                         DataSource src = new DataSource(bounds, origin);
                         ds.dataSources.add(src);
