/// <summary> /// Ping Yang Overwrite the function for Executes the Erase Opaeration tool for external testing /// </summary> public bool Execute(IFeatureSet self, IFeatureSet other, IFeatureSet output) { if (self == null || other == null || output == null) { return(false); } output.CopyTableSchema(self); // Fill the 1st Featureset fields IFeatureSet tempSet = self.CombinedFields(other); // go through every feature in 1st featureSet foreach (IFeature t in self.Features) { // go through every feature in 2nd featureSet foreach (IFeature t1 in other.Features) { t.Difference(t1, tempSet, FieldJoinType.All); } } // Add to the Output Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { output.Features.Add(tempSet.Features[a]); } output.SaveAs(output.Filename, true); // add to map? return(true); }
/// <summary> /// Executes the Erase Opaeration tool programaticaly /// </summary> /// <param name="self">The input feature that is to be erased</param> /// <param name="other">The other feature defining the area to remove</param> /// <param name="output">The resulting erased content</param> /// <param name="cancelProgressHandler">The progress handler</param> /// <returns>Boolean, true if the operation was a success</returns> public static bool Execute( IFeatureSet self, IFeatureSet other, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { // Validates the input and output data if (self == null || other == null || output == null) { return(false); } int previous; int max = self.Features.Count * other.Features.Count; output.CopyTableSchema(self); // Fill the 1st Featureset fields IFeatureSet tempSet = self.CombinedFields(other); // go through every feature in 1st featureSet for (int i = 0; i < self.Features.Count; i++) { // go through every feature in 2nd featureSet for (int j = 0; j < other.Features.Count; j++) { self.Features[i].Difference(other.Features[j], tempSet, FieldJoinType.All); previous = Convert.ToInt32(Math.Round(i * j * 50D / max)); if (cancelProgressHandler.Cancel) { return(false); } cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } } // Add to the Output Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { output.Features.Add(tempSet.Features[a]); previous = Convert.ToInt32(Math.Round((a * 50D / tempSet.Features.Count) + 50D)); if (cancelProgressHandler.Cancel) { return(false); } cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } output.SaveAs(output.Filename, true); // add to map? return(true); }
/// <summary> /// Removes portions of the input polygon shapefile that are within the erase polygons. /// </summary> /// <param name="inputShapefile">The input polygon shapefile.</param> /// <param name="eraseShapefile">The erase polygon shapefile.</param> /// <param name="resultShapefile">The resulting shapefile, with portions removed.</param> public static void ErasePolygonShapefileWithPolygonShapefile( IFeatureSet inputShapefile, IFeatureSet eraseShapefile, IFeatureSet resultShapefile) { // Validates the input and resultSF data if (inputShapefile == null || eraseShapefile == null || resultShapefile == null) { return; } resultShapefile.CopyTableSchema(inputShapefile); // Fill the 1st Featureset fields IFeatureSet tempSet = inputShapefile.CombinedFields(eraseShapefile); // go through every feature in 1st featureSet foreach (IFeature t in inputShapefile.Features) { // go through every feature in 2nd featureSet foreach (IFeature t1 in eraseShapefile.Features) { t.Difference(t1, tempSet, FieldJoinType.All); } } // Add to the resultSF Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { resultShapefile.Features.Add(tempSet.Features[a]); } resultShapefile.Save(); return; }
/// <summary> /// Executes the Union Opaeration tool programaticaly /// </summary> /// <param name="self">The input are feature set</param> /// <param name="other">The second input feature set</param> /// <param name="output">The output feature set</param> /// <param name="cancelProgressHandler">The progress handler</param> /// <returns></returns> public bool Execute( IFeatureSet self, IFeatureSet other, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { // Validates the input and output data if (self == null || other == null || output == null) { return false; } IFeatureSet tempOutput = self.Intersection(other, FieldJoinType.All, null); IFeatureSet tempFeatureSet = self.CombinedFields(other); int previous = 0; int max = self.Features.Count; // Take (Self-Intersect Featureset) List<IFeature> intersectList; for (int i = 0; i < self.Features.Count; i++) { intersectList = other.Select(self.Features[i].Envelope.ToExtent()); foreach (IFeature feat in intersectList) { if (cancelProgressHandler.Cancel) { return false; } self.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly); } if (Math.Round(i * 40D / max) <= previous) { continue; } previous = Convert.ToInt32(Math.Round(i * 40D / max)); cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } max = other.Features.Count; // Take (Other-Intersect Featureset) for (int i = 0; i < other.Features.Count; i++) { intersectList = self.Select(other.Features[i].Envelope.ToExtent()); foreach (IFeature feat in intersectList) { if (cancelProgressHandler.Cancel) { return false; } other.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly); } if (Math.Round((i * 40D / max) + 40D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 40D / max) + 40D)); cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } max = tempFeatureSet.Features.Count; output.CopyTableSchema(tempFeatureSet); // Add the individual feature to output for (int i = 0; i < tempFeatureSet.Features.Count; i++) { output.Features.Add(tempFeatureSet.Features[i]); if (Math.Round((i * 10D / max) + 80D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 10D / max) + 80D)); if (cancelProgressHandler.Cancel) { return false; } cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } max = tempOutput.Features.Count; // Add the Intersect feature to output for (int i = 0; i < tempOutput.Features.Count; i++) { output.Features.Add(tempOutput.Features[i]); if (cancelProgressHandler.Cancel) { return false; } if (Math.Round((i * 10D / max) + 90D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 10D / max) + 90D)); cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } output.SaveAs(output.Filename, true); return true; }
/// <summary> /// Removes portions of the input polygon shapefile that are within the erase polygons. /// </summary> /// <param name="inputSF">The input polygon shapefile.</param> /// <param name="eraseSF">The erase polygon shapefile.</param> /// <param name="resultSF">The resulting shapefile, with portions removed.</param> /// <returns>False if an error was encountered, true otherwise.</returns> public static void ErasePolySFWithPolySF(ref IFeatureSet inputSF, ref IFeatureSet eraseSF, ref IFeatureSet resultSF) { //Validates the input and resultSF data if (inputSF == null || eraseSF == null || resultSF == null) { return; } resultSF.CopyTableSchema(inputSF);//Fill the 1st Featureset fields IFeatureSet tempSet = inputSF.CombinedFields(eraseSF); //go through every feature in 1st featureSet for (int i = 0; i < inputSF.Features.Count; i++) { //go through every feature in 2nd featureSet for (int j = 0; j < eraseSF.Features.Count; j++) { inputSF.Features[i].Difference(eraseSF.Features[j], tempSet, FieldJoinType.All); } } //Add to the resultSF Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { resultSF.Features.Add(tempSet.Features[a]); } resultSF.Save(); return; }
/// <summary> /// Executes the Union Opaeration tool programmatically. /// </summary> /// <param name="self">The input are feature set.</param> /// <param name="other">The second input feature set.</param> /// <param name="output">The output feature set.</param> /// <param name="cancelProgressHandler">The progress handler.</param> /// <returns>True, if executed successfully.</returns> public bool Execute(IFeatureSet self, IFeatureSet other, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { // Validates the input and output data if (self == null || other == null || output == null) { return(false); } IFeatureSet tempOutput = self.Intersection(other, FieldJoinType.All, null); IFeatureSet tempFeatureSet = self.CombinedFields(other); int previous = 0; int max = self.Features.Count; // Take (Self-Intersect Featureset) List <IFeature> intersectList; for (int i = 0; i < self.Features.Count; i++) { intersectList = other.Select(self.Features[i].Geometry.EnvelopeInternal.ToExtent()); foreach (IFeature feat in intersectList) { if (cancelProgressHandler.Cancel) { return(false); } self.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly); } if (Math.Round(i * 40D / max) <= previous) { continue; } previous = Convert.ToInt32(Math.Round(i * 40D / max)); cancelProgressHandler.Progress(previous, previous + TextStrings.progresscompleted); } max = other.Features.Count; // Take (Other-Intersect Featureset) for (int i = 0; i < other.Features.Count; i++) { intersectList = self.Select(other.Features[i].Geometry.EnvelopeInternal.ToExtent()); foreach (IFeature feat in intersectList) { if (cancelProgressHandler.Cancel) { return(false); } other.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly); } if (Math.Round((i * 40D / max) + 40D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 40D / max) + 40D)); cancelProgressHandler.Progress(previous, previous + TextStrings.progresscompleted); } max = tempFeatureSet.Features.Count; output.CopyTableSchema(tempFeatureSet); // Add the individual feature to output for (int i = 0; i < tempFeatureSet.Features.Count; i++) { output.Features.Add(tempFeatureSet.Features[i]); if (Math.Round((i * 10D / max) + 80D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 10D / max) + 80D)); if (cancelProgressHandler.Cancel) { return(false); } cancelProgressHandler.Progress(previous, previous + TextStrings.progresscompleted); } max = tempOutput.Features.Count; // Add the Intersect feature to output for (int i = 0; i < tempOutput.Features.Count; i++) { output.Features.Add(tempOutput.Features[i]); if (cancelProgressHandler.Cancel) { return(false); } if (Math.Round((i * 10D / max) + 90D) <= previous) { continue; } previous = Convert.ToInt32(Math.Round((i * 10D / max) + 90D)); cancelProgressHandler.Progress(previous, previous + TextStrings.progresscompleted); } output.SaveAs(output.Filename, true); return(true); }
/// <summary> /// Executes the Erase Opaeration tool programaticaly /// </summary> /// <param name="self">The input feature that is to be erased</param> /// <param name="other">The other feature defining the area to remove</param> /// <param name="output">The resulting erased content</param> /// <param name="cancelProgressHandler">The progress handler</param> /// <returns>Boolean, true if the operation was a success</returns> public static bool Execute( IFeatureSet self, IFeatureSet other, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { // Validates the input and output data if (self == null || other == null || output == null) { return false; } int previous; int max = self.Features.Count * other.Features.Count; output.CopyTableSchema(self); // Fill the 1st Featureset fields IFeatureSet tempSet = self.CombinedFields(other); // go through every feature in 1st featureSet for (int i = 0; i < self.Features.Count; i++) { // go through every feature in 2nd featureSet for (int j = 0; j < other.Features.Count; j++) { self.Features[i].Difference(other.Features[j], tempSet, FieldJoinType.All); previous = Convert.ToInt32(Math.Round(i * j * 50D / max)); if (cancelProgressHandler.Cancel) { return false; } cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } } // Add to the Output Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { output.Features.Add(tempSet.Features[a]); previous = Convert.ToInt32(Math.Round((a * 50D / tempSet.Features.Count) + 50D)); if (cancelProgressHandler.Cancel) { return false; } cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted); } output.SaveAs(output.Filename, true); // add to map? return true; }
/// <summary> /// Ping Yang Overwrite the function for Executes the Erase Opaeration tool for external testing /// </summary> public bool Execute(IFeatureSet self, IFeatureSet other, IFeatureSet output) { if (self == null || other == null || output == null) { return false; } output.CopyTableSchema(self); // Fill the 1st Featureset fields IFeatureSet tempSet = self.CombinedFields(other); // go through every feature in 1st featureSet foreach (IFeature t in self.Features) { // go through every feature in 2nd featureSet foreach (IFeature t1 in other.Features) { t.Difference(t1, tempSet, FieldJoinType.All); } } // Add to the Output Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { output.Features.Add(tempSet.Features[a]); } output.SaveAs(output.Filename, true); // add to map? return true; }
/// <summary> /// Ping Yang Overwrite the function for Executes the Erase Opaeration tool for external testing /// </summary> public bool Execute(IFeatureSet self, IFeatureSet other, IFeatureSet output) { if (self == null || other == null || output == null) { return false; } int previous; int max = self.Features.Count * other.Features.Count; output.CopyTableSchema(self);//Fill the 1st Featureset fields IFeatureSet tempSet = self.CombinedFields(other); //go through every feature in 1st featureSet for (int i = 0; i < self.Features.Count; i++) { //go through every feature in 2nd featureSet for (int j = 0; j < other.Features.Count; j++) { self.Features[i].Difference(other.Features[j], tempSet, FieldJoinType.All); previous = Convert.ToInt32(Math.Round((i * j * 50D / max))); } } //Add to the Output Feature Set for (int a = 0; a < tempSet.Features.Count; a++) { output.Features.Add(tempSet.Features[a]); previous = Convert.ToInt32(Math.Round((a * 50D / tempSet.Features.Count) + 50D)); } output.SaveAs(output.Filename, true); //add to map? return true; }