Package org.geotools.data

Examples of org.geotools.data.DataStore


  @Before
  public void setUp() throws Exception {
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(SHAPE_FILE);
    DataStore dataStore = new ShapefileDataStore(url);
    featureModel = new ShapeInMemFeatureModel(dataStore, LAYER_NAME, 4326, converterService);
    featureModel.setLayerInfo(layerInfo);

    FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource();
    FeatureIterator<SimpleFeature> fi = fs.getFeatures().features();
View Full Code Here


  @Before
  public void init() throws Exception {
    ClassLoader classloader = Thread.currentThread().getContextClassLoader();
    URL url = classloader.getResource(SHAPE_FILE);
    DataStore dataStore = new ShapefileDataStore(url);
    featureModel = new GeoToolsFeatureModel(dataStore, LAYER_NAME, 4326, converterService);
    featureModel.setLayerInfo(layerInfo);

    FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource();
    FeatureIterator<SimpleFeature> fi = fs.getFeatures().features();
View Full Code Here

  public void setUrl(String url) throws LayerException {
    try {
      this.url = url;
      Map<String, String> params = new HashMap<String, String>();
      params.put("url", url);
      DataStore store = DataStoreFactory.create(params);
      if (store == null) {
        throw new LayerException(ExceptionCode.INVALID_SHAPE_FILE_URL, url);
      }
      setDataStore(store);
    } catch (IOException ioe) {
View Full Code Here

        if (null != parameters) {
          for (Parameter parameter : parameters) {
            params.put(parameter.getName(), parameter.getValue());
          }
        }
        DataStore store = DataStoreFactory.create(params);
        setDataStore(store);
      }
      if (null == super.getDataStore()) {
        return;
      }
View Full Code Here

  public static DataStore create(Map<String, String> parameters) throws IOException {
    String url = parameters.get("url");
    if (url != null) {
      parameters.put("url", ResourceUtils.getURL(url).toExternalForm());
    }
    DataStore store = DataStoreFinder.getDataStore(parameters);
    if (store instanceof PostgisDataStore) {
      PostgisDataStore jdbcStore = (PostgisDataStore) store;
      jdbcStore.setFIDMapperFactory(new NonTypedPostgisFidMapperFactory(false));
    } else if (store instanceof JDBCDataStore) {
      JDBCDataStore jdbcStore = (JDBCDataStore) store;
View Full Code Here

    class DB2GeoResourceInfo extends IGeoResourceInfo {

        private SimpleFeatureType ft = null;

        DB2GeoResourceInfo( IProgressMonitor monitor, String nameArg ) throws IOException {
            DataStore ds = parent.getDataStore(monitor);
            if (ds == null)
                return;

            try {
                this.ft = ds.getSchema(nameArg);
            } catch (DataSourceException e) {
                return;
            }

            try {
View Full Code Here

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

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

    }
    public DataStoreService service( IProgressMonitor monitor ) throws IOException {
        return (DataStoreService) this.service;
    };
    public SimpleFeatureSource toFeatureSource() throws IOException {
        DataStore dataStore = service(null).toDataAccess();
        return dataStore.getFeatureSource(name);
    }
View Full Code Here

            return;
        }
       
        ShapefileDataStoreFactory dsfac = new ShapefileDataStoreFactory();
        File tmp = File.createTempFile(layers[0].getName() + "_" + layers[1].getName() + "_diff", ".shp"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        DataStore ds = dsfac.createDataStore(tmp.toURL());
        final SimpleFeatureType newSchema = FeatureTypes.newFeatureType(
                fromLayer.getSchema().getAttributeDescriptors().toArray(
                        new AttributeDescriptor[0]), "diff"); //$NON-NLS-1$
        ds.createSchema(newSchema);
       
        final FeatureSource<SimpleFeatureType, SimpleFeature> fromSource = fromLayer.getResource(FeatureSource.class, monitor);
        final FeatureSource<SimpleFeatureType, SimpleFeature> diffSource = diffLayer.getResource(FeatureSource.class, monitor);
        if (isGeometryCollection(fromSource.getSchema().getGeometryDescriptor())) {
            MessageDialog.openError(display.getActiveShell(), Messages.differenceOp_inputError, fromLayer.getName() + Messages.differenceOp_multiGeoms);
            return;
        }
        if (isGeometryCollection(diffSource.getSchema().getGeometryDescriptor())) {
            MessageDialog.openError(display.getActiveShell(), Messages.differenceOp_inputError, fromLayer.getName() + Messages.differenceOp_multiGeoms);
            return;
        }
       
        final DefaultFeatureCollection diffFeatures = new DefaultFeatureCollection();
        diffFeatures.addAll(diffSource.getFeatures());
       
        FeatureStore<SimpleFeatureType, SimpleFeature> destStore = (FeatureStore<SimpleFeatureType, SimpleFeature>)ds.getFeatureSource("diff"); //$NON-NLS-1$
       
        // TODO: figure out whatever this FeatureReader is doing; and make it a feature collection instead
        destStore.addFeatures(DataUtilities.collection(new FeatureReader<SimpleFeatureType, SimpleFeature>(){
        // TODO this needs an undo
//        ((FeatureStore<SimpleFeatureType, SimpleFeature>)fromSource).setFeatures(new FeatureReader() {
View Full Code Here

        if (adaptee.isAssignableFrom(IGeoResourceInfo.class))
            return adaptee.cast(createInfo(monitor));

        if (adaptee.isAssignableFrom(SimpleFeatureSource.class)) {
            DataStore ds = parent.getDataStore(monitor);
            if (ds != null) {
                SimpleFeatureSource fs = ds.getFeatureSource(name);
                if (fs != null){
                    return adaptee.cast(fs);
                }
            }
        }
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.