Examples of ShapefileDataStore


Examples of org.geotools.data.shapefile.ShapefileDataStore

        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put("url", newFile.toURI().toURL());
        params.put("create spatial index", Boolean.TRUE);

        ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);

        /*
         * TYPE is used as a template to describe the file contents
         */
        newDataStore.createSchema(TYPE);
       
        // docs break transaction
        /*
         * Write the features to the shapefile
         */
        Transaction transaction = new DefaultTransaction("create");

        String typeName = newDataStore.getTypeNames()[0];
        SimpleFeatureSource featureSource = newDataStore.getFeatureSource(typeName);
        SimpleFeatureType SHAPE_TYPE = featureSource.getSchema();
        /*
         * The Shapefile format has a couple limitations:
         * - "the_geom" is always first, and used for the geometry attribute name
         * - "the_geom" must be of type Point, MultiPoint, MuiltiLineString, MultiPolygon
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

                  File testFile= DataUtilities.urlToFile(testPropertiesUrl);
                  if( !testFile.exists() ){
                      return false;
                  }
                   
                  ShapefileDataStore store = new ShapefileDataStore(sourceURL);
                  store.setTimeZone(Utils.UTC_TIME_ZONE);
                  tileIndexStore = store;
              }
  
                //
                // Now look for the properties file and try to parse relevant fields
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    private int numFeatures;

    @Before
    public void setUpFixQueryTest() throws Exception {
        URL url = backshp.toURI().toURL();
        ds = new ShapefileDataStore(url);
        numFeatures = 0;
        featureStore = (SimpleFeatureStore) ds.getFeatureSource();
        {
            SimpleFeatureIterator features = featureStore.getFeatures().features();
            try {
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    @Test
    public void testGenerate() throws Exception {
        ShpFiles shpFiles = new ShpFiles(backshp.toURI().toURL());
        FidIndexer.generate(shpFiles);

        ShapefileDataStore ds = new ShapefileDataStore(DataUtilities.fileToURL(backshp));

        SimpleFeatureSource fs = ds.getFeatureSource();
        int features = fs.getCount(Query.ALL);

        IndexedFidReader reader = new IndexedFidReader(shpFiles);

        try {
            assertEquals(features, reader.getCount());

            int i = 1;

            while (reader.hasNext()) {
                assertEquals(shpFiles.getTypeName() + "." + i, reader.next());
                assertEquals(shpFiles.getTypeName() + "." + i, i - 1, reader.currentSHXIndex());
                i++;
            }

            assertEquals(features, i - 1);
        } finally {
            reader.close();
            ds.dispose();
        }
    }
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

        }
    }

    @Test
    public void testCreateFeatureEntry() throws Exception {
        ShapefileDataStore shp = new ShapefileDataStore(setUpShapefile());

        FeatureEntry entry = new FeatureEntry();
        geopkg.add(entry, shp.getFeatureSource(), null);

        assertTableExists("bugsites");

        //check metadata contents
        assertFeatureEntry(entry);
       
        SimpleFeatureReader re = Features.simple(shp.getFeatureReader());
        SimpleFeatureReader ra = geopkg.reader(entry, null, null);

        while(re.hasNext()) {
            assertTrue(ra.hasNext());
            assertSimilar(re.next(), ra.next());
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    }

    private static MapContext loadShapefile( final URL shape, final Style style )
            throws IOException
    {
        final ShapefileDataStore shapefileDataStore = new ShapefileDataStore( shape );

        final FeatureSource featureSource = shapefileDataStore.getFeatureSource();

        CoordinateReferenceSystem crs = featureSource.getSchema().getDefaultGeometry().getCoordinateSystem();
        if ( crs == null )
        {
            crs = DefaultGeographicCRS.WGS84;
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    }


    public MapContext load( URL shape, URL sld ) throws Exception
    {
        ShapefileDataStore ds = new ShapefileDataStore( shape );

        FeatureSource fs = ds.getFeatureSource();
        com.vividsolutions.jts.geom.Envelope env = fs.getBounds();
        myMapPane.setMapArea( env );
        StyleFactory factory = CommonFactoryFinder.getStyleFactory( null );

        SLDParser stylereader = new SLDParser( factory, sld );
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

    }

    private MapContext createContextFromShapefile( final URL shape, final URL sld )
            throws IOException
    {
        ShapefileDataStore ds = new ShapefileDataStore( shape );

        FeatureSource fs = ds.getFeatureSource();
        com.vividsolutions.jts.geom.Envelope env = fs.getBounds();
        myMapPane.setMapArea( env );
        StyleFactory factory = CommonFactoryFinder.getStyleFactory( null );

        SLDParser stylereader = new SLDParser( factory, sld );
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

        System.out.println("OGR: " + (end - start) / 1000.0);
    }
   
    public void testShapefilePerformance() throws Exception {
        URL url = TestData.url(STATE_POP);
        ShapefileDataStore sds = new ShapefileDataStore(url, false);
        long start = System.currentTimeMillis();
        sds.getSchema();
        long end = System.currentTimeMillis();
        System.out.println("SDS schema: " + (end - start) / 1000.0);

        DefaultQuery query = new DefaultQuery(sds.getTypeNames()[0]);
        start = System.currentTimeMillis();
        FeatureReader sfr = sds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        while (sfr.hasNext())
            sfr.next();
        sfr.close();
        end = System.currentTimeMillis();
        System.out.println("SDS: " + (end - start) / 1000.0);

        System.out.println("Attribute count: " + sds.getSchema().getAttributeCount());
        System.out.println("Feature count: "
                + sds.getFeatureSource(sds.getSchema().getTypeName()).getCount(Query.ALL));
    }
View Full Code Here

Examples of org.geotools.data.shapefile.ShapefileDataStore

     *
     * @throws Exception
     */
    public void testOptimizedEnvelope() throws Exception {
        URL url = TestData.url(STATE_POP);
        ShapefileDataStore sds = new ShapefileDataStore(url);
        OGRDataStore s = new OGRDataStore(getAbsolutePath(STATE_POP), null, null);
        String typeName = s.getTypeNames()[0];

        ReferencedEnvelope expectedBounds = sds.getFeatureSource().getBounds();
        ReferencedEnvelope actualBounds = s.getFeatureSource(typeName).getBounds();
        assertEquals(expectedBounds, actualBounds);
        assertNotNull(actualBounds);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.