Exemplo n.º 1
0
        void ESRI.ArcGIS.Display.ISymbol.Draw(ESRI.ArcGIS.Geometry.IGeometry Geometry)
        {
            if (m_lhDC == 0 | m_colorTop == null | m_colorLeft == null | m_colorRight == null | m_colorBorder == null)
                return;
            if (Geometry == null)
                return;
            if (!(Geometry is ESRI.ArcGIS.Geometry.IPoint))
                return;

            // Transform the Point coords to device coords, accounting for rotation, offset etc.
            ESRI.ArcGIS.Geometry.IPoint point = (IPoint)Geometry;

            int lCenterX = 0;
            int lCenterY = 0;

            Utility.FromMapPoint(m_trans, ref point, ref lCenterX, ref lCenterY);
            double tempy1 = System.Convert.ToDouble(lCenterY);
            CalcCoords(System.Convert.ToDouble(lCenterX), ref tempy1);

            //  Draw the chord, and two polygons, and flood fill them.
            //int lResult = 0;
            //int lTempBrush = 0;
            //m_lOldBrush = Utility.SelectObject(m_lhDC, m_lBrushTop);
            //lResult = Utility.Chord(m_lhDC, m_coords[5].x, m_coords[5].y, m_coords[6].x, m_coords[6].y, m_coords[4].x, m_coords[4].y, m_coords[1].x, m_coords[1].y);

            //Utility.SelectObject(m_lhDC, m_lBrushLeft);
            //lResult = Utility.Polygon(m_lhDC, ref m_coords[1], 3);

            //Utility.SelectObject(m_lhDC, m_lBrushRight);
            //lResult = Utility.Polygon(m_lhDC, ref m_coords[2], 3);

            //Utility.SelectObject(m_lhDC, m_lOldBrush);
        }
Exemplo n.º 2
0
        public static GeoAPI.Geometries.ILinearRing ConvertTo(ESRI.ArcGIS.Geometry.IRing ring)
        {
            ESRI.ArcGIS.Geometry.IPoint          fromToPoint = ring.FromPoint;
            List <GeoAPI.Geometries.ICoordinate> list        = new List <GeoAPI.Geometries.ICoordinate>();

            list.Add(ConvertTo(fromToPoint));
            ISegmentCollection segmentCollection = ring as ISegmentCollection;

            if (segmentCollection != null)
            {
                int count = segmentCollection.SegmentCount;
                for (int i = 0; i < count; i++)
                {
                    ISegment segment = segmentCollection.get_Segment(i);
                    if (!(segment is ILine))
                    {
                        throw new ApplicationException("Curves are not supported.");
                    }
                    list.Add(ConvertTo(segment.ToPoint));
                }
            }
            else
            {
                throw new ApplicationException("No segments found in the ring geometry.");
            }

            list.Add(ConvertTo(fromToPoint));
            list.Reverse();
            return(new GisSharpBlog.NetTopologySuite.Geometries.LinearRing(list.ToArray()));
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            if (m_frmQuery == null)
            {
                m_frmQuery             = new frmQuery(m_MapControl, m_enumQueryMode);
                m_frmQuery.Owner       = m_mainFrm;
                m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
            }

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            frmBufferSet pFrmBufSet            = new frmBufferSet(pPoint as IGeometry, m_MapControl.Map, m_frmQuery);
            IGeometry    pGeometry             = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            m_frmQuery.Show();
            m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry);
        }
