Package org.locationtech.udig.tools.feature.split

Examples of org.locationtech.udig.tools.feature.split.SplitFeatureBuilder


            if(originalFeatureList.isEmpty()){
                throw new SplitFeaturesCommandException(Messages.SplitFeaturesCommand_did_not_apply_to_any_feature);
            }
          ProjectPlugin.log(className + " - Split using CRS: " + mapCRS.toString()); //$NON-NLS-1$

      SplitFeatureBuilder builder = SplitFeatureBuilder.newInstance(originalFeatureList, splitterInMapCrs, mapCRS);
      try {
        builder.buildSplit();
      } catch (CannotSplitException e) {
        throw new SplitFeaturesCommandException(e.getMessage());
      }

      // make the requires list of commands to update the affected features
      final List<UndoableMapCommand> undoableCommands = new LinkedList<UndoableMapCommand>();
     
      // delete the features that suffered split
      List<SimpleFeature> featuresThatSufferedSplit = builder.getFeaturesThatSufferedSplit();

      for (SimpleFeature feature : featuresThatSufferedSplit) {

          UndoableMapCommand command = cmdFac.createDeleteFeature(feature, selectedLayer);
         
        undoableCommands.add(command);
        ProjectPlugin.log(className + " - Delete original feature: " + ((Geometry) feature.getDefaultGeometry()).toText()); //$NON-NLS-1$
      }
      // add the new features
      List<SimpleFeature> splitResult = builder.getSplitResult();
      for (SimpleFeature feature : splitResult) {
          UndoableMapCommand command = cmdFac.createAddFeatureCommand(feature, selectedLayer);
        undoableCommands.add(command);
        ProjectPlugin.log(className + " - Split result: " + ((Geometry) feature.getDefaultGeometry()).toText()); //$NON-NLS-1$
      }
      // modify the neighbor features.
      builder.buildNeighbours();
      List<SimpleFeature> modifiedNeighbour = builder.getNeighbourResult();
      for (SimpleFeature neighbor : modifiedNeighbour) {

          for( SimpleFeature original : originalFeatureList ) {
                    if(original.getID().equals(neighbor.getID())){
                        UndoableMapCommand command = new ModifyGeometryFeatureCommand(original.getID(), (Geometry)neighbor.getDefaultGeometry(), (Geometry)original.getDefaultGeometry(), this.selectedLayer);
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.feature.split.SplitFeatureBuilder

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.