ShapefileDataStore extends ContentDataStore implements FileDataStore { public ContentFeatureSource getFeatureSource() throws IOException { ContentEntry entry = ensureEntry(getTypeName()); if (shpFiles.isWritable()) { return new ShapefileFeatureStore(entry, shpFiles); } else { return new ShapefileFeatureSource(entry, shpFiles); } } ShapefileDataStore(URL url); ContentFeatureSource getFeatureSource(); Charset getCharset(); void setCharset(Charset charset); TimeZone getTimeZone(); void setTimeZone(TimeZone timeZone); boolean isMemoryMapped(); void setMemoryMapped(boolean memoryMapped); boolean isBufferCachingEnabled(); void setBufferCachingEnabled(boolean bufferCachingEnabled); boolean isIndexed(); void setIndexed(boolean indexed); SimpleFeatureType getSchema(); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(); long getCount(Query query); void createSchema(SimpleFeatureType featureType); void forceSchemaCRS(CoordinateReferenceSystem crs); @Override void dispose(); boolean isFidIndexed(); void setFidIndexed(boolean fidIndexed); @Override String toString(); @Override void updateSchema(SimpleFeatureType featureType); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Filter filter,
            Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(
            Transaction transaction); boolean isIndexCreationEnabled(); void setIndexCreationEnabled(boolean indexCreationEnabled); static final String ORIGINAL_FIELD_NAME; static final String ORIGINAL_FIELD_DUPLICITY_COUNT; static final Charset DEFAULT_STRING_CHARSET; static final TimeZone DEFAULT_TIMEZONE; }
@Test public void testLinestringOnePoint() throws Exception { URL u = TestData.url(TestCaseSupport.class, "lsOnePoint/lsOnePoint.shp"); File f = DataUtilities.urlToFile(u); assertTrue(f.exists()); store = new ShapefileDataStore(u); SimpleFeatureSource fs = store.getFeatureSource(store.getTypeNames()[0]); SimpleFeatureCollection fc = fs.getFeatures(); assertEquals(3, fc.size()); int i = 418; SimpleFeatureIterator it = fc.features(); while (it.hasNext()) { SimpleFeature sf = it.next(); assertEquals("Activity" + i, sf.getAttribute("Name")); if (i == 419) { assertNotNull(sf.getDefaultGeometry()); assertTrue(sf.getDefaultGeometry() instanceof MultiLineString); MultiLineString mls = (MultiLineString) sf.getDefaultGeometry(); assertEquals(1, mls.getNumGeometries()); LineString ls = (LineString) mls.getGeometryN(0); assertEquals(2, ls.getNumPoints()); assertEquals(ls.getStartPoint(), ls.getEndPoint()); } i++; } it.close(); assertEquals(421, i); assertEquals(3, fc.toArray().length); }
@Test public void testFeatureStoreHints() throws Exception { File shpFile = copyShapefiles(STATE_POP); URL url = shpFile.toURI().toURL(); ShapefileDataStore ds = new ShapefileDataStore(url); ShapefileFeatureStore store = (ShapefileFeatureStore) ds.getFeatureSource("statepop"); assertEquals(store.getSupportedHints(), store.delegate.getSupportedHints()); }