Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevFeatureType


        }

        private MathTransform getMathTransform(ObjectId mdid) {
            MathTransform transform = this.transformsByMetadataId.get(mdid);
            if (transform == null) {
                RevFeatureType revtype = source.getFeatureType(mdid);
                FeatureType type = revtype.type();
                CoordinateReferenceSystem sourceCrs = type.getCoordinateReferenceSystem();
                CoordinateReferenceSystem targetCrs = this.crs;
                if (sourceCrs == null) {
                    sourceCrs = targetCrs;
                }
View Full Code Here


                    }
                    RevFeature feature = (RevFeature) obj.get();
                    DepthSearch depthSearch = new DepthSearch(repository.objectDatabase());
                    Optional<NodeRef> noderef = depthSearch
                            .find(this.workingTree().getTree(), path);
                    RevFeatureType featureType = command(RevObjectParse.class)
                            .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class)
                            .get();
                    ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors();
                    FeatureDiff featureDiff = command(DiffFeature.class)
                            .setOldVersion(Suppliers.ofInstance(diff.getOldObject()))
                            .setNewVersion(Suppliers.ofInstance(diff.getNewObject())).call();
                    Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = featureDiff
                            .getDiffs().entrySet();
View Full Code Here

                                    // the resulting merged feature equals the feature to merge from
                                    // the branch, which means that it exists in the repo and there
                                    // is no need to add it
                                    report.addUnconflicted(toMergeDiff);
                                } else {
                                    RevFeatureType featureType = command(RevObjectParse.class)
                                            .setObjectId(
                                                    mergeIntoDiff.getNewObject().getMetadataId())
                                            .call(RevFeatureType.class).get();
                                    FeatureInfo merged = new FeatureInfo(mergedFeature,
                                            featureType, path);
View Full Code Here

    private String featureTypeDiffAsString(FeatureTypeDiff diff) {
        StringBuilder sb = new StringBuilder();
        sb.append(diff.toString() + "\n");
        if (!diff.getNewFeatureType().equals(ObjectId.NULL)
                && !diff.getOldFeatureType().equals(ObjectId.NULL)) {
            RevFeatureType oldFeatureType = getFeatureTypeFromId(diff.getOldFeatureType()).get();
            RevFeatureType newFeatureType = getFeatureTypeFromId(diff.getNewFeatureType()).get();
            ImmutableList<PropertyDescriptor> oldDescriptors = oldFeatureType.sortedDescriptors();
            ImmutableList<PropertyDescriptor> newDescriptors = newFeatureType.sortedDescriptors();
            BitSet updatedDescriptors = new BitSet(newDescriptors.size());
            for (int i = 0; i < oldDescriptors.size(); i++) {
                PropertyDescriptor oldDescriptor = oldDescriptors.get(i);
                int idx = newDescriptors.indexOf(oldDescriptor);
                if (idx != -1) {
View Full Code Here

                break;
            }
            RevFeature feature = (RevFeature) obj.get();
            DepthSearch depthSearch = new DepthSearch(stagingDatabase());
            Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(), path);
            RevFeatureType featureType = command(RevObjectParse.class)
                    .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get();
            ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors();
            Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = diff.getDiffs().entrySet();
            boolean ok = true;
            for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = attrDiffs.iterator(); iterator
                    .hasNext();) {
                Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next();
                AttributeDiff attrDiff = entry.getValue();
                PropertyDescriptor descriptor = entry.getKey();
                switch (attrDiff.getType()) {
                case ADDED:
                    if (descriptors.contains(descriptor)) {
                        ok = false;
                    }
                    break;
                case REMOVED:
                case MODIFIED:
                    if (!descriptors.contains(descriptor)) {
                        ok = false;
                        break;
                    }
                    for (int i = 0; i < descriptors.size(); i++) {
                        if (descriptors.get(i).equals(descriptor)) {
                            Optional<Object> value = feature.getValues().get(i);
                            if (!attrDiff.canBeAppliedOn(value)) {
                                ok = false;
                            }
                            break;
                        }
                    }
                }
            }
            if (!ok) {
                toReject.addModifiedFeature(diff);
            } else {
                toApply.addModifiedFeature(diff);
            }
        }
        List<FeatureInfo> added = patch.getAddedFeatures();
        for (FeatureInfo feature : added) {
            String refSpec = Ref.WORK_HEAD + ":" + feature.getPath();
            obj = command(RevObjectParse.class).setRefSpec(refSpec).call();
            if (obj.isPresent()) {
                toReject.addAddedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            } else {
                toApply.addAddedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            }

        }
        List<FeatureInfo> removed = patch.getRemovedFeatures();
        for (FeatureInfo feature : removed) {
            String refSpec = Ref.WORK_HEAD + ":" + feature.getPath();
            obj = command(RevObjectParse.class).setRefSpec(refSpec).call();
            if (!obj.isPresent()) {
                toReject.addRemovedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            } else {
                RevFeature revFeature = (RevFeature) obj.get();
                DepthSearch depthSearch = new DepthSearch(stagingDatabase());
                Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(),
                        feature.getPath());
                RevFeatureType revFeatureType = command(RevObjectParse.class)
                        .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class)
                        .get();
                RevFeature patchRevFeature = RevFeatureBuilder.build(feature.getFeature());
                if (revFeature.equals(patchRevFeature)
                        && revFeatureType.equals(feature.getFeatureType())) {
                    toApply.addRemovedFeature(feature.getPath(), feature.getFeature(),
                            feature.getFeatureType());
                } else {
                    toReject.addRemovedFeature(feature.getPath(), feature.getFeature(),
                            feature.getFeatureType());
View Full Code Here

        return projectedFilter;
    }

    private ReferencedEnvelope createProjectedFilter(ObjectId metadataId) {
        final ReferencedEnvelope boundsFilter = this.boundsFilter;
        RevFeatureType featureType = ftypeSource.getFeatureType(metadataId);
        CoordinateReferenceSystem nativeCrs = featureType.type().getCoordinateReferenceSystem();
        if (null == nativeCrs || nativeCrs instanceof DefaultEngineeringCRS) {
            return boundsFilter;
        }
        ReferencedEnvelope transformedFilter;
        try {
View Full Code Here

                String operation = headerTokens[0].trim();
                if (operation.equals("M")) {
                    String fullPath = headerTokens[1].trim();
                    String oldMetadataId = headerTokens[2].trim();
                    String newMetadataId = headerTokens[3].trim();
                    RevFeatureType newRevFeatureType = featureTypes.get(newMetadataId);
                    RevFeatureType oldRevFeatureType = featureTypes.get(oldMetadataId);

                    Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
                    for (int i = 1; i < lines.size(); i++) {
                        addDifference(lines.get(i), map, oldRevFeatureType, newRevFeatureType);
                    }
                    FeatureDiff featureDiff = new FeatureDiff(fullPath, map, oldRevFeatureType,
                            newRevFeatureType);
                    patch.addModifiedFeature(featureDiff);
                } else if (operation.equals("A") || operation.equals("R")) {
                    String fullPath = headerTokens[1].trim();
                    String featureTypeId = headerTokens[2].trim();
                    RevFeatureType revFeatureType;
                    revFeatureType = featureTypes.get(featureTypeId);
                    FeatureBuilder featureBuilder = new FeatureBuilder(revFeatureType);
                    ObjectReader<RevFeature> reader = factory.createFeatureReader();
                    RevFeature revFeature = reader.read(null, stream);
                    Feature feature = featureBuilder.build(NodeRef.nodeFromPath(fullPath),
                            revFeature);
                    if (operation.equals("R")) {
                        patch.addRemovedFeature(fullPath, feature, revFeatureType);
                    } else {
                        patch.addAddedFeature(fullPath, feature, revFeatureType);
                    }
                } else {
                    throw new IllegalArgumentException("Wrong patch content: " + lines.get(0));
                }
            }

        } else if (headerTokens.length == 1) {// feature type definition
            String element = Joiner.on("\n").join(lines);
            ByteArrayInputStream stream = new ByteArrayInputStream(element.getBytes(Charsets.UTF_8));
            String[] tokens = lines.get(1).split("\t");
            ObjectReader<RevFeatureType> reader = factory.createFeatureTypeReader();
            RevFeatureType featureType = reader.read(null, stream);
            featureTypes.put(featureType.getId().toString(), featureType);
        } else {
            throw new IllegalArgumentException("Wrong patch content: " + lines.get(0));
        }

    }