Exemplo n.º 4
0
 private void pAxMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     pPt = new ESRI.ArcGIS.Geometry.PointClass();
     pPt.PutCoords(e.mapX, e.mapY);
     Scale = Convert.ToInt32(cBoxScale.Text.Split(':')[1]);
     if (Scale > 2000)
     {
         WKSPoint pPoint = new WKSPoint();
         pPoint.X = e.mapX;
         pPoint.Y = e.mapY;
         if (pAxMapControl.MapUnits == esriUnits.esriMeters)
         {
             (pAxMapControl.SpatialReference as IProjectedCoordinateSystem).Inverse(1, ref pPoint);//求点投影的经纬度坐标
         }
         GeoDrawSheetMap.basPageLayout.GetNewCodeFromCoordinate(ref MapNo, (long)(pPoint.X * 3600), (long)(pPoint.Y * 3600),
                                                                Convert.ToInt32(cBoxScale.Text.Split(':')[1]));
         MapNo         = MapNo.Insert(3, " ");//H50 G 054071
         MapNo         = MapNo.Insert(5, " ");
         txtMapNo.Text = MapNo;
         this.Show(pMainForm);
     }
     else
     {
         txtMapNo.Text = getMapNOforBigScale(Scale, pPt);
         this.Show(pMainForm);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 将点线面要素都转换为点要素,并返回点要素的IGeometry
        /// </summary>
        /// <param name="pFeature">要素</param>
        /// <returns></returns>
        private IGeometry GetErrorGeometry(IFeature pFeature)
        {
            IGeometry        pGeo = null;
            esriGeometryType type = pFeature.Shape.GeometryType;

            switch (type)
            {
            case esriGeometryType.esriGeometryPoint:
                pGeo = pFeature.ShapeCopy;
                break;

            case esriGeometryType.esriGeometryPolygon:
            {
                IPolygon pPolygon = (IPolygon)pFeature.Shape;
                IArea    pArea    = (IArea)pPolygon;
                IPoint   pPoint   = pArea.Centroid;
                pGeo = (IGeometry)pPoint;
                break;
            }

            case esriGeometryType.esriGeometryPolyline:
            {
                IPolyline pPolyLine = (IPolyline)pFeature.Shape;
                IPoint    pPoint    = GetMidPoint(pPolyLine);
                pGeo = (IGeometry)pPoint;
                break;
            }
            }
            return(pGeo);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 绘制文字到地图中
        /// </summary>
        /// <params name="text"></params>
        /// <params name="pPoint"></params>
        /// <params name="drawFont"></params>
        void DrawTextToMap(string text, ESRI.ArcGIS.Geometry.IPoint pPoint)
        {
            IElement element;

            ITextElement textElement = new TextElementClass();

            element = textElement as IElement;

            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = m_color;
            if (m_pFont != null)
            {
                textSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(m_pFont);
                textSymbol.Size = Convert.ToDouble(m_pFont.Size);
            }
            element.Geometry = pPoint;

            textElement.Symbol = textSymbol;
            textElement.Text   = text;
            IFeature pFeature = DataEditCommon.SaveAnno(element, text);

            GIS.Common.DataEditCommon.g_pMap.SelectFeature(GIS.Common.DataEditCommon.g_pLayer, pFeature);
            GIS.Common.DataEditCommon.g_pAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
        }
Exemplo n.º 7
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     try
     {
         ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
         ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();
         m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
         pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         if (pMapPoint == null)
         {
             return;
         }
         pMapPoint.Project(m_psurface.Domain.SpatialReference);
         pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
         IGroupElement pGroup = null;
         ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         m_Geometry = pMapPoint;
         EndDtrawd(true);
     }
     catch
     {
         return;
     }
 }
Exemplo n.º 8
0
        internal void LoadFile(int X, int Y)
        {
            if (CheckRequirments())
            {
                try
                {
                    ESRI.ArcGIS.Display.IScreenDisplay screenDisplay    = (_application.Document as IMxDocument).ActiveView.ScreenDisplay;
                    ESRI.ArcGIS.Geometry.IPoint        point            = screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    ESRI.ArcGIS.Carto.IFeatureLayer    tilefeaturelayer = _utilitiesArcMap.FeatureLayer(cboTileIndex.Text);
                    IFeatureClass tilefeatureclass = tilefeaturelayer.FeatureClass;

                    ISpatialFilter spatialfilter = new SpatialFilter();
                    spatialfilter.GeometryField = tilefeatureclass.ShapeFieldName;
                    spatialfilter.Geometry      = point;
                    spatialfilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                    IFeatureCursor tilefeaturecursor = tilefeatureclass.Search(spatialfilter, false);
                    IFeature       tilefeature       = null;

                    while ((tilefeature = tilefeaturecursor.NextFeature()) != null)
                    {
                        object obj = tilefeature.get_Value(_utilitiesArcMap.FindField(tilefeature, this.cboNameField.Text));
                        if (obj != DBNull.Value)
                        {
                            string tilename = obj.ToString();
                            LoadFile(txbFileWorkspace.Text + "\\" + tilename + ".");
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 9
0
 public frmQuerySlope(string strText)
 {
     InitializeComponent();
     this.Text    = strText + "查询";
     m_SurFace    = null;
     m_SlopePoint = null;
     labelX2.Text = strText + "值:";
 }
Exemplo n.º 10
0
        public static GeoAPI.Geometries.ICoordinate ConvertTo(ESRI.ArcGIS.Geometry.IPoint point)
        {
            if (point == null)
            {
                throw new ArgumentNullException("point", "A valid point reference is required.");
            }

            return(new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(point.X, point.Y, point.Z));
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            if (m_frmQuery == null)
            {
                m_frmQuery             = new frmQuery(m_MapControl, m_enumQueryMode);
                m_frmQuery.Owner       = m_mainFrm;
                m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
            }
            //清除上次的所有元素
            (m_MapControl.Map as IGraphicsContainer).DeleteAllElements();

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            if (m_frmBufferSet != null)
            {
                SysCommon.ScreenDraw.list.Remove(m_frmBufferSet.BufferSetAfterDraw);
                m_frmBufferSet.setBufferGeometry(null);
                m_frmBufferSet = null;
            }
            m_frmBufferSet = new frmBufferSet(pPoint as IGeometry, m_MapControl.Map, m_frmQuery);
            IGeometry pGeometry = m_frmBufferSet.GetBufferGeometry();

            if (pGeometry == null || m_frmBufferSet.Res == false)
            {
                return;
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("点缓冲查询");//xisheng 日志记录 0928;
            }
            // m_frmQuery.Show();
            ///ZQ 20111119  modify
            //m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry,m_frmBufferSet.pesriSpatialRelEnum);
            _QuerBar.m_pMapControl = m_MapControl;
            _QuerBar.EmergeQueryData(m_MapControl.ActiveView.FocusMap, pGeometry, m_frmBufferSet.pesriSpatialRelEnum);

            try
            {
                DevComponents.DotNetBar.Bar pBar = _QuerBar.Parent.Parent as DevComponents.DotNetBar.Bar;
                if (pBar != null)
                {
                    pBar.AutoHide = false;
                    //pBar.SelectedDockTab = 1;
                    int tmpindex = pBar.Items.IndexOf("dockItemDataCheck");
                    pBar.SelectedDockTab = tmpindex;
                }
            }
            catch
            { }
            //pFrmBufSet.setBufferGeometry(null);
            //pFrmBufSet.Refresh();
            //pFrmBufSet = null;
        }
Exemplo n.º 12
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_pPoint = pPoint;
        }
Exemplo n.º 13
0
        public void OnMouseUp(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }
            IPoint pPoint = m_pScrd.DisplayTransformation.ToMapPoint(x, y);

            m_pPoint = pPoint;
            AddNormalTextElement(m_pPoint);
        }
Exemplo n.º 14
0
        private void BroadcastCoordinateValues(ESRI.ArcGIS.Geometry.IPoint point)
        {
            var dict = new Dictionary <CoordinateType, string>();

            if (point == null)
            {
                return;
            }

            var cn = point as IConversionNotation;

            if (cn == null)
            {
                return;
            }

            try
            {
                dict.Add(CoordinateType.DD, cn.GetDDFromCoords(6));
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.DDM, cn.GetDDMFromCoords(6));
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.DMS, cn.GetDMSFromCoords(6));
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.GARS, cn.GetGARSFromCoords());
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.MGRS, cn.CreateMGRS(5, true, esriMGRSModeEnum.esriMGRSMode_Automatic));
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.USNG, cn.GetUSNGFromCoords(5, true, false));
            }
            catch { }
            try
            {
                dict.Add(CoordinateType.UTM, cn.GetUTMFromCoords(esriUTMConversionOptionsEnum.esriUTMAddSpaces | esriUTMConversionOptionsEnum.esriUTMUseNS));
            }
            catch { }

            Mediator.NotifyColleagues(CoordinateToolLibrary.Constants.BroadcastCoordinateValues, dict);
        }
