Ignore:
Timestamp:
2013-04-14T15:54:06+02:00 (11 years ago)
Author:
donvip
Message:

[josm_opendata] Add Toulouse car_sharing dataset

Location:
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/OdConstants.java

    r29299 r29493  
    6060        public static final String PREF_MAXDISTANCE = "opendata.maxdistance";
    6161    public static final double DEFAULT_MAXDISTANCE = 10;
     62
     63    public static final String PREF_TOLERANCE = "opendata.spreadsheet.tolerance";
     64    public static final double DEFAULT_TOLERANCE = 0.1;
    6265
    6366    public static final String PREF_MODULES = "opendata.modules";
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java

    r29299 r29493  
    7272       
    7373        public static class CoordinateColumns {
     74        public Projection proj = null;
    7475                public int xCol = -1;
    7576                public int yCol = -1;
     
    7778                        return xCol > -1 && yCol > -1;
    7879                }
    79         @Override
    80         public String toString() {
    81             return "[xCol=" + xCol + ", yCol=" + yCol + "]";
     80        @Override public String toString() {
     81            return "CoordinateColumns [proj=" + proj + ", xCol=" + xCol + ", yCol=" + yCol + "]";
    8282        }
    8383        }
     
    112112                }
    113113
    114                 Projection proj = null;
    115114                final List<CoordinateColumns> columns = new ArrayList<CoordinateColumns>();
    116115               
     
    119118                    if (col.isOk()) {
    120119                    columns.add(col);
    121                         if (proj == null) {
    122                             proj = pp.getProjection(header[col.xCol], header[col.yCol]);
     120                        if (col.proj == null) {
     121                            col.proj = pp.getProjection(header[col.xCol], header[col.yCol]);
    123122                        }
    124123                    }
     
    128127                final boolean handlerOK = handler != null && handler.handlesProjection();
    129128
    130                 if (proj != null) {
     129                boolean projFound = false;
     130               
     131                for (CoordinateColumns c : columns) {
     132                    if (c.proj != null) {
     133                        projFound = true;
     134                        break;
     135                    }
     136                }
     137               
     138                if (projFound) {
    131139                        // projection identified, do nothing
    132140                } else if (!columns.isEmpty()) {
     
    137145                                        return null; // User clicked Cancel
    138146                                }
    139                                 proj = dialog.getProjection();
     147                                Projection proj = dialog.getProjection();
     148                        for (CoordinateColumns c : columns) {
     149                            c.proj = proj;
     150                        }
    140151                        }
    141152                       
     
    149160                        message += "; ";
    150161                    }
    151                     message += header[c.xCol]+", "+header[c.yCol];
    152                 }
    153                
    154                 System.out.println("Loading data using projection "+proj+" ("+message+")");
     162                    message += c.proj + "("+header[c.xCol]+", "+header[c.yCol]+")";
     163                }
     164               
     165                System.out.println("Loading data using projections "+message);
    155166               
    156167                final DataSet ds = new DataSet();
     
    204215                                }
    205216                        }
     217                        Node firstNode = null;
    206218                        for (CoordinateColumns c : columns) {
    207219                            Node n = nodes.get(c);
    208220                            EastNorth en = ens.get(c);
    209221                        if (en.isValid()) {
    210                                 n.setCoor(proj != null && !handlerOK ? proj.eastNorth2latlon(en) : handler.getCoor(en, fields));
     222                                n.setCoor(c.proj != null && !handlerOK ? c.proj.eastNorth2latlon(en) : handler.getCoor(en, fields));
    211223                        } else {
    212224                                System.err.println("Warning: Skipping line "+lineNumber+" because no valid coordinates have been found at columns "+c);
    213225                        }
    214226                        if (n.getCoor() != null) {
    215                                 ds.addPrimitive(n);
     227                            if (firstNode == null) {
     228                                firstNode = n;
     229                            }
     230                            if (n == firstNode || n.getCoor().greatCircleDistance(firstNode.getCoor()) > Main.pref.getDouble(PREF_TOLERANCE, DEFAULT_TOLERANCE)) {
     231                                ds.addPrimitive(n);
     232                            } else {
     233                                nodes.remove(c);
     234                            }
    216235                        }
    217236                        }
Note: See TracChangeset for help on using the changeset viewer.