View Full Code Here

            if (conflictJson.isJsonObject()) {
                final JsonObject conflict = conflictJson.getAsJsonObject();
                String featureId = null;
                RevFeature ourFeature = null;
                RevFeatureType ourFeatureType = null;
                RevFeature theirFeature = null;
                RevFeatureType theirFeatureType = null;
                JsonObject merges = null;
                if (conflict.has("path") && conflict.get("path").isJsonPrimitive()) {
                    featureId = conflict.get("path").getAsJsonPrimitive().getAsString();
                }
                Preconditions.checkState(featureId != null);

                if (conflict.has("ours") && conflict.get("ours").isJsonPrimitive()) {
                    String ourCommit = conflict.get("ours").getAsJsonPrimitive().getAsString();
                    Optional<NodeRef> ourNode = parseID(ObjectId.valueOf(ourCommit), featureId,
                            ggit);
                    if (ourNode.isPresent()) {
                        Optional<RevObject> object = ggit.command(RevObjectParse.class)
                                .setObjectId(ourNode.get().objectId()).call();
                        Preconditions.checkState(object.isPresent()
                                && object.get() instanceof RevFeature);

                        ourFeature = (RevFeature) object.get();

                        object = ggit.command(RevObjectParse.class)
                                .setObjectId(ourNode.get().getMetadataId()).call();
                        Preconditions.checkState(object.isPresent()
                                && object.get() instanceof RevFeatureType);

                        ourFeatureType = (RevFeatureType) object.get();
                    }
                }

                if (conflict.has("theirs") && conflict.get("theirs").isJsonPrimitive()) {
                    String theirCommit = conflict.get("theirs").getAsJsonPrimitive().getAsString();
                    Optional<NodeRef> theirNode = parseID(ObjectId.valueOf(theirCommit), featureId,
                            ggit);
                    if (theirNode.isPresent()) {
                        Optional<RevObject> object = ggit.command(RevObjectParse.class)
                                .setObjectId(theirNode.get().objectId()).call();
                        Preconditions.checkState(object.isPresent()
                                && object.get() instanceof RevFeature);

                        theirFeature = (RevFeature) object.get();

                        object = ggit.command(RevObjectParse.class)
                                .setObjectId(theirNode.get().getMetadataId()).call();
                        Preconditions.checkState(object.isPresent()
                                && object.get() instanceof RevFeatureType);

                        theirFeatureType = (RevFeatureType) object.get();
                    }
                }

                if (conflict.has("merges") && conflict.get("merges").isJsonObject()) {
                    merges = conflict.get("merges").getAsJsonObject();
                }
                Preconditions.checkState(merges != null);

                Preconditions.checkState(ourFeatureType != null || theirFeatureType != null);

                SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
                        (SimpleFeatureType) (ourFeatureType != null ? ourFeatureType.type()
                                : theirFeatureType.type()));

                ImmutableList<PropertyDescriptor> descriptors = (ourFeatureType == null ? theirFeatureType
                        : ourFeatureType).sortedDescriptors();

                for (Entry<String, JsonElement> entry : merges.entrySet()) {
View Full Code Here

                + "' did not match any valid path");

        Optional<RevObject> revObject = cli.getGeogig().command(RevObjectParse.class)
                .setObjectId(featureTypeTree.get().getMetadataId()).call();
        if (revObject.isPresent() && revObject.get() instanceof RevFeatureType) {
            RevFeatureType revFeatureType = (RevFeatureType) revObject.get();
            if (revFeatureType.type() instanceof SimpleFeatureType) {
                return (SimpleFeatureType) revFeatureType.type();
            } else {
                throw new InvalidParameterException(
                        "Cannot find feature type for the specified path");
            }
        } else {
View Full Code Here

                + "' did not match any valid path");

        Optional<RevObject> revObject = cli.getGeogig().command(RevObjectParse.class)
                .setObjectId(featureTypeTree.get().getMetadataId()).call();
        if (revObject.isPresent() && revObject.get() instanceof RevFeatureType) {
            RevFeatureType revFeatureType = (RevFeatureType) revObject.get();
            if (revFeatureType.type() instanceof SimpleFeatureType) {
                return (SimpleFeatureType) revFeatureType.type();
            } else {
                throw new InvalidParameterException(
                        "Cannot find feature type for the specified path");
            }
        } else {
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevFeatureType

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.