Exemplo n.º 15
0
        public ESRI.ArcGIS.Geometry.IPoint GetPointFromMouseClicks(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPoint();
            ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, null);

            ESRI.ArcGIS.Geometry.IPoint point = (ESRI.ArcGIS.Geometry.IPoint)geometry;

            return(point);
        }
Exemplo n.º 16
0
        public bool OnContextMenu(int x, int y)
        {
            ESRI.ArcGIS.Geometry.IPoint point = this.hk.PageLayoutControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            IElement mapSurroundElement = ElementPropetyImp.GetElementFromPage(this.hk.PageLayoutControl, (int)point.X, (int)point.Y);

            _rightMenu1.SetCurrentElement(mapSurroundElement);
            _rightMenu2.SetCurrentElement(mapSurroundElement);
            _layerMenu.PopupMenu(x, y, this.hk.PageLayoutControl.hWnd);

            return(false);
        }
Exemplo n.º 17
0
        private byte[] QueryPoint(ESRI.ArcGIS.Geometry.IPoint location, double distance)
        {
            if (distance <= 0.0)
                throw new ArgumentOutOfRangeException("distance");
            // Buffer the point.
            ITopologicalOperator topologicalOperator = (ESRI.ArcGIS.Geometry.ITopologicalOperator)location;
            IGeometry queryGeometry = topologicalOperator.Buffer(distance);
            // Query the feature class.
            ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilter();
            spatialFilter.Geometry = queryGeometry;
            spatialFilter.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects;
            spatialFilter.GeometryField = m_fcToQuery.ShapeFieldName;
            IFeatureCursor resultsFeatureCursor = m_fcToQuery.Search(spatialFilter, true);
            // Loop through the features, clip each geometry to the buffer
            // and total areas by attribute value.
            topologicalOperator = (ESRI.ArcGIS.Geometry.ITopologicalOperator)queryGeometry;
            int classFieldIndex = m_fcToQuery.FindField(m_mapFieldToQuery);
            // System.Collections.Specialized.ListDictionary summaryStatsDictionary = new System.Collections.Specialized.ListDictionary();
            Dictionary<string, double> summaryStatsDictionary = new Dictionary<string, double>();
            // Initialize a list to hold JSON geometries.
            List<JsonObject> jsonGeometries = new List<JsonObject>();

            IFeature resultsFeature = null;
            while ((resultsFeature = resultsFeatureCursor.NextFeature()) != null)
            {
                // Clip the geometry.
                IPolygon clippedResultsGeometry = (IPolygon)topologicalOperator.Intersect(resultsFeature.Shape,
                    ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension);
                clippedResultsGeometry.Densify(0, 0); // Densify to maintain curved appearance when converted to JSON. 
                // Convert the geometry to JSON and add it to the list.
                JsonObject jsonClippedResultsGeometry = Conversion.ToJsonObject(clippedResultsGeometry);
                jsonGeometries.Add(jsonClippedResultsGeometry);
                // Get statistics.
                IArea area = (IArea)clippedResultsGeometry;
                string resultsClass = resultsFeature.get_Value(classFieldIndex) as string;
                // If the class is already in the dictionary, add the current feature's area to the existing entry.
                if (summaryStatsDictionary.ContainsKey(resultsClass))
                    summaryStatsDictionary[resultsClass] = (double)summaryStatsDictionary[resultsClass] + area.Area;
                else
                    summaryStatsDictionary[resultsClass] = area.Area;
            }
            // Use a helper method to get a JSON array of area records.
            JsonObject[] areaResultJson = CreateJsonRecords(summaryStatsDictionary) as JsonObject[];
            // Create a JSON object of the geometry results and the area records.
            JsonObject resultJsonObject = new JsonObject();
            resultJsonObject.AddArray("geometries", jsonGeometries.ToArray());
            resultJsonObject.AddArray("records", areaResultJson);
            // Get byte array of json and return results.
            byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson());
            return result;
        }
