当前位置: 首页>>代码示例>>C#>>正文


C# IGeometry.Project方法代码示例

本文整理汇总了C#中IGeometry.Project方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Project方法的具体用法?C# IGeometry.Project怎么用?C# IGeometry.Project使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGeometry的用法示例。


在下文中一共展示了IGeometry.Project方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TransformShapeCS

 public IGeometry TransformShapeCS(IGeometry pGeometry, ISpatialReference pInputSR, ISpatialReference pOutputSR)
 {
     IGeometry oGeometry;
     try
     {
         oGeometry = pGeometry;
         oGeometry.SpatialReference = pInputSR;
         oGeometry.Project(pOutputSR);
         return oGeometry;
     }
     catch
     {
         return pGeometry;
     }
 }
开发者ID:johnzastrow,项目名称:AGSOpenFormats,代码行数:15,代码来源:Helpers.cs

示例2: InsertPointAtIntersection

        public void InsertPointAtIntersection(ref IPolyline pPolyline, IGeometry pOther, double hmgetal)
        {
            bool SplitHappened = false;
            int newPartIndex = 0;
            int newSegmentIndex = 0;
            int index = 0;
            List<int> indices;
            IPoint Point = null;

            IClone pClone = pPolyline.SpatialReference as IClone;
            if (pClone.IsEqual(pOther.SpatialReference as IClone) == false)
            {
                pOther.Project(pPolyline.SpatialReference);
            }

            ITopologicalOperator pTopoOp = pOther as ITopologicalOperator;
            pTopoOp.Simplify();

            pTopoOp = pPolyline as ITopologicalOperator;
            IGeometry pGeomResult = pTopoOp.Intersect(pOther, esriGeometryDimension.esriGeometry0Dimension);

            indices = new List<int>();
            if ((pGeomResult is IPointCollection) && ((pGeomResult as IPointCollection).PointCount > 0))
            {

                for (int i = 0; i < (pGeomResult as IPointCollection).PointCount; i++)
                {
                    (pPolyline as IPolycurve2).SplitAtPoint((pGeomResult as IPointCollection).get_Point(i), true, false, out SplitHappened, out newPartIndex, out newSegmentIndex);
                    //TODO Zet de measure op het ingevoegde punt, houdt rekening met partindex en segmentindex

                    for (int j = 0; j < newPartIndex; j++)
                    {
                        index += ((pPolyline as IGeometryCollection).get_Geometry(j) as IPointCollection).PointCount;
                    }
                    index += newSegmentIndex;

                    Point = (pPolyline as IPointCollection).get_Point(index);
                    Point.M = hmgetal;
                    (pPolyline as IPointCollection).UpdatePoint(index, Point);

                }

            }

            (pPolyline as ITopologicalOperator2).IsKnownSimple_2 = false;
            (pPolyline as IPolyline4).SimplifyEx(true);
        }
开发者ID:Isolf,项目名称:CalibreerMShape,代码行数:47,代码来源:ArcObjectsHelper.cs

示例3: AddGraphicToMap

        /// <summary>
        /// Adds a graphic element to the map graphics container
        /// </summary>
        /// <param name="geom">IGeometry</param>
        internal void AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, esriRasterOpCode rasterOpCode = esriRasterOpCode.esriROPNOP)
        {
            if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null)
                return;
            IElement element = null;
            double width = 2.0;

            geom.Project(ArcMap.Document.FocusMap.SpatialReference);

            if(geom.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol;
                simpleMarkerSymbol.Color = color;
                simpleMarkerSymbol.Outline = true;
                simpleMarkerSymbol.OutlineColor = color;
                simpleMarkerSymbol.Size = 5;
                simpleMarkerSymbol.Style = markerStyle;

                var markerElement = new MarkerElement() as IMarkerElement;
                markerElement.Symbol = simpleMarkerSymbol;
                element = markerElement as IElement;
            }
            else if(geom.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                // create graphic then add to map
                var lineSymbol = new SimpleLineSymbolClass();
                lineSymbol.Color = color;
                lineSymbol.Width = width;
                if (IsTempGraphic && rasterOpCode != esriRasterOpCode.esriROPNOP)
                {
                    lineSymbol.Width = 1;
                    lineSymbol.ROP2 = rasterOpCode;
                }

                var le = new LineElementClass() as ILineElement;  
                element = le as IElement;
                le.Symbol = lineSymbol;
            }

            if (element == null)
                return;

            IClone clone = geom as IClone;
            element.Geometry = clone as IGeometry;       

            var mxdoc = ArcMap.Application.Document as IMxDocument;
            var av = mxdoc.FocusMap as IActiveView;
            var gc = av as IGraphicsContainer;

            // store guid
            var eprop = element as IElementProperties;
            eprop.Name = Guid.NewGuid().ToString();
 
            if (this is LinesViewModel)
                GraphicsList.Add(new Graphic(GraphicTypes.Line, eprop.Name, geom, IsTempGraphic));
            else if (this is CircleViewModel)
                GraphicsList.Add(new Graphic(GraphicTypes.Circle, eprop.Name, geom, IsTempGraphic));
            else if (this is EllipseViewModel)
                GraphicsList.Add(new Graphic(GraphicTypes.Ellipse, eprop.Name, geom, IsTempGraphic));
            else if (this is RangeViewModel)
                GraphicsList.Add(new Graphic(GraphicTypes.RangeRing, eprop.Name, geom, IsTempGraphic));

            gc.AddElement(element, 0);

            //refresh map
            av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            if (!IsTempGraphic)
                RaisePropertyChanged(() => HasMapGraphics);
        }
