@Test public void testReadToPolygonRDD() throws Exception { String inputLocation = getShapeFilePath("polygon"); FeatureCollection<SimpleFeatureType, SimpleFeature> collection = loadFeatures(inputLocation); FeatureIterator<SimpleFeature> features = collection.features(); ArrayList<String> featureTexts = new ArrayList<String>(); while (features.hasNext()) { SimpleFeature feature = features.next(); Object geometry = feature.getDefaultGeometry(); if (geometry instanceof MultiPolygon) { MultiPolygon multiPolygon = (MultiPolygon) geometry; if (multiPolygon.getNumGeometries() == 1) { geometry = multiPolygon.getGeometryN(0); } } featureTexts.add(String.valueOf(geometry)); } features.close(); final Iterator<String> featureIterator = featureTexts.iterator(); PolygonRDD spatialRDD = ShapefileReader.readToPolygonRDD(sc, inputLocation); SpatialRDD<Geometry> geomeryRDD = ShapefileReader.readToGeometryRDD(sc, inputLocation); long count = RangeQuery.SpatialRangeQuery(spatialRDD, new Envelope(-180, 180, -90, 90), false, false).count(); assertEquals(spatialRDD.rawSpatialRDD.count(), count); for (Geometry geometry : geomeryRDD.rawSpatialRDD.collect()) { assertEquals(featureIterator.next(), geometry.toText()); } }
public void close() throws IOException { shpInputStream.close(); }
ShapeFileReader extends RecordReader<ShapeKey, ShpRecord> { public void close() throws IOException { shpInputStream.close(); } }
ShapeFileReader extends RecordReader<ShapeKey, ShpRecord> { public void close() throws IOException { shpInputStream.close(); } ShapeFileReader();  ShapeFileReader(int[] indexes); }
ShapeFileReader extends RecordReader<ShapeKey, ShpRecord> { public void close() throws IOException { shpInputStream.close(); } ShapeFileReader();  ShapeFileReader(int[] indexes); void initialize(InputSplit split, TaskAttemptContext context); boolean nextKeyValue(); ShapeKey getCurrentKey(); ShpRecord getCurrentValue(); float getProgress(); void close(); }
ShapeFileReader extends RecordReader<ShapeKey, ShpRecord> { public void close() throws IOException { shpInputStream.close(); } ShapeFileReader();  ShapeFileReader(int[] indexes); void initialize(InputSplit split, TaskAttemptContext context); boolean nextKeyValue(); ShapeKey getCurrentKey(); ShpRecord getCurrentValue(); float getProgress(); void close();  }