/// <summary> /// /// </summary> /// <param name="selectingBox"></param> /// <returns></returns> private moFeatures SearchFeaturesByBox(moRectangle selectingBox) { moFeatures sSelectedFeatures = new moFeatures(); Int32 sFeatureCount = _Features.Count; for (Int32 i = 0; i <= sFeatureCount - 1; i++) { if (_ShapeType == moGeometryTypeConstant.Point) { moPoint sPoint = (moPoint)_Features.GetItem(i).Geometry; if (moMapTools.IsPointWithinBox(sPoint, selectingBox) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } else if (_ShapeType == moGeometryTypeConstant.MultiPolyline) { moMultiPolyline sMultiPolyline = (moMultiPolyline)_Features.GetItem(i).Geometry; if (moMapTools.IsMultiPolylinePartiallyWithinBox(sMultiPolyline, selectingBox) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } else if (_ShapeType == moGeometryTypeConstant.MultiPolygon) { moMultiPolygon sMultiPolygon = (moMultiPolygon)_Features.GetItem(i).Geometry; if (moMapTools.IsMultiPolygonPartiallyWithinBox(sMultiPolygon, selectingBox) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } } return(sSelectedFeatures); }
/// <summary> /// 根据指定点搜索要素 /// </summary> /// <param name="point"></param> /// <param name="tolerance"></param> /// <returns></returns> public moFeatures SearchFeaturesByPoint(moPoint point, double tolerance) { moFeatures sSelectedFeatures = new moFeatures(); Int32 sFeatureCount = _Features.Count; for (Int32 i = 0; i <= sFeatureCount - 1; i++) { if (_ShapeType == moGeometryTypeConstant.Point) { moPoint sPoint = (moPoint)_Features.GetItem(i).Geometry; if (moMapTools.IsPointOnPoint(point, sPoint, tolerance) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } else if (_ShapeType == moGeometryTypeConstant.MultiPolyline) { moMultiPolyline sMultiPolyline = (moMultiPolyline)_Features.GetItem(i).Geometry; if (moMapTools.IsPointOnMultiPolyline(point, sMultiPolyline, tolerance) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } else if (_ShapeType == moGeometryTypeConstant.MultiPolygon) { moMultiPolygon sMultiPolygon = (moMultiPolygon)_Features.GetItem(i).Geometry; if (moMapTools.IsPointWithinMultiPolygon(point, sMultiPolygon) == true) { sSelectedFeatures.Add(_Features.GetItem(i)); } } } return(sSelectedFeatures); }
/// <summary> /// 根据指定方法执行选择,selectMethod即新建、求差、求交等 /// </summary> /// <param name="features"></param> /// <param name="selectMethod"></param> public void ExecuteSelect(moFeatures features, Int32 selectMethod) { //说明:此处仅考虑新建集合 if (selectMethod == 0) { _SelectedFeatures.Clear(); Int32 sFeatureCount = features.Count; for (Int32 i = 0; i < sFeatureCount; i++) { _SelectedFeatures.Add(features.GetItem(i)); } } else { throw new NotFiniteNumberException(); } }
/// <summary> /// 根据指定的选择盒与选择方法执行选择 /// </summary> /// <param name="selectingBox"></param> /// <param name="tolerance"></param> /// <param name="selectMethod"></param> public void SelectByBox(moRectangle selectingBox, double tolerance, Int32 selectMethod) { Int32 sLayerCount = _Layers.Count; for (Int32 i = 0; i < sLayerCount; i++) { moMapLayer sLayer = _Layers.GetItem(i); if (sLayer.Visible == true && sLayer.Selectable == true) { moFeatures sFeatures = sLayer.SearchByBox(selectingBox, tolerance); sLayer.ExecuteSelect(sFeatures, selectMethod); } else { sLayer.SelectedFeatures.Clear(); } } }
/// <summary> /// 根据矩形盒执行搜索,返回选中的要素集合 /// </summary> /// <param name="selectionBox"></param> /// <param name="tolerance"></param> /// <returns></returns> public moFeatures SearchByBox(moRectangle selectingBox, double tolerance) { //说明:仅考虑一种选择模式 moFeatures sSelection = null; if (selectingBox.Width == 0 && selectingBox.Height == 0) { //点选 moPoint sSelectingPoint = new moPoint(selectingBox.MinX, selectingBox.MinY); sSelection = SearchFeaturesByPoint(sSelectingPoint, tolerance); } else { //框选 sSelection = SearchFeaturesByBox(selectingBox); } return(sSelection); }