/// <summary> /// Create a Polyline from two Points /// </summary> /// <param name="pointFrom">Start point</param> /// <param name="pointTo">End point</param> /// <returns>Esri poliline</returns> public static IPolyline CreatePolylineFromPoints(IPoint pointFrom, IPoint pointTo) { if (pointFrom == null || pointTo == null) { return(null); } WKSPoint[] segmentWksPoints = new WKSPoint[2]; segmentWksPoints[0].X = pointFrom.X; segmentWksPoints[0].Y = pointFrom.Y; segmentWksPoints[1].X = pointTo.X; segmentWksPoints[1].Y = pointTo.Y; IPointCollection4 trackLine = new PolylineClass(); IGeometryBridge2 m_geometryBridge = new GeometryEnvironmentClass(); m_geometryBridge.AddWKSPoints(trackLine, ref segmentWksPoints); var result = trackLine as IPolyline; if (pointFrom.SpatialReference != null && pointTo.SpatialReference != null && pointFrom.SpatialReference == pointTo.SpatialReference) { result.SpatialReference = pointFrom.SpatialReference; } return(result); }
/// <summary> /// Create a polygon from a set of /// </summary> /// <param name="envelope"></param> /// <returns></returns> public IPolygon CreatePolygonFromEnvelope(IEnvelope envelope) { // Build a polygon from a sequence of points. IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass(); IPointCollection4 pointCollection4 = new PolygonClass(); // Define the point collection; i.e. polygon verticies List <WKSPoint> wksPoints = new List <WKSPoint>(); wksPoints.Add(new WKSPoint() { X = envelope.LowerLeft.X, Y = envelope.LowerLeft.Y }); wksPoints.Add(new WKSPoint() { X = envelope.UpperLeft.X, Y = envelope.UpperLeft.Y }); wksPoints.Add(new WKSPoint() { X = envelope.UpperRight.X, Y = envelope.UpperRight.Y }); wksPoints.Add(new WKSPoint() { X = envelope.LowerRight.X, Y = envelope.LowerRight.Y }); geometryBridge2.SetWKSPoints(pointCollection4, wksPoints.ToArray()); // Cast point collection to IPolygon IPolygon polygon = pointCollection4 as IPolygon; polygon.SpatialReference = envelope.SpatialReference; polygon.SimplifyPreserveFromTo(); return(polygon); }
public static IPolygon GetVisilityPolygon(IPointCollection points) { IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass(); IPointCollection4 pointCollection4 = new PolygonClass(); WKSPointZ[] aWKSPoints = new WKSPointZ[points.PointCount]; for (int i = 0; i < aWKSPoints.Length; i++) { aWKSPoints[i] = PointToWKSPoint(points.Point[i]); } geometryBridge2.SetWKSPointZs(pointCollection4, ref aWKSPoints); var geometry = pointCollection4 as IGeometry; IZAware zAware = geometry as IZAware; zAware.ZAware = true; var result = pointCollection4 as IPolygon; result.SpatialReference = points.Point[0].SpatialReference; return(result); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add ZoomToSelectedFeatures.OnClick implementation ILayer pLayer = (ILayer)m_mapControl.CustomProperty; IFeatureLayer pFLayer = (IFeatureLayer)pLayer; IFeatureSelection pFSel = (IFeatureSelection)pFLayer; ISelectionSet pSelSet = pFSel.SelectionSet; IEnumGeometry pEnumGeom = new EnumFeatureGeometry(); IEnumGeometryBind pEnumGeomBind = (IEnumGeometryBind)pEnumGeom; pEnumGeomBind.BindGeometrySource(null, pSelSet); IGeometryFactory pGeomFactory = new GeometryEnvironmentClass(); IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom); double dblXPer = (pGeom.Envelope.XMax - pGeom.Envelope.XMin) / 10; double dblYPer = (pGeom.Envelope.YMax - pGeom.Envelope.YMin) / 10; IEnvelope pEnvel = new EnvelopeClass(); pEnvel.PutCoords(pGeom.Envelope.XMin - dblXPer, pGeom.Envelope.YMin - dblYPer, pGeom.Envelope.XMax + dblXPer, pGeom.Envelope.YMax + dblYPer); //envelope1.PutCoords(pFLayer1.AreaOfInterest.Envelope.XMin - (pFLayer1.AreaOfInterest.Envelope.XMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.YMin - (pFLayer1.AreaOfInterest.Envelope.YMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.XMax * 1.0005, pFLayer1.AreaOfInterest.Envelope.YMax * 1.0005); m_mapControl.ActiveView.Extent = pEnvel; m_mapControl.ActiveView.Refresh(); }
//构造偏移点法 private void button7_Click(object sender, EventArgs e) { delFeature("point"); IPoint[] points = new IPoint[4]; for (int i = 0; i < 4; i++) { points[i] = new PointClass(); } points[0].PutCoords(0, 0); points[1].PutCoords(10, 0); points[2].PutCoords(20, 0); points[3].PutCoords(30, 0); IPointCollection polyline = new Polyline(); IGeometryBridge geometryBride = new GeometryEnvironmentClass(); geometryBride.AddPoints(polyline as IPointCollection4, ref points); IConstructPoint constructionPointRight = new PointClass(); IConstructPoint constructionPointLeft = new PointClass(); constructionPointRight.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 15, false, 5); IPoint outPutPoint1 = constructionPointRight as IPoint; constructionPointLeft.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 1, false, -5); IPoint outPutPoint2 = constructionPointLeft as IPoint; addFeature("point", points[0]); addFeature("point", points[1]); addFeature("point", points[2]); addFeature("point", points[3]); addFeature("point", outPutPoint1); addFeature("point", outPutPoint2); axMapControl1.Refresh(); }
/// <summary> /// Converte um array de bytes (WKB) em uma geometria. /// </summary> /// <param name="wkbBytes">O array de bytes (WKIB).</param> /// <returns>A geometria.</returns> public static IGeometry WKBToGeometry(byte[] wkbBytes) { IGeometryFactory3 geometryfactory = new GeometryEnvironmentClass(); IGeometry outputGeometry; int bytesRead; geometryfactory.CreateGeometryFromWkbVariant(wkbBytes, out outputGeometry, out bytesRead); return(outputGeometry); }
/// <summary> /// 显示参考面 张琪 20110629 /// </summary> /// <param name="pPoly">参考多边形</param> private void ShowRefPlane(IPolygon pPoly) { SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条"); try { IGeometry pBoundary = new PolylineClass(); pBoundary = null; IGeometry pPolygon = new PolygonClass(); pPolygon = null; object StepSize = Type.Missing; m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize); Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName); //清除已有的参考面 if (!chkShowLWRP.Checked) //当为false时不显示参考面 { m_pCurrentSceneControl.SceneGraph.RefreshViewers(); return; } vProgress.EnableCancel = false;//设置进度条 vProgress.ShowDescription = true; vProgress.FakeProgress = true; vProgress.TopMost = true; vProgress.ShowProgress(); vProgress.SetProgress("正在绘制参考面"); ITopologicalOperator pTopo = pPolygon as ITopologicalOperator; pBoundary = pTopo.Boundary as IPolyline; //设置Z值方向显示 IZAware pZAware = pBoundary as IZAware; pZAware.ZAware = true; m_SurFace.InterpolateShape(pBoundary as IGeometry, out pBoundary, ref StepSize); m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize); IExtrude pExtrude = new GeometryEnvironmentClass(); //获取参考面的多面体 IMultiPatch pMultiPatchRefPlaneWall = pExtrude.ExtrudeAbsolute(Convert.ToDouble(txtPlaneHeight.Text), pBoundary as IGeometry) as IMultiPatch; pMultiPatchRefPlaneWall.SpatialReference = m_pCurrentSceneControl.Scene.SpatialReference; IZ pZ; pZAware = pPolygon as IZAware; pZAware.ZAware = true; pZ = pPolygon as IZ; pZ.SetConstantZ(Convert.ToDouble(txtPlaneHeight.Text)); //用于绘制三维效果 IGroupElement pGroup = null; Cls3DMarkDraw.AddSimpleGraphic(pMultiPatchRefPlaneWall as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup); Cls3DMarkDraw.AddSimpleGraphic(pPolygon as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup); m_pCurrentSceneControl.SceneGraph.RefreshViewers(); vProgress.Close(); } catch { vProgress.Close(); } }
void activeViewEvents_SelectionChanged() { ///loop through all feature layer and do a partial refresh if the layer is polygon ///This important as selection change only does a partial refresh at geoselection level and since we are drawing polygon at geography phase, this step is essential. IMap m_Map = m_MxDoc.FocusMap; ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID(); m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer m_EnumLayer = m_Map.Layers[m_UID]; ILayer m_Layer = m_EnumLayer.Next(); IActiveView m_activeview = (IActiveView)m_MxDoc.ActivatedView; do { if (m_Layer is IFeatureLayer) { if (m_Layer != null) { if (m_Layer.Visible == true) { IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer; ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet; if (m_SelSet.Count > 0) { IEnumGeometry m_EnumGeo; IEnumGeometryBind m_EnumGeoBind; m_EnumGeo = new EnumFeatureGeometry(); m_EnumGeoBind = (IEnumGeometryBind)m_EnumGeo; m_EnumGeoBind.BindGeometrySource(null, m_SelSet); IGeometryFactory m_GeoFactory = new GeometryEnvironmentClass(); IGeometry m_GeoEnvelop = m_GeoFactory.CreateGeometryFromEnumerator(m_EnumGeo); m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_GeoEnvelop.Envelope); } else { m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } } } } m_Layer = m_EnumLayer.Next(); } while (m_Layer != null); }
private IPolygon CreatePolygonByPoints(IPointCollection pCol) { IGeometryBridge2 gb2 = new GeometryEnvironmentClass(); IPointCollection4 pPolygon = new PolygonClass(); WKSPoint[] pWKSPoint = new WKSPoint[pCol.PointCount]; for (int i = 0; i < pCol.PointCount; i++) { pWKSPoint[i].X = pCol.get_Point(i).X; pWKSPoint[i].Y = pCol.get_Point(i).Y; } gb2.SetWKSPoints(pPolygon, ref pWKSPoint); IPolygon poly = pPolygon as IPolygon; poly.Close(); return(poly); }
private void btn_showBuilding3D_Click(object sender, EventArgs e) { m_pSceneCtl.Scene.AddLayer(GetFeatureLayerByName("Building3D")); IFeatureLayer pFeatureLayer = m_pSceneCtl.Scene.Layer[0] as IFeatureLayer; IExtrude pExtrude = new GeometryEnvironmentClass() as IExtrude; IFeatureCursor pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); while (pFeature != null) { pExtrude.ExtrudeFromTo(0, (double)pFeature.get_Value(3), pFeature.Shape); pFeature = pFeatureCursor.NextFeature(); } pFea //m_pSceneCtl.SceneGraph.RefreshViewers(); }
/// <summary> /// 通过点集创建线段(IPolyline对象) /// </summary> /// <param name="pts"></param> /// <returns></returns> public static IPolyline CreatePolyline(IPoint[] pts) { var segments = new List <ISegment>();//存放单条线的每一段(Line对象) for (int i = 0; i < pts.Length - 1; i++) { Line line = new LineClass(); line.PutCoords(pts[i], pts[i + 1]); segments.Add((ISegment)line); } ISegment[] segmentArray = segments.ToArray();//存放单条线的每一段(Line对象) ISegmentCollection segmentCollection = new PolylineClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddSegments(segmentCollection, ref segmentArray); IPolyline polyLine = segmentCollection as IPolyline; return(polyLine); }
//查询Segment private void querySegmentsToolStripMenuItem_Click(object sender, EventArgs e) { ISegment[] segmentArray = new ISegment[10]; for (int i = 0; i < 10; i++) { ILine line = new LineClass(); IPoint fromPoint = new PointClass(); fromPoint.PutCoords(i * 10, i * 10); IPoint toPoint = new PointClass(); toPoint.PutCoords(i * 15, i * 15); line.PutCoords(fromPoint, toPoint); segmentArray[i] = line as ISegment; } ISegmentCollection segmentCollection = new PolylineClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddSegments(segmentCollection, ref segmentArray); int index = 0; ISegment[] outputSegmentArray = new ISegment[segmentCollection.SegmentCount - index]; for (int i = 0; i < outputSegmentArray.Length; i++) { outputSegmentArray[i] = new LineClass(); } //查询Segment geometryBridge.QuerySegments(segmentCollection, index, ref outputSegmentArray); String report = ""; for (int i = 0; i < outputSegmentArray.Length; i++) { ISegment currentSegment = outputSegmentArray[i]; ILine currentLine = currentSegment as ILine; report = report + "index = " + i + " , FromPoint X = " + currentLine.FromPoint.X + " , FromPoint Y = " + currentLine.FromPoint.X; report = report + " , ToPoint X = " + currentLine.ToPoint.X + " , ToPoint Y = " + currentLine.ToPoint.X + "\n"; } System.Windows.Forms.MessageBox.Show(report); }
//用实体数组取代实体集中的实体对象 private void setGeometriesToolStripMenuItem_Click(object sender, EventArgs e) { IGeometryCollection geometryCollection1 = new MultipointClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); IGeometry[] geometryArray = new IGeometry[10]; IMultipoint multipoint; object missing = Type.Missing; IPoint point; for (int i = 0; i < 10; i++) { point = new PointClass(); point.PutCoords(i * 2, i * 2); geometryArray[i] = point as IGeometry; } geometryBridge.SetGeometries(geometryCollection1, ref geometryArray); multipoint = geometryCollection1 as IMultipoint; addFeature("multipoint", multipoint as IGeometry); this.axMapControl1.Extent = multipoint.Envelope; this.axMapControl1.Refresh(); }
private void queryPointsToolStripMenuItem_Click(object sender, EventArgs e) { IPoint point1 = new PointClass(); point1.PutCoords(10, 10); IPoint point2 = new PointClass(); point2.PutCoords(20, 20); IPoint[] inputPointArray = new IPoint[2]; inputPointArray[0] = point1; inputPointArray[1] = point2; IPointCollection4 pointCollection = new MultipointClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddPoints(pointCollection, ref inputPointArray); int index = 0; IPoint[] outputPointArray = new IPoint[2]; for (int i = 0; i < outputPointArray.Length; i++) { outputPointArray[i] = new PointClass(); } pointCollection.QueryPoint(0, outputPointArray[0]); //geometryBridge.QueryPoints(pointCollection, index, ref outputPointArray); for (int i = 0; i < outputPointArray.Length; i++) { IPoint currentPoint = outputPointArray[i]; if (currentPoint.IsEmpty == true) { System.Windows.Forms.MessageBox.Show("Current point = null"); } else { System.Windows.Forms.MessageBox.Show("X = " + currentPoint.X + ", Y = " + currentPoint.Y); } } }
//高亮显示查询到的要素集合 private void ZoomToSelectedFeature(IFeatureLayer pFeatureLyr, IQueryFilter pQueryFilter) { //符号边线颜色 IRgbColor pLineColor = new RgbColor(); pLineColor.Green = 130; ILineSymbol ilSymbl = new SimpleLineSymbolClass(); ilSymbl.Color = pLineColor; ilSymbl.Width = 3; //定义选中要素的符号为红色 ISimpleFillSymbol ipSimpleFillSymbol = new SimpleFillSymbol(); ipSimpleFillSymbol.Outline = ilSymbl; RgbColor pFillColor = new RgbColor(); pFillColor.Green = 60; ipSimpleFillSymbol.Color = pFillColor; ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; //选取要素集 IFeatureSelection pFtSelection = pFeatureLyr as IFeatureSelection; pFtSelection.SetSelectionSymbol = true; pFtSelection.SelectionSymbol = (ISymbol)ipSimpleFillSymbol; pFtSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); ISelectionSet pSelectionSet = pFtSelection.SelectionSet; //居中显示选中要素 IEnumGeometry pEnumGeom = new EnumFeatureGeometry(); IEnumGeometryBind pEnumGeomBind = pEnumGeom as IEnumGeometryBind; pEnumGeomBind.BindGeometrySource(null, pSelectionSet); IGeometryFactory pGeomFactory = new GeometryEnvironmentClass(); IGeometry pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom); MyMapControl.ActiveView.Extent = pGeom.Envelope; MyMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); }
private void setSegmentsToolStripMenuItem_Click(object sender, EventArgs e) { IPolyline polyline = new PolylineClass(); ISegmentCollection segmentCollection = new PolylineClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); ISegment[] insertSegmentArray = new ISegment[5]; for (int i = 0; i < 5; i++) { ILine insertLine = new LineClass(); IPoint insertFromPoint = new PointClass(); insertFromPoint.PutCoords(i, 1); IPoint insertToPoint = new PointClass(); insertToPoint.PutCoords(i * 10, 1); insertLine.PutCoords(insertFromPoint, insertToPoint); insertSegmentArray[i] = insertLine as ISegment; } geometryBridge.SetSegments(segmentCollection, ref insertSegmentArray); polyline = segmentCollection as IPolyline; addFeature("polyline", polyline as IGeometry); this.axMapControl1.Extent = polyline.Envelope; this.axMapControl1.Refresh(); }
private IPolyline6 ConstructSpiralbyDeltaAngle(IPoint theFromPoint, IPoint theTangentpoint, double theFromCurvature, double theToCurvature, bool isCCW, double theSpiralDeltaAngle, esriCurveDensifyMethod DensifyMethod, double theCurveDensity, out double ExitTangent) { //the parameter name "curvature" is actually the inverse of the radius. Infinity radius is 0 curvature. ExitTangent = 0; IPolyline6 thePolyLine = new PolylineClass() as IPolyline6; try { IGeometryEnvironment4 theGeometryEnvironment = new GeometryEnvironmentClass(); IConstructClothoid TheSpiralConstruction = theGeometryEnvironment as IConstructClothoid; thePolyLine = TheSpiralConstruction.ConstructClothoidByAngle(theFromPoint, theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralDeltaAngle, DensifyMethod, theCurveDensity) as IPolyline6; //now use the Query on the same Spiral, to get the precise exit tangent double dCurvature; double dSplitLength; double dSplitAngle; ILine pExitTangentLine; if (thePolyLine != null) { TheSpiralConstruction.ConstructSplitClothoidByAngle(thePolyLine.ToPoint, theFromPoint, theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralDeltaAngle, out dCurvature, out dSplitLength, out dSplitAngle, out pExitTangentLine); ExitTangent = pExitTangentLine.Angle; //returns polar azimuth in radians } return(thePolyLine); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
private IGeometry BufferBoundary(IRing currentRing, double bufferDistance, bool draw) { ISegmentCollection polyline = new PolylineClass() as ISegmentCollection; ISegmentCollection ringSegmentCollection = currentRing as ISegmentCollection; List <ISegment> ringSegments = new List <ISegment>(); for (int i = 0; i < ringSegmentCollection.SegmentCount; i++) { ringSegments.Add(ringSegmentCollection.get_Segment(i)); } ISegment[] ringSegmentsArray = ringSegments.ToArray(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddSegments(polyline, ref ringSegmentsArray); ITopologicalOperator topoBndBuffer = polyline as ITopologicalOperator; IGeometry bndBuffer = topoBndBuffer.Buffer(bufferDistance); if (draw) { DrawGraphics(bndBuffer); } return(bndBuffer); }
private void addPointCollectionToolStripMenuItem_Click(object sender, EventArgs e) { IPointCollection4 pointCollection = new MultipointClass(); IPointCollection pointCollection2 = new MultipointClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); IPoint[] points = new PointClass[10]; IMultipoint multipoint; object missing = Type.Missing; IPoint point; for (int i = 0; i < 10; i++) { point = new PointClass(); point.PutCoords(i * 5, i); points[i] = point; } geometryBridge.SetPoints(pointCollection, ref points); pointCollection2.AddPointCollection(pointCollection); multipoint = pointCollection2 as IMultipoint; addFeature("multipoint", multipoint as IGeometry); this.axMapControl1.Extent = multipoint.Envelope; this.axMapControl1.Refresh(); }
//创建线对象 private void CreatePolyline() { ISegment[] segmentArray = new ISegment[10]; IPolyline polyline = new PolylineClass(); for (int i = 0; i < 10; i++) { ILine line = new LineClass(); IPoint fromPoint = new PointClass(); fromPoint.PutCoords(i * 10, i * 10); IPoint toPoint = new PointClass(); toPoint.PutCoords(i * 15, i * 15); line.PutCoords(fromPoint, toPoint); segmentArray[i] = line as ISegment; } ISegmentCollection segmentCollection = new PolylineClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); geometryBridge.AddSegments(segmentCollection, ref segmentArray); polyline = segmentCollection as IPolyline; addFeature("polyline", polyline as IGeometry); this.axMapControl1.Extent = polyline.Envelope; this.axMapControl1.Refresh(); }
private List<IGeometry> splitGeometry(IGeometry geo,bool mergePolys) { IGeometry geoM = null; if (mergePolys) { geoM = mergeSmallGeos(geo); } else { geoM = geo; } List<IGeometry> geoLst = new List<IGeometry>(); IPolygon4 poly4 = (IPolygon4)geoM; IGeometryCollection geoColl = (IGeometryCollection)poly4.ConnectedComponentBag; for (int i = 0; i < geoColl.GeometryCount; i++) { IGeometry geo2 = geoColl.get_Geometry(i); IEnvelope env = geo2.Envelope; double xmax = env.XMax; double xmin = env.XMin; double ymax = env.YMax; double ymin = env.YMin; double xRange = xmax - xmin; double yRange = ymax - ymin; double nMinX, nMinY, nMaxX, nMaxY; if (xRange > yRange) { nMinY = ymin - 1; nMaxY = ymax + 1; nMinX = xmin + (xRange / 2); nMaxX = nMinX; } else { nMinX = xmin - 1; nMaxX = xmax + 1; nMinY = ymin + (yRange / 2); nMaxY = nMinY; } WKSPoint[] wksPoint = new WKSPoint[2]; IPointCollection4 pointCollection4 = new PolylineClass(); wksPoint[0].X = nMinX; wksPoint[0].Y = nMinY; wksPoint[1].X = nMaxX; wksPoint[1].Y = nMaxY; IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass(); geometryBridge2.AddWKSPoints(pointCollection4, ref wksPoint); IPolyline polyline = pointCollection4 as ESRI.ArcGIS.Geometry.IPolyline; polyline.SpatialReference = geo2.SpatialReference; ITopologicalOperator4 tp = (ITopologicalOperator4)geo2; IGeometry geoL = null; IGeometry geoR = null; try { tp.Cut(polyline, out geoL, out geoR); if (((IArea)geoL).Area > maxarea) { geoLst.AddRange(splitGeometry(geoL,false)); } else { geoLst.Add(geoL); } if (((IArea)geoR).Area > maxarea) { geoLst.AddRange(splitGeometry(geoR,false)); } else { geoLst.Add(geoR); } } catch (Exception e) { geoLst.Add(geo2); Console.WriteLine(e.ToString()); } } return geoLst; }
/// <summary> /// 删除几何形状指定的顶点。 /// 顶点的会与几何形状的顶点进行IPoint::Compare比较, /// 因此顶点必须是通过几何形状的顶点获取,才能成功删除。 /// 如果删除的结果导致几何形状为空,则几何形状接口不为空,只是setEmpty。 /// </summary> /// <param name="geometry">需要删除顶点的ESRI几何形状接口</param> /// <param name="point">指定要删除的顶点ESRI点接口</param> /// <returns>是否成功删除</returns> public static bool GeometryRemoveVertex(IGeometry geometry, IPoint point) { bool deleted = false; if (IsValidGeometry(geometry) && IsValidGeometry(point)) { switch (geometry.GeometryType) { case esriGeometryType.esriGeometryPoint: #region 点几何形状 if (geometry is IPoint) { if ((geometry as IPoint).Compare(point) == 0) { geometry.SetEmpty(); deleted = true; } } #endregion break; case esriGeometryType.esriGeometryMultipoint: #region 多点几何形状 if (geometry is IPointCollection) { for (int i = 0; i <= (geometry as IPointCollection).PointCount - 1; i++) { if ((geometry as IPointCollection).get_Point(i).Compare(point) == 0) { (geometry as IPointCollection).RemovePoints(i, 1); deleted = true; break; } } } #endregion break; case esriGeometryType.esriGeometryPolyline: #region 多义线几何形状 if (geometry is IPointCollection) { for (int i = 0; i <= (geometry as IPointCollection).PointCount - 1; i++) { if ((geometry as IPointCollection).get_Point(i).Compare(point) == 0) { (geometry as IPointCollection).RemovePoints(i, 1); deleted = true; break; } } } #endregion break; case esriGeometryType.esriGeometryPolygon: #region 面几何形状 if (geometry is IGeometryCollection) { bool removed = false; for (int i = 0; i <= (geometry as IGeometryCollection).GeometryCount - 1; i++) { IGeometry partGeom = (geometry as IGeometryCollection).get_Geometry(i); if (IsValidGeometry(partGeom) && partGeom is IRing && partGeom is IPointCollection) { if ((partGeom as IRing).IsClosed) { #region 闭合的环(在编辑草图中存在) if ((partGeom as IRing).FromPoint.Compare(point) == 0 || (partGeom as IRing).ToPoint.Compare(point) == 0) { if ((partGeom as IPointCollection).PointCount <= 2) { partGeom = null; removed = true; } else { IPoint startPoint = (partGeom as IPointCollection).get_Point(1); (partGeom as IPointCollection).RemovePoints((partGeom as IPointCollection).PointCount - 1, 1); (partGeom as IPointCollection).RemovePoints(0, 1); //(partGeom as IRing).FromPoint = startPoint; (partGeom as IRing).Close(); removed = true; } } else { for (int j = 0; j <= (partGeom as IPointCollection).PointCount - 1; j++) { if ((partGeom as IPointCollection).get_Point(j).Compare(point) == 0) { (partGeom as IPointCollection).RemovePoints(j, 1); removed = true; break; } } } #endregion } else { #region 非闭合的环(在编辑草图中应该不存在) for (int j = 0; j <= (partGeom as IPointCollection).PointCount - 1; j++) { if ((partGeom as IPointCollection).get_Point(j).Compare(point) == 0) { (partGeom as IPointCollection).RemovePoints(j, 1); removed = true; break; } } #endregion } } if (removed) { (geometry as IGeometryCollection).RemoveGeometries(i, 1); if (IsValidGeometry(partGeom)) { IGeometryCollection geometryCollection = new MultipointClass(); IGeometryBridge geometryBridge = new GeometryEnvironmentClass(); IGeometry[] geometryArray = { partGeom }; geometryBridge.InsertGeometries((IGeometryCollection)geometry, i, ref geometryArray); } deleted = true; break; } } } #endregion break; default: break; } } return(deleted); }
private void btnOK_Click(object sender, EventArgs e) { IEnvelope extent; if (this.rdoCurrentMapExtend.Checked) { extent = (this.Map as IActiveView).Extent; this.ClipGeometry = extent; } else if (this.rdoCustomExtend.Checked) { double num; double num2; double num3; double num4; if (!double.TryParse(this.txtBottom.Text, out num)) { MessageBox.Show("底部值输入错误!"); return; } if (!double.TryParse(this.txtLeft.Text, out num2)) { MessageBox.Show("左边值输入错误!"); return; } if (!double.TryParse(this.txtTop.Text, out num3)) { MessageBox.Show("顶部值输入错误!"); return; } if (!double.TryParse(this.txtRight.Text, out num4)) { MessageBox.Show("右边值输入错误!"); return; } extent = new EnvelopeClass { XMin = num2, XMax = num4, YMax = num3, YMin = num }; this.ClipGeometry = extent; } else if (this.rdoLayerExtend.Checked) { IEnumGeometry geometry; ITopologicalOperator @operator; if (this.cboLayers.SelectedIndex == -1) { MessageBox.Show("请选择图层!"); return; } extent = null; ILayer layer = (this.cboLayers.SelectedItem as LayerObject).Layer; if (this.cboFeatures.SelectedIndex == 0) { geometry = new EnumFeatureGeometryClass(); (geometry as IEnumGeometryBind).BindGeometrySource(null, (layer as IGeoFeatureLayer).FeatureClass); @operator = new PolygonClass(); @operator.ConstructUnion(geometry); this.ClipGeometry = @operator as IGeometry; } else if (this.cboFeatures.SelectedIndex == 1) { IQueryFilter outputFilter = new SpatialFilterClass(); (outputFilter as ISpatialFilter).Geometry = this.Extend; (outputFilter as ISpatialFilter).SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; geometry = new EnumFeatureGeometryClass(); (geometry as IEnumGeometryBind).BindGeometrySource(outputFilter, (layer as IGeoFeatureLayer).FeatureClass); IGeometryFactory3 factory = new GeometryEnvironmentClass(); IGeometry geometry2 = factory.CreateGeometryFromEnumerator(geometry); int geometryCount = (geometry2 as IGeometryCollection).GeometryCount; @operator = new PolygonClass(); @operator.ConstructUnion(geometry2 as IEnumGeometry); this.ClipGeometry = @operator as IGeometry; } else { geometry = new EnumFeatureGeometryClass(); (geometry as IEnumGeometryBind).BindGeometrySource(null, (layer as IFeatureSelection).SelectionSet); @operator = new PolygonClass(); @operator.ConstructUnion(geometry); this.ClipGeometry = @operator as IGeometry; } } else { this.ClipGeometry = this.method_3(this.Map as IGraphicsContainerSelect); } base.DialogResult = DialogResult.OK; }
private void ZoomSelected() { if ((_hluFeatureClass == null) || (_hluView == null)) return; if (_hluFeatureSelection == null) _hluFeatureSelection = (IFeatureSelection)_hluFeatureClass; if (_hluFeatureSelection.SelectionSet.Count == 0) return; IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass(); enumGeometryBind.BindGeometrySource(null, _hluFeatureSelection.SelectionSet); IGeometryFactory geometryFactory = new GeometryEnvironmentClass(); IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind); _hluView.Extent = geom.Envelope; _hluView.PartialRefresh(esriViewDrawPhase.esriViewGeography, _hluLayer, _hluView.Extent); }
private void FlashFeature(IQueryFilter queryFilter) { if (_pipeData == null) _pipeData = new List<string>(); else _pipeData.Clear(); try { //--------------------------------------------------------------------- // CHANGED: CR23 (Merged features) // Flash all the features relating to the selected incid at once. // This method may be triggered more than once if there are too // many to pass via the Named Pipes in one go. // IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass(); enumGeometryBind.BindGeometrySource(null, _hluFeatureSelection.SelectionSet.Select(queryFilter, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, null)); IGeometryFactory geometryFactory = new GeometryEnvironmentClass(); IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind); IMxDocument mxDoc = (IMxDocument)_application.Document; IActiveView activeView = mxDoc.FocusMap as IActiveView; IScreenDisplay screenDisplay = activeView.ScreenDisplay; //--------------------------------------------------------------------- //--------------------------------------------------------------------- // FIX: 018 Bring ArcGIS and MapInfo into line by flashing all features twice FlashGeometry(geom, screenDisplay, 300, 2); //--------------------------------------------------------------------- } catch { } }
void m_editEvents_OnCreateFeature(IObject obj) { // check if feature contains more than 2000 nodes/vertices // applies to lines and polygons // notify the user and offer a split // check if feature geometry is multi-part // applies to lines and polygons // notify the user and offer a conversion to relation IFeatureClass currentObjectFeatureClass = obj.Class as IFeatureClass; if ((currentObjectFeatureClass == null) || (currentObjectFeatureClass.EXTCLSID == null)) return; // check if the current feature class being edited is acutally an OpenStreetMap feature class // all other feature class should not be touched by this extension UID osmEditorExtensionCLSID = currentObjectFeatureClass.EXTCLSID; if (osmEditorExtensionCLSID.Value.ToString().Equals("{65CA4847-8661-45eb-8E1E-B2985CA17C78}", StringComparison.InvariantCultureIgnoreCase) == false) { return; } IFeature currentFeature = obj as IFeature; if (currentFeature == null) return; ISegmentCollection segmentCollection = currentFeature.Shape as ISegmentCollection; bool densifyRequired = false; if (segmentCollection != null) { for (int segmentIndex = 0; segmentIndex < segmentCollection.SegmentCount; segmentIndex++) { ISegment segment = segmentCollection.get_Segment(segmentIndex); if (!(segment is Line)) { densifyRequired = true; break; } } } if (densifyRequired) { IGeometryEnvironment4 geometryEnvironment = new GeometryEnvironmentClass() as IGeometryEnvironment4; double densifyTolerance = geometryEnvironment.AutoDensifyTolerance; double deviationTolerance = geometryEnvironment.DeviationAutoDensifyTolerance; IPolycurve polycurve = currentFeature.Shape as IPolycurve; polycurve.Densify(densifyTolerance, deviationTolerance); currentFeature.Shape = polycurve; obj.Store(); } }
// zooms to features in the map that correspond to selected features in the list view private void btnZoomSelected_Click(object sender, System.EventArgs e) { try { IQueryFilter pQueryFilter = new QueryFilterClass(); IFeatureClass pFeatureClass = m_pFeatureLayer.FeatureClass; // build array of selected OIDs string[] OID = new string[lvGPS.SelectedItems.Count]; for(int x = 0; x < lvGPS.SelectedItems.Count; x++) { OID[x] = lvGPS.SelectedItems[x].Text; } string OIDs = String.Join(",",OID); // build the whereclause string whereclause = pFeatureClass.OIDFieldName + " IN (" + OIDs + ")"; Debug.WriteLine(whereclause); pQueryFilter.WhereClause = whereclause; // bind query filter resultant geometry into a geometry bag IEnumGeometryBind pEnumBind = new EnumFeatureGeometryClass(); IGeometryFactory pGeomFactory = new GeometryEnvironmentClass(); pEnumBind.BindGeometrySource(pQueryFilter,pFeatureClass); IGeometryBag pGeometryBag = (IGeometryBag)pGeomFactory.CreateGeometryFromEnumerator((IEnumGeometry)pEnumBind); IGeometryCollection pGeomCollection = (IGeometryCollection)pGeometryBag; // TODO: //IMxDocument pMxDoc = (IMxDocument)m_pApp.Document; IActiveView pActiveView = (IActiveView)m_pISDUTExt.FocusMap; //pMxDoc.FocusMap; //util.Utils.Release(pMxDoc); IEnvelope pEnv = pGeometryBag.Envelope; if(pGeomCollection.GeometryCount == 1) { // if only one point the do a pan instead of a zoom IPoint pPoint = new PointClass(); pPoint.PutCoords(pEnv.XMin,pEnv.YMin); // get SR of featureclass IGeoDataset pGeodataset = (IGeoDataset)m_pFeatureLayer.FeatureClass; pPoint.SpatialReference = pGeodataset.SpatialReference; // project point to match focus map SR // TODO: //pMxDoc = (IMxDocument)m_pApp.Document; pPoint.Project(m_pISDUTExt.FocusMap.SpatialReference);// pMxDoc.FocusMap.SpatialReference); //util.Utils.Release(pMxDoc); IEnvelope pPanEnv = pActiveView.Extent; pPanEnv.CenterAt(pPoint); pActiveView.Extent = pPanEnv; } else { pEnv.Expand(1.1,1.1,true); pActiveView.Extent = pEnv; } pActiveView.Refresh(); } catch(Exception ex) { util.Logger.Write(" Descrip : Zooms to features on the map the correspond with items selected in the list view." + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); MessageBox.Show(ex.Message + "\n" + ex.StackTrace); Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); } //lvGPS.Focus(); }
/// <summary> /// Create a polygon from a set of /// </summary> /// <param name="envelope"></param> /// <returns></returns> public IPolygon CreatePolygonFromEnvelope(IEnvelope envelope) { // Build a polygon from a sequence of points. IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass(); IPointCollection4 pointCollection4 = new PolygonClass(); // Define the point collection; i.e. polygon verticies List<WKSPoint> wksPoints = new List<WKSPoint>(); wksPoints.Add(new WKSPoint() { X = envelope.LowerLeft.X, Y = envelope.LowerLeft.Y }); wksPoints.Add(new WKSPoint() { X = envelope.UpperLeft.X, Y = envelope.UpperLeft.Y }); wksPoints.Add(new WKSPoint() { X = envelope.UpperRight.X, Y = envelope.UpperRight.Y }); wksPoints.Add(new WKSPoint() { X = envelope.LowerRight.X, Y = envelope.LowerRight.Y }); geometryBridge2.SetWKSPoints(pointCollection4, wksPoints.ToArray()); // Cast point collection to IPolygon IPolygon polygon = pointCollection4 as IPolygon; polygon.SpatialReference = envelope.SpatialReference; polygon.SimplifyPreserveFromTo(); return polygon; }
void m_editEvents_OnCreateFeature(IObject obj) { // check if feature contains more than 2000 nodes/vertices // applies to lines and polygons // notify the user and offer a split // check if feature geometry is multi-part // applies to lines and polygons // notify the user and offer a conversion to relation IFeatureClass currentObjectFeatureClass = obj.Class as IFeatureClass; if ((currentObjectFeatureClass == null) || (currentObjectFeatureClass.EXTCLSID == null)) { return; } // check if the current feature class being edited is acutally an OpenStreetMap feature class // all other feature class should not be touched by this extension UID osmEditorExtensionCLSID = currentObjectFeatureClass.EXTCLSID; if (osmEditorExtensionCLSID.Value.ToString().Equals("{65CA4847-8661-45eb-8E1E-B2985CA17C78}", StringComparison.InvariantCultureIgnoreCase) == false) { return; } IFeature currentFeature = obj as IFeature; if (currentFeature == null) { return; } ISegmentCollection segmentCollection = currentFeature.Shape as ISegmentCollection; bool densifyRequired = false; if (segmentCollection != null) { for (int segmentIndex = 0; segmentIndex < segmentCollection.SegmentCount; segmentIndex++) { ISegment segment = segmentCollection.get_Segment(segmentIndex); if (!(segment is Line)) { densifyRequired = true; break; } } } if (densifyRequired) { IGeometryEnvironment4 geometryEnvironment = new GeometryEnvironmentClass() as IGeometryEnvironment4; double densifyTolerance = geometryEnvironment.AutoDensifyTolerance; double deviationTolerance = geometryEnvironment.DeviationAutoDensifyTolerance; IPolycurve polycurve = currentFeature.Shape as IPolycurve; polycurve.Densify(densifyTolerance, deviationTolerance); currentFeature.Shape = polycurve; obj.Store(); } }
void m_editEvents_OnChangeFeature(IObject obj) { // check if feature contains more than 2000 nodes/vertices // applies to lines and polygons // notify the user and offer a split // check if feature geometry is multi-part // applies to lines and polygons // notify the user and offer a conversion to relation IFeatureClass currentObjectFeatureClass = obj.Class as IFeatureClass; if ((currentObjectFeatureClass == null) || (currentObjectFeatureClass.EXTCLSID == null)) { return; } // check if the current feature class being edited is acutally an OpenStreetMap feature class // all other feature class should not be touched by this extension UID osmEditorExtensionCLSID = currentObjectFeatureClass.EXTCLSID; if (osmEditorExtensionCLSID.Value.ToString().Equals("{65CA4847-8661-45eb-8E1E-B2985CA17C78}", StringComparison.InvariantCultureIgnoreCase) == false) { return; } IFeature currentFeature = obj as IFeature; if (currentFeature == null) { return; } IPointCollection pointCollection = currentFeature.Shape as IPointCollection; if (pointCollection == null) { return; } // block changing features that are supporting features for multi-part geometries (relations) if (currentFeature.Shape is IPolygon || currentFeature.Shape is IPolyline) { if (((IFeatureChanges)currentFeature).ShapeChanged == true) { int memberOFFieldIndex = currentFeature.Fields.FindField("osmMemberOf"); int membersFieldIndex = currentFeature.Fields.FindField("osmMembers"); int osmIDFieldIndex = currentFeature.Fields.FindField("OSMID"); long osmID = 0; if (osmIDFieldIndex > -1) { object osmIDValue = currentFeature.get_Value(osmIDFieldIndex); if (osmIDValue != DBNull.Value) { osmID = Convert.ToInt64(osmIDValue); } } if (membersFieldIndex > -1) { ESRI.ArcGIS.OSM.OSMClassExtension.member[] relationMembers = _osmUtility.retrieveMembers(currentFeature, membersFieldIndex); if (relationMembers != null) { if (relationMembers.Length > 0) { string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_multipartchangeparentconflictmessage"), osmID); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); } } } if (memberOFFieldIndex > -1) { List <string> isMemberOfList = _osmUtility.retrieveIsMemberOf(currentFeature, memberOFFieldIndex); Dictionary <string, string> dictofParentsAndTypes = _osmUtility.parseIsMemberOfList(isMemberOfList); StringBuilder typeAndIDString = new StringBuilder(); foreach (var item in dictofParentsAndTypes) { switch (item.Value) { case "rel": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_relationidtext") + item.Key + ","); break; case "ply": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polygonidtext") + item.Key + ","); break; case "ln": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polylineidtext") + item.Key + ","); break; case "pt": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_pointidtext") + item.Key + ","); break; default: break; } } if (typeAndIDString.Length > 0) { string parentsString = typeAndIDString.ToString(0, typeAndIDString.Length - 1); string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_multipartchangeconflictmessage"), osmID, parentsString); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); } } } } ISegmentCollection segmentCollection = currentFeature.Shape as ISegmentCollection; bool densifyRequired = false; for (int segmentIndex = 0; segmentIndex < segmentCollection.SegmentCount; segmentIndex++) { ISegment segment = segmentCollection.get_Segment(segmentIndex); if (!(segment is Line)) { densifyRequired = true; break; } } if (densifyRequired) { IGeometryEnvironment4 geometryEnvironment = new GeometryEnvironmentClass() as IGeometryEnvironment4; double densifyTolerance = geometryEnvironment.AutoDensifyTolerance; double deviationTolerance = geometryEnvironment.DeviationAutoDensifyTolerance; IPolycurve polycurve = currentFeature.Shape as IPolycurve; polycurve.Densify(densifyTolerance, deviationTolerance); currentFeature.Shape = polycurve; obj.Store(); } }
private byte[] AreasAndLengthsHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requesetProperties, out string responseProperties) { responseProperties = null; var errors = new ResponseContainer(HttpStatusCode.BadRequest, ""); string base64Geometry; var found = operationInput.TryGetString("geometry", out base64Geometry); if (!found || string.IsNullOrEmpty(base64Geometry)) { errors.Message = "geometry parameter is required."; return Json(errors); } #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "AreasAndLengthsHandler", MessageCode, "Params received"); #endif IGeometry geometry; int read; var factory = new GeometryEnvironmentClass() as IGeometryFactory3; factory.CreateGeometryFromWkbVariant(Convert.FromBase64String(base64Geometry), out geometry, out read); var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); if (geometry.SpatialReference == null) { //Create a projected coordinate system and define its domain, resolution, and x,y tolerance. var spatialReferenceResolution = spatialReferenceFactory.CreateProjectedCoordinateSystem(3857) as ISpatialReferenceResolution; spatialReferenceResolution.ConstructFromHorizon(); var spatialReferenceTolerance = spatialReferenceResolution as ISpatialReferenceTolerance; spatialReferenceTolerance.SetDefaultXYTolerance(); var spatialReference = spatialReferenceResolution as ISpatialReference; geometry.SpatialReference = spatialReference; } #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "AreasAndLengthsHandler", MessageCode, "Geometry converted"); #endif if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon) { var filterGeometry = (ITopologicalOperator4)geometry; filterGeometry.IsKnownSimple_2 = false; filterGeometry.Simplify(); if (((IArea)geometry).Area < 0) { ((ICurve)geometry).ReverseOrientation(); } } var utmResolution = spatialReferenceFactory.CreateProjectedCoordinateSystem(26912) as ISpatialReferenceResolution; utmResolution.ConstructFromHorizon(); var utmTolerance = utmResolution as ISpatialReferenceTolerance; utmTolerance.SetDefaultXYTolerance(); var utmSr = utmResolution as ISpatialReference; geometry.Project(utmSr); var size = 0D; switch (geometry.GeometryType) { case esriGeometryType.esriGeometryPolygon: size = ((IArea) geometry).Area; break; case esriGeometryType.esriGeometryPolyline: size = ((IPolyline5) geometry).Length; break; } #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "AreasAndLengthsHandler", MessageCode, string.Format("Returning size {0}", size.ToString(CultureInfo.InvariantCulture))); #endif return Json(new ResponseContainer<SizeResponse>(new SizeResponse(size))); }
private bool UpdateCircularArcValues(IFeatureClass LineTable, IQueryFilter QueryFilter, bool Unversioned, IDictionary<int, InferredCurve> CurveLookup, myProgessor progressor, Dictionary<int, int> MaxSequenceCache) { IFeature pLineFeat = null; IFeatureBuffer buffer = null; IFeatureCursor pLineCurs = null; IFeatureCursor pRadialCur = null; IFeatureCursor maxCursor = null; IDataStatistics dataStatistics = null; IGeometryFactory3 geometryFactory = new GeometryEnvironmentClass(); IGeometry geometry = new PolylineClass(); geometryFactory.CreateEmptyGeometryByType(LineTable.ShapeType, out geometry); IGeometryDef geometryDef = LineTable.Fields.get_Field(LineTable.FindField(LineTable.ShapeFieldName)).GeometryDef; if (geometryDef.HasZ) { IZAware zAware = (IZAware)(geometry); zAware.ZAware = true; } if (geometryDef.HasM) { IMAware mAware = (IMAware)(geometry); mAware.MAware = true; } try { CurveByInferenceSettings.FieldPositions positions = new CurveByInferenceSettings.FieldPositions((ITable)LineTable); buffer = LineTable.CreateFeatureBuffer(); pLineCurs = LineTable.Update(QueryFilter, false); pRadialCur = LineTable.Insert(false); while ((pLineFeat = pLineCurs.NextFeature()) != null) { //loop through all of the given lines, and update centerpoint ids, radius, and arc length values if (!progressor.Continue()) return false; progressor.Step(); InferredCurve curveInfo = CurveLookup[pLineFeat.OID]; pLineFeat.set_Value(positions.RadiusFieldIdx, curveInfo.InferredRadius); pLineFeat.set_Value(positions.CenterpointIDFieldIdx, curveInfo.InferredCenterpointID); IFeature feature = pLineFeat as IFeature; double length = 0; if (feature != null) { IPolyline polyline = feature.ShapeCopy as IPolyline; if (polyline != null) { length = ((IProximityOperator)polyline.FromPoint).ReturnDistance(polyline.ToPoint); pLineFeat.set_Value(positions.ArcLengthFieldIdx, length); Marshal.ReleaseComObject(polyline); } } if (Unversioned) pLineCurs.UpdateFeature(pLineFeat); else pLineFeat.Store(); //fine the max sequence value int maxSequence = -1; if (MaxSequenceCache.ContainsKey(curveInfo.Parcel)) { maxSequence = MaxSequenceCache[curveInfo.Parcel]; } else { maxCursor = LineTable.Search(new QueryFilter() { SubFields = String.Format("{0}, {1}, {2}", LineTable.OIDFieldName, CurveByInferenceSettings.Instance.SequenceFieldName, CurveByInferenceSettings.Instance.ParcelIDFieldName), WhereClause = String.Format("{0} = {1}", CurveByInferenceSettings.Instance.ParcelIDFieldName, curveInfo.Parcel) }, true); int seqenceIdx = maxCursor.Fields.FindField(CurveByInferenceSettings.Instance.SequenceFieldName); IRow maxFeat = null; while ((maxFeat = maxCursor.NextFeature()) != null) { maxSequence = Math.Max((int)maxFeat.get_Value(seqenceIdx), maxSequence); Marshal.ReleaseComObject(maxFeat); } Marshal.ReleaseComObject(maxCursor); MaxSequenceCache.Add(curveInfo.Parcel, maxSequence); dataStatistics = null; maxCursor = null; } if (maxSequence <= 0) throw new Exception("Failed to find max sequence value"); //the chord bearing double featureBearing = (double)pLineFeat.get_Value(positions.BearingFieldIdx); //half the delta of the proposed curve would be: double halfdelta = toDegrees(Math.Asin(length / 2 / curveInfo.InferredRadius.Value)); //perpendicular to the chord double perpendicular = (curveInfo.InferredRadius.Value > 0) ? featureBearing + 90 : featureBearing - 90; if (perpendicular > 360) perpendicular = perpendicular - 360; else if (perpendicular < 0) perpendicular = perpendicular + 360; for (int i = 0; i < 2; i++) { buffer.set_Value(positions.ParcelIDFieldIdx, curveInfo.Parcel); buffer.set_Value(positions.ToPointFieldIdx, curveInfo.InferredCenterpointID); buffer.set_Value(positions.CategoryFieldIdx, 4); buffer.set_Value(positions.SequenceFieldIdx, ++maxSequence); buffer.set_Value(positions.TypeFieldIdx, 0); buffer.set_Value(positions.DistanceFieldIdx, curveInfo.InferredRadius); buffer.set_Value(positions.HistoricalFieldIdx, 0); buffer.set_Value(positions.LineParametersFieldIdx, 0); buffer.set_Value(positions.DensifyTypeIdx, 0); buffer.set_Value(positions.SystemStartDateFieldIdx, pLineFeat.get_Value(positions.SystemStartDateFieldIdx)); buffer.Shape = geometry; if (i == 0) // startpoing { buffer.set_Value(positions.FromPointFieldIdx, pLineFeat.get_Value(positions.FromPointFieldIdx)); buffer.set_Value(positions.BearingFieldIdx, perpendicular + halfdelta); } else //endpoint { buffer.set_Value(positions.FromPointFieldIdx, pLineFeat.get_Value(positions.ToPointFieldIdx)); buffer.set_Value(positions.BearingFieldIdx, perpendicular - halfdelta); } pRadialCur.InsertFeature(buffer); } MaxSequenceCache[curveInfo.Parcel] = maxSequence; Marshal.ReleaseComObject(pLineFeat); } return true; } catch (COMException ex) { messageBox.Show(String.Format("Problem updating circular arc: {0} ({1})", ex.Message, ex.ErrorCode)); return false; } finally { if(pLineCurs != null) Marshal.ReleaseComObject(pLineCurs); if(buffer != null) Marshal.ReleaseComObject(buffer); if(pRadialCur != null) Marshal.ReleaseComObject(pRadialCur); if(dataStatistics != null) Marshal.ReleaseComObject(dataStatistics); if (maxCursor != null) Marshal.ReleaseComObject(maxCursor); if (geometry != null) Marshal.FinalReleaseComObject(geometry); if (geometryFactory != null) Marshal.FinalReleaseComObject(geometryFactory); } }
private List <IGeometry> splitGeometry(IGeometry geo, bool mergePolys) { IGeometry geoM = null; if (mergePolys) { geoM = mergeSmallGeos(geo); } else { geoM = geo; } List <IGeometry> geoLst = new List <IGeometry>(); IPolygon4 poly4 = (IPolygon4)geoM; IGeometryCollection geoColl = (IGeometryCollection)poly4.ConnectedComponentBag; for (int i = 0; i < geoColl.GeometryCount; i++) { IGeometry geo2 = geoColl.get_Geometry(i); IEnvelope env = geo2.Envelope; double xmax = env.XMax; double xmin = env.XMin; double ymax = env.YMax; double ymin = env.YMin; double xRange = xmax - xmin; double yRange = ymax - ymin; double nMinX, nMinY, nMaxX, nMaxY; if (xRange > yRange) { nMinY = ymin - 1; nMaxY = ymax + 1; nMinX = xmin + (xRange / 2); nMaxX = nMinX; } else { nMinX = xmin - 1; nMaxX = xmax + 1; nMinY = ymin + (yRange / 2); nMaxY = nMinY; } WKSPoint[] wksPoint = new WKSPoint[2]; IPointCollection4 pointCollection4 = new PolylineClass(); wksPoint[0].X = nMinX; wksPoint[0].Y = nMinY; wksPoint[1].X = nMaxX; wksPoint[1].Y = nMaxY; IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass(); geometryBridge2.AddWKSPoints(pointCollection4, ref wksPoint); IPolyline polyline = pointCollection4 as ESRI.ArcGIS.Geometry.IPolyline; polyline.SpatialReference = geo2.SpatialReference; ITopologicalOperator4 tp = (ITopologicalOperator4)geo2; IGeometry geoL = null; IGeometry geoR = null; try { tp.Cut(polyline, out geoL, out geoR); if (((IArea)geoL).Area > maxarea) { geoLst.AddRange(splitGeometry(geoL, false)); } else { geoLst.Add(geoL); } if (((IArea)geoR).Area > maxarea) { geoLst.AddRange(splitGeometry(geoR, false)); } else { geoLst.Add(geoR); } } catch (Exception e) { geoLst.Add(geo2); Console.WriteLine(e.ToString()); } } return(geoLst); }
private void ZoomSelectedCursor(IQueryFilter queryFilter) { if ((queryFilter == null) || (_hluFeatureClass == null) || (_hluView == null)) return; IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass(); enumGeometryBind.BindGeometrySource(queryFilter, _hluFeatureClass); IGeometryFactory geometryFactory = new GeometryEnvironmentClass(); IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind); _hluView.Extent = geom.Envelope; _hluView.PartialRefresh(esriViewDrawPhase.esriViewGeography, _hluLayer, _hluView.Extent); }
public IGeometry CreateSphere(IPoint centerPoint, double radius, double minLon = 0.0, double maxLon = 360.0, double minLat = -90.0, double maxLat = 90.0, double stepAngle = 18.0, bool bSmooth = false, bool bFlipS = false, bool bFlipT = false) { IMultiPatch patch = new MultiPatchClass(); IGeometryCollection pGCol = patch as IGeometryCollection; IGeometry2 pGeom; IPoint pt; IPointCollection pStrip; IVector3D pVector = new Vector3DClass(); IEncode3DProperties pGE = new GeometryEnvironmentClass(); double xStep = (maxLon - minLon) / stepAngle; double yStep = (maxLat - minLat) / (stepAngle / 2.0); double lonRange = maxLon - minLon; double latRange = maxLat - minLat; object missing = Type.Missing; double lon = minLon; while (lon < maxLon) { pStrip = new TriangleStripClass(); double lat = minLat; while (lat < maxLat) { double azi = DegreesToRadians(lon); double inc = DegreesToRadians(lat); pVector.PolarSet(-azi, inc, radius); pt = new PointClass(); pt.X = centerPoint.X + pVector.XComponent; pt.Y = centerPoint.Y + pVector.YComponent; pt.Z = centerPoint.Z + pVector.ZComponent; double s = (lon - minLon) / lonRange; if (bFlipS) { s = 1 + (s * -1); } if (s <= 0) { s = 0.001; } else if (s >= 1) { s = 0.999; } double t = (maxLat - lat) / latRange; if (bFlipT) { t = 1 + (t * -1); } if (t <= 0) { t = 0.001; } else if (t >= 1) { t = 0.999; } double m = 0.0; pGE.PackTexture2D(s, t, out m); if (bSmooth) { pVector.Normalize(); pGE.PackNormal(pVector, out m); } pt.M = m; pStrip.AddPoint(pt, ref missing, ref missing); if ((lat != -90) && (lat != 90)) { azi = (lon + xStep) * Math.PI / 180.00; inc = lat * Math.PI / 180.00; pVector.PolarSet(-azi, inc, radius); pt = new PointClass(); pt.X = centerPoint.X + pVector.XComponent; pt.Y = centerPoint.Y + pVector.YComponent; pt.Z = centerPoint.Z + pVector.ZComponent; s = (lon + xStep - minLon) / lonRange; if (bFlipS) { s = 1 + (s * -1); } if (s <= 0) { s = 0.001; } else if (s >= 1) { s = 0.999; } t = (maxLat - lat) / latRange; if (bFlipT) { t = 1 + (t * -1); } if (t <= 0) { t = 0.001; } else if (t >= 1) { t = 0.999; } m = 0.0; pGE.PackTexture2D(s, t, out m); if (bSmooth) { pVector.Normalize(); pGE.PackNormal(pVector, out m); } pt.M = m; pStrip.AddPoint(pt, ref missing, ref missing); } lat = lat + yStep; } pGeom = pStrip as IGeometry2; pGCol.AddGeometry(pGeom, ref missing, ref missing); lon = lon + xStep; } IMAware pMAware = patch as IMAware; pMAware.MAware = true; return(patch); }
//空间信息查询确定按钮 private void Btn_QueryOk_Click(object sender, EventArgs e) { //获得图层ID int iLyrID = -1; for (int i = 0; i < axMapControl_1.LayerCount; i++) { if (axMapControl_1.get_Layer(i).Name == Cbx_LyrName.Text) { iLyrID = i; break; } } //获取图层信息及要素集 pFeaLyr = axMapControl_1.get_Layer(iLyrID) as IFeatureLayer; IFeatureClass pFC = pFeaLyr.FeatureClass; //获得字段的ID int iClmID = -1; for (int i = 0; i < pFC.Fields.FieldCount; i++) { if (pFC.Fields.get_Field(i).Name == "Name" || pFC.Fields.get_Field(i).Name == "name") { iClmID = i; break; } } //开始查询 if (iClmID != -1) { //初始化一个条件过滤器 IQueryFilter qfilter = new QueryFilter(); string ColumName = pFC.Fields.get_Field(iClmID).Name; qfilter.WhereClause = ColumName + " like'%" + Txt_Query.Text + "%'"; IFeatureCursor fCursor = pFC.Search(qfilter, false); //初始化数据表 DataTable DT = new DataTable(); //数据表字段填充 for (int i = 0; i < fCursor.Fields.FieldCount; i++) { DT.Columns.Add(fCursor.Fields.get_Field(i).Name, typeof(string)); } //清除地图选择集 axMapControl_1.Map.ClearSelection(); //清除Gridview中的字段,解除gridcontrol数据源 GridView_Info.Columns.Clear(); GridControl_Info.DataSource = null; //数据填充 for (int i = 0; i < pFC.FeatureCount(qfilter); i++) { IFeature feature = fCursor.NextFeature(); axMapControl_1.Map.SelectFeature(axMapControl_1.get_Layer(iLyrID), feature); DataRow dr = DT.NewRow(); for (int j = 0; j < feature.Fields.FieldCount; j++) { dr[j] = feature.get_Value(j).ToString(); } DT.Rows.Add(dr); } //绑定结果是 GridControl_Info.DataSource = DT; for (int i = 0; i < GridView_Info.Columns.Count; i++) { if (GridView_Info.Columns[i].Name == "colshape" || GridView_Info.Columns[i].Name == "colShape") { GridView_Info.Columns[i].Visible = false; } } //地图窗口缩放到选择位置 IFeatureSelection featureSelection = pFeaLyr as IFeatureSelection; if (featureSelection.SelectionSet.Count == 0) { return; } IEnumGeometryBind tEnumGeometryBind = new EnumFeatureGeometryClass(); tEnumGeometryBind.BindGeometrySource(null, featureSelection.SelectionSet); IEnumGeometry tEnumGeometry = (IEnumGeometry)tEnumGeometryBind; IGeometryFactory tGeometryFactory = new GeometryEnvironmentClass(); IGeometry tGeometry = tGeometryFactory.CreateGeometryFromEnumerator(tEnumGeometry); //缓冲处理,使处于边界的元素在视图中能够完全显示 ITopologicalOperator mTopologicalOperator = (ITopologicalOperator)tGeometry; IGeometry mPolygonBuffer = mTopologicalOperator.Buffer(0.001) as IGeometry; axMapControl_1.Extent = mPolygonBuffer.Envelope; axMapControl_1.ActiveView.Refresh(); } else { MessageBox.Show("该图层没有名称字段!!!"); } }
private void btnOKNextScale_Click(object sender, EventArgs e) { if (!CheckRequirements()) { return; } IFeatureLayer buildingslayer = _utilitiesArcMap.FeatureLayer(this.cboBuildingLayer.Text); try { if (buildingslayer != null) { int indexField = _utilitiesArcMap.FindField(buildingslayer, "rsi_index"); int inspectionfieldindex = _utilitiesArcMap.FindField(buildingslayer, "rsi"); IFeatureClass buildingsfeatureclass = buildingslayer.FeatureClass; IFeatureSelection buildingsfeatureselection = buildingslayer as IFeatureSelection; if (buildingsfeatureselection.SelectionSet.Count > 0) { Update(1, buildingslayer); } IFeatureCursor featurecursor = null; IQueryFilter queryfilter = new QueryFilterClass(); queryfilter.WhereClause = "\"rsi\" IS NULL"; if (indexField > -1) { queryfilter.SubFields = "rsi_index"; IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)queryfilter; queryFilterDef.PostfixClause = "ORDER BY rsi_index"; } featurecursor = buildingsfeatureclass.Search(queryfilter, false); IFeature feature = null; while ((feature = featurecursor.NextFeature()) != null) { IPolygon polygon = feature.Shape as IPolygon; IPolyline polyline = feature.Shape as IPolyline; if ((polygon != null) || (polyline != null)) { buildingsfeatureselection.Clear(); buildingsfeatureselection.Add(feature); buildingsfeatureselection.SelectionChanged(); IEnumGeometry enumgeometry = new EnumFeatureGeometryClass(); IEnumGeometryBind enumgeometrybind = enumgeometry as IEnumGeometryBind; enumgeometrybind.BindGeometrySource(null, buildingsfeatureselection.SelectionSet); IGeometryFactory geometryfactory = new GeometryEnvironmentClass(); IGeometry geometry = geometryfactory.CreateGeometryFromEnumerator(enumgeometry); double scale = _map.MapScale; IEnvelope envelope = geometry.Envelope; _activeView.Extent = envelope; _map.MapScale = scale; _activeView.Refresh(); GetStatus(); return; } IPoint point = feature.Shape as IPoint; if (point != null) { buildingsfeatureselection.Clear(); buildingsfeatureselection.Add(feature); buildingsfeatureselection.SelectionChanged(); double scale = _map.MapScale; IEnvelope envelope = _activeView.Extent; envelope.CenterAt(point); _activeView.Extent = envelope; _map.MapScale = scale; _activeView.Refresh(); GetStatus(); return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { //_restartreport = false; } }
void m_editEvents_OnChangeFeature(IObject obj) { // check if feature contains more than 2000 nodes/vertices // applies to lines and polygons // notify the user and offer a split // check if feature geometry is multi-part // applies to lines and polygons // notify the user and offer a conversion to relation IFeatureClass currentObjectFeatureClass = obj.Class as IFeatureClass; if ((currentObjectFeatureClass == null) || (currentObjectFeatureClass.EXTCLSID == null)) return; // check if the current feature class being edited is acutally an OpenStreetMap feature class // all other feature class should not be touched by this extension UID osmEditorExtensionCLSID = currentObjectFeatureClass.EXTCLSID; if (osmEditorExtensionCLSID.Value.ToString().Equals("{65CA4847-8661-45eb-8E1E-B2985CA17C78}", StringComparison.InvariantCultureIgnoreCase) == false) { return; } IFeature currentFeature = obj as IFeature; if (currentFeature == null) return; IPointCollection pointCollection = currentFeature.Shape as IPointCollection; if (pointCollection == null) { return; } // block changing features that are supporting features for multi-part geometries (relations) if (currentFeature.Shape is IPolygon || currentFeature.Shape is IPolyline) { if (((IFeatureChanges)currentFeature).ShapeChanged == true) { int memberOFFieldIndex = currentFeature.Fields.FindField("osmMemberOf"); int membersFieldIndex = currentFeature.Fields.FindField("osmMembers"); int osmIDFieldIndex = currentFeature.Fields.FindField("OSMID"); long osmID = 0; if (osmIDFieldIndex > -1) { object osmIDValue = currentFeature.get_Value(osmIDFieldIndex); if (osmIDValue != DBNull.Value) { osmID = Convert.ToInt64(osmIDValue); } } if (membersFieldIndex > -1) { ESRI.ArcGIS.OSM.OSMClassExtension.member[] relationMembers = _osmUtility.retrieveMembers(currentFeature, membersFieldIndex); if (relationMembers != null) { if (relationMembers.Length > 0) { string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_multipartchangeparentconflictmessage"), osmID); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); } } } if (memberOFFieldIndex > -1) { List<string> isMemberOfList = _osmUtility.retrieveIsMemberOf(currentFeature, memberOFFieldIndex); Dictionary<string, string> dictofParentsAndTypes = _osmUtility.parseIsMemberOfList(isMemberOfList); StringBuilder typeAndIDString = new StringBuilder(); foreach (var item in dictofParentsAndTypes) { switch (item.Value) { case "rel": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_relationidtext") + item.Key + ","); break; case "ply": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polygonidtext") + item.Key + ","); break; case "ln": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_polylineidtext") + item.Key + ","); break; case "pt": typeAndIDString.Append(resourceManager.GetString("OSMEditor_FeatureInspector_pointidtext") + item.Key + ","); break; default: break; } } if (typeAndIDString.Length > 0) { string parentsString = typeAndIDString.ToString(0, typeAndIDString.Length - 1); string abortMessage = String.Format(resourceManager.GetString("OSMEditor_FeatureInspector_multipartchangeconflictmessage"), osmID, parentsString); MessageBox.Show(abortMessage, resourceManager.GetString("OSMEditor_FeatureInspector_relationconflictcaption"), MessageBoxButtons.OK, MessageBoxIcon.Stop); m_editor3.AbortOperation(); } } } } ISegmentCollection segmentCollection = currentFeature.Shape as ISegmentCollection; bool densifyRequired = false; for (int segmentIndex = 0; segmentIndex < segmentCollection.SegmentCount; segmentIndex++) { ISegment segment = segmentCollection.get_Segment(segmentIndex); if (!(segment is Line)) { densifyRequired = true; break; } } if (densifyRequired) { IGeometryEnvironment4 geometryEnvironment = new GeometryEnvironmentClass() as IGeometryEnvironment4; double densifyTolerance = geometryEnvironment.AutoDensifyTolerance; double deviationTolerance = geometryEnvironment.DeviationAutoDensifyTolerance; IPolycurve polycurve = currentFeature.Shape as IPolycurve; polycurve.Densify(densifyTolerance, deviationTolerance); currentFeature.Shape = polycurve; obj.Store(); } }
private IPolyline6 ConstructSpiralbyLength(IPoint theFromPoint, IPoint theTangentpoint, double theFromCurvature, double theToCurvature, bool isCCW, double theSpiralLength, esriCurveDensifyMethod DensifyMethod, double theCurveDensity, out double ExitTangent) { //the parameter name "curvature" is the inverse of the radius. Infinity radius is 0 radius. ExitTangent = 0; IPolyline6 thePolyLine = new PolylineClass() as IPolyline6; try { IGeometryEnvironment4 theGeometryEnvironment = new GeometryEnvironmentClass(); IConstructClothoid TheSpiralConstruction = theGeometryEnvironment as IConstructClothoid; thePolyLine = TheSpiralConstruction.ConstructClothoidByLength(theFromPoint, theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, DensifyMethod, theCurveDensity) as IPolyline6; //now use the Query on the same Spiral, to get the precise exit tangent double dCurvature; double dSplitLength; double dSplitAngle; ILine pExitTangentLine; if (thePolyLine != null) { TheSpiralConstruction.ConstructSplitClothoidByLength(thePolyLine.ToPoint, theFromPoint, theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, out dCurvature, out dSplitLength, out dSplitAngle, out pExitTangentLine); ExitTangent = pExitTangentLine.Angle; //returns polar azimuth in radians } #region tests //TEST +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //IAngularConverter pAngConv = new AngularConverterClass(); //double dCurvatureTEST = 0; //double dSplitLengthTEST = 0; //double dSplitAngleTEST = 0; //double ExitTangentTEST = 0; //ILine pExitTangentLineTEST = null; ////IPoint theFromPoint = new PointClass(); ////theFromPoint.PutCoords(2356762.676, 1919302.7); ////theFromPoint.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; ////IPoint theTangentpoint = new PointClass(); ////theTangentpoint.PutCoords(2356409.122, 1918949.146); ////theTangentpoint.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINT1 = new PointClass(); //TESTPOINT1.PutCoords(2356868.410, 1918327.316); //TESTPOINT1.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINT2 = new PointClass(); //TESTPOINT2.PutCoords(2356876.899, 1918316.005); //TESTPOINT2.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINT3 = new PointClass(); //TESTPOINT3.PutCoords(2356884.312, 1918317.906); //TESTPOINT3.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINT4 = new PointClass(); //TESTPOINT4.PutCoords(2356872.308, 1918333.903); //TESTPOINT4.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINTA_Centroid = new PointClass(); //TESTPOINTA_Centroid.PutCoords(2356633.395, 1918788.139); //TESTPOINTA_Centroid.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINTB_Centroid_OnCurve = new PointClass(); //TESTPOINTB_Centroid_OnCurve.PutCoords(2356633.396, 1918788.358); //TESTPOINTB_Centroid_OnCurve.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINTC_OutsideOffsetTransferredToCurve = new PointClass(); //TESTPOINTC_OutsideOffsetTransferredToCurve.PutCoords(2356511.754, 1919017.119); //TESTPOINTC_OutsideOffsetTransferredToCurve.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint TESTPOINTD_OutsideOffsetPoint = new PointClass(); //TESTPOINTD_OutsideOffsetPoint.PutCoords(2355963.185,1919377.363); //TESTPOINTD_OutsideOffsetPoint.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //IPoint ComputedEndPOINT = new PointClass(); //ComputedEndPOINT.PutCoords(2356878.31, 1918325.904); //ComputedEndPOINT.SpatialReference = ArcMap.Document.ActiveView.FocusMap.SpatialReference; //string sReport = ""; //if (thePolyLine != null) //{ // TheSpiralConstruction.ConstructSplitClothoidByLength(thePolyLine.ToPoint, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); // ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians // pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); // string sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians // string sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // sReport += ("To Point " +Environment.NewLine + "------------------" + Environment.NewLine + // "Curvature at To point : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Radius at To point : " + (1/dCurvatureTEST).ToString("0.00000") + Environment.NewLine + // "Length along curve at To point : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle at To point : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing at To point : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINT1, theFromPoint, //theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, //out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); // ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians // pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); // sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians // sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // sReport += ("TESTPOINT1" +Environment.NewLine + "---" + Environment.NewLine + // "Curvature at query point : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Length along curve at query point : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle at query point : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing at query point : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINT2, theFromPoint, //theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, //out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); // ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians // pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); // sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians // sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // sReport += ("TESTPOINT2" +Environment.NewLine + "---" + Environment.NewLine + // "Curvature at query point : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Length along curve at query point : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle at query point : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing at query point : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINT3, theFromPoint, //theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, //out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); // ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians // pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); // sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians // sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // sReport += ("TESTPOINT3" +Environment.NewLine + "---" + Environment.NewLine + // "Curvature at query point : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Length along curve at query point : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle at query point : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing at query point : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINT4, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); //ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians //pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians //sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //sReport += ("TESTPOINT4" +Environment.NewLine + "---" + Environment.NewLine + // "Curvature at query point : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Length along curve at query point : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle at query point : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing at query point : " + sTangentBearing + Environment.NewLine // ); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINTA_Centroid, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); //ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians //pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians //sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //sReport += ("A " +Environment.NewLine + "------------------" + Environment.NewLine + // "Curvature; query point A : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Radius; query point A : " + (1/dCurvatureTEST).ToString("0.00000") + Environment.NewLine + // "Length along curve; query point A: " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle; query point A : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing; query point A : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINTB_Centroid_OnCurve, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); //ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians //pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians //sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //sReport += ("B " +Environment.NewLine + "---" + Environment.NewLine + // "Curvature; query point B : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Radius; query point B : " + (1/dCurvatureTEST).ToString("0.00000") + Environment.NewLine + // "Length along curve; query point B : " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle; query point B : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing; query point B : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINTC_OutsideOffsetTransferredToCurve, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); //ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians //pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians //sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); //sReport += ("C " +Environment.NewLine + "---" + Environment.NewLine + // "Curvature; query point C : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Radius; query point C : " + (1/dCurvatureTEST).ToString("0.00000") + Environment.NewLine + // "Length along curve; query point C: " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle ; query point C : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing; query point C : " + sTangentBearing + Environment.NewLine // ); /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TheSpiralConstruction.ConstructSplitClothoidByLength(TESTPOINTD_OutsideOffsetPoint, theFromPoint, // theTangentpoint, isCCW, theFromCurvature, theToCurvature, theSpiralLength, // out dCurvatureTEST, out dSplitLengthTEST, out dSplitAngleTEST, out pExitTangentLineTEST); // ExitTangentTEST = pExitTangentLineTEST.Angle; //returns polar azimuth in radians // pAngConv.SetAngle(ExitTangentTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); // sTangentBearing = pAngConv.GetString(esriDirectionType.esriDTQuadrantBearing, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // pAngConv.SetAngle(dSplitAngleTEST, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians); //returns polar azimuth in radians // sSplitCentralAngle = pAngConv.GetString(esriDirectionType.esriDTPolar, esriDirectionUnits.esriDUDegreesMinutesSeconds, 0); // sReport += ("D " +Environment.NewLine + "---------------" + Environment.NewLine + // "Curvature; query point D : " + dCurvatureTEST.ToString("0.00000") + Environment.NewLine + // "Radius; query point D : " + (1/dCurvatureTEST).ToString("0.00000") + Environment.NewLine + // "Length along curve; query point D: " + dSplitLengthTEST.ToString("0.00") + Environment.NewLine + // "Central angle; query point D : " + sSplitCentralAngle + Environment.NewLine + // "Tangent bearing; query point D : " + sTangentBearing + Environment.NewLine // ); // MessageBox.Show(sReport, "Query Point Results"); //} //END TEST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endregion return(thePolyLine); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
/// <summary> /// 选择一行,并在地图中显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void att_gridview_RowClick(object sender, RowClickEventArgs e) { GridView att_gridview = (GridView)sender; GridHitInfo info = att_gridview.CalcHitInfo(e.X, e.Y); //只有单击rowinditor时才执行选择行 if (!info.InRowCell) { if (info.InRow) { //存放selectedrow ArrayList rows = new ArrayList(); for (int i = 0; i < att_gridview.SelectedRowsCount; i++) { if (att_gridview.GetSelectedRows()[i] >= 0) { rows.Add(att_gridview.GetDataRow(att_gridview.GetSelectedRows()[i])); } } if (rows.Count > 0) { //遍历flayer_list寻找当前属性表对应的图层 for (int i = 0; i < flayer_list.Count; i++) { IDataLayer datalayer = flayer_list[i] as IDataLayer; IWorkspaceName w_name = ((IDatasetName)(datalayer.DataSourceName)).WorkspaceName; if (att_gridview.Tag.ToString() == w_name.PathName + "\\" + flayer_list[i].Name + "_" + flayer_list[i].DataSourceType) { IFeatureClass m_featureclass = flayer_list[i].FeatureClass; IFeatureSelection m_fselection = flayer_list[i] as IFeatureSelection; //构造查询条件 IQueryFilter m_queryfilter = new QueryFilterClass(); string key = flayer_list[i].FeatureClass.Fields.get_Field(0).Name; string m_whereclause = key + "="; for (int j = 0; j < rows.Count; j++) { DataRow m_dr = rows[j] as DataRow; if (j < 1) { m_whereclause += m_dr[0].ToString(); } else { m_whereclause = m_whereclause + " or " + key + "=" + m_dr[0].ToString(); } } m_queryfilter.WhereClause = m_whereclause; //显示查询的要素 m_fselection.SelectFeatures(m_queryfilter, esriSelectionResultEnum.esriSelectionResultNew, false); ISelectionSet m_selectionset = m_fselection.SelectionSet; IEnumGeometry m_enumgeometry = new EnumFeatureGeometry(); IEnumGeometryBind m_enumgeobine = m_enumgeometry as IEnumGeometryBind; m_enumgeobine.BindGeometrySource(null, m_selectionset); IGeometryFactory m_geofactory = new GeometryEnvironmentClass(); IGeometry m_geometry = m_geofactory.CreateGeometryFromEnumerator(m_enumgeometry); m_mapControl.ActiveView.Extent = m_geometry.Envelope; m_mapControl.Refresh(); } } } } } }
private byte[] Extracthandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; var errors = new ResponseContainer(HttpStatusCode.BadRequest, ""); string base64Geometry; var found = operationInput.TryGetString("geometry", out base64Geometry); if (!found || string.IsNullOrEmpty(base64Geometry)) { errors.Message = "geometry parameter is required."; return Json(errors); } JsonObject queryCriteria; found = operationInput.TryGetJsonObject("criteria", out queryCriteria); if (!found) { errors.Message = "criteria parameter is required."; return Json(errors); } #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, "Params received"); #endif IGeometry geometry; int read; var factory = new GeometryEnvironmentClass() as IGeometryFactory3; factory.CreateGeometryFromWkbVariant(Convert.FromBase64String(base64Geometry), out geometry, out read); var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); if (geometry.SpatialReference == null) { //Create a projected coordinate system and define its domain, resolution, and x,y tolerance. var spatialReferenceResolution = spatialReferenceFactory.CreateProjectedCoordinateSystem(3857) as ISpatialReferenceResolution; spatialReferenceResolution.ConstructFromHorizon(); var spatialReferenceTolerance = spatialReferenceResolution as ISpatialReferenceTolerance; spatialReferenceTolerance.SetDefaultXYTolerance(); var spatialReference = spatialReferenceResolution as ISpatialReference; geometry.SpatialReference = spatialReference; } #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, "Geometry converted"); #endif if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon) { var filterGeometry = (ITopologicalOperator4) geometry; filterGeometry.IsKnownSimple_2 = false; filterGeometry.Simplify(); if (((IArea)geometry).Area < 0) { ((ICurve)geometry).ReverseOrientation(); } } var filter = new SpatialFilter { Geometry = geometry, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }; var utmResolution = spatialReferenceFactory.CreateProjectedCoordinateSystem(26912) as ISpatialReferenceResolution; utmResolution.ConstructFromHorizon(); var utmTolerance = utmResolution as ISpatialReferenceTolerance; utmTolerance.SetDefaultXYTolerance(); var utmSr = utmResolution as ISpatialReference; var notEsri = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(queryCriteria.ToJson()); var searchResults = new Dictionary<string, IList<IntersectAttributes>>(); foreach (var keyValue in notEsri) { var container = _featureClassIndexMap.Single(x => x.Index == int.Parse(keyValue.Key)); var fields = keyValue.Value.Select(x => x.ToUpper()); var fieldMap = container.FieldMap.Select(x => x.Value) .Where(y => fields.Contains(y.Field.ToUpper())) .ToList(); #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, string.Format("Querying {0} at index {1}", container.LayerName, container.Index)); #endif var cursor = container.FeatureClass.Search(filter, true); IFeature feature; while ((feature = cursor.NextFeature()) != null) { var values = new GetValueAtIndexCommand(fieldMap, feature).Execute(); var attributes = new IntersectAttributes(values); // line over polygon = 1D // polygon over polygon = 2D switch (geometry.GeometryType) { case esriGeometryType.esriGeometryPolygon: { #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, "User input polygon, intersecting " + container.LayerName); #endif var gis = (ITopologicalOperator4)geometry; gis.Simplify(); if (feature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPolygon) { try { var intersection = gis.Intersect(feature.ShapeCopy, esriGeometryDimension.esriGeometry2Dimension); intersection.Project(utmSr); var utm = (IArea) intersection; attributes.Intersect = Math.Abs(utm.Area); #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, string.Format("Area: {0}", utm.Area)); #endif } catch (Exception ex) { return Json(new ResponseContainer(HttpStatusCode.InternalServerError, ex.Message)); } } else if (feature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPolyline) { var intersection = gis.Intersect(feature.ShapeCopy, esriGeometryDimension.esriGeometry1Dimension); intersection.Project(utmSr); var utm = (IPolyline5) intersection; attributes.Intersect = Math.Abs(utm.Length); #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, string.Format("Length: {0}", utm.Length)); #endif } } break; case esriGeometryType.esriGeometryPolyline: { #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, "User input polyline, acting on " + container.LayerName); #endif var gis = (ITopologicalOperator5) geometry; gis.Simplify(); var intersection = gis.Intersect(feature.ShapeCopy, esriGeometryDimension.esriGeometry1Dimension); intersection.Project(utmSr); var utm = (IPolyline) intersection; attributes.Intersect = Math.Abs(utm.Length); #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, string.Format("Length: {0}", utm.Length)); #endif } break; } if (searchResults.ContainsKey(container.LayerName)) { if (searchResults[container.LayerName].Any(x => new MultiSetComparer<object>().Equals(x.Attributes, attributes.Attributes))) { var duplicate = searchResults[container.LayerName] .Single(x => new MultiSetComparer<object>().Equals(x.Attributes, attributes.Attributes)); duplicate.Intersect += attributes.Intersect; } else { searchResults[container.LayerName].Add(attributes); } } else { searchResults[container.LayerName] = new Collection<IntersectAttributes> {attributes}; } } } var response = new IntersectResponse(searchResults); #if !DEBUG _logger.LogMessage(ServerLogger.msgType.infoStandard, "Extracthandler", MessageCode, string.Format("Returning results {0}", searchResults.Count)); #endif return Json(new ResponseContainer<IntersectResponse>(response)); }