Package org.geotools.data.memory

Examples of org.geotools.data.memory.MemoryDataStore


    public void testExportFromTreeWithSeveralFeatureTypesUsingNonexistantTypeId() throws Exception {
        Feature[] points = new Feature[] { points2, points1B, points3 };
        for (Feature feature : points) {
            insert(feature);
        }
        MemoryDataStore dataStore = new MemoryDataStore(pointsType);
        final String typeName = dataStore.getTypeNames()[0];
        SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
        SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        try {
            geogig.command(ExportOp.class).setFeatureStore(featureStore).setPath(pointsName)
                    .setFilterFeatureTypeId(ObjectId.forString("fake")).call();
            fail();
View Full Code Here


    public void testExportFromTreeWithSeveralFeatureTypes() throws Exception {
        Feature[] points = new Feature[] { points2, points1B, points3 };
        for (Feature feature : points) {
            insert(feature);
        }
        MemoryDataStore dataStore = new MemoryDataStore(pointsType);
        final String typeName = dataStore.getTypeNames()[0];
        SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
        SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        try {
            geogig.command(ExportOp.class).setFeatureStore(featureStore).setPath(pointsName).call();
            fail();
        } catch (GeoToolsOpException e) {
View Full Code Here

    public void testInsertNonPagingFeatureSource() throws Exception {
        assertEquals(2, super.getGeogig().getPlatform().availableProcessors());

        final List<SimpleFeature> features = ImmutableList.of((SimpleFeature) points1,
                (SimpleFeature) points2, (SimpleFeature) points3);
        MemoryDataStore store = new MemoryDataStore();
        store.addFeatures(features);

        final QueryCapabilities caps = mock(QueryCapabilities.class);
        when(caps.isOffsetSupported()).thenReturn(true);

        @SuppressWarnings("rawtypes")
        FeatureSource source = store.getFeatureSource(pointsName);
        assertFalse(source.getQueryCapabilities().isOffsetSupported());

        String treePath = "target_typename";
        workTree.insert(treePath, source, Query.ALL, LISTENER);
View Full Code Here

    public void testInsertPagingFeatureSource() throws Exception {
        assertEquals(2, super.getGeogig().getPlatform().availableProcessors());

        final List<SimpleFeature> features = ImmutableList.of((SimpleFeature) points1,
                (SimpleFeature) points2, (SimpleFeature) points3);
        MemoryDataStore store = new MemoryDataStore();
        store.addFeatures(features);

        final QueryCapabilities caps = mock(QueryCapabilities.class);
        when(caps.isOffsetSupported()).thenReturn(true);

        FeatureSource source = new ForwardingFeatureSource(store.getFeatureSource(pointsName)) {
            @Override
            public QueryCapabilities getQueryCapabilities() {
                return caps;
            }
View Full Code Here

        SimpleFeature f7 = SimpleFeatureBuilder.build(typeGeoJson,
                new Object[] { 4.2, 1200, gf.createPoint(new Coordinate(0, 8)) }, "feature1");
        SimpleFeature f8 = SimpleFeatureBuilder.build(typeGeoJson2,
                new Object[] { 4.2, 1200, gf.createPoint(new Coordinate(0, 9)) }, "feature1");

        MemoryDataStore testDataStore = new MemoryDataStore();
        testDataStore.addFeature(f1);
        testDataStore.addFeature(f2);
        testDataStore.addFeature(f3);
        testDataStore.addFeature(f4);
        testDataStore.addFeature(f5);
        testDataStore.addFeature(f6);
        testDataStore.addFeature(f7);
        testDataStore.addFeature(f8);
        testDataStore.createSchema(builder4.buildFeatureType());

        final AbstractDataStoreFactory factory = mock(AbstractDataStoreFactory.class);
        when(factory.createDataStore(anyMapOf(String.class, Serializable.class))).thenReturn(
                testDataStore);
        when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true);
View Full Code Here

        return factory;
    }

    public static AbstractDataStoreFactory createEmptyTestFactory() throws Exception {

        MemoryDataStore testDataStore = new MemoryDataStore();

        final AbstractDataStoreFactory factory = mock(AbstractDataStoreFactory.class);
        when(factory.createDataStore(anyMapOf(String.class, Serializable.class))).thenReturn(
                testDataStore);
        when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true);
View Full Code Here

        return factory;
    }

    public static AbstractDataStoreFactory createFactoryWithGetNamesException() throws Exception {

        MemoryDataStore testDataStore = mock(MemoryDataStore.class);
        when(testDataStore.getNames()).thenThrow(new IOException());
        when(testDataStore.getTypeNames()).thenThrow(new RuntimeException());
        when(testDataStore.getSchema(anyString())).thenThrow(new IOException());

        final AbstractDataStoreFactory factory = mock(AbstractDataStoreFactory.class);
        when(factory.createDataStore(anyMapOf(String.class, Serializable.class))).thenReturn(
                testDataStore);
        when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true);
View Full Code Here

        SimpleFeature f2 = SimpleFeatureBuilder.build(type,
                new Object[] { gf.createPoint(new Coordinate(5, 4)), "feature2" }, null);
        SimpleFeature f3 = SimpleFeatureBuilder.build(type2,
                new Object[] { gf.createPoint(new Coordinate(3, 2)), "feature3" }, null);

        MemoryDataStore testDataStore = new MemoryDataStore();
        testDataStore.addFeature(f1);
        testDataStore.addFeature(f2);
        testDataStore.addFeature(f3);

        MemoryDataStore spyDataStore = spy(testDataStore);

        when(spyDataStore.getFeatureSource("table1")).thenThrow(new IOException("Exception"));

        final AbstractDataStoreFactory factory = mock(AbstractDataStoreFactory.class);
        when(factory.createDataStore(anyMapOf(String.class, Serializable.class))).thenReturn(
                spyDataStore);
        when(factory.canProcess(anyMapOf(String.class, Serializable.class))).thenReturn(true);
View Full Code Here

            InputStream in = new FileInputStream(geoJsonfile);
            FeatureJSON fjson = new FeatureJSON();
            @SuppressWarnings("rawtypes")
            FeatureCollection fc = fjson.readFeatureCollection(in);
            @SuppressWarnings("unchecked")
            DataStore dataStore = new MemoryDataStore(fc);
            return dataStore;
        } catch (IOException ioe) {
            throw new CommandFailedException("Error opening GeoJSON: " + ioe.getMessage(), ioe);
        }
    }
View Full Code Here

            } catch (GeoToolsOpException e) {
                cli.getConsole().println("No features to export.");
                return;
            }
        }
        DataStore dataStore = new MemoryDataStore(outputFeatureType);

        final String typeName = dataStore.getTypeNames()[0];
        final SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
        if (!(featureSource instanceof SimpleFeatureStore)) {
            throw new CommandFailedException("Could not create feature store.");
        }
        final SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
        ExportOp op = cli.getGeogig().command(ExportOp.class).setFeatureStore(featureStore)
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.