Search in sources :

Example 1 with ChangeType

use of org.locationtech.geogig.geotools.data.GeoGigDataStore.ChangeType in project GeoGig by boundlessgeo.

the class GeogigFeatureSource method getNativeReader.

/**
     * @param propertyNames properties to retrieve, empty array for no properties at all
     *        {@link Query#NO_NAMES}, {@code null} means all properties {@link Query#ALL_NAMES}
     */
private FeatureReader<SimpleFeatureType, SimpleFeature> getNativeReader(@Nullable String[] propertyNames, Filter filter, @Nullable Integer offset, @Nullable Integer maxFeatures, @Nullable final ScreenMap screenMap) {
    if (screenMap == null) {
        LOGGER.trace("GeoGigFeatureSource.getNativeReader: no screenMap provided");
    } else {
        LOGGER.trace("GeoGigFeatureSource.getNativeReader: using screenMap filter");
    }
    LOGGER.trace("Query filter: {}", filter);
    filter = (Filter) filter.accept(new SimplifyingFilterVisitor(), null);
    LOGGER.trace("Simplified filter: {}", filter);
    GeogigFeatureReader<SimpleFeatureType, SimpleFeature> nativeReader;
    final String rootRef = getRootRef();
    final String featureTypeTreePath = getTypeTreePath();
    final SimpleFeatureType fullType = getSchema();
    boolean ignoreAttributes = false;
    if (propertyNames != null && propertyNames.length == 0) {
        String[] inProcessFilteringAttributes = Filters.attributeNames(filter, fullType);
        ignoreAttributes = inProcessFilteringAttributes.length == 0;
    }
    final String compareRootRef = oldRoot();
    final GeoGigDataStore.ChangeType changeType = changeType();
    final Context context = getCommandLocator();
    nativeReader = new GeogigFeatureReader<SimpleFeatureType, SimpleFeature>(context, fullType, filter, featureTypeTreePath, rootRef, compareRootRef, changeType, offset, maxFeatures, screenMap, ignoreAttributes);
    return nativeReader;
}
Also used : Context(org.locationtech.geogig.api.Context) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ChangeType(org.locationtech.geogig.geotools.data.GeoGigDataStore.ChangeType) SimplifyingFilterVisitor(org.geotools.filter.visitor.SimplifyingFilterVisitor) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 2 with ChangeType

use of org.locationtech.geogig.geotools.data.GeoGigDataStore.ChangeType in project GeoGig by boundlessgeo.

the class GeoGigDataStoreTest method testDiffFeatures.

private void testDiffFeatures(ObjectId oldRoot, ObjectId newRoot, int expectedAdded, int expectedRemoved, int expectedChanged) throws IOException {
    dataStore.setHead(newRoot.toString());
    List<String> fids;
    SimpleFeatureCollection features;
    ChangeType changeType = ChangeType.ADDED;
    features = dataStore.getDiffFeatureSource(pointsName, oldRoot.toString(), changeType).getFeatures();
    fids = toIdList(features);
    assertEquals(changeType + fids.toString(), expectedAdded, fids.size());
    assertEquals(changeType + fids.toString(), expectedAdded, features.size());
    changeType = ChangeType.REMOVED;
    features = dataStore.getDiffFeatureSource(pointsName, oldRoot.toString(), changeType).getFeatures();
    fids = toIdList(features);
    assertEquals(changeType + fids.toString(), expectedRemoved, fids.size());
    assertEquals(changeType + fids.toString(), expectedRemoved, features.size());
    changeType = ChangeType.CHANGED_NEW;
    features = dataStore.getDiffFeatureSource(pointsName, oldRoot.toString(), changeType).getFeatures();
    fids = toIdList(features);
    assertEquals(changeType + fids.toString(), expectedChanged, fids.size());
    assertEquals(changeType + fids.toString(), expectedChanged, features.size());
    changeType = ChangeType.CHANGED_OLD;
    features = dataStore.getDiffFeatureSource(pointsName, oldRoot.toString(), changeType).getFeatures();
    fids = toIdList(features);
    assertEquals(changeType + fids.toString(), expectedChanged, fids.size());
    assertEquals(changeType + fids.toString(), expectedChanged, features.size());
}
Also used : ChangeType(org.locationtech.geogig.geotools.data.GeoGigDataStore.ChangeType) LineString(com.vividsolutions.jts.geom.LineString) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection)

Aggregations

ChangeType (org.locationtech.geogig.geotools.data.GeoGigDataStore.ChangeType)2 LineString (com.vividsolutions.jts.geom.LineString)1 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)1 SimplifyingFilterVisitor (org.geotools.filter.visitor.SimplifyingFilterVisitor)1 Context (org.locationtech.geogig.api.Context)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1