Exemplo n.º 18
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                if (m_hookHelper == null)
                {
                    return;
                }
                IFeature featureFinded = null;
                if (Button == 1)
                {
                    Map = m_hookHelper.FocusMap;
                    if (Map == null)
                    {
                        return;
                    }
                    activeView = (IActiveView)Map;

                    clickedPoint = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    IEnvelope envelope = Envelope_Search(activeView);
                    for (int i = 0; i < Map.LayerCount - 1; i++)
                    {
                        ILayer layer = Map.get_Layer(i);
                        if (layer is IFeatureLayer)
                        {
                            IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)layer;
                            if (geoFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                            {
                                featureFinded = GetFirstFeatureFromPointSearchInGeoFeatureLayer(envelope, geoFeatureLayer, activeView);
                                if (featureFinded != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (featureFinded != null)
                    {
                        IFeatureClass featureClass   = (IFeatureClass)featureFinded.Class;
                        int           indexAreaField = featureClass.FindField(featureClass.AreaField.Name);
                        AddTextElement((double)featureFinded.get_Value(indexAreaField), activeView);
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 19
0
 private void pToolQuerySlope_EndDtrawd(bool BeginDraw)
 {
     if (BeginDraw)
     {
         m_SlopePoint = null;
         m_SlopePoint = pToolQuerySlope.m_Geometry;
         if (this.Text == "坡度查询")
         {
             txtSlope.Text = m_SurFace.GetSlopeDegrees(m_SlopePoint).ToString();
         }
         else if (this.Text == "坡向查询")
         {
             txtSlope.Text = m_SurFace.GetAspectDegrees(m_SlopePoint).ToString();
         }
     }
 }
Exemplo n.º 20
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (_axmapcontrol != null)
            {
                try
                {
                    /*xisheng 20110802 */
                    p1.Visible = p2.Visible = p3.Visible = p4.Visible = false;
                    ISpatialReferenceFactory2 pSpatRefFac = new SpatialReferenceEnvironmentClass();
                    earthref = pSpatRefFac.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

                    point = new ESRI.ArcGIS.Geometry.PointClass();
                    double x1 = Convert.ToDouble(textBoxX.Text);
                    double y1 = Convert.ToDouble(textBoxY.Text);
                    if (_axmapcontrol.MapUnits == esriUnits.esriMeters)
                    {
                        flatref = _axmapcontrol.Map.SpatialReference;
                        point   = GetProject(x1, y1);
                    }
                    else if (_axmapcontrol.MapUnits == esriUnits.esriDecimalDegrees)
                    {
                        point.PutCoords(x1, y1);
                    }
                    //end 0802
                    if (this.WriteLog)
                    {
                        Plugin.LogTable.Writelog("地图坐标定位到中心点(" + x1 + "," + y1 + ")");//xisheng 日志记录
                    }
                    _axmapcontrol.CenterAt(point);
                    _axmapcontrol.ActiveView.Refresh();

                    int x = Convert.ToInt32(point.X);
                    int y = Convert.ToInt32(point.Y);
                    _axmapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(point, out x, out y);
                    p1.Location = new System.Drawing.Point(x - 11, y - 1);
                    p2.Location = new System.Drawing.Point(x - 1, y - 11);
                    p3.Location = new System.Drawing.Point(x + 1, y - 1);
                    p4.Location = new System.Drawing.Point(x - 1, y + 1);
                    p1.Visible  = p2.Visible = p3.Visible = p4.Visible = true;
                }
                catch (Exception ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "错误:" + ex.Message);
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 判断两点要素是否在同一位置    张琪 201108208
        /// </summary>
        /// <param name="Point1"></param>
        /// <param name="Point2"></param>
        /// <returns></returns>
        public static bool PointIsSame(ESRI.ArcGIS.Geometry.IPoint Point1, ESRI.ArcGIS.Geometry.IPoint Point2)
        {
            bool TheSame = true;

            if (Point1.X != Point2.X)
            {
                TheSame = false;
            }
            if (Point1.Y != Point2.Y)
            {
                TheSame = false;
            }
            if (Point1.Z != Point2.Z)
            {
                TheSame = false;
            }
            return(TheSame);
        }
Exemplo n.º 22
0
        private void dataGridViewR_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (dataGridViewR.SelectedRows.Count == 0)
            {
                return;
            }
            int      oid      = Convert.ToInt32(dataGridViewR.SelectedRows[0].Cells["OBJECTID"].Value);
            IFeature pFeature = pFLayer.FeatureClass.GetFeature(oid);

            ESRI.ArcGIS.Geometry.IPoint pPoint = pFeature.ShapeCopy as ESRI.ArcGIS.Geometry.IPoint;
            IEnvelope pEnv = new EnvelopeClass();

            pEnv.PutCoords(pPoint.X - 250, pPoint.Y - 250, pPoint.X + 250, pPoint.Y + 250);
            ///ZQ 20111020 定位范围扩大1.5倍
            SysCommon.ModPublicFun.ResizeEnvelope(pEnv, 1.5);
            (pMap as IActiveView).Extent = pEnv;
            (pMap as IActiveView).Refresh();
        }
Exemplo n.º 23
0
        private void method_3()
        {
            IPointCollection pointCollection = (IPointCollection)this.m_pBaseLine;
            int pointCount = pointCollection.PointCount;

            if (pointCount != 0)
            {
                IPoint point   = pointCollection.get_Point(0);
                IPoint point2  = pointCollection.get_Point(pointCount - 1);
                GPoint gPoint  = new GPoint();
                GPoint gPoint2 = new GPoint();
                gPoint.X  = point.X;
                gPoint.Y  = point.Y;
                gPoint2.X = point2.X;
                gPoint2.Y = point2.Y;
                double angleToPt = gPoint.GetAngleToPt(gPoint2);
                this.m_pSectionDisp.TranAngle = angleToPt;
            }
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            frmBufferSet pFrmBufSet            = new frmBufferSet(pPoint as IGeometry, m_MapControl.Map);
            IGeometry    pGeometry             = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            //==================================================================================================
            //执行查询数据操作
            ModDBOperator.QueryDataByGeometry(pGeometry, m_hook);
        }
Exemplo n.º 25
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            if (m_frmQuery == null)
            {
                m_frmQuery             = new frmQuery(m_MapControl, m_enumQueryMode);
                m_frmQuery.Owner       = m_mainFrm;
                m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
            }

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            frmBufferSet pFrmBufSet            = new frmBufferSet(pPoint as IGeometry, m_MapControl.Map, m_frmQuery);
            IGeometry    pGeometry             = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            //m_frmQuery.Show();
            //m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry);
            _QuerBar.m_pMapControl = m_MapControl;
            _QuerBar.EmergeQueryData(m_MapControl.ActiveView.FocusMap, pGeometry, pFrmBufSet.pesriSpatialRelEnum);
            try
            {
                DevComponents.DotNetBar.Bar pBar = _QuerBar.Parent.Parent as DevComponents.DotNetBar.Bar;
                if (pBar != null)
                {
                    pBar.AutoHide = false;
                    //pBar.SelectedDockTab = 1;
                    int tmpindex = pBar.Items.IndexOf("dockItemDataCheck");
                    pBar.SelectedDockTab = tmpindex;
                }
            }
            catch
            { }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Returns a polygon with a centroid at the given x and y exactly 1 acre in size
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <returns></returns>
        private IPolygon CreateHomesitePolygon(int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = (_application.Document as IMxDocument).ActiveView.ScreenDisplay;
                ESRI.ArcGIS.Geometry.IPoint        point         = screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                ITopologicalOperator topologicalOperator         = point as ITopologicalOperator;
                IGeometry            geometry = topologicalOperator.Buffer(104.3551628); // radius of circle --> envelope is 1 square acre :)
                IPolygon             polygon  = geometry as IPolygon;

                // Might be able to skip this
                ISegmentCollection segmentcollection = polygon as ISegmentCollection;
                segmentcollection.SetRectangle(polygon.Envelope);

                return(segmentcollection as IPolygon);
            } catch (Exception ex)
            {
                RS_Tools.Utilities.Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE);
            }
            return(null);
        }
Exemplo n.º 27
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (m_pNewEnvelope == null)
            {
                pPoint.SpatialReference = m_MapControl.Map.SpatialReference;
                m_pNewEnvelope          = new NewEnvelopeFeedbackClass();

                m_pNewEnvelope.Display = m_MapControl.ActiveView.ScreenDisplay;

                m_pNewEnvelope.Start(pPoint);
            }

            m_pPoint = pPoint;
        }
Exemplo n.º 28
0
        /// <summary>
        /// 获取指定线的中心点
        /// </summary>
        /// <param name="pPolyline">线图形</param>
        /// <returns>返回线图形的中新点坐标</returns>
        private IPoint GetMidPoint(IPolyline pPolyline)
        {
            IPoint pPoint = null;

            if (pPolyline == null)
            {
                return(null);
            }

            IPointCollection pPoints = pPolyline as IPointCollection;

            long lPointCount;

            //记录线物点个数
            lPointCount = pPoints.PointCount;

            long nMid = (lPointCount - 1) / 2 + 1;

            pPoint = pPoints.get_Point((int)nMid);
            return(pPoint);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 判断两个点对象是否相等
        /// </summary>
        /// <param name="point1">第一个点</param>
        /// <param name="point2">第二个点</param>
        /// <param name="tolerance">精度控制</param>
        /// <returns>相等返回true,否则返回false</returns>
        public bool equalPoints(ESRI.ArcGIS.Geometry.IPoint point1, ESRI.ArcGIS.Geometry.IPoint point2, double tolerance)
        {
            if ((Math.Abs(point1.X - point2.X) <= tolerance) &&
                (Math.Abs(point1.Y - point2.Y) <= tolerance))
            {
                if (!double.IsNaN(point1.Z) && !double.IsNaN(point2.Z))
                {
                    if (Math.Abs(point1.Z - point2.Z) <= tolerance)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 30
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IFeatureLayer     curLayer   = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;
            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;

            ESRI.ArcGIS.Geometry.IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IFeature pFeatureCreated           = IFeatureClass_CreatePoint(curLayer.FeatureClass, pPoint);

            m_MapControl.ActiveView.Refresh();
            if (pFeatureCreated == null)
            {
                return;
            }
            //curLayerSn.Clear();
            m_MapControl.Map.FeatureSelection.Clear();
            curLayerSn.Add(pFeatureCreated);//选择刚创建的point
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Exemplo n.º 31
0
        private IPoint[] GetPoints(string sInput, ISpatialReference pSR)
        {
            int iStrCnt;
            int iPairCnt;
            string[] sNumbers;
            IPoint[] pPts;
            IPoint pPt;
            int i;
            int iPos;
            double dX;
            double dY;

            sNumbers = sInput.Split(',');
            iStrCnt = sNumbers.GetUpperBound(0) + 1;
            iPairCnt = iStrCnt / 2;
            Logger.WriteLine("Pairs:" + iPairCnt + "," + iStrCnt);
            if ((iPairCnt * 2) == iStrCnt)
            {
                pPts = new ESRI.ArcGIS.Geometry.IPoint[iPairCnt];
                iPos = 0;
                for (i = 0; i < iPairCnt; i++)
                {
                    pPt = new Point();
                    pPt.SpatialReference = pSR;
                    dX = Convert.ToDouble(sNumbers[iPos]);
                    dY = Convert.ToDouble(sNumbers[iPos + 1]);
                    Logger.WriteLine("(" + i + "DX,DY:" + dX + "," + dY);
                    pPt.PutCoords(dX, dY);
                    pPts[i] = pPt;
                    iPos = iPos + 2;
                }
                return pPts;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 32
0
 public InputText(ESRI.ArcGIS.Geometry.IPoint pPoint)
 {
     InitializeComponent();
     m_Point = pPoint;
     m_color = GetRGBColor(0, 0, 0);
 }