Package org.geotools.data

Examples of org.geotools.data.DataStore


                    } catch (IOException e1) {
                        return;
                    }
                } else if (layer instanceof DataStore || layer instanceof UDIGFeatureStore) {
                    try {
                        DataStore store = ((DataStore) layer);
                        FeatureSource featureStore = store.getFeatureSource(store.getTypeNames()[0]);
                        Envelope envelope = featureStore.getBounds();

                        ActiveRegionStyle style = getActiveRegionStyle();
                        JGrassRegion activeWindow = new JGrassRegion(style.west, style.east, style.south, style.north,
                                style.rows, style.cols);
View Full Code Here


    protected String doOtherChecks( Map<String, Serializable> params ) {
        ShapefileDataStoreFactory factory = getSHPDSFactory();
        if( !factory.canProcess(params) ) {
            // this is tough we don't have a good error message out of the geotools factory canProcess method
            // So we will try (and fail!) to connect ...
            DataStore datastore = null;
            try {
                datastore = factory.createDataStore(params);
            }
            catch (Throwable t){
                return t.getLocalizedMessage(); // We cannot connect because of this ...
            }
            finally {
                if( datastore != null){
                    datastore.dispose();
                }
            }
        }
        return null; // apparently we can connect
    }
View Full Code Here

    IGeoResource resource = existingLayer.findGeoResource(FeatureSource.class);
    if (resource != null) {
      FeatureSource<SimpleFeatureType, SimpleFeature> source = resource.resolve(FeatureSource.class,
            new NullProgressMonitor());
      DataStore ds = (DataStore) source.getDataStore();
      String[] dsTypes = ds.getTypeNames();
      Set<String> typeNames = new HashSet<String>(Arrays.asList(dsTypes));
      int matches = 1;
      while (typeNames.contains(newLayerName)) {
        matches++;
        newLayerName = name + matches;
View Full Code Here

        FeatureStore<SimpleFeatureType, SimpleFeature> fs = createMock(FeatureStore.class);
        expect(fs.addFeatures(isA(FeatureCollection.class))).andReturn(
                Collections.singletonList((FeatureId)(new FeatureIdImpl("trees.105"))));
        replay(fs);

        DataStore ds = createMock(DataStore.class);
        expect(ds.getTypeNames()).andReturn(new String[] { "trees" }).anyTimes();
        expect(ds.getSchema("trees")).andReturn(type).anyTimes();
        expect(ds.getFeatureSource("trees")).andReturn(fs);
        replay(ds);

        RetypingDataStore rts = new RetypingDataStore(ds) {
            @Override
            protected String transformFeatureTypeName(String originalName) {
View Full Code Here

                    URL url = new URL(WFS_SERVER_URL + "service=WFS&request=GetCapabilities");
                    params.put(WFSDataStoreFactory.URL.key, url);
                    params.put(WFSDataStoreFactory.TRY_GZIP.key, Boolean.TRUE);
                    //give it five seconds to respond...
                    params.put(WFSDataStoreFactory.TIMEOUT.key, Integer.valueOf(5000));
                    DataStore remoteStore = factory.createDataStore(params);
                    FeatureSource fs = remoteStore.getFeatureSource(TOPP_STATES);
                    remoteStatesAvailable = Boolean.TRUE;
                    // check a basic response can be answered correctly
                    DefaultQuery dq = new DefaultQuery(TOPP_STATES);
                    FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
                    dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000)));
View Full Code Here

        testCreateDataStore();
       
        DataStoreInfo dsinfo = catalog.getDataStoreByName( "gs", "acme");
        assertNull( catalog.getFeatureTypeByDataStore(dsinfo, "widgetsNG"));
       
        DataStore ds = (DataStore) dsinfo.getDataStore(null);
        try {
            if ( ds.getSchema("widgetsNG") != null ) {
                return;
            }
        }
        catch( Exception e ) {}
       
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.setName( "widgetsNG" );
        tb.add( "name", String.class );
       
        ds.createSchema( tb.buildFeatureType() );
       
        FeatureWriter fw = ds.getFeatureWriterAppend( "widgetsNG", Transaction.AUTO_COMMIT );
        fw.hasNext();
        SimpleFeature sf = (SimpleFeature) fw.next();
        sf.setAttribute( "name", "one");
        fw.write();
       
View Full Code Here

        this.mapProducer.produceMap();
        assertTestResult("PolygonWithSkippedHoles", this.mapProducer);
  }
 
  public void testMapProduceReproject() throws Exception {
    final DataStore ds = getProjectedTestDataStore();
        final FeatureSource<SimpleFeatureType,SimpleFeature> fs = ds.getFeatureSource("ProjectedPolygon");
        final ReferencedEnvelope env = new ReferencedEnvelope(fs.getBounds(),CRS.decode("EPSG:3004"));
       
        LOGGER.info("about to create map ctx for ProjectedPolygon with bounds " + env);

        final WMSMapContext map = new WMSMapContext();
View Full Code Here

        assertTrue( response.getHeader("Location").endsWith( "/workspaces/sf/datastores/newDataStore" ) );

        DataStoreInfo newDataStore = catalog.getDataStoreByName( "newDataStore" );
        assertNotNull( newDataStore );
       
        DataStore ds = (DataStore) newDataStore.getDataStore(null);
        assertNotNull(ds);
    }
View Full Code Here

        assertTrue( response.getHeader("Location").endsWith( "/workspaces/sf/datastores/newDataStore" ) );
       
        DataStoreInfo newDataStore = catalog.getDataStoreByName( "newDataStore" );
        assertNotNull( newDataStore );
       
        DataStore ds = (DataStore) newDataStore.getDataStore(null);
        assertNotNull(ds);
    }
View Full Code Here

        @Override
        protected void onValidate(IValidatable validatable) {
            String directory = (String) validatable.getValue();
           
            DataStore store = null;
            Map<String, Serializable> params = new HashMap<String, Serializable>();
            try {
                // check the store can be built (we need to provide the namespace as well
                params.put(DirectoryDataStoreFactory.URLP.key, new File(directory).toURI().toURL());
                params.put(DirectoryDataStoreFactory.NAMESPACE.key, new URI("http://www.geoserver.org"));
                store = DataStoreFinder.getDataStore(params);
                if (store == null) {
                    error(validatable, "ImportPage.invalidPath");
                } else if (store.getTypeNames().length == 0) {
                    error(validatable, "ImportPage.noData");
                }
            } catch(Exception e) {
                error(validatable, "ImportPage.noData");
            }
View Full Code Here

TOP

Related Classes of org.geotools.data.DataStore

Copyright © 2018 www.massapicom. 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.