protected override void GenerateTestResultCore() { Collection <Feature> results = null; if (!LoadingFromShapeFile) { results = TopologyValidator.PolygonsMustBeCoveredByPolygons(FirstInputFeatureLayer.InternalFeatures, SecondInputFeatureLayer.InternalFeatures); } OutputFeatureLayer.InternalFeatures.Clear(); foreach (Feature shape in results) { OutputFeatureLayer.InternalFeatures.Add(shape); } }
protected override void GenerateTestResultCore() { Collection <Feature> results = null; if (!LoadingFromShapeFile) { results = TopologyValidator.LinesMustNotOverlap(InputFeatureLayer.InternalFeatures); } OutputFeatureLayer.InternalFeatures.Clear(); foreach (var item in results) { OutputFeatureLayer.InternalFeatures.Add(item); } }
/// <summary> /// Validate lines based on whether they form a closed polygon, and display the results on the map /// </summary> private void CheckLinesMustFormClosedPolygon(object sender, EventArgs e) { // Create a sample set of line features to use for the validation Feature lineFeature1 = new Feature("LINESTRING(0 0,100 0,100 100,20 100)"); Feature lineFeature2 = new Feature("LINESTRING(0 0,-50 0,-50 100,0 100)"); // Use the TopologyValidator API to validate the sample data Collection <Feature> lines = new Collection <Feature>() { lineFeature1, lineFeature2 }; TopologyValidationResult result = TopologyValidator.LinesMustFormClosedPolygon(lines); // Get the invalid features returned from the API Collection <Feature> invalidResultFeatures = result.InvalidFeatures; // Clear the MapView and add the new valid/invalid features to the map ClearMapAndAddFeatures(lines, invalidResultFeatures); // Update the help text txtValidationInfo.Text = "Lines being validated are shown in green. \n\nLine endpoints that do not form a closed polygon are shown in red."; }
/// <summary> /// 拓扑检查 /// Check topology /// </summary> public Boolean TopoCheck() { Boolean result = false; if (m_dataset != null) { try { this.ResetDatasetAddMap(); TopologyDatasetRelationItem topoItem = new TopologyDatasetRelationItem(m_bufDataset); TopologyDatasetRelationItem[] items = { topoItem }; // 拓扑预处理,这个需要先调用 // Topology Preprocessing TopologyValidator.Preprocess(items, 2); // 检查线相重叠 // Check the topology according to the rule of LineNoOverlap m_dataset.Datasource.Datasets.Delete(m_checkDataName); m_resultDataset = TopologyValidator.Validate(m_bufDataset, m_bufDataset, TopologyRule.LineNoOverlap, 2, null, m_dataset.Datasource, m_checkDataName); m_mapControl.Map.Layers.Add(m_resultDataset, true); this.SetLayerStyle(m_mapControl.Map.Layers[0], Color.Red, 0.5); m_mapControl.Map.Refresh(); result = true; } catch (Exception ex) { Trace.Write(ex.Message); result = false; } } return(result); }
/// <summary> /// Validate lines based on whether they elf-overlap, and display the results on the map /// </summary> private void CheckLinesMustNotSelfOverlap(object sender, EventArgs e) { // Create a sample set of line features to use for the validation Feature selfOverlappingLine = new Feature("LINESTRING(0 0,100 0,100 100,0 100,20 0,40 0,40 -50)"); // Use the TopologyValidator API to validate the sample data Collection <Feature> lines = new Collection <Feature>() { selfOverlappingLine }; TopologyValidationResult result = TopologyValidator.LinesMustNotSelfOverlap(lines); // Get the invalid features returned from the API Collection <Feature> invalidResultFeatures = result.InvalidFeatures; // Clear the MapView and add the new valid/invalid features to the map ClearMapAndAddFeatures(new Collection <Feature>() { selfOverlappingLine }, invalidResultFeatures); // Update the help text txtValidationInfo.Text = "Lines being validated are shown in green. \n\nOverlapping segments are shown in red."; }