IPoint IntersectPointExtendedTo(IPolyline pPolyline, IPolygon pCirclePoly) { ICurve pCurve; ILine pLine; IPolyline pPLine; ITopologicalOperator pTopoOpt; IGeometryCollection pGeoCol; pCurve = pPolyline; pLine = new Line(); double gridWidth = _mapTemplate.Width * _scale / 100.0; pCurve.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, gridWidth * 1.1, pLine); pPLine = new Polyline() as IPolyline; IPointCollection pPnts = pPLine as IPointCollection; IClone pClone = pLine.FromPoint as IClone; pPnts.AddPoint(pClone.Clone() as IPoint); pClone = pLine.ToPoint as IClone; pPnts.AddPoint(pClone.Clone() as IPoint); pTopoOpt = pPLine as ITopologicalOperator; pGeoCol = new GeometryBag() as IGeometryCollection; pGeoCol = pTopoOpt.Intersect(pCirclePoly, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection; if (pGeoCol.GeometryCount == 0) { return(null); } return(pGeoCol.Geometry[0] as IPoint); }
private void method_5() { this.bool_6 = true; this.bool_1 = false; IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection; enumFeature.Reset(); IFeature feature = enumFeature.Next(); object value = Missing.Value; while (feature != null) { esriGeometryType geometryType = feature.Shape.GeometryType; if (geometryType == esriGeometryType.esriGeometryPolygon || geometryType == esriGeometryType.esriGeometryPolyline) { IClone clone = feature.Shape as IClone; geometryCollection.AddGeometry(clone.Clone() as IGeometry, ref value, ref value); this.bool_4 = true; } feature = enumFeature.Next(); } if (this.bool_2) { this.isegmentGraph_0.SetEmpty(); this.isegmentGraphCursor_0 = null; } this.isegmentGraph_0.Load(geometryCollection as IEnumGeometry, false, true); this.bool_2 = false; }
public IGeometryBag ConstructPolygonByLine(IGeometryBag igeometryBag_0) { int i; IPolygon polygon; IGeometryCollection geometryBagClass = new GeometryBag() as IGeometryCollection; object value = Missing.Value; IArray array = this.SplitLine(igeometryBag_0); int[] numArray = new int[array.Count]; IArray arrayClass = new Array(); for (i = 0; i < array.Count; i++) { numArray[i] = 0; } IGeometry element = null; IGeometry geometry = null; for (i = 0; i < array.Count; i++) { element = array.Element[i] as IGeometry; IPolyline polyline = (IPolyline)element; geometry = element; if (this.method_3(array, polyline.FromPoint) != 1 && this.method_3(array, polyline.ToPoint) != 1) { if (!polyline.IsClosed) { if ((numArray[i] & 2) == 0) { numArray[i] = numArray[i] | 2; polygon = this.BulidPoly(array, numArray, geometry, false); if (polygon != null) { geometryBagClass.AddGeometry(polygon, ref value, ref value); } } if ((numArray[i] & 1) == 0) { numArray[i] = numArray[i] | 1; polygon = this.BulidPoly(array, numArray, geometry, true); if (polygon != null) { geometryBagClass.AddGeometry(polygon, ref value, ref value); } } } else { ISegmentCollection polygonClass = new Polygon() as ISegmentCollection; polygonClass.AddSegmentCollection((ISegmentCollection)polyline); polygon = (IPolygon)polygonClass; ((ITopologicalOperator)polygon).Simplify(); geometryBagClass.AddGeometry(polygon, ref value, ref value); } } } return((IGeometryBag)geometryBagClass); }
/// <summary> /// /// </summary> /// <param name="dbGeometry"></param> /// <returns></returns> public static IGeometry dbGeometryToGeometry(DbGeometry dbGeometry) { if (dbGeometry == null) { return(null); } byte[] wkb = dbGeometry.AsBinary(); IGeometry geomOut = new GeometryBag(); IGeometryFactory gf = new GeometryEnvironment() as IGeometryFactory; int readCount = 0; gf.CreateGeometryFromWkbVariant(wkb, out geomOut, out readCount); return(geomOut); }
/// <summary> /// 合并几何体 /// </summary> /// <returns></returns> private IGeometry GetMergeGeometry(string str) { IGeometryBag pGeometryBag = new GeometryBag() as IGeometryBag; pGeometryBag.SpatialReference = GetSpatialReference(); IGeometryCollection pGeometryCollection = pGeometryBag as IGeometryCollection; // 属性过滤 IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = str; IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer; IFeatureClass in_FeatureClass = pFeatureLayer.FeatureClass; // 要素游标 IFeatureCursor pFeatureCursor = in_FeatureClass.Search(pQueryFilter, true); IFeature pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { return null; } // 遍历游标 object missing = Type.Missing; while (pFeature != null) { pGeometryCollection.AddGeometry(pFeature.ShapeCopy, ref missing, ref missing); pFeature = pFeatureCursor.NextFeature(); } Marshal.ReleaseComObject(pFeatureCursor); // 合并要素 ITopologicalOperator pTopologicalOperator = null; if (in_FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { pTopologicalOperator = new Multipoint() as ITopologicalOperator; pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry); } else if (in_FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { pTopologicalOperator = new Polyline() as ITopologicalOperator; pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry); } else { pTopologicalOperator = new Polygon() as ITopologicalOperator; pTopologicalOperator.ConstructUnion(pGeometryCollection as IEnumGeometry); } return pTopologicalOperator as IGeometry; }
protected override void OnClick() { try { if (Module1.Geometries == null || Module1.Geometries.Count <= 0) { MessageBox.Show($@"You have to first render a geometry before you can export the Geometry"); return; } var bpf = new BrowseProjectFilter("esri_browseDialogFilters_json_file") { Name = "Specify JSON file to export Geometries to" }; var saveItemDialog = new SaveItemDialog { BrowseFilter = bpf }; var result = saveItemDialog.ShowDialog(); if (result.Value == false) { return; } var jsonPath = $@"{saveItemDialog.FilePath}.json"; var folder = System.IO.Path.GetDirectoryName(jsonPath); if (!System.IO.Directory.Exists(folder)) { System.IO.Directory.CreateDirectory(folder); } var exists = System.IO.File.Exists(jsonPath); if (exists) { var isYes = MessageBox.Show($@"The export will write over the existing file {jsonPath}", "Override File", System.Windows.MessageBoxButton.YesNo); if (isYes != System.Windows.MessageBoxResult.Yes) { return; } System.IO.File.Delete(jsonPath); } GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(Module1.Geometries, Module1.Geometries[0].SpatialReference); System.IO.File.WriteAllText(jsonPath, bag.ToJson()); MessageBox.Show($@"Export saved to {jsonPath}"); } catch (Exception ex) { MessageBox.Show($@"Export Exception: {ex}"); } }
public static IPolygon MergePolygons(IGeometry polygon1, IGeometry polygon2, IFeatureClass fc_for_spatial_reference) { IGeometry geometry_bag = new GeometryBag(); IGeoDataset ds = fc_for_spatial_reference as IGeoDataset; geometry_bag.SpatialReference = ds.SpatialReference; IGeometryCollection gc = geometry_bag as IGeometryCollection; object missing = Type.Missing; gc.AddGeometry(polygon1, ref missing, ref missing); gc.AddGeometry(polygon2, ref missing, ref missing); ITopologicalOperator union_polygon = new Polygon() as ITopologicalOperator; union_polygon.ConstructUnion(geometry_bag as IEnumGeometry); IPolygon new_polygon = union_polygon as IPolygon; return(new_polygon); }
public override bool SplitAtPoint(IPoint ipoint_0, out IGeometryBag igeometryBag_0) { bool flag; bool flag1; int num; int num1; int i; igeometryBag_0 = null; IPolycurve mPGeometry = this.m_pGeometry as IPolycurve; if (mPGeometry != null) { mPGeometry.SplitAtPoint(ipoint_0, true, true, out flag1, out num, out num1); if (flag1) { igeometryBag_0 = new GeometryBag() as IGeometryBag; IGeometryCollection geometryCollection = mPGeometry as IGeometryCollection; IGeometryCollection polylineClass = new Polyline() as IGeometryCollection; object value = Missing.Value; for (i = 0; i < num; i++) { polylineClass.AddGeometry(geometryCollection.Geometry[i], ref value, ref value); } (igeometryBag_0 as IGeometryCollection).AddGeometry(polylineClass as IGeometry, ref value, ref value); polylineClass = new Polyline() as IGeometryCollection; for (i = num; i < geometryCollection.GeometryCount; i++) { polylineClass.AddGeometry(geometryCollection.Geometry[i], ref value, ref value); } (igeometryBag_0 as IGeometryCollection).AddGeometry(polylineClass as IGeometry, ref value, ref value); flag = true; } else { flag = false; } } else { flag = false; } return(flag); }
public bool Split(IPolyline ipolyline_0, out IGeometryBag igeometryBag_0) { bool flag; IGeometry geometry; IGeometry geometry1; igeometryBag_0 = null; if (this.m_pGeometry.GeometryType != esriGeometryType.esriGeometryPoint) { try { ITopologicalOperator mPGeometry = this.m_pGeometry as ITopologicalOperator; if (mPGeometry != null) { if (!mPGeometry.IsSimple) { mPGeometry.Simplify(); } mPGeometry.Cut(ipolyline_0, out geometry, out geometry1); object value = Missing.Value; igeometryBag_0 = new GeometryBag() as IGeometryBag; (igeometryBag_0 as IGeometryCollection).AddGeometry(geometry, ref value, ref value); (igeometryBag_0 as IGeometryCollection).AddGeometry(geometry1, ref value, ref value); } else { flag = false; return(flag); } } catch { } flag = false; } else { flag = false; } return(flag); }
public IPolygon union(IFeatureClass featureClass) { if (featureClass == null) { return(null); } IGeoDataset geoDataset = featureClass as IGeoDataset; IGeometry geometryBag = new GeometryBag(); ISpatialFilter queryFilter = new SpatialFilter(); geometryBag.SpatialReference = geoDataset.SpatialReference; IFeatureCursor featureCursor = featureClass.Search(queryFilter, false); IGeometryCollection geometryCollection = geometryBag as IGeometryCollection; IFeature currentFeature = featureCursor.NextFeature(); while (currentFeature != null) { object missing = Type.Missing; geometryCollection.AddGeometry(currentFeature.Shape, ref missing, ref missing); currentFeature = featureCursor.NextFeature(); } ITopologicalOperator unionedPolygon = new Polygon() as ITopologicalOperator; unionedPolygon.ConstructUnion(geometryBag as IEnumGeometry); return(unionedPolygon as IPolygon); }
private void method_2() { this.bool_0 = false; IEnumFeature featureSelection = this.imap_0.FeatureSelection as IEnumFeature; IGeometryCollection geometryBagClass = new GeometryBag() as IGeometryCollection; featureSelection.Reset(); for (IFeature i = featureSelection.Next(); i != null; i = featureSelection.Next()) { esriGeometryType geometryType = i.Shape.GeometryType; if ((geometryType == esriGeometryType.esriGeometryPolygon ? true : geometryType == esriGeometryType.esriGeometryPolyline)) { IClone shape = i.Shape as IClone; object value = Missing.Value; geometryBagClass.AddGeometry(shape.Clone() as IGeometry, ref value, ref value); this.bool_0 = true; } } this.isegmentGraph_0.SetEmpty(); this.isegmentGraph_0.Load(geometryBagClass as IEnumGeometry, false, true); }
private void CreateResultElements() { IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection; for (int i = 0; i < this._networkInfo.arrayList_1.Count; i++) { object missing = Type.Missing; IFeature feature = (IFeature)this._networkInfo.arrayList_1[i]; geometryCollection.AddGeometry(feature.ShapeCopy, ref missing, ref missing); } if (this._networkInfo.arrayList_1.Count > 0) { IRgbColor rgbColor = new RgbColor(); rgbColor.Red = (255); rgbColor.Green = (0); rgbColor.Blue = (255); IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_iApp.ActiveView; for (int j = 0; j < geometryCollection.GeometryCount; j++) { ILineElement lineElement = new LineElement() as ILineElement; IElement element = (IElement)lineElement; element.Geometry = (geometryCollection.get_Geometry(j)); ILineElement arg_F5_0 = lineElement; ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol(); simpleLineSymbolClass.Color = (rgbColor); simpleLineSymbolClass.Width = (10.0); simpleLineSymbolClass.Style = (0); arg_F5_0.Symbol = (simpleLineSymbolClass); graphicsContainer.AddElement(element, 0); } IEnvelope envelope = ((IGeometry)geometryCollection).Envelope; envelope.Expand(1.2, 1.2, true); m_iApp.ActiveView.Extent = (envelope); m_iApp.ActiveView.Refresh(); } }
public override bool SplitAtPoint(IPoint ipoint_0, out IGeometryBag igeometryBag_0) { bool flag; bool flag1; int num; int num1; igeometryBag_0 = null; IPolycurve mPGeometry = this.m_pGeometry as IPolycurve; if (mPGeometry != null) { mPGeometry.SplitAtPoint(ipoint_0, true, true, out flag1, out num, out num1); object value = Missing.Value; igeometryBag_0 = new GeometryBag() as IGeometryBag; (igeometryBag_0 as IGeometryCollection).AddGeometry(mPGeometry, ref value, ref value); flag = true; } else { flag = false; } return(flag); }
public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3) { if (int_0 != 2 && this.bool_0) { this.bool_0 = false; IActiveView activeView = (IActiveView)_context.FocusMap; IEnvelope envelope = null; IPoint point = null; if (this.inewEnvelopeFeedback_0 == null) { point = this.ipoint_0; } else { envelope = this.inewEnvelopeFeedback_0.Stop(); this.inewEnvelopeFeedback_0 = null; if (envelope.Width == 0.0 || envelope.Height == 0.0) { point = this.ipoint_0; envelope = null; } } IList list = new ArrayList(); IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; enumFeature.Reset(); IFeature feature = enumFeature.Next(); IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection; object value = Missing.Value; while (feature != null) { list.Add(feature); geometryCollection.AddGeometry(feature.ShapeCopy, ref value, ref value); feature = enumFeature.Next(); } IEnvelope envelope2 = (geometryCollection as IGeometryBag).Envelope; IPoint point2 = new Point { X = (envelope2.XMax + envelope2.XMin) / 2.0, Y = (envelope2.YMax + envelope2.YMin) / 2.0 }; double num; double num2; if (envelope != null) { IPoint point3 = new Point { X = (envelope.XMax + envelope.XMin) / 2.0, Y = (envelope.YMax + envelope.YMin) / 2.0 }; num = point2.X - point3.X; num2 = point2.Y - point3.Y; double num3 = envelope.Width / envelope2.Width; double num4 = envelope.Height / envelope2.Height; num3 = ((num3 > num4) ? num4 : num3); (geometryCollection as ITransform2D).Scale(point2, num3, num3); } else { num = point2.X - point.X; num2 = point2.Y - point.Y; } (geometryCollection as ITransform2D).Move(-num, -num2); Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation(); for (int i = 0; i < list.Count; i++) { feature = (list[i] as IFeature); try { IFeature feature2 = RowOperator.CreatRowByRow(feature) as IFeature; feature2.Shape = geometryCollection.get_Geometry(i); feature2.Store(); } catch (Exception exception_) { CErrorLog.writeErrorLog(this, exception_, ""); } } Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation(); activeView.Refresh(); } }
private bool AddEditArea(IServerObject serverObject, string creator, string versionName, int editCount, IEnvelope editZone, bool autoExpandZone = true) { bool isOk = false; IFeatureClass editAreasFC = null; try { // Open edit areas feature class in default workspace editAreasFC = GetEditAreaFeatureClass(serverObject); // Get field indices int creatorFIdx = editAreasFC.FindField(_creatorFName); int creationDateFIdx = editAreasFC.FindField(_creationDateFName); int lastUpdateFIdx = editAreasFC.FindField(_lastUpdateFName); int editCountFIdx = editAreasFC.FindField(_editCountFName); int versionNameFIdx = editAreasFC.FindField(_versionNameFName); DateTime currentTime = DateTime.Now; // Expand zone to make it more visible if (autoExpandZone) { double expandRatio = (editCount <= 3) ? 1.5 : 1.15; editZone.Expand(expandRatio, expandRatio, true); } // Check if there's an existing area IFeature curFeature = null; IFeatureCursor fCursor = GetEditAreas(serverObject, versionName); if (fCursor != null && (curFeature = fCursor.NextFeature()) != null) { // Union the edit zones IPolygon curZone = (IPolygon)curFeature.Shape; IGeometry geometryBag = new GeometryBag(); geometryBag.SpatialReference = curZone.SpatialReference; IGeometryCollection geometryCollection = (IGeometryCollection)geometryBag; geometryCollection.AddGeometry(curZone); geometryCollection.AddGeometry(editZone); Polygon zoneConstructor = new Polygon(); ITopologicalOperator newZone = (ITopologicalOperator)zoneConstructor; newZone.ConstructUnion((IEnumGeometry)geometryCollection); // Update feature values curFeature.Shape = (IGeometry)newZone; curFeature.Value[lastUpdateFIdx] = currentTime; int curCount = (int)curFeature.Value[editCountFIdx]; curFeature.Value[editCountFIdx] = curCount + editCount; // Store feature curFeature.Store(); curFeature = null; } else { // Save edit zone to feature class IFeature zoneFeature = editAreasFC.CreateFeature(); zoneFeature.Value[creatorFIdx] = creator; zoneFeature.Value[creationDateFIdx] = currentTime; zoneFeature.Value[lastUpdateFIdx] = currentTime; zoneFeature.Value[versionNameFIdx] = versionName; zoneFeature.Value[editCountFIdx] = editCount; // Set geometry Polygon editAreaPoly = new Polygon(); ISegmentCollection editAreaSeg = (ISegmentCollection)editAreaPoly; editAreaSeg.SetRectangle(editZone); IZAware polyZAware = editAreaPoly as IZAware; polyZAware.ZAware = false; zoneFeature.Shape = polyZAware as IGeometry; // Store feature zoneFeature.Store(); fCursor.Flush(); fCursor = null; zoneFeature = null; } isOk = true; } catch (Exception e) { _serverLog.LogMessage(ServerLogger.msgType.infoStandard, _soiName + ".AddEditArea()", 200, "Error while adding edit are: " + e.ToString()); } finally { editAreasFC = null; } return(isOk); }
private IGeometry method_4(IArray iarray_0, IGeometry igeometry_0, IPoint ipoint_0, bool bool_1, ref bool bool_2) { IGeometry geometry; IGeometry geometry1; IRelationalOperator ipoint0 = (IRelationalOperator)ipoint_0; IGeometryCollection geometryBagClass = new GeometryBag() as IGeometryCollection; object value = Missing.Value; for (int i = 0; i < iarray_0.Count; i++) { if (!((IPolyline)iarray_0.Element[i]).IsClosed && ipoint0.Touches((IGeometry)iarray_0.Element[i])) { geometryBagClass.AddGeometry((IGeometry)iarray_0.Element[i], ref value, ref value); } } int geometryCount = geometryBagClass.GeometryCount; if (geometryCount > 1) { geometryBagClass = this.method_5(geometryBagClass, !bool_1, ipoint_0); int num = 0; while (true) { geometry1 = geometryBagClass.Geometry[num]; if (igeometry_0 == geometry1) { break; } num++; if (num == geometryCount) { num = 0; } } do { num++; if (num == geometryCount) { num = 0; } geometry1 = geometryBagClass.Geometry[num]; if (CommonHelper.distance(((ICurve)geometry1).FromPoint, ipoint_0) >= CommonHelper.distance(((ICurve)geometry1).ToPoint, ipoint_0)) { if (this.method_3(iarray_0, ((ICurve)geometry1).FromPoint) <= 1) { continue; } bool_2 = false; geometry = geometry1; return(geometry); } else { if (this.method_3(iarray_0, ((ICurve)geometry1).ToPoint) <= 1) { continue; } bool_2 = true; geometry = geometry1; return(geometry); } } while (igeometry_0 != geometry1); geometry = null; } else { geometry = null; } return(geometry); }
private IGeometryCollection method_5(IGeometryCollection igeometryCollection_0, bool bool_1, IPoint ipoint_0) { int i; object value = Missing.Value; int geometryCount = igeometryCollection_0.GeometryCount; double[] numArray = new double[geometryCount]; double[] numArray1 = new double[geometryCount - 1]; for (i = 0; i < geometryCount; i++) { ICurve geometry = (ICurve)igeometryCollection_0.Geometry[i]; ILine lineClass = new Line(); IPointCollection pointCollection = (IPointCollection)geometry; if (CommonHelper.distance(geometry.FromPoint, ipoint_0) >= CommonHelper.distance(geometry.ToPoint, ipoint_0)) { numArray[i] = CommonHelper.azimuth(pointCollection.Point[pointCollection.PointCount - 1], pointCollection.Point[pointCollection.PointCount - 2]); } else { numArray[i] = CommonHelper.azimuth(pointCollection.Point[0], pointCollection.Point[1]); } } for (i = 1; i < geometryCount; i++) { numArray1[i - 1] = numArray[i] - numArray[0]; if (numArray1[i - 1] < 0) { numArray1[i - 1] = numArray1[i - 1] + 360; } } IGeometryCollection geometryBagClass = new GeometryBag() as IGeometryCollection; while (geometryBagClass.GeometryCount != geometryCount) { double num = numArray[0]; int num1 = 0; for (i = 1; i < geometryCount; i++) { if (num > numArray[i]) { num = numArray[i]; num1 = i; } } numArray[num1] = numArray[num1] + 363; geometryBagClass.AddGeometry(igeometryCollection_0.Geometry[num1], ref value, ref value); } if (!bool_1) { IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection; geometryCollection.AddGeometry(geometryBagClass.Geometry[0], ref value, ref value); for (i = geometryCount - 1; i > 0; i--) { geometryCollection.AddGeometry(geometryBagClass.Geometry[i], ref value, ref value); } geometryBagClass = geometryCollection; } return(geometryBagClass); }
public List <IPrintPageInfo> CreateStripMapPageInfos(IPolyline stripLine) { IPolyline pPolyline; IPoint pCenterPoint; IPolygon pCirclePoly; IPolygon pGridPoly; IConstructCircularArc pCircularArc; ISegmentCollection pSegmentCollection; ITopologicalOperator pTopoOpt; IGeometryCollection pGeoCol; IPoint pIntersectPoint; ICurve pArc; IPoint pIntersectPointPrev; bool bFirstRun; int lLoop2; double dHighest = 0; int lHighestRef; double dHighestPrev; ICurve pCurve; ILine pLine; IPolyline pPLine; bool bContinue; bool bReducedRadius; double dGridAngle; double dHighestThisTurn; int lCounter = 0; List <IPrintPageInfo> pages = new List <IPrintPageInfo>(); pPolyline = stripLine; pCenterPoint = pPolyline.FromPoint; double m_GridWidth = _mapTemplate.Width * _scale / 100.0; double m_GridHeight = _mapTemplate.Height * _scale / 100.0; double dCircleRadius; List <double> colIntersects = new List <double>(); double dIntersect; dHighestPrev = -1; bFirstRun = true; pArc = pPolyline; bContinue = false; bool isLoop1 = true; object missing = Missing.Value; do { if (bFirstRun) { dCircleRadius = m_GridWidth / 2.0; } else { dCircleRadius = m_GridWidth; } bReducedRadius = false; do { //! 创建搜索圆 pCircularArc = new CircularArc() as IConstructCircularArc; pCircularArc.ConstructCircle(pCenterPoint, dCircleRadius, false); pCirclePoly = new Polygon() as IPolygon; pSegmentCollection = pCirclePoly as ISegmentCollection; pSegmentCollection.AddSegment(pCircularArc as ISegment, ref missing, ref missing); pTopoOpt = pPolyline as ITopologicalOperator; pGeoCol = new GeometryBag() as IGeometryCollection; pGeoCol = pTopoOpt.Intersect(pCirclePoly, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection; if (pGeoCol.GeometryCount == 0) { //! 需要检查,没有交点的的时候的处理 return(null); } pArc = pPolyline; lHighestRef = -1; dHighestThisTurn = 102; for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint; dIntersect = ReturnPercentageAlong(pPolyline, pIntersectPoint); if (dIntersect > (dHighestPrev * 1.001) && dIntersect < dHighestThisTurn) { dHighest = dIntersect; dHighestThisTurn = dIntersect; lHighestRef = lLoop2; } } if (lHighestRef < 0) { dHighest = 101; pIntersectPoint = IntersectPointExtendedTo(pPolyline, pCirclePoly); pIntersectPointPrev = pCenterPoint; } else { pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint; if (bFirstRun) { pIntersectPointPrev = new Point(); pIntersectPointPrev.PutCoords(pCenterPoint.X - (pIntersectPoint.X - pCenterPoint.X), pCenterPoint.Y - (pIntersectPoint.Y - pCenterPoint.Y)); } else { pIntersectPointPrev = pCenterPoint; } } if (bReducedRadius) { IPolyline pTmpPLine; IPolygon pTmpCPoly; IPoint pTmpIntPoint; pCircularArc = new CircularArc() as IConstructCircularArc; if (bFirstRun) { pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth / 2.0, false); } else { pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth, false); } pTmpCPoly = new Polygon() as IPolygon; pSegmentCollection = pTmpCPoly as ISegmentCollection; pSegmentCollection.AddSegment((ISegment)pCircularArc, ref missing, ref missing); pTmpPLine = new Polyline() as IPolyline; pTmpPLine.FromPoint = pIntersectPointPrev; pTmpPLine.ToPoint = pIntersectPoint; pTmpIntPoint = IntersectPointExtendedTo(pTmpPLine, pTmpCPoly); CreateAngledGridPolygon(pIntersectPointPrev, pTmpIntPoint, out pGridPoly, out dGridAngle); } else { CreateAngledGridPolygon(pIntersectPointPrev, pIntersectPoint, out pGridPoly, out dGridAngle); } pTopoOpt = pGridPoly as ITopologicalOperator; pGeoCol = new GeometryBag() as IGeometryCollection; pGeoCol = pTopoOpt.Intersect(pPolyline, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection; bContinue = true; if (pGeoCol.GeometryCount > 2) { colIntersects = new List <double>(); for (lLoop2 = 2; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { colIntersects.Add(ReturnPercentageAlong(pArc, pGeoCol.Geometry[lLoop2] as IPoint)); } for (lLoop2 = 0; lLoop2 < colIntersects.Count; lLoop2++) { if (colIntersects[lLoop2] > (dHighestPrev * 1.001) && colIntersects[lLoop2] < (dHighestPrev * 0.999)) { bContinue = false; dHighest = dHighestPrev; dCircleRadius = dCircleRadius - m_GridWidth * 0.1; bReducedRadius = true; if (dCircleRadius < 0) { bContinue = true; break; } } } } if (bContinue && bReducedRadius) { double dTmpHighest; pArc = pPolyline; lHighestRef = -1; dTmpHighest = -1; for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint; dIntersect = ReturnPercentageAlong(pArc, pIntersectPoint); if (dIntersect > dTmpHighest) { dTmpHighest = dIntersect; lHighestRef = lLoop2; } } if (lHighestRef >= 0) { pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint; } dHighest = dTmpHighest; } } while (!bContinue); bFirstRun = false; dHighestPrev = dHighest; lCounter++; IPrintPageInfo page = new PrintPageInfo(); page.Boundary = pGridPoly; page.PageID = lCounter; page.Angle = dGridAngle; page.PageName = "带状图(" + lCounter.ToString() + ")"; page.Scale = _scale; pages.Add(page); pCenterPoint = pIntersectPoint; } while (dHighest < 100); foreach (IPrintPageInfo pageInfo in pages) { pageInfo.TotalCount = pages.Count; } return(pages); }