コード例 #1
0
ファイル: SeadasFileReader.java プロジェクト: bcdev/seadas
 protected static HashMap<String, String> readTwoColumnTable(String resourceName) {
   final InputStream stream = SeadasProductReader.class.getResourceAsStream(resourceName);
   if (stream != null) {
     try {
       HashMap<String, String> validExpressionMap = new HashMap<String, String>(32);
       final CsvReader csvReader = new CsvReader(new InputStreamReader(stream), new char[] {';'});
       final List<String[]> table = csvReader.readStringRecords();
       for (String[] strings : table) {
         if (strings.length == 2) {
           validExpressionMap.put(strings[0], strings[1]);
         }
       }
       return validExpressionMap;
     } catch (IOException e) {
       // ?
     } finally {
       try {
         stream.close();
       } catch (IOException e) {
         // ok
       }
     }
   }
   return new HashMap<String, String>(0);
 }
コード例 #2
0
ファイル: ImportTrackAction.java プロジェクト: TonioF/beam
  static FeatureCollection<SimpleFeatureType, SimpleFeature> readTrack(
      Reader reader, GeoCoding geoCoding) throws IOException {
    CsvReader csvReader = new CsvReader(reader, new char[] {'\t', ' '}, true, "#");
    SimpleFeatureType trackFeatureType = createTrackFeatureType(geoCoding);
    FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection =
        new ListFeatureCollection(trackFeatureType);
    double[] record;
    int pointIndex = 0;
    while ((record = csvReader.readDoubleRecord()) != null) {
      if (record.length < 3) {
        throw new IOException(
            "Illegal track file format.\n"
                + "Expecting tab-separated lines containing 3 values: lat, lon, data.");
      }

      float lat = (float) record[0];
      float lon = (float) record[1];
      double data = record[2];

      final SimpleFeature feature =
          createFeature(trackFeatureType, geoCoding, pointIndex, lat, lon, data);
      if (feature != null) {
        featureCollection.add(feature);
      }

      pointIndex++;
    }

    if (featureCollection.isEmpty()) {
      throw new IOException(
          "No track point found or all of them are located outside the scene boundaries.");
    }

    return featureCollection;
  }