Changeset 29008 in osm for applications


Ignore:
Timestamp:
2012-11-29T01:25:24+01:00 (12 years ago)
Author:
donvip
Message:

[josm_opendata] see #josm8007 - ignore Colombus CSV files

File:
1 edited

Legend:

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

    r28000 r29008  
    1616package org.openstreetmap.josm.plugins.opendata.core.io.tabular;
    1717
     18import java.io.BufferedReader;
     19import java.io.File;
     20import java.io.FileReader;
    1821import java.io.IOException;
    1922import java.io.InputStream;
     
    2528
    2629public class CsvImporter extends AbstractImporter {
     30   
     31    public static final String COLOMBUS_HEADER = "INDEX,TAG,DATE,TIME,LATITUDE N/S,LONGITUDE E/W,HEIGHT,SPEED,HEADING,FIX MODE,VALID,PDOP,HDOP,VDOP,VOX";
    2732       
    2833    public CsvImporter() {
     
    3944                }
    4045        }
     46
     47    @Override
     48    public boolean acceptFile(File pathname) {
     49        return super.acceptFile(pathname) && !isColombusCsv(pathname);
     50    }
     51
     52    public static boolean isColombusCsv(File file) {
     53        boolean result = false;
     54        if (file != null && file.isFile()) {
     55            try {
     56                BufferedReader reader = new BufferedReader(new FileReader(file));
     57                try {
     58                    String line = reader.readLine();
     59                    result = line != null && line.equalsIgnoreCase(COLOMBUS_HEADER);
     60                } finally {
     61                    reader.close();
     62                }
     63            } catch (IOException e) {
     64                // Ignore exceptions
     65            }
     66        }
     67        return result;
     68    }
    4169}
Note: See TracChangeset for help on using the changeset viewer.