开发者ID:Esri,项目名称:distance-direction-addin-dotnet,代码行数:75,代码来源:TabBaseViewModel.cs

示例4: ProjectGeometry

 public static IGeometry ProjectGeometry(IGeometry pGeo)
 {
     //如果是地理坐标系,则投影到投影坐标系
     if (pGeo.SpatialReference is IGeographicCoordinateSystem)
     {
         ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment();
         IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_World_Mercator);      //投影到 Mercator 坐标系
         pGeo.Project(pcs);
     }
     return pGeo;
 }
开发者ID:BNU-Chen,项目名称:3DGlobe,代码行数:11,代码来源:ZoomToPointWithAnimation.cs

示例5: FlashGeometry

        public static void FlashGeometry(IGeometry geometry, IActiveView activeView, string colorName, int interval)
        {
            if (activeView == null || !DisplayMap.IsGeometryValid(geometry))
                return;

            IPolygon poly = new PolygonClass();
            try
            {
                //this is to handle if data is in ProjectedCoordinate System & map is in Grographic Coordinate system
                if (geometry.SpatialReference.Equals(activeView.FocusMap.SpatialReference) == false)
                    geometry.Project(activeView.FocusMap.SpatialReference);

                ITopologicalOperator topOp = geometry as ITopologicalOperator;
                poly.SpatialReference = geometry.SpatialReference;
                poly = topOp.Buffer(activeView.Extent.Width * .01) as IPolygon;

                ISimpleFillSymbol fillSym = DisplayMap.GenerateGenericFillSymbol(colorName, esriSimpleFillStyle.esriSFSSolid);
                fillSym.Outline = DisplayMap.GenerateGenericLineSymbol();

                activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
                activeView.ScreenDisplay.SetSymbol(fillSym as ISymbol);

                activeView.ScreenDisplay.DrawPolygon(poly);
                System.Threading.Thread.Sleep(interval);
                activeView.ScreenDisplay.DrawPolygon(poly);
                //activeView.PartialRefresh((esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection), null, activeView.Extent.Envelope);
            }
            catch (Exception e)
            {
                //_logger.LogException(e);
            }
            finally
            {
                activeView.ScreenDisplay.FinishDrawing();
            }
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:36,代码来源:DisplayMap.cs

示例6: CenterOnEnvelope

        /// <summary>
        /// Centers the active view on the extent of the given geometry.
        /// </summary>
        /// <param name="activeView">The active view.</param>
        /// <param name="geom">The geometry on which to center the active view.</param>
        /// <param name="mapScale">The mapscale to apply to the map.</param>
        private static void CenterOnEnvelope(IActiveView activeView, IGeometry geom, double mapScale)
        {
            if (activeView != null && geom != null)
            {
                if (geom.IsEmpty == false)
                {
                    if (geom.SpatialReference.Equals(activeView.FocusMap.SpatialReference) == false)
                        geom.Project(activeView.FocusMap.SpatialReference);
                    IEnvelope env = new EnvelopeClass();
                    env = geom.Envelope;
                    if (env.Width == 0 || env.Height == 0)
                    {
                        IEnvelope activeViewEnvelope = activeView.Extent;
                        activeViewEnvelope.CenterAt(env.LowerLeft);
                        activeView.Extent = activeViewEnvelope;
                        if (mapScale == 0)
                            mapScale = 2000;
                    }
                    else
                        activeView.Extent = env;

                    if (mapScale > 0)
                        activeView.FocusMap.MapScale = mapScale;

                    activeView.Refresh();
                }
            }
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:34,代码来源:DisplayMap.cs

示例7: AddTextToMap

        internal string AddTextToMap(string text, IGeometry geom, IColor color, bool IsTempGraphic = false, int size = 12)
        {
            if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null)
                return string.Empty;

            IElement element = null;

            geom.Project(ArcMap.Document.FocusMap.SpatialReference);

            if (geom.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                var te = new TextElementClass() as ITextElement;
                te.Text = text;

                var ts = new TextSymbolClass();
                ts.Size = size;
                ts.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                ts.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;

                te.Symbol = ts;

                element = te as IElement;
            }

            if (element == null)
                return string.Empty;

            element.Geometry = geom;

            var mxdoc = ArcMap.Application.Document as IMxDocument;
            var av = mxdoc.FocusMap as IActiveView;
            var gc = av as IGraphicsContainer;

            // store guid
            var eprop = element as IElementProperties;
            eprop.Name = Guid.NewGuid().ToString();

            if (IsTempGraphic)
                TempGraphicsList.Add(eprop.Name);
            else
                MapGraphicsList.Add(eprop.Name);

            gc.AddElement(element, 0);

            av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            RaisePropertyChanged(() => HasMapGraphics);

            return eprop.Name;
        }
开发者ID:Esri,项目名称:visibility-addin-dotnet,代码行数:50,代码来源:TabBaseViewModel.cs

示例8: AddGraphicToMap

        /// <summary>
        /// Adds a graphic element to the map graphics container
        /// </summary>
        /// <param name="geom">IGeometry</param>
        internal string AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, int size = 5)
        {
            if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null)
                return string.Empty;

            IElement element = null;
            double width = 2.0;

            geom.Project(ArcMap.Document.FocusMap.SpatialReference);

            if (geom.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol;
                simpleMarkerSymbol.Color = color;
                simpleMarkerSymbol.Outline = true;
                simpleMarkerSymbol.OutlineColor = color;
                simpleMarkerSymbol.Size = size;
                simpleMarkerSymbol.Style = markerStyle;

                var markerElement = new MarkerElement() as IMarkerElement;
                markerElement.Symbol = simpleMarkerSymbol;
                element = markerElement as IElement;
            }
            else if (geom.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                // create graphic then add to map
                var le = new LineElementClass() as ILineElement;
                element = le as IElement;

                var lineSymbol = new SimpleLineSymbolClass();
                lineSymbol.Color = color;
                lineSymbol.Width = width;

                le.Symbol = lineSymbol;
            }
            else if (geom.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                // create graphic then add to map
                IPolygonElement pe = new PolygonElementClass() as IPolygonElement;
                element = pe as IElement;
                IFillShapeElement fe = pe as IFillShapeElement;

                var fillSymbol = new SimpleFillSymbolClass();
                RgbColor selectedColor = new RgbColorClass();
                selectedColor.Red = 0;
                selectedColor.Green = 0;
                selectedColor.Blue = 0;

                selectedColor.Transparency = (byte)0;
                fillSymbol.Color = selectedColor;

                fe.Symbol = fillSymbol;
            }

            if (element == null)
                return string.Empty;

            element.Geometry = geom;

            var mxdoc = ArcMap.Application.Document as IMxDocument;
            var av = mxdoc.FocusMap as IActiveView;
            var gc = av as IGraphicsContainer;

            // store guid
            var eprop = element as IElementProperties;
            eprop.Name = Guid.NewGuid().ToString();

            if (IsTempGraphic)
                TempGraphicsList.Add(eprop.Name);
            else
                MapGraphicsList.Add(eprop.Name);

            gc.AddElement(element, 0);

            av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            RaisePropertyChanged(() => HasMapGraphics);

            return eprop.Name;
        }
