Package org.geotools.data.memory

Examples of org.geotools.data.memory.MemoryDataStore


                    }
                }
            }
            if (service == null)
                return;
            MemoryDataStore ds = service.resolve(MemoryDataStore.class, new NullProgressMonitor());
            if (Arrays.asList(ds.getTypeNames()).contains(typeName)) {
                CatalogPlugin.getDefault().getLocalCatalog().remove(service);
            }
        } catch (IOException e) {
            CatalogPlugin.log("Error finding services", e); //$NON-NLS-1$
        }
View Full Code Here


                id = (URL) params.get(KEY);
            }
            if (!impl.containsKey(id))
                impl.put(id, new MemoryServiceImpl(id, this.factory));
            MemoryServiceImpl service = impl.get(id);
            MemoryDataStore store = null;
           
            try {
                store = service.resolve(MemoryDataStore.class, null);
            } catch (IOException e) {
                // won't happen
                throw (RuntimeException) new RuntimeException(e.getLocalizedMessage())
                        .initCause(e);
            }
            for( Map.Entry<String, Serializable> entry : params.entrySet() ) {
                if (entry.getKey().equals(MEMBER_PARAM)) {
                    String[] members = ((String) entry.getValue()).split("_MEMBER_"); //$NON-NLS-1$
                    for( String member : members ) {

                        String[] spec = (member.split("_SPLIT_")); //$NON-NLS-1$
                        try {
                            store.getSchema(spec[0]);
                        } catch (Exception e) {
                            // schema does not exist create it
                            try {
                                store.createSchema(DataUtilities.createType(spec[0], spec[1]));
                            } catch (Exception e2) {
                                CatalogPlugin.log("Error creating type in datastore", e2); //$NON-NLS-1$
                            }
                        }
                    }
View Full Code Here

    public IGeoResource createResource( Object param ) throws IOException {
        SimpleFeatureType featureType = (SimpleFeatureType) param;

        IService service = getMemoryService();

        MemoryDataStore ds = service.resolve(MemoryDataStore.class, new NullProgressMonitor());
        List<String> typeNamesList = Arrays.asList(ds.getTypeNames());
        String localPart = featureType.getName().getLocalPart();
        if (typeNamesList.contains(localPart)) {
            try {
                ds.updateSchema(localPart, featureType);
            } catch (Exception e) {
                // some datastores do not support schema update, try a name change
                // create the feature type
                String name = checkSameName(typeNamesList, localPart);
                SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
                b.setName(name);
                b.setCRS(featureType.getCoordinateReferenceSystem());
                List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
                b.addAll(attributeDescriptors);
                featureType = b.buildFeatureType();
                ds.createSchema(featureType);
            }
        } else {
            ds.createSchema(featureType);
        }

        IGeoResource resource = null;
        for( IResolve resolve : service.resources(new NullProgressMonitor()) ) {
            if (resolve instanceof IGeoResource) {
View Full Code Here

                            s.removeFeatures(Filter.INCLUDE);
                    }
                }
        }
       
        MemoryDataStore ds=service.resolve(MemoryDataStore.class, null);
        try{
          ds.getSchema(features[0].getFeatureType().getTypeName());
    //      if( deleteService)
    //        throw new IOException("SimpleFeatureType already exists in Service"); //$NON-NLS-1$
        }catch( SchemaNotFoundException exception){
          // verified that schema does not yet exist.
        }
        ds.addFeatures(features);
        return service;
      }
View Full Code Here

        dataStoreInfo = new DataStoreInfoImpl(catalog);
        dataStoreInfo.setName("mockDataStore");
        dataStoreInfo.setEnabled(true);
        dataStoreInfo.setWorkspace(workspaceInfo);

        dataStore = new MemoryDataStore();
        ResourcePool resourcePool = new ResourcePool(catalog) {
            @Override
            public DataStore getDataStore(DataStoreInfo info) throws IOException {
                return dataStore;
            }
View Full Code Here

        SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[] { point }, null);
        SimpleFeature f2 = SimpleFeatureBuilder.build(type, new Object[] { line }, null);
        SimpleFeature f3 = SimpleFeatureBuilder.build(type, new Object[] { polygon }, null);

        MemoryDataStore ds = new MemoryDataStore();
        ds.createSchema(type);
        ds.addFeatures(new SimpleFeature[] { f1, f2, f3 });

        FeatureSource fs = ds.getFeatureSource("test");

        final WMSMapContext map = new WMSMapContext();
        map.setAreaOfInterest(new ReferencedEnvelope(-250, 250, -250, 250, null));
        map.setMapWidth(300);
        map.setMapHeight(300);
View Full Code Here

        tb.setName("latlon");
        tb.add("the_geom", LineString.class, CRS.decode("EPSG:4326", true));
        tb.add("level", Integer.class);

        SimpleFeatureType type = tb.buildFeatureType();
        MemoryDataStore ds = new MemoryDataStore();

        ds.createSchema(type);

        FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
        writer = ds.getFeatureWriterAppend("latlon", Transaction.AUTO_COMMIT);

        for (int lon = -180; lon < 180; lon += 5) {
            for (int lat = -90; lat < 90; lat += 5) {
                LineString geom;
                int level;
View Full Code Here

            DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore();
            ilReader = inlineFeatureDatastore.getFeatureReader(q, Transaction.AUTO_COMMIT);
            CoordinateReferenceSystem crs = (getMapRequest.getCrs() == null) ? DefaultGeographicCRS.WGS84
                    : getMapRequest.getCrs();
            String typeName = inlineFeatureDatastore.getTypeNames()[0];
            MemoryDataStore reTypedDS = new MemoryDataStore(new ForceCoordinateSystemFeatureReader(
                    ilReader, crs));
            featureSource = reTypedDS.getFeatureSource(typeName);
        }else{
            DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore();
            String typeName = inlineFeatureDatastore.getTypeNames()[0];
            featureSource = inlineFeatureDatastore.getFeatureSource(typeName);
        }
View Full Code Here

            Query q = new DefaultQuery(currFt.getTypeName(), Filter.INCLUDE);
            FeatureReader<SimpleFeatureType, SimpleFeature> ilReader;
            ilReader = inlineDatastore.getFeatureReader(q, Transaction.AUTO_COMMIT);
            ForceCoordinateSystemFeatureReader reader = new ForceCoordinateSystemFeatureReader(
                    ilReader, requestCrs);
            MemoryDataStore reTypedDS = new MemoryDataStore(reader);
            source = reTypedDS.getFeatureSource(reTypedDS.getTypeNames()[0]);
        }else{
            source = inlineDatastore.getFeatureSource(inlineDatastore.getTypeNames()[0]);
        }

        MapLayerInfo mapLayer = new MapLayerInfo(source);
View Full Code Here

       
        GeometryFactory gf = new GeometryFactory();
        SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[]{gf.createPoint(new Coordinate(5, 8)), "A label with \"quotes\""}, null);
        SimpleFeature f2 = SimpleFeatureBuilder.build(type, new Object[]{gf.createPoint(new Coordinate(5, 4)), "A long label\nwith newlines"}, null);
       
        MemoryDataStore data = new MemoryDataStore();
        data.addFeature(f1);
        data.addFeature(f2);
        FeatureSource<SimpleFeatureType, SimpleFeature> fs = data.getFeatureSource("funnyLabels");
       
        // build the request objects and feed the output format
        GetFeatureType gft = WfsFactory.eINSTANCE.createGetFeatureType();
        Operation op = new Operation("GetFeature", getServiceDescriptor10(), null, new Object[] {gft});
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.geotools.data.memory.MemoryDataStore

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.