void IFeatureRenderer.Draw(ESRI.ArcGIS.Geodatabase.IFeatureCursor Cursor, ESRI.ArcGIS.esriSystem.esriDrawPhase DrawPhase, IDisplay Display, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel) { // do not draw features if no display if (Display == null) { return; } else { clsSnippet pSnippet = new clsSnippet(); IFeature pFeat = null; intBrksCount = pCSMembers.ClassBrks.Length - 1; ISimpleFillSymbol pSFillSym = new SimpleFillSymbolClass(); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblLineWidth; pOutLines.Color = (IColor)pLineRgb; pFeat = Cursor.NextFeature(); IRgbColor pRGBColor = null; int i = 0; double dblValue = 0; //Start Loop while (pFeat != null) { dblValue = Convert.ToDouble(pFeat.get_Value(intEstIdx)); IFeatureDraw pFeatDraw = (IFeatureDraw)pFeat; pSFillSym = new SimpleFillSymbolClass(); pSFillSym.Outline = pOutLines; pRGBColor = null; for (int j = 0; j < intBrksCount; j++) { if (j == 0) { if (dblValue >= pCSMembers.ClassBrks[0] && dblValue <= pCSMembers.ClassBrks[1]) { pRGBColor = pSnippet.getRGB(pCSMembers.Colors[0, 0], pCSMembers.Colors[0, 1], pCSMembers.Colors[0, 2]); } } else { if (dblValue > pCSMembers.ClassBrks[j] && dblValue <= pCSMembers.ClassBrks[j + 1]) { pRGBColor = pSnippet.getRGB(pCSMembers.Colors[j, 0], pCSMembers.Colors[j, 1], pCSMembers.Colors[j, 2]); } } } pSFillSym.Color = (IColor)pRGBColor; Display.SetSymbol((ISymbol)pSFillSym); pFeatDraw.Draw(esriDrawPhase.esriDPGeography, Display, (ISymbol)pSFillSym, true, null, esriDrawStyle.esriDSNormal); i++; pFeat = Cursor.NextFeature(); } } }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (DoQueryIndex == 1)//点击查询 { ESRI.ArcGIS.Carto.IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(layerComboBox.SelectedIndex) as ESRI.ArcGIS.Carto.IFeatureLayer; ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.PutCoords(e.mapX, e.mapY); ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); spatialFilter.Geometry = point; spatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects; ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = pFeatureLayer.Search(spatialFilter, false); ESRI.ArcGIS.Geodatabase.IFeature pFeature; while ((pFeature = featureCursor.NextFeature()) != null) { axMapControl1.FlashShape(pFeature.Shape); } } else if (DoQueryIndex == 2)//面范围查询 { ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.PutCoords(e.mapX, e.mapY); pointCollection.AddPoints(1, ref point); if (pointCollection.PointCount > 1) { DrawPolygon(pointCollection, axMapControl1); } } }
List <double> InterfaceClassIndex.CaculateClassIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { List <double> result = new List <double>(); for (int i = 0; i < clssValue.Count; i++) { result.Add(0.0); } IFeature pFeature = null; double tmparea = 0.0; while ((pFeature = pFeatureCursor.NextFeature()) != null) { tmparea += (double)pFeature.get_Value(basedata.areaIndex); for (int j = 0; j < clssValue.Count; j++) { string code = pFeature.get_Value(basedata.codeIndex).ToString(); if (code == clssValue[j]) { result[j] += 1; } } } tmparea /= 1000000; for (int i = 0; i < clssValue.Count; i++) { result[i] /= tmparea; } return(result); }
private void button1_Click(object sender, EventArgs e) { IQueryFilter pFilter = new QueryFilter(); pFilter.WhereClause = textBox1.Text.ToString();//添加过滤参数 try { ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureLayer.Search(pFilter, false); ESRI.ArcGIS.Geodatabase.IFeature pFeature; if (featureCursor == null) { MessageBox.Show("feature cursor is null"); } else { MessageBox.Show("feature cursor is not null"); } pFeature = featureCursor.NextFeature(); this.Hide(); refresh1(pFeature); // Form1 form1 = new Form1(); // form1.flashShape(featureCursor); } catch (Exception ee) { MessageBox.Show("出现错误楼"); } }
public List <double> CaculateClassIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { List <double> result = new List <double>(); for (int i = 0; i < classvalue.Count; i++) { result.Add(0.0); } IFeature pFeature = null; double totalarea = 0.0; while ((pFeature = pFeatureCursor.NextFeature()) != null) { //double tempedge = (double)pFeature.get_Value(basedata.perimeterIndex); double temparea = (double)pFeature.get_Value(basedata.areaIndex); for (int j = 0; j < classvalue.Count; j++)//分类 { string code = pFeature.get_Value(basedata.codeIndex).ToString(); if (code == classvalue[j] && temparea >= limitevalue) { result[j] += temparea; } } totalarea += temparea; } for (int i = 0; i < classvalue.Count; i++) { double temp = result[i] / totalarea; result[i] = temp * 100; } return(result); //throw new NotImplementedException(); }
public List <double> CaculateClassIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { List <double> result = new List <double>(); int count = classvalue.Count; double[] lnpij = new double[count]; double[] lnaij = new double[count]; double[] lnpij2 = new double[count]; double[] lnaijlnpij = new double[count]; int[] classCount = new int[count]; for (int i = 0; i < count; i++) { result.Add(0.0); lnpij[i] = 0.0; lnaij[i] = 0.0; lnpij2[i] = 0.0; lnaijlnpij[i] = 0.0; classCount[i] = 0; } IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { double temparea = (double)pFeature.get_Value(basedata.areaIndex); double templength = (double)pFeature.get_Value(basedata.perimeterIndex); for (int j = 0; j < classvalue.Count; j++)//分类 { string code = pFeature.get_Value(basedata.codeIndex).ToString(); if (code == classvalue[j]) { classCount[j]++; lnpij[j] += System.Math.Log(templength, Math.E); lnaij [j] += System.Math.Log(temparea, Math.E); lnpij2[j] += System.Math.Log(templength, Math.E) * System.Math.Log(templength, Math.E); lnaijlnpij[j] += System.Math.Log(templength, Math.E) * System.Math.Log(temparea, Math.E); } } }///end of while for (int j = 0; j < count; j++) { double temp1 = classCount[j] * lnpij2[j] - lnpij[j] * lnpij[j]; double temp2 = classCount[j] * lnaijlnpij[j] - lnaij[j] * lnpij[j]; double temp = 2.0 / (temp2 / temp1); if (temp1 < 0.000001 || temp2 < 0.000001) { result[j] = -9999; } else { result[j] = temp; } } return(result); }
/// <summary> /// Finds the connected device/port /// </summary> /// <param name="siblingFtClass">Any feature class from the workspace</param> /// <param name="cableId">Cable ID to check connx for</param> /// <param name="fiberNumber">Fiber Number to check connx for</param> /// <param name="isFromEnd">Whether to check the cable's from or to end</param> /// <param name="portRow">(out) result port</param> /// <param name="deviceFt">(out) result device</param> /// <returns>True if a connx was found</returns> private bool GetConnectedPort(ESRI.ArcGIS.Geodatabase.IFeatureClass siblingFtClass, string cableId, int fiberNumber, bool isFromEnd, out ESRI.ArcGIS.Geodatabase.IRow portRow, out ESRI.ArcGIS.Geodatabase.IFeature deviceFt) { portRow = null; deviceFt = null; bool result = false; string[] portTableNames = ConfigUtil.PortTableNames; using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); filter.WhereClause = string.Format("{0}='{1}' AND {2}={3} AND {4}='{5}'", ConfigUtil.ConnectedCableFieldName, cableId, ConfigUtil.ConnectedFiberFieldName, fiberNumber, ConfigUtil.ConnectedEndFieldName, isFromEnd ? "T" : "F"); releaser.ManageLifetime(filter); for (int i = 0; i < portTableNames.Length; i++) { string portTableName = portTableNames[i]; ESRI.ArcGIS.Geodatabase.ITable portTable = _wkspHelper.FindTable(portTableName); ESRI.ArcGIS.Geodatabase.ICursor cursor = portTable.Search(filter, false); releaser.ManageLifetime(cursor); portRow = cursor.NextRow(); if (null != portRow) { ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetDeviceRelationship(portTable); if (null == deviceHasPorts) { throw new Exception("Device to port relationship is missing or cannot be opened."); } ESRI.ArcGIS.Geodatabase.IFeatureClass deviceClass = deviceHasPorts.OriginClass as ESRI.ArcGIS.Geodatabase.IFeatureClass; if (null == deviceClass) { throw new Exception("Device feature class is missing or cannot be opened."); } filter.WhereClause = string.Format("{0}='{1}'", deviceHasPorts.OriginPrimaryKey, portRow.get_Value(portTable.FindField(deviceHasPorts.OriginForeignKey))); ESRI.ArcGIS.Geodatabase.IFeatureCursor deviceCursor = deviceClass.Search(filter, false); deviceFt = deviceCursor.NextFeature(); result = true; break; } } } return(result); }
void IFeatureRenderer.Draw(ESRI.ArcGIS.Geodatabase.IFeatureCursor Cursor, ESRI.ArcGIS.esriSystem.esriDrawPhase DrawPhase, IDisplay Display, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel) { // do not draw features if no display if (Display == null) { return; } else { IFeature pFeat = null; intBrksCount = arrClassBrks.Length - 1; ILineFillSymbol pLineFillSym = new LineFillSymbolClass(); pFeat = Cursor.NextFeature(); dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intBrksCount - 1); int i = 0; //Start Loop while (pFeat != null) { IFeatureDraw pFeatDraw = (IFeatureDraw)pFeat; pLineFillSym = new LineFillSymbolClass(); pLineFillSym.Angle = dblLineAngle; pLineFillSym.Color = pLineRgb; pLineFillSym.LineSymbol.Width = dblLineWidth; for (int j = 0; j < intBrksCount; j++) { if (arrValue[i] >= arrClassBrks[j] && arrValue[i] <= arrClassBrks[j + 1]) { pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(j)); } } Display.SetSymbol((ISymbol)pLineFillSym); pFeatDraw.Draw(esriDrawPhase.esriDPGeography, Display, (ISymbol)pLineFillSym, true, null, esriDrawStyle.esriDSNormal); i++; pFeat = Cursor.NextFeature(); } } }
double InterfaceLandIndex.CaculateLandIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { // throw new NotImplementedException(); double result = 0.0; IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { result++; } return(result); }
double InterfaceLandIndex.CaculateLandIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { double result = 0.0; IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { double templength = (double)pFeature.get_Value(basedata.perimeterIndex); result += templength; } return(result); }
public List <double> CaculateClassIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { List <double> result = new List <double>(); for (int i = 0; i < classvalue.Count; i++) { result.Add(0.0); } IFeature pFeature = null; double totalarea = 0.0; while ((pFeature = pFeatureCursor.NextFeature()) != null) { double temparea = (double)pFeature.get_Value(basedata.areaIndex); for (int j = 0; j < classvalue.Count; j++)//分类 { string code = pFeature.get_Value(basedata.codeIndex).ToString(); if (code == classvalue[j]) { double computeArea = 0.0; ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = pFeature.Shape; spatialFilter.GeometryField = pFeatureClass.ShapeFieldName; spatialFilter.SubFields = "Shape_Area"; spatialFilter.SpatialRelDescription = "T********"; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelRelation; IFeatureCursor pSpatialFCursor = pFeatureClass.Search(spatialFilter, false); IFeature pSpatialFeature = pSpatialFCursor.NextFeature(); while (pSpatialFeature != null) { computeArea += (double)pSpatialFeature.get_Value(0); pSpatialFeature = pSpatialFCursor.NextFeature(); } result[j] += (double)pFeature.get_Value(basedata.areaIndex) * computeArea; } } totalarea += temparea; } for (int i = 0; i < result.Count; i++) { result[i] /= totalarea; } return(result); }
public double CaculateLandIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { double result = 0.0, total = 0.0; IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { double temparea = (double)pFeature.get_Value(basedata.areaIndex); total += temparea; if (result <= temparea) { result = temparea; } } return(result / total * 100); }
//鼠标点击事件 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (pMouseOperate == "ZoomIn") { axMapControl1.Extent = axMapControl1.TrackRectangle(); } if (pMouseOperate == "ZoomOut") { IEnvelope penv = axMapControl1.Extent; penv.Expand(2, 2, true); axMapControl1.Extent = penv; } if (pMouseOperate == "Pan") { axMapControl1.Pan(); } if (pMouseOperate == "Identify") { IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(e.mapX, e.mapY); IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(0) as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; string shapefieldname = pFeatureClass.ShapeFieldName; ESRI.ArcGIS.Geodatabase.ISpatialFilter pSpatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilter(); pSpatialFilter.Geometry = point; pSpatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.set_OutputSpatialReference(shapefieldname, axMapControl1.SpatialReference); pSpatialFilter.GeometryField = shapefieldname; ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false); ESRI.ArcGIS.Geodatabase.IFeature pFeature = pFeatureCursor.NextFeature(); if (pFeature != null) { axMapControl1.FlashShape(pFeature.Shape); } IFields pField = pFeature.Fields; listFields.Items.Clear(); for (int i = 0; i <= pField.FieldCount - 1; i++) { listFields.Items.Add(pField.get_Field(i).Name + "=" + pFeature.get_Value(i)); } } }
List <double> InterfaceClassIndex.CaculateClassIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { //throw new NotImplementedException(); List <double> result = new List <double>(); List <int> count = new List <int>(); for (int i = 0; i < clssValue.Count; i++) { result.Add(0.0); count.Add(0); } IFeature pFeature = null; double tmparea = 0.0; while ((pFeature = pFeatureCursor.NextFeature()) != null) { tmparea = (double)pFeature.get_Value(basedata.areaIndex); for (int j = 0; j < clssValue.Count; j++) { string code = pFeature.get_Value(basedata.codeIndex).ToString(); if (code == clssValue[j]) { count[j] += 1; result[j] += tmparea; } } } for (int i = 0; i < clssValue.Count; i++) { if (count[i] < 0.01) { result[i] = 0; } else { result[i] = result[i] / 10000 / count[i]; } } return(result); }
double InterfaceLandIndex.CaculateLandIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { //throw new NotImplementedException(); double result = 0.0, count = 0.0; IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { result += (double)pFeature.get_Value(basedata.areaIndex); count++; } if (count < 0.01) { result = 0.0; } else { result = result / 10000 / count; } return(result); }
public double CaculateLandIndex(ESRI.ArcGIS.Geodatabase.IFeatureCursor pFeatureCursor, BaseData basedata) { double result = 0.0; double lnpij = 0.0; double lnaij = 0.0; double lnpij2 = 0.0; double lnaijlnpij = 0.0; int Count = 0; IFeature pFeature = null; while ((pFeature = pFeatureCursor.NextFeature()) != null) { Count++; double temparea = (double)pFeature.get_Value(basedata.areaIndex); double templength = (double)pFeature.get_Value(basedata.perimeterIndex); lnpij += System.Math.Log(templength, Math.E); lnaij += System.Math.Log(temparea, Math.E); lnpij2 += System.Math.Log(templength, Math.E) * System.Math.Log(templength, Math.E); lnaijlnpij += System.Math.Log(temparea, Math.E) * System.Math.Log(templength, Math.E); } double temp1 = Count * lnpij2 - lnpij * lnpij; double temp2 = Count * lnaijlnpij - lnaij * lnpij; double temp = 2.0 / (temp2 / temp1); if (temp2 < 0.0000001 || temp1 < 0.0000001) { result = -9999; } else { result = temp; } return(result); }
// get features that intersect the buffered mouse click and return them as a list of IFeature public List <IFeature> checkForIntersectingSegments(IPoint mousePoint, double buffer, IFeatureClass featureClass) { var envelope = mousePoint.Envelope; envelope.Expand(buffer, buffer, false); var geodataset = (IGeoDataset)featureClass; string shapeFieldName = featureClass.ShapeFieldName; ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilter(); spatialFilter.Geometry = envelope; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses; // website for other options edndoc.esri.com/arcobjects/9.2/ComponentHelp/esrigeodatabase/esrispatialrelenum.htm spatialFilter.set_OutputSpatialReference(shapeFieldName, geodataset.SpatialReference); ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false); var features = new List <IFeature>(); ESRI.ArcGIS.Geodatabase.IFeature feature; while ((feature = featureCursor.NextFeature()) != null) { features.Add(feature); } return(features); }
private void KalibreerVormpuntenOpBasisVanSpoorhartlijn(IFeatureSelection FeatureSelectionMShape) { #region Bepaal de overlappende extent van raaien en selectie IGeoDataset GeoDatasetMShape = flMShape as IGeoDataset; IGeoDataset GeodatasetLRS = fcLRS as IGeoDataset; IEnvelope pQueryingGeometryFullExtent = GeoDatasetMShape.Extent; pQueryingGeometryFullExtent.Union(GeodatasetLRS.Extent); pQueryingGeometryFullExtent.Expand(10000, 10000, false); #endregion Bepaal de overlappende extent van raaien en selectie int featurecount = FeatureSelectionMShape.SelectionSet.Count; int featurecounter = 0; ICursor SelectionCursor = null; if (featurecount == 0) { SelectionCursor = ((FeatureSelectionMShape as IFeatureLayer).FeatureClass.Search(null, false)) as ICursor; featurecount = (FeatureSelectionMShape as IFeatureLayer).FeatureClass.FeatureCount(null); } else { FeatureSelectionMShape.SelectionSet.Search(null, false, out SelectionCursor); } IPolyline Polyline = null; IPolygon buffer = null; IPointCollection PointCollection = null; IList <IPolyline> PolylinesLRS = null; try { IFeature feature = SelectionCursor.NextRow() as IFeature; while (feature != null) { Polyline = feature.ShapeCopy as IPolyline; PointCollection = Polyline as IPointCollection; #region lees de begin- en eindkilometrering en het selectie criterium double m_begin = (Polyline as IPointCollection).get_Point(0).M; double m_eind = (Polyline as IPointCollection).get_Point((Polyline as IPointCollection).PointCount - 1).M; string sleutel1 = Convert.ToString(feature.get_Value(feature.Fields.FindField(this.mshape_sleutel1))); string sleutel2 = null; if (this.mshape_sleutel2 != "") { sleutel2 = Convert.ToString(feature.get_Value(feature.Fields.FindField(this.mshape_sleutel2))); } #endregion // Selecteer alle LRS lijnen binnen de zoekafstand ISpatialFilter SpatialFilter = new SpatialFilter(); IQueryFilter QueryFilter = SpatialFilter; buffer = (Polyline as ITopologicalOperator).Buffer(Properties.Settings.Default.mshape_maxafstand) as IPolygon; SpatialFilter.Geometry = buffer; SpatialFilter.GeometryField = fcLRS.ShapeFieldName; string whereclauseLRS = Properties.Settings.Default.lrs_selectie; SpatialFilter.WhereClause = string.Format(whereclauseLRS, sleutel1, sleutel2); SpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects; ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = fcLRS.Search(QueryFilter, false); try { PolylinesLRS = new List <IPolyline>(); IFeature featureLRS = featureCursor.NextFeature(); while (featureLRS != null) { PolylinesLRS.Add(featureLRS.ShapeCopy as IPolyline); featureLRS = featureCursor.NextFeature(); } } catch { throw; } finally { ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor); } // Controleer of er een spoorhartlijn (LRS) in de buurt ligt. Zo niet, dan evt. markeren if ((PolylinesLRS.Count == 0) && (this.MarkeerLijnBuitenZoekAfstand)) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Polyline, this.KleurLijnBuitenZoekAfstand, this.KleurLijnBuitenZoekAfstand); // Als er geen spoorhartlijn (LRS) in de buurt ligt, dan hoeven ook niet alle vormpunten doorlopen te worden. continue; // while (feature != null) } #region Doorloop alle vormpunten en werk de vormpunten bij bool bUpdated = false; bool bNietMonotoon = false; bool outPointGevonden = false; double pDistance = 0; for (int i = 1; i < PointCollection.PointCount - 1; i++) // sla het eerste en het laatste punt over { // zoek de dichtstbijzijnde feature, eventueel aangevuld met geocode in een queryfilter IPoint Point = PointCollection.get_Point(i); IPoint outPoint = new ESRI.ArcGIS.Geometry.Point(); outPointGevonden = false; pDistance = double.PositiveInfinity; bUpdated = false; this.ZoekPuntOpSpoorhartlijn(Point, PolylinesLRS, m_begin, m_eind, out outPoint, out outPointGevonden, out pDistance); if (this.LogVormpunten) { if (outPointGevonden) { this._ArcObjectsHelper.LogRecord(logtable, feature.OID, i, Point.X, Point.Y, Point.M, outPoint.X, outPoint.Y, outPoint.M); } else { this._ArcObjectsHelper.LogRecord(logtable, feature.OID, i, Point.X, Point.Y, Point.M, Point.X, Point.Y, Point.M); } } // Als er een punt gevonden is, binnen de zoekafstand en binnen het kilometerinterval if (outPointGevonden) { if (Math.Abs((Point as IPoint).M - outPoint.M) > (this.VerschilVormpuntMetAfwijking / 1000)) { if (MarkeerVormpuntMetAfwijking) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntMetAfwijking, this.KleurVormpuntMetAfwijking); } } if ((pDistance > this.AfstandVormpuntBuitenZoekAfstand) && (this.MarkeerVormpuntBuitenZoekAfstand)) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntBuitenZoekAfstand, this.KleurVormpuntBuitenZoekAfstand); } Point.M = outPoint.M; PointCollection.UpdatePoint(i, Point); bUpdated = true; } else if ((!outPointGevonden) && (outPoint != null)) // er is wel een punt gevonden, maar niet binnen het kilometerinterval. { // Als er een punt buiten het kilometerinterval gevonden is, binnen de zoekafstand, markeer het punt dan if ((this.MarkeerVormpuntMetAfwijking) && (Math.Abs((Point as IPoint).M - outPoint.M) > (this.VerschilVormpuntMetAfwijking / 1000))) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntMetAfwijking, this.KleurVormpuntMetAfwijking); } if ((this.MarkeerVormpuntBuitenInterval) && !(between(m_begin, m_eind, outPoint.M, (TolerantieVormpuntBuitenInterval / 1000)))) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntBuitenInterval, this.KleurVormpuntBuitenInterval); } if ((pDistance > this.AfstandVormpuntBuitenZoekAfstand) && (this.MarkeerVormpuntBuitenZoekAfstand)) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntBuitenZoekAfstand, this.KleurVormpuntBuitenZoekAfstand); } } else if (!outPointGevonden) // er is geen punt gevonden binnen de zoekafstand { if (this.MarkeerVormpuntBuitenZoekAfstand) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntBuitenZoekAfstand, this.KleurVormpuntBuitenZoekAfstand); } } #region Markeer de bijgewerkte en niet bijgewerkte punten if ((bUpdated) && (this.MarkeerVormpuntBijgewerkt)) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntBijgewerkt, this.KleurVormpuntBijgewerkt); } if (!(bUpdated) && (this.MarkeerVormpuntNietBijgewerkt)) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, Point, this.KleurVormpuntNietBijgewerkt, this.KleurVormpuntNietBijgewerkt); } #endregion } #endregion // doorloop de vormpunten #region Reset begin- en eindkilometer this.ResetBeginEnEindMeasure(Polyline, m_begin, m_eind, false); #endregion #region Controleer of de lijn monotoon oplopend of aflopend is en markeer de lijn. int MMonotonicity = ((PointCollection as IMSegmentation3).MMonotonicity); if (MMonotonicity == 5 || MMonotonicity == 7 || MMonotonicity == 15) { bNietMonotoon = true; if (this.MarkeerLijnNietMonotoon) { _ArcObjectsHelper.AddGraphicToMap(ArcMap.Document.FocusMap, PointCollection as IPolyline, this.KleurLijnNietMonotoon, this.KleurLijnNietMonotoon); } } if ((bNietMonotoon) && (this.OpslaanLijnNietMonotoon)) { feature.Shape = (PointCollection as IGeometry); // UpdateCursor.UpdateFeature(feature); } else if (!bNietMonotoon) { feature.Shape = (PointCollection as IGeometry); } #endregion // Voortgang featurecounter += 1; this.progress = (100 * featurecounter) / featurecount; // Bijwerken feature.Store(); // Volgende feature feature = SelectionCursor.NextRow() as IFeature; } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Er is een onverwachte fout opgetreden; raadpleeg de logfile: " + ex.Message + ": " + ex.StackTrace, "Foutmelding"); logger.LogException(LogLevel.Trace, "FOUT", ex); throw; } finally { ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(SelectionCursor); } }
///// <summary> ///// The active view has refreshed. Redraw our results, if we have any ///// </summary> ///// <param name="Display">Display to draw on</param> ///// <param name="phase"></param> //private void _arcMapWrapper_ActiveViewAfterDraw(ESRI.ArcGIS.Display.IDisplay Display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase) //{ // if (phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection) // { // // Draw after the selection // if (null != _currentResults) // { // ESRI.ArcGIS.Display.ILineSymbol lineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbol(); // ESRI.ArcGIS.Display.IRgbColor color = new ESRI.ArcGIS.Display.RgbColorClass(); // color.Red = 255; // color.Green = 0; // color.Blue = 0; // lineSymbol.Color = color; // lineSymbol.Width = 4; // ESRI.ArcGIS.Display.ISimpleMarkerSymbol markerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass(); // markerSymbol.Color = color; // markerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle; // markerSymbol.Size = 6; // for (int i = 0; i < _currentResults.Count; i++) // { // ESRI.ArcGIS.Geometry.IGeometry geometry = _currentResults[i]; // if (geometry is ESRI.ArcGIS.Geometry.IPolyline) // { // Display.SetSymbol((ESRI.ArcGIS.Display.ISymbol)lineSymbol); // Display.DrawPolyline((ESRI.ArcGIS.Geometry.IPolyline)geometry); // } // else if (geometry is ESRI.ArcGIS.Geometry.IPoint) // { // Display.SetSymbol((ESRI.ArcGIS.Display.ISymbol)markerSymbol); // Display.DrawPoint((ESRI.ArcGIS.Geometry.IPoint)geometry); // } // } // } // } //} private List <ESRI.ArcGIS.Geodatabase.IRow> TracePath(ESRI.ArcGIS.Geodatabase.IFeature cableFeature, int fiberNumber, bool isStartingAtFromEnd) { List <ESRI.ArcGIS.Geodatabase.IRow> result = new List <ESRI.ArcGIS.Geodatabase.IRow>(); string ipid = cableFeature.get_Value(cableFeature.Fields.FindField(ConfigUtil.IpidFieldName)).ToString(); ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = (ESRI.ArcGIS.Geodatabase.IFeatureClass)cableFeature.Class; ESRI.ArcGIS.Geodatabase.IFeatureClass spliceFtClass = _wkspHelper.FindFeatureClass(ConfigUtil.SpliceClosureFtClassName); ESRI.ArcGIS.Geodatabase.ITable fiberSpliceTable = _wkspHelper.FindTable(ConfigUtil.FiberSpliceTableName); ESRI.ArcGIS.Geodatabase.IFields spliceFields = fiberSpliceTable.Fields; string fiberClassName = ConfigUtil.FiberTableName; ESRI.ArcGIS.Geodatabase.IRelationshipClass fiberRelationship = GdbUtils.GetRelationshipClass(cableFtClass, ConfigUtil.FiberCableToFiberRelClassName); if (null != fiberRelationship && null != fiberRelationship.DestinationClass) { fiberClassName = GdbUtils.ParseTableName(fiberRelationship.DestinationClass as ESRI.ArcGIS.Geodatabase.IDataset); } ESRI.ArcGIS.Geodatabase.ITable fiberTable = _wkspHelper.FindTable(fiberClassName); _aCableIdx = spliceFields.FindField(ConfigUtil.ACableIdFieldName); _bCableIdx = spliceFields.FindField(ConfigUtil.BCableIdFieldName); _aFiberNumIdx = spliceFields.FindField(ConfigUtil.AFiberNumberFieldName); _bFiberNumIdx = spliceFields.FindField(ConfigUtil.BFiberNumberFieldName); _isAFromIdx = spliceFields.FindField(ConfigUtil.IsAFromEndFieldName); _isBFromIdx = spliceFields.FindField(ConfigUtil.IsBFromEndFieldName); _spliceClosureIpidIdx = spliceFields.FindField(ConfigUtil.SpliceClosureIpidFieldName); ESRI.ArcGIS.Geodatabase.IQueryFilter spliceFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); spliceFilter.WhereClause = string.Format("({0}='{1}' AND {2}={3})" + " OR ({4}='{1}' AND {5}={3})", ConfigUtil.ACableIdFieldName, ipid, ConfigUtil.AFiberNumberFieldName, fiberNumber, ConfigUtil.BCableIdFieldName, ConfigUtil.BFiberNumberFieldName); int connections = fiberSpliceTable.RowCount(spliceFilter); if (2 < connections) { // TODO: warning? System.Windows.Forms.MessageBox.Show("Less than 2 connections were detected: " + fiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } string spliceClosureIpid = string.Empty; string nextCableId = string.Empty; int nextFiberNumber = -1; bool isNextFromEnd = false; // {{0}} causes the string.format to string cableWhereFormat = string.Format("{0}='{{0}}'", ConfigUtil.IpidFieldName); string spliceWhereFormat = string.Format("{0}='{{0}}'", ConfigUtil.IpidFieldName); string fiberWhereFormat = string.Format("{0}='{{0}}' AND {1}={{1}}", fiberRelationship.OriginForeignKey, ConfigUtil.Fiber_NumberFieldName); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); // Ripple down the start cable's to end ESRI.ArcGIS.Geodatabase.IRow spliceRow = GetNextSplice(fiberSpliceTable, ipid, fiberNumber, isStartingAtFromEnd, out nextCableId, out nextFiberNumber, out spliceClosureIpid, out isNextFromEnd); while (null != spliceRow) { ESRI.ArcGIS.Geodatabase.IFeature spliceClosure = null; if (spliceClosureIpid.Equals("")) { System.Windows.Forms.MessageBox.Show("Found Splice with no SpliceClosure (ID/#) " + nextCableId + "/" + nextFiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } else { filter.WhereClause = string.Format(spliceWhereFormat, spliceClosureIpid); ESRI.ArcGIS.Geodatabase.IFeatureCursor spliceCursor = spliceFtClass.Search(filter, false); releaser.ManageLifetime(spliceCursor); spliceClosure = spliceCursor.NextFeature(); if (spliceClosure == null) { System.Windows.Forms.MessageBox.Show("Invalid SpliceClosure referenced: (IPID)" + spliceClosureIpid, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } } filter.WhereClause = string.Format(cableWhereFormat, nextCableId); ESRI.ArcGIS.Geodatabase.IFeatureCursor cableCursor = cableFtClass.Search(filter, false); releaser.ManageLifetime(cableCursor); ESRI.ArcGIS.Geodatabase.IFeature cable = cableCursor.NextFeature(); if (cable == null) { System.Windows.Forms.MessageBox.Show("Invalid cable ID referenced: (ID)" + nextCableId, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } filter.WhereClause = string.Format(fiberWhereFormat, nextCableId, nextFiberNumber); ESRI.ArcGIS.Geodatabase.ICursor fiberCursor = fiberTable.Search(filter, false); releaser.ManageLifetime(fiberCursor); ESRI.ArcGIS.Geodatabase.IRow fiber = fiberCursor.NextRow(); if (fiber == null) { System.Windows.Forms.MessageBox.Show("Invalid Fiber Cable or # referenced: (ID/#) " + nextCableId + "/" + nextFiberNumber, "Telecom Trace", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } if (isStartingAtFromEnd) { if (spliceRow != null) { result.Add(spliceRow); } if (spliceClosure != null) { result.Add(spliceClosure); } if (fiber != null) { result.Add(fiber); } if (cable != null) { result.Add(cable); } } else { if (spliceClosure != null) { result.Add(spliceClosure); } if (spliceRow != null) { result.Add(spliceRow); } if (cable != null) { result.Add(cable); } if (fiber != null) { result.Add(fiber); } } spliceRow = GetNextSplice(fiberSpliceTable, nextCableId, nextFiberNumber, !isNextFromEnd, out nextCableId, out nextFiberNumber, out spliceClosureIpid, out isNextFromEnd); } // See if there is a port for this one ESRI.ArcGIS.Geodatabase.IRow portRow = null; ESRI.ArcGIS.Geodatabase.IFeature deviceFt = null; if (GetConnectedPort(cableFtClass, nextCableId, nextFiberNumber, isNextFromEnd, out portRow, out deviceFt)) { if (isStartingAtFromEnd) { result.Add(portRow); result.Add(deviceFt); } else { result.Add(deviceFt); result.Add(portRow); } } return(result); } }
private FiberCableWrapper GetConnectedFiber(DeviceWrapper device, int portId, PortType portType, out int fiberNumber) { FiberCableWrapper result = null; fiberNumber = -1; ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = (ESRI.ArcGIS.Geodatabase.IFeatureClass)device.Feature.Class; ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass); if (null == deviceHasPorts) { throw new Exception("Device to port relationship is missing or cannot be opened."); } ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable; if (null == portTable) { throw new Exception("Port table is missing or cannot be opened."); } using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); releaser.ManageLifetime(filter); filter.WhereClause = string.Format("{0}='{1}' AND {2}={3} AND {4}='{5}'", deviceHasPorts.OriginForeignKey, device.Feature.get_Value(deviceFtClass.FindField(deviceHasPorts.OriginPrimaryKey)), ConfigUtil.PortIdFieldName, portId, ConfigUtil.PortTypeFieldName, PortType.Input == portType ? 1 : 2); ESRI.ArcGIS.Geodatabase.ICursor cursor = portTable.Search(filter, false); releaser.ManageLifetime(cursor); ESRI.ArcGIS.Geodatabase.IRow portRow = cursor.NextRow(); if (null != portRow) { //releaser.ManageLifetime(portRow); object cableIdValue = portRow.get_Value(portTable.FindField(ConfigUtil.ConnectedCableFieldName)); if (DBNull.Value != cableIdValue) { ESRI.ArcGIS.Geodatabase.IFeatureClass cableFtClass = _wkspHelper.FindFeatureClass(ConfigUtil.FiberCableFtClassName); filter.WhereClause = string.Format("{0}='{1}'", ConfigUtil.IpidFieldName, cableIdValue); ESRI.ArcGIS.Geodatabase.IFeatureCursor cableCursor = cableFtClass.Search(filter, false); releaser.ManageLifetime(cableCursor); ESRI.ArcGIS.Geodatabase.IFeature cable = cableCursor.NextFeature(); if (null != cable) { result = new FiberCableWrapper(cable); object fiberNumberValue = portRow.get_Value(portTable.FindField(ConfigUtil.ConnectedFiberFieldName)); if (DBNull.Value != fiberNumberValue) { int.TryParse(fiberNumberValue.ToString(), out fiberNumber); } } } } } return(result); }
private void KalibreerVormpuntenOpBasisVanRaaien(IFeatureSelection FeatureSelectionMShape) { IPolygon buffer; int featurecount = FeatureSelectionMShape.SelectionSet.Count; int featurecounter = 0; double m_begin = 0; double m_eind = 0; ICursor SelectionCursor = null; if (featurecount == 0) { SelectionCursor = ((FeatureSelectionMShape as IFeatureLayer).FeatureClass.Search(null, false)) as ICursor; featurecount = (FeatureSelectionMShape as IFeatureLayer).FeatureClass.FeatureCount(null); } else { FeatureSelectionMShape.SelectionSet.Search(null, false, out SelectionCursor); } try { IFeature feature = SelectionCursor.NextRow() as IFeature; string sleutel1 = Convert.ToString(feature.get_Value(feature.Fields.FindField(this.mshape_sleutel1))); string sleutel2 = null; if (this.mshape_sleutel2 != "") { sleutel2 = Convert.ToString(feature.get_Value(feature.Fields.FindField(this.mshape_sleutel2))); } IPolyline Polyline = null; IPolyline RaaiExtended = null; string hmwaarde = ""; double hmgetal = 0; while (feature != null) { // Vraag de lijn op Polyline = feature.ShapeCopy as IPolyline; m_begin = (Polyline as IPointCollection).get_Point(0).M; m_eind = (Polyline as IPointCollection).get_Point((Polyline as IPointCollection).PointCount - 1).M; // bestaande measures wissen (Polyline as IMAware).DropMs(); buffer = (Polyline as ITopologicalOperator).Buffer(Properties.Settings.Default.raai_afstand) as IPolygon; // Selecteer alle LRS lijnen binnen de zoekafstand ISpatialFilter SpatialFilter = new SpatialFilter(); IQueryFilter QueryFilter = SpatialFilter; IFeature FeatureRaai = null; SpatialFilter.Geometry = buffer; SpatialFilter.GeometryField = fcRaai.ShapeFieldName; string whereclause = Properties.Settings.Default.raai_selectie; SpatialFilter.WhereClause = string.Format(whereclause, sleutel1, sleutel2); SpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; ESRI.ArcGIS.Geodatabase.IFeatureCursor FeatureCursorRaaien = fcRaai.Search(QueryFilter, false); try { FeatureRaai = FeatureCursorRaaien.NextFeature(); // this._ArcObjectsHelper.AddGraphicToMap((ArcMap.Document as IMxDocument).FocusMap, Polyline, System.Drawing.Color.Red, System.Drawing.Color.Red); while (FeatureRaai != null) { RaaiExtended = FeatureRaai.ShapeCopy as IPolyline; hmwaarde = Convert.ToString(FeatureRaai.get_Value(FeatureRaai.Fields.FindField(Properties.Settings.Default.raai_hmgetal))); if (!(double.TryParse(hmwaarde, NumberStyles.Float, CultureInfo.InvariantCulture, out hmgetal))) { if (this.MarkeerRaaiMetOngeldigeHmwaarde) { _ArcObjectsHelper.AddGraphicToMap(FeatureRaai.ShapeCopy, this.KleurRaaiMetOngeldigeHmwaarde); } continue; } if (between(m_begin, m_eind, hmgetal)) { _ArcObjectsHelper.ScaleRaai(ref RaaiExtended); _ArcObjectsHelper.InsertPointAtIntersection(ref Polyline, RaaiExtended as IGeometry, hmgetal); } FeatureRaai = FeatureCursorRaaien.NextFeature(); } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Er is een onverwachte fout opgetreden; raadpleeg de logfile: " + ex.Message + ": " + ex.StackTrace, "Foutmelding"); logger.LogException(LogLevel.Trace, "FOUT", ex); throw; } finally { FeatureRaai = null; QueryFilter = null; ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(FeatureCursorRaaien); } // bijwerken measures met oorspronkelijke begin- en eindmeasure this.ResetBeginEnEindMeasure(Polyline, m_begin, m_eind, true); // controleer of de lijn monotoon op- of aflopend is bool bNietMonotoon = false; #region Controleer of de lijn monotoon oplopend of aflopend is en markeer de lijn. int MMonotonicity = ((Polyline as IMSegmentation3).MMonotonicity); if (MMonotonicity == 5 || MMonotonicity == 7 || MMonotonicity == 15) { bNietMonotoon = true; if (this.MarkeerLijnNietMonotoon) { _ArcObjectsHelper.AddGraphicToMap(Polyline, this.KleurLijnNietMonotoon); } } if ((bNietMonotoon) && (this.OpslaanLijnNietMonotoon)) { feature.Shape = Polyline; feature.Store(); } else if (!bNietMonotoon) { feature.Shape = Polyline; feature.Store(); } #endregion // voortgang featurecounter += 1; this.progress = (100 * featurecounter) / featurecount; feature = SelectionCursor.NextRow() as IFeature; } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Er is een onverwachte fout opgetreden; raadpleeg de logfile: " + ex.Message + ": " + ex.StackTrace, "Foutmelding"); logger.LogException(LogLevel.Trace, "FOUT", ex); throw; } finally { ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(SelectionCursor); } }
private void button_Import_Click(object sender, System.EventArgs e) { // point to the first selected feature: ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass(); // Set properties for AGImportPathOptions AGImportPathOptionsCls.BasicMap = (ESRI.ArcGIS.Carto.IBasicMap)globe; // Explicit Cast AGImportPathOptionsCls.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)globe; // Explicit Cast AGImportPathOptionsCls.AnimationType = new ESRI.ArcGIS.GlobeCore.AnimationTypeGlobeCameraClass(); AGImportPathOptionsCls.AnimatedObject = globe.GlobeDisplay.ActiveViewer.Camera; if (this.radioButton_flyby.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObsAndTarget; AGImportPathOptionsCls.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative); AGImportPathOptionsCls.PutAngleCalculationValues(0.0, 0.0, 0.0); } else if (this.radioButton_currentTarget.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathObserver; } else if (this.radioButton_currentObserver.Checked == true) { AGImportPathOptionsCls.ConversionType = esriFlyFromPathType.esriFlyFromPathTarget; } double pAzimuth, pInclination, pRollVal; AGImportPathOptionsCls.GetAngleCalculationValues(out pAzimuth, out pInclination, out pRollVal); AGImportPathOptionsCls.LookaheadFactor = this.trackBarSimplificationFactor.Value / 100; AGImportPathOptionsCls.TrackName = this.textBox_TrackName.Text; AGImportPathOptionsCls.OverwriteExisting = Convert.ToBoolean(this.checkBox_Overwrite.CheckState); AGImportPathOptionsCls.VerticalOffset = Convert.ToDouble(this.textBox_VertOffset.Text); AGImportPathOptionsCls.ReversePath = Convert.ToBoolean(this.checkBox_ReverseOrder.CheckState); // get the layer selected in the combo box if (this.comboBoxLayers.SelectedIndex == -1) { MessageBox.Show("Please select a layer before you proceed"); } else { //set the layer based on the item selected in the combo box ESRI.ArcGIS.Carto.ILayer layer = (ESRI.ArcGIS.Carto.ILayer)layerArray.get_Element(this.comboBoxLayers.SelectedIndex); // Explicit Cast // Get the line feature selected in the layer ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)layer; // Explicit Cast ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = (ESRI.ArcGIS.Carto.IFeatureSelection)layer; // Explicit Cast ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet = featureSelection.SelectionSet; ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass; string shapeField = featureClass.ShapeFieldName; ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); IScene scene = globe.GlobeDisplay.Scene; ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = scene.SpatialReference; spatialFilterCls.GeometryField = shapeField; spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference); ESRI.ArcGIS.Geodatabase.ICursor cursor; selectionSet.Search(spatialFilterCls, true, out cursor); ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = (ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor; // Explicit Cast ESRI.ArcGIS.Geodatabase.IFeature lineFeature; lineFeature = featureCursor.NextFeature(); if (lineFeature == null) { MessageBox.Show("Please select a feature in the feature layer selected"); } else { CreateFlybyFromPathAnimation(globe, lineFeature, AGImportPathOptionsCls); } } this.Close(); }
/// <summary> /// Returns all features from a given feature class that have a vertex or endpoint coincident with a given point /// </summary> /// <param name="point">IPoint to use as the spatial filter</param> /// <param name="searchFtClass">IFeatureClass to search in</param> /// <param name="linearEndpointsOnly">Flag to use only the endpoints of a line instead of all vertices</param> /// <param name="buffer">Search geometry buffer in map units</param> /// <returns>List of IFeature</returns> public static List <ESRI.ArcGIS.Geodatabase.IFeature> GetFeaturesWithCoincidentVertices(ESRI.ArcGIS.Geometry.IPoint point, ESRI.ArcGIS.Geodatabase.IFeatureClass searchFtClass, bool linearEndpointsOnly, double buffer) { List <ESRI.ArcGIS.Geodatabase.IFeature> result = new List <ESRI.ArcGIS.Geodatabase.IFeature>(); using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser()) { ESRI.ArcGIS.Geodatabase.ISpatialFilter filter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass(); releaser.ManageLifetime(filter); ESRI.ArcGIS.Geometry.IEnvelope filterGeometry = point.Envelope; if (0 < buffer) { filterGeometry.Expand(buffer, buffer, false); } filter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects; filter.Geometry = filterGeometry; ESRI.ArcGIS.Geodatabase.IFeatureCursor fts = searchFtClass.Search(filter, false); releaser.ManageLifetime(fts); ESRI.ArcGIS.Geodatabase.IFeature ft = fts.NextFeature(); while (null != ft) { if (searchFtClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { result.Add(ft); } else if (searchFtClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline && linearEndpointsOnly) { ESRI.ArcGIS.Geometry.IPolyline polyline = (ESRI.ArcGIS.Geometry.IPolyline)ft.Shape; ESRI.ArcGIS.Geometry.IRelationalOperator fromPoint = polyline.FromPoint as ESRI.ArcGIS.Geometry.IRelationalOperator; ESRI.ArcGIS.Geometry.IRelationalOperator toPoint = polyline.ToPoint as ESRI.ArcGIS.Geometry.IRelationalOperator; if (fromPoint.Equals(point) || toPoint.Equals(point)) { result.Add(ft); } } else { ESRI.ArcGIS.Geometry.IPointCollection pointCollection = ft.Shape as ESRI.ArcGIS.Geometry.IPointCollection; if (null != pointCollection) { for (int i = 0; i < pointCollection.PointCount; i++) { ESRI.ArcGIS.Geometry.IRelationalOperator testPoint = pointCollection.get_Point(i) as ESRI.ArcGIS.Geometry.IRelationalOperator; if (testPoint.Equals(point)) { result.Add(ft); break; } } } } ft = fts.NextFeature(); } } return(result); }