silverp / osm-android

Automatically exported from code.google.com/p/osm-android
0 stars 0 forks source link

RuntimeException: Less than three points #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Trying to compile a map with this data http://download.geofabrik.de/osm/
europe/germany/schleswig-holstein.osm.bz2

What is the expected output? What do you see instead?
I get an error message:
Exception in thread "main" java.lang.RuntimeException: Less than three 
points
    at 
com.google.code.osmandroidconverter.main.Polygon.polygonClockwise
(Polygon.java:219)
    at com.google.code.osmandroidconverter.main.Polygon.<init>
(Polygon.java:14)
    at com.google.code.osmandroidconverter.mapdata.OsmElement.convert
(OsmElement.java:191)
    at com.google.code.osmandroidconverter.main.MapBuilder.buildTiles
(MapBuilder.java:85)
    at com.google.code.osmandroidconverter.main.OSMconverter.main
(OSMconverter.java:18)

What version of the product are you using? On what operating system?
Using svn-readonly-checkout from 27-11-2009 - 15:53
OSM-Dataset off the same day

Please provide any additional information below.
Exception should be caught in a more user-friendly way. For example by 
message-output and removing the polygon from the dataset.

I'll try to solve this myself and send a patch

Original issue reported on code.google.com by janrose....@googlemail.com on 27 Nov 2009 at 2:56

GoogleCodeExporter commented 9 years ago
I had similar problem with my dataset. I think it's reasonable to just to skip 
the offending elements. Patch is here:

Index: src/com/google/code/osmandroidconverter/main/MapBuilder.java
===================================================================
--- src/com/google/code/osmandroidconverter/main/MapBuilder.java    (revision 37)
+++ src/com/google/code/osmandroidconverter/main/MapBuilder.java    (working copy)
@@ -6,6 +6,8 @@
 import java.io.FileOutputStream;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -76,6 +78,7 @@

        for (OsmElement element : this.osmElements) {

+           try {
            // skip place elements represented by an area
            if (element.getType().indexOf("place") >= 0 && element.getNumNodes() != 1) {

@@ -103,6 +106,9 @@
                t.addItem(item);        
                tileMap.put(tileName, t);
            }
+           } catch (Exception e) {
+               logger.info("Element skipped. id:"+element.id+" reason:"+e.getMessage());
+           }

        }
    }

Original comment by tibor.arpas on 15 Sep 2010 at 4:06