开发者ID:Esri,项目名称:visibility-addin-dotnet,代码行数:85,代码来源:TabBaseViewModel.cs

示例9: merge

        public static IGeometry merge(IGeometry g1, IGeometry g2, ISDUTExtension ext)
        {
            ITopologicalOperator2 op_2 = (ITopologicalOperator2)g2;
            if(g1 == null)
            {
                if( g2 == null )
                    return null;

                op_2.IsKnownSimple_2 = false;
                try
                {
                    op_2.Simplify();
                }
                catch (Exception e)
                {
                    Logger.Warn(e);
                }
                return g2;
            }

            ITopologicalOperator2 op_1 = (ITopologicalOperator2)g1;
            if(g2 == null)
            {
                op_1.IsKnownSimple_2 = false;
                try
                {
                    op_1.Simplify();
                }
                catch (Exception e)
                {
                    Logger.Warn(e);
                }
                return g1;
            }

            // http://forums.esri.com/Thread.asp?c=93&f=1170&t=88297#242834

            op_1.IsKnownSimple_2 = false;
            try
            {
                op_1.Simplify();
            }
            catch (Exception e)
            {
                Logger.Warn(e);
            }

            op_2.IsKnownSimple_2 = false;
            try
            {
                op_2.Simplify();
            }
            catch (Exception e)
            {
                Logger.Warn(e);
            }

            if (g1.SpatialReference == null || g1.SpatialReference is IUnknownCoordinateSystem)
            {
                g1.SpatialReference = ext.FocusMap.SpatialReference;
            }

            if (g2.SpatialReference == null || g2.SpatialReference is IUnknownCoordinateSystem)
            {
                g2.SpatialReference = ext.FocusMap.SpatialReference;
            }

            g2.Project(g1.SpatialReference);

            ISpatialReference sr = g1.SpatialReference;

            g1.SnapToSpatialReference();
            g2.SnapToSpatialReference();

            IGeometry r = (IGeometry)(op_1.Union(g2));
            r.SpatialReference = sr;

            if (r.SpatialReference == null || r.SpatialReference is IUnknownCoordinateSystem)
            {
                r.SpatialReference = ext.FocusMap.SpatialReference;
            }

            ITopologicalOperator2 op_r = (ITopologicalOperator2)r;
            op_r.IsKnownSimple_2 = false;
            try
            {
                op_r.Simplify();
            }
            catch (Exception e)
            {
                Logger.Warn(e);
            }

            return r;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:95,代码来源:CmdNew.cs


注:本文中的IGeometry.Project方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。