Esempio n. 1
0
        /// <summary>
        /// Reads a stream and converts the shapefile record to an equilivant geometry object.
        /// </summary>
        /// <param name="file">The stream to read.</param>
        /// <param name="geometryFactory">The geometry factory to use when making the object.</param>
        /// <returns>The Geometry object that represents the shape file record.</returns>
        public override IGeometry Read(BigEndianBinaryReader file, IGeometryFactory geometryFactory)
        {
            int shapeTypeNum = file.ReadInt32();

            type = (ShapeGeometryType) Enum.Parse(typeof(ShapeGeometryType), shapeTypeNum.ToString());
            if (type == ShapeGeometryType.NullShape)
                return geometryFactory.CreateMultiPoint(new IPoint[] { });
            
            if (!(type == ShapeGeometryType.MultiPoint  || type == ShapeGeometryType.MultiPointM ||
                  type == ShapeGeometryType.MultiPointZ || type == ShapeGeometryType.MultiPointZM))	
                throw new ShapefileException("Attempting to load a non-multipoint as multipoint.");

            // Read and for now ignore bounds.
            int bblength = GetBoundingBoxLength();
            bbox = new double[bblength];
            for (; bbindex < 4; bbindex++)
            {
                double d = file.ReadDouble();
                bbox[bbindex] = d;
            }

            // Read points
            int numPoints = file.ReadInt32();
            IPoint[] points = new IPoint[numPoints];
            for (int i = 0; i < numPoints; i++)
            {
                double x = file.ReadDouble();
                double y = file.ReadDouble();
                IPoint point = geometryFactory.CreatePoint(new Coordinate(x, y));                
                points[i] = point;
            }
            geom = geometryFactory.CreateMultiPoint(points);
            GrabZMValues(file);
            return geom;
        }        
		public bool IsOnField(IPoint point) { 
			return
				!IsLeft(point) &&
				!IsRight(point) &&
				!IsAbove(point) &&
				!IsUnder(point);
		}
Esempio n. 3
0
        public bool Contains(IPoint point)
        {
            var crossProduct = (point.YCoordinate - StartingPoint.YCoordinate)*
                               (EndingPoint.XCoordinate - StartingPoint.XCoordinate) -
                               (point.XCoordinate - StartingPoint.XCoordinate)*
                               (EndingPoint.YCoordinate - StartingPoint.YCoordinate);

            if (Math.Abs(crossProduct) > Double.Epsilon)
                return false;

            var dotProduct = (point.XCoordinate - StartingPoint.XCoordinate)*
                             (EndingPoint.XCoordinate - StartingPoint.XCoordinate) +
                             (point.YCoordinate - StartingPoint.YCoordinate)*
                             (EndingPoint.YCoordinate - StartingPoint.YCoordinate);
            if (dotProduct < 0)
                return false;

            var squaredLength = (EndingPoint.XCoordinate - StartingPoint.XCoordinate)*
                                  (EndingPoint.XCoordinate - StartingPoint.XCoordinate) +
                                  (EndingPoint.YCoordinate - StartingPoint.YCoordinate)*
                                  (EndingPoint.YCoordinate - StartingPoint.YCoordinate);
            if (dotProduct > squaredLength)
                return false;

            return true;
        }
        public void UpdateHandlePosition(IPoint newPoint)
        {
            var rect = Child.Rect();

            if (InsideLimitsX(newPoint.X) && CanChangeHorizontalPosition)
            {
                var left = Math.Min(newPoint.X, Opposite.X);
                var right = Math.Max(newPoint.X, Opposite.X);
                rect.X = left;
                rect.SetRightKeepingLeft(right);
            }

            if (InsideLimitsY(newPoint.Y) && CanChangeVerticalPosition)
            {
                var top = Math.Min(newPoint.Y, Opposite.Y);
                var bottom = Math.Max(newPoint.Y, Opposite.Y);
                rect.Y = top;
                rect.SetBottomKeepingTop(bottom);
            }

            if (rect.Width > 0 && rect.Height > 0)
            {
                SnappingEngine.SetSourceRectForResize(rect);                               
            }
            
        }
Esempio n. 5
0
        public QAException(QAError error, string operationalDSName, string status)
        {
            if (error == null)
                throw new ArgumentNullException("error", "Cannot pass null QAError to QAException");

            if (error.Error == null)
                throw new ArgumentException("The QAError passed to QAException has no data associated with it", "error");

            if (error.Error.Location == null)
                throw new ArgumentException("The QAError passed to QAException has no location associated with it", "error");

            if (status.Equals(DataQualityError.STATUS_EXCEPTION) == false
                && status.Equals(DataQualityError.STATUS_DEFERRED) == false)
                throw new ArgumentException("A QAException can only be created with a status of'"+DataQualityError.STATUS_EXCEPTION+"' or '"+DataQualityError.STATUS_DEFERRED+"'", "error");

            this._attachment = error.Error.ExtendedData;
            this._description = error.Error.Description;
            this._latitude = error.Latitude;
            this._longitude = error.Longitude;
            this._operationDSName = operationalDSName;
            this._status = status;
            this._testName = error.Error.ErrorType;

            this._location = error.Error.Location;
        }
Esempio n. 6
0
        public HouseManager(IPoint llPt, House h, CommonHouse ch)
        {
            //四个角的点是外面圈的四个顶点, 因为在进行计算时, 一直以外圈为准.
            lowerLeftPt = new PointClass();
            lowerLeftPt.X = llPt.X;
            lowerLeftPt.Y = llPt.Y;
            house = h;
            commonHouse = ch;

            lowerRightPt = new PointClass();
            lowerRightPt.X = lowerLeftPt.X + house.leftGap + house.width + house.rightGap;
            lowerRightPt.Y = lowerLeftPt.Y;

            upperLeftPt = new PointClass();
            upperLeftPt.X = lowerLeftPt.X;
            upperLeftPt.Y = lowerLeftPt.Y + commonHouse.frontGap + commonHouse.height + commonHouse.backGap;

            upperRightPt = new PointClass();
            upperRightPt.X = lowerRightPt.X;
            upperRightPt.Y = upperLeftPt.Y;

            southDirctionPt = new PointClass();
            southDirctionPt.X = (lowerLeftPt.X + lowerRightPt.X) / 2;
            southDirctionPt.Y = lowerLeftPt.Y;

            rotateAngle = 0;
        }
Esempio n. 7
0
 public static IPoint Rotate( this IPoint point, double degrees, IPoint pivot )
 {
     var translate = new Point( pivot.X * -1, pivot.Y * -1 );
       var translatedPoint = point.Translate( translate );
       var rotatedPoint = translatedPoint.Rotate( degrees );
       return rotatedPoint.Translate( pivot );
 }
Esempio n. 8
0
 public void addSplitPt(IPoint startPt, IPoint endPt)
 {
     LineEndPt lineEnd = new LineEndPt();
     lineEnd.startPt = startPt;
     lineEnd.endPt = endPt;
     splitLineEndPtArray.Add(lineEnd);
 }
        public void Create()
        {
            var points = new IPoint[,]
                             {
                                 {new Point(0, 0), new Point(1, 0)},
                                 {new Point(2, 1), new Point(3, 1.5)},
                                 {new Point(1, 2), new Point(3, 3)}
                             };


            var coverage = new DiscreteGridPointCoverage(3, 2, points.Cast<IPoint>());

            var values = new[,]
                             {
                                 {1.0, 2.0},
                                 {3.0, 4.0},
                                 {5.0, 6.0}
                             };

            coverage.SetValues(values);

            var value = coverage.Evaluate(points[1, 1].Coordinate);

            const double expectedValue = 4.0;
            Assert.AreEqual(expectedValue, value);
            
            Assert.IsTrue(coverage.Components[0].Values.Cast<double>().SequenceEqual(new [] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }));
            Assert.AreEqual("new grid point coverage", coverage.Name);
        }
        public void Create()
        {
            var points = new IPoint[,]
                             {
                                 {new Point(0.0, 1.0), new Point(0.0, 0.0)}, 
                                 {new Point(0.5, 1.5), new Point(1.0, 0.0)}, 
                                 {new Point(1.0, 2.0), new Point(2.0, 2.0)}
                             };


            var coverage = new DiscreteGridPointCoverage(3, 2, points.Cast<IPoint>());

            var values = new[,]
                             {
                                 {1.0, 2.0},
                                 {3.0, 4.0},
                                 {5.0, 6.0}
                             };

            coverage.SetValues(values);

/*
            var coverageLayer = new DiscreteGridPointCoverageLayer { Coverage = coverage, ShowFaces = true };
            var map = new Map { Layers = { coverageLayer } };
            MapTestHelper.Show(map);
*/

            var value = coverage.Evaluate(points[1, 1].Coordinate);

            const double expectedValue = 4.0;
            Assert.AreEqual(expectedValue, value);
            
            Assert.IsTrue(coverage.Components[0].Values.Cast<double>().SequenceEqual(new [] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }));
            Assert.AreEqual("new grid point coverage", coverage.Name);
        }
    public static double CalcDistanceBetweenTwoPointsIn2D(IPoint firstPoint, IPoint secondPoint)
    {
        double distance = Math.Sqrt((secondPoint.X - firstPoint.X) * (secondPoint.X - firstPoint.X) + 
                                    (secondPoint.Y - firstPoint.Y) * (secondPoint.Y - firstPoint.Y));

        return distance;
    }
    public MyDynamicLayerClass() : base()
    {
			m_table = new DataTable ("rows");
			m_table.Columns.Add("OID",			typeof (int));	//0
      m_table.Columns.Add("X",        typeof(double)); //1
      m_table.Columns.Add("Y",        typeof(double)); //2
      m_table.Columns.Add("STEPX",    typeof(double)); //3
      m_table.Columns.Add("STEPY",    typeof(double)); //4
      m_table.Columns.Add("HEADING",  typeof(double)); //5
      m_table.Columns.Add("TYPE",     typeof(int));    //6

      //set the ID column to be AutoIncremented
      m_table.Columns[0].AutoIncrement = true;

      m_point = new PointClass();

      //set an array to store the glyphs used to symbolize the tracked object
      m_markerGlyphs = new IDynamicGlyph[3];

      //set the update timer for the layer
      m_updateTimer = new Timer(50);
      m_updateTimer.Enabled = false;
      m_updateTimer.Elapsed += new ElapsedEventHandler(OnLayerUpdateEvent);

    }
Esempio n. 13
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (VectorLayer == null)
            {
                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            isBusy = true;
            StartDrawing();
            newNetworkFeature = GeometryFactory.CreatePoint(worldPosition);
            ((DataTableFeatureProvider)newNetworkFeatureLayer.DataSource).Clear();
            newNetworkFeatureLayer.DataSource.Add(newNetworkFeature);

            snapResult = MapControl.SnapTool.ExecuteLayerSnapRules(VectorLayer, null, newNetworkFeature, worldPosition, -1); //TODO check: why is this commented out in trunk?
            if (snapResult != null)
            {
                newNetworkFeature.Coordinates[0].X = snapResult.Location.X;
                newNetworkFeature.Coordinates[0].Y = snapResult.Location.Y;
            }

            newNetworkFeatureLayer.Style = MapControl.SnapTool.Failed ? errorNetworkFeatureStyle : networkFeatureStyle;
        }
Esempio n. 14
0
 public static IPartialEvaluator CreatePartial(IPoint point)
 {
     // It's important for efficiency that the same objects are reused whenever possible. Thus no compact memory
     // implementation of IPartialEvaluator (like InnerCompactEvaluator; but in that case only primitive types
     // are returned, i.e. doubles).
     return new InnerPartialEvaluator(point);
 }
Esempio n. 15
0
        public void Run(ModuleInfo info, CancellationToken token = default(CancellationToken))
        {
            double a = 0;
            double b = Math.PI/2;
            double h = 0.00000001;
            const int pointsNum = 2;
            var points = new IPoint[pointsNum];
            var channels = new IChannel[pointsNum];
            for (int i = 0; i < pointsNum; ++i)
            {
                points[i] = info.CreatePoint();
                channels[i] = points[i].CreateChannel();
                points[i].ExecuteClass("FirstModule.IntegralModule");
            }

            double y = a;
            for (int i = 0; i < pointsNum; ++i)
            {
                channels[i].WriteData(y);
                channels[i].WriteData(y + (b - a) / pointsNum);
                channels[i].WriteData(h);
                y += (b - a) / pointsNum;
            }
            DateTime time = DateTime.Now;            
            Console.WriteLine("Waiting for result...");

            double res = 0;
            for (int i = pointsNum - 1; i >= 0; --i)
            {
                res += channels[i].ReadData(typeof(double));
            }

            Console.WriteLine("Result found: res = {0}, time = {1}", res, Math.Round((DateTime.Now - time).TotalSeconds,3));
            
        }
Esempio n. 16
0
 public DragOperation(ICanvasItem child, IPoint startingPoint, ISnappingEngine snappingEngine)
 {
     SnappingEngine = snappingEngine;
     Child = child;                                   
     StartingPoint = startingPoint;            
     ChildStartingPoint = child.GetPosition();
 }
 public IpoptOptimizerResult(bool status, bool hasConverged, IPoint optimalPoint, double optimalValue, IpoptReturnCode returnCode, int iterations)
     : base(status, optimalPoint, optimalValue)
 {
     HasConverged = hasConverged;
     ReturnCode = returnCode;
     Iterations = iterations;
 }
 private static IGeometry SqlGeometryToGeometryMultiPoint(SqlGeometry geometry, GeometryFactory factory)
 {
     IPoint[] points = new IPoint[geometry.STNumGeometries().Value];
     for (int i = 1; i <= points.Length; i++)
         points[i - 1] = SqlGeometryToGeometryPoint(geometry.STGeometryN(i), factory);
     return factory.CreateMultiPoint(points);
 }
		public static float GetPositionImprovement(IPoint source, IPoint target, int turns)
		{
			float dSource = (float)Goal.Other.GetDistance(source);
			float dTarget = (float)Goal.Other.GetDistance(target);
			var gain = dSource- dTarget;
			return gain / (float)turns;
		}
        public void AddPoint(IPoint point)
        {
            IPointCollection pointCollection = _geometry as IPointCollection;

            object missing = Type.Missing;

            pointCollection.AddPoint(point, ref missing, ref missing);
        }
Esempio n. 21
0
        public static double Slope(IPoint start, IPoint end)
        {
            var rise = end.Y - start.Y;
            var run = end.X - start.X;

            var slope = rise / run;
            return slope;
        }
        private void WriteGeom(JsonWriter writer, JsonSerializer serializer, IPoint pt)
        {
            if (pt == null)
                throw new ArgumentNullException("pt");

            writer.WritePropertyName("coordinates");
            WriteJsonCoordinate(writer, pt.Coordinate, serializer);
        }
Esempio n. 23
0
        /// <summary>
        /// Indicates if the two points are the same.
        /// </summary>
        /// <param name="shape">The current geometry.</param>
        /// <param name="comparisonShape">The geometry to compare with.</param>
        /// <returns>True or false.</returns>
        public static bool Equals2(this IPoint shape, IPoint comparisonShape)
        {
            var tolerance = 0.001;

            return Math.Abs(shape.X - comparisonShape.X) < tolerance
                && Math.Abs(shape.Y - comparisonShape.Y) < tolerance
                && ((IRelationalOperator)shape).Equals(comparisonShape);
        }
 public static IEnvelope GetEnvlope(IActiveView activeView, IPoint queryPoint, double envlopeDistance)
 {
     IEnvelope envelope = new EnvelopeClass();
     envelope.CenterAt(queryPoint);
     envelope.Width = 2 * envlopeDistance;
     envelope.Height = 2 * envlopeDistance;
     return envelope;           
 }
 public ShapeFieldCacheDistanceValueSource(SpatialContext ctx, 
     ShapeFieldCacheProvider<IPoint> provider, IPoint from, double multiplier)
 {
     this.ctx = ctx;
     this.from = from;
     this.provider = provider;
     this.multiplier = multiplier;
 }
        //点+半径转圆几何
        public static IGeometry GetCircleGeometry(IPoint pPoint, double radius)
        {
            ICircularArc pCircularArc = new CircularArcClass();
            IConstructCircularArc pConstructCircularArc = pCircularArc as IConstructCircularArc;
            pConstructCircularArc.ConstructCircle(pPoint, radius, true);
            return GetCircleGeometry(pCircularArc);

        }
Esempio n. 27
0
 /// <summary>
 /// Checks if the unit can move during this round to a certain destination.
 /// The destination must be next to the current position,
 /// the unit must have some movement points left,
 /// the tile can't be a sea.
 /// </summary>
 /// <param name="currentPosition">The current position.</param>
 /// <param name="currentTile">The current type of tile.</param>
 /// <param name="destination">The destination to reach.</param>
 /// <param name="tile">The type of tile the destination is.</param>
 /// <returns>True if the unit can move to the destination.</returns>
 public override bool CanMove(IPoint currentPosition, ITile currentTile, IPoint destination, ITile tile, bool occupied)
 {
     return !(tile is ISea)
         && destination.IsNext(currentPosition)
         && (remainingMovementPoints >= MOVEMENT_COST
             // Special case for movement to lowland.
             || ((tile is ILowland) && remainingMovementPoints >= MOVEMENT_COST / 2));
 }
Esempio n. 28
0
        public void UpdateFeature( IMap pMap ,ILayer pCurrentLayer,IPoint pPoint )
        {
            //处理具体数据
            if (pMap == null || pPoint == null )
                return;
            m_pMap = pMap;

            //如果没有地图图层 ,则不处理
            long nLayerCount = pMap.LayerCount;
            if( nLayerCount == 0 )
                return;

            //删除树结点
            FtTreeView.Nodes.Clear();

            this.FTtreeList.Nodes.Clear();

            //开始选择
            IGeometry geom = pPoint;

            ISpatialReference spatialReference = m_pMap.SpatialReference;
            geom.SpatialReference = spatialReference;

            //Refresh the active view
            IActiveView activeView = (IActiveView)m_pMap;

            ISelectionEnvironment selEnv =  new SelectionEnvironment();
            selEnv.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelWithin;
            m_pMap.SelectByShape(geom, selEnv, false);
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);

            //如果没有设置 当前图层pCurrentLayer ,则不处理

            ESRI.ArcGIS.esriSystem.IPersist pPersist = new FeatureLayer() as ESRI.ArcGIS.esriSystem.IPersist;
            UID uid = pPersist as UID ;

            IEnumLayer pEnumlayer = pMap.get_Layers(uid,true );

            pEnumlayer.Reset();
            ILayer pLayer = pEnumlayer.Next();
            while( pLayer != null )
            {

                if( pLayer.Visible == false )
                {
                    pLayer = pEnumlayer.Next();
                    continue;
                }

                IFeatureLayer2 pFtLayer = (IFeatureLayer2)pLayer;
                IFeatureSelection pFtSelect = (IFeatureSelection)pFtLayer;
                ISelectionSet pSelectset = (ISelectionSet)pFtSelect.SelectionSet;

                InitTreeView(pSelectset, pLayer);

                pLayer = pEnumlayer.Next();
            }
        }
Esempio n. 29
0
        public void NotifyNewPosition(IPoint newPoint)
        {
            var delta = newPoint.Subtract(StartingPoint);
            var newChildLocation = ChildStartingPoint.Add(delta);

            var originalRect = new Rect(newChildLocation.X, newChildLocation.Y, Child.Width, Child.Height);

            SnappingEngine.SetSourceRectForDrag(originalRect);                                                
        }
 public ResizeOperation(ICanvasItem child, IPoint handlePoint, ISnappingEngine snappingEngine)
 {
     Child = child;
     HandlePoint = handlePoint;
     SetCanResize(child, handlePoint);
     Opposite = HandlePoint.GetOpposite(child.Rect().MiddlePoint());
     SnappingEngine = snappingEngine;
     this.recordingScope = RecordingServices.DefaultRecorder.OpenScope(string.Format( "Resize {0}", this.child.GetName() ));
 }
Esempio n. 31
0
 public Organism(IPoint location, int size)
 {
     this.Location = location;
     this.Size     = size;
     this.IsAlive  = true;
 }
Esempio n. 32
0
 public Position(IPoint point) : this(point.X, point.Y)
 {
 }
Esempio n. 33
0
 public abstract void DrawEnd(IPoint p);
Esempio n. 34
0
 public void DrawSegment(IPoint start, IPoint finish)
 {
     gr.DrawLine(pen, (float)start.GetX(), (float)start.GetY(), (float)finish.GetX(), (float)finish.GetY());
 }
Esempio n. 35
0
 public override double AngleWith(IPoint <double, double> pt)
 {
     throw new NotImplementedException();
 }
 private void DelVertexNode(IPoint pPnt)
 {
     try
     {
         IFeatureLayer pFeaturelayer = m_EngineEditLayers.TargetLayer;
         IActiveView   pActiveView   = m_activeView;
         IPoint        pPoint        = pPnt;
         if (pFeaturelayer.FeatureClass == null)
         {
             return;
         }
         //如果不是面状地物则退出
         if (pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryEnvelope &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryLine &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
         {
             return;
         }
         IGeometry pGeo        = null;
         IFeature  pSelFeature = null;
         pSelFeature = EditVertexClass.GetSelectedFeature(pFeaturelayer);
         //是否有选中的几何体
         if (pSelFeature == null)
         {
             return;
         }
         pGeo = pSelFeature.ShapeCopy;
         double pSrchDis = 0;
         double pHitDis  = 0;
         pSrchDis = pActiveView.Extent.Width / 200;
         pPoint.Z = 0;
         int              pIndex       = 0;
         IElement         pElement     = null;
         IHitTest         pHtTest      = null;
         bool             pBoolHitTest = false;
         IPoint           pPtHit       = null;
         IPointCollection pPointCol    = null;
         IPolygon         pPolygon     = null;
         IPolyline        pPyline      = null;
         bool             bRightZSide  = true;
         int              pInt         = 0;
         m_EngineEditor.StartOperation();
         //删除面状要素的节点
         if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon ||
             pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryEnvelope)
         {
             pElement          = new PolygonElement();
             pElement.Geometry = pSelFeature.Shape;
             IPolygon pPoly = null;
             pPoly        = pElement.Geometry as IPolygon;
             pHtTest      = pPoly as IHitTest;
             pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex,
                                            pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide);
             if (pBoolHitTest == false)
             {
                 return;
             }
             EditVertexClass.pHitPnt = pPtHit;
             pPointCol = pSelFeature.ShapeCopy as IPointCollection;
             //如果多边形的节点只有3个则不能再删除了
             if (pPointCol.PointCount <= 4)
             {
                 MessageBox.Show("多边形的节点至少需要3个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             //顶点删除
             pPointCol.RemovePoints(pIndex, 1);
             pPolygon = pPointCol as IPolygon;
             pPolygon.Close();
             pSelFeature.Shape = pPolygon;
             pSelFeature.Store();
         }
         //删除线状要素的节点
         else if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline ||
                  pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryLine)
         {
             pElement          = new LineElement();
             pElement.Geometry = pSelFeature.Shape;
             IPolyline pPolyLine = default(IPolyline);
             pPolyLine    = pElement.Geometry as IPolyline;
             pHtTest      = pPolyLine as IHitTest;
             pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex,
                                            pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide);
             if (pBoolHitTest == false)
             {
                 return;
             }
             EditVertexClass.pHitPnt = pPtHit;
             pPointCol = pSelFeature.ShapeCopy as IPointCollection;
             //如果Polyline节点只有2个则不能再删除了
             if (pPointCol.PointCount <= 2)
             {
                 MessageBox.Show("线的节点至少需要2个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             //顶点删除
             pPointCol.RemovePoints(pIndex, 1);
             pPyline           = pPointCol as IPolyline;
             pSelFeature.Shape = pPyline;
             pSelFeature.Store();
         }
         //与选中点坐标相同的节点都删除
         for (int i = 0; i <= pPointCol.PointCount - 1; i++)
         {
             if (i > pPointCol.PointCount - 1)
             {
                 break;
             }
             if (pPointCol.get_Point(i).X == pPoint.X & pPointCol.get_Point(i).Y == pPoint.Y)
             {
                 pPointCol.RemovePoints(i, 1);
                 i = i - 1;
             }
         }
         //停止编辑
         m_EngineEditor.StopOperation("DelVertexTool");
         //显示顶点
         EditVertexClass.ShowAllVertex(pFeaturelayer);
         m_activeView.Refresh();
     }
     catch (Exception ex)
     {
         //SysLogHelper.WriteOperationLog("删除节点错误", ex.Source, "数据编辑");
         m_activeView.Refresh();
     }
 }
Esempio n. 37
0
        public static List <IElement> CreateAnnoElementList(IMultiCheQiConfig multiCheQiConfig,
                                                            List <MultiCheQiModel> modelList, IPoint point)
        {
            List <IElement> list = new List <IElement>();

            IElement element = CreateHeaderElements(multiCheQiConfig, point);

            list.Add(element);
            list.AddRange(CreateContentElements(multiCheQiConfig, modelList, element.Geometry as IPoint,
                                                element.Geometry.Envelope.Width, element.Geometry.Envelope.Height));

            return(list);
        }
Esempio n. 38
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="geometry"></param>
 /// <returns></returns>
 protected int SetByteStream(IPoint geometry)
 {
     return(Double.IsNaN(geometry.Coordinate.Z) ? 21 : 29);
 }
 public void DrawSegment(IPoint start, IPoint finish)
 {
     //Надо добавить все точки между стартом и финишом
     points.Add(start);
     points.Add(finish);
 }
 public void DrawStart(IPoint p)
 {
     points.Add(p);
 }
Esempio n. 41
0
 public Rectangle(IPoint lowerLeft, IPoint upperRight)
 {
     LowerLeft  = lowerLeft;
     UpperRight = upperRight;
 }
Esempio n. 42
0
 /// <summary>
 /// 地图定跳转到指定图形位置(单个图形),并高亮显示此图形,会清除其它高亮
 /// </summary>
 /// <param name="activeView"></param>
 /// <param name="point"></param>
 /// <param name="visualRange"></param>
 public static void MapZoomToPointAndHightLight(this IActiveView activeView, IPoint point, double visualRange)
 {
     activeView.GraphicsContainer.DeleteAllElements();
     MapZoomToPoint(activeView, point, visualRange);
     HightLightGeo(activeView, point);
 }
Esempio n. 43
0
        public void OnMouseUp(int button, int shift, int x, int y)
        {
            if (shift == 0)
            {
                //清除所有选择的内容
                m_Map.ClearSelection();
                m_activeView.Refresh();
            }
            if (button != 1)
            {
                return;
            }
            try
            {
                if (m_EngineEditor == null)
                {
                    return;
                }
                if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
                {
                    return;
                }
                if (m_EngineEditLayers == null)
                {
                    return;
                }
                //获取目标图层
                IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
                IFeatureClass pFeatCls = pFeatLyr.FeatureClass;

                //MapControl axMapControl1 = Control.FromHandle(new IntPtr(this.m_hookHelper.ActiveView.ScreenDisplay.hWnd)) as MapControl;
                IMapControl4 axMapControl1 = GlobalVars.instance.MapControl;
                IEnvelope    pEnvelope     = axMapControl1.TrackRectangle();
                IGeometry    pGeometry     = null;
                //当点选的情况时,Envelope为空,此时建立缓冲区
                if (pEnvelope.IsEmpty == true)
                {
                    IPoint point = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                    //定义缓冲区
                    double db = MapManager.ConvertPixelsToMapUnits(m_activeView, 4);
                    ITopologicalOperator pTop;
                    pTop      = point as ITopologicalOperator;
                    pGeometry = pTop.Buffer(db);
                }
                else
                {
                    pGeometry = pEnvelope as IGeometry;
                }
                //设置选择过滤条件
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                //不同的图层类型设置不同的过滤条件
                switch (pFeatCls.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    //将像素距离转换为地图单位距离
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;
                }
                pSpatialFilter.Geometry      = pGeometry;
                pSpatialFilter.GeometryField = pFeatCls.ShapeFieldName;
                IQueryFilter pQueryFilter = pSpatialFilter as IQueryFilter;
                //根据过滤条件进行查询
                IFeatureCursor    pFeatCursor = pFeatCls.Search(pQueryFilter, false);
                IFeature          pFeature    = pFeatCursor.NextFeature();
                IFeatureSelection pFeatureSelection;
                pFeatureSelection = pFeatLyr as IFeatureSelection;

                IEnumFeature pEnumFeature2 = m_Map.FeatureSelection as IEnumFeature;//已经选择的选择集
                int          a             = pFeatureSelection.SelectionSet.Count;
                pEnumFeature2.Reset();
                IFeature pFeature2 = pEnumFeature2.Next();

                //遍历整个要素类中符合条件的要素
                while (pFeature != null)
                {
                    if (pFeature2 == null)
                    {
                        pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
                        break;
                    }
                    //遍历当前选择的要素
                    while (pFeature2 != null)
                    {
                        IRelationalOperator re = (IRelationalOperator)pFeature.Shape;
                        if (re.Equals(pFeature2.Shape))
                        {
                            pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultSubtract, false);
                            break;
                        }
                        else
                        {
                            m_Map.SelectFeature(pFeatLyr as ILayer, pFeature);
                        }
                        pFeature2 = pEnumFeature2.Next();
                    }
                    pFeature = pFeatCursor.NextFeature();
                }
                m_activeView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCursor);
            }
            catch (Exception ex)
            {
                //SysLogHelper.WriteOperationLog("选择要素错误", ex.Source, "数据编辑");
            }
        }
Esempio n. 44
0
        public static IElement CreateHeaderElements(IMultiCheQiConfig multiCheQiConfig, IPoint point)
        {
            IPoint originPoint = new PointClass
            {
                X = point.X,
                Y = point.Y
            };
            string strHeader = null;

            for (int i = 0; i < multiCheQiConfig.FieldSettingList.Count; i++)
            {
                IFieldSetting fieldSetting = multiCheQiConfig.FieldSettingList[i];
                strHeader += fieldSetting.FieldName.PadRight(fieldSetting.Length);
            }
            IElement element = CreateTextElement(originPoint, ConvertToRgbColor(multiCheQiConfig.HeaderFontConfig.Color),
                                                 strHeader, multiCheQiConfig.HeaderFontConfig);

            return(element);
        }
Esempio n. 45
0
        public static List <IElement> CreateContentElements(IMultiCheQiConfig multiCheQiConfig,
                                                            List <MultiCheQiModel> models, IPoint point, double xLength, double yLength)
        {
            List <IElement> list        = new List <IElement>();
            IPoint          originPoint = new PointClass
            {
                X = point.X,
                Y = point.Y
            };

            for (int i = 0; i < models.Count; i++)
            {
                MultiCheQiModel multiCheQiModel = models[i];
                IPoint          tempPoint       = new PointClass();
                tempPoint.X = originPoint.X;
                tempPoint.Y = originPoint.Y - yLength * (i + 1);
                string strContent = null;
                for (int j = 0; j < multiCheQiModel.FieldMappingList.Count; j++)
                {
                    CheQiFieldMapping mapping = multiCheQiModel.FieldMappingList[j];
                    strContent += mapping.FieldValue.PadRight(mapping.FieldSetting.Length);
                }
                IElement element = CreateTextElement(tempPoint, multiCheQiModel.Color, strContent,
                                                     multiCheQiConfig.ContentFontConfig);
                list.Add(element);
            }

            return(list);
        }
Esempio n. 46
0
 void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender)
 {
     MessageBox.Show(string.Format("拾取到{0}类型的物体", PickResult.Type.ToString()));
 }
Esempio n. 47
0
 public static double GetDistance(IPoint point1, IPoint point2)
 {
     return(Math.Sqrt((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y)));
 }
Esempio n. 48
0
        private void WmtsCapabilities100(IServiceRequestContext context, TileServiceMetadata metadata)
        {
            gView.Framework.OGC.WMTS.Version_1_0_0.Capabilities capabilities = new Framework.OGC.WMTS.Version_1_0_0.Capabilities()
            {
                version = "1.0.0"
            };

            capabilities.NameSpaces = new System.Xml.Serialization.XmlSerializerNamespaces();
            capabilities.NameSpaces.Add("ows", "http://www.opengis.net/ows/1.1");
            capabilities.NameSpaces.Add("xlink", "http://www.w3.org/1999/xlink");
            capabilities.NameSpaces.Add("gml", "http://www.opengis.net/gml");

            #region ServiceIndentification

            capabilities.ServiceIdentification       = new gView.Framework.OGC.WMTS.Version_1_0_0.ServiceIdentification();
            capabilities.ServiceIdentification.Title = new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType()
                                                                                                                         {
                                                                                                                             Value = CapabilitiesMapName(context) // do not add folder to the name => tilecache will not work with arcgis
                                                                                                                         } };
            capabilities.ServiceIdentification.ServiceType = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType()
            {
                Value = "OGC WMTS"
            };
            capabilities.ServiceIdentification.ServiceTypeVersion = new string[] { "1.0.0" };

            #endregion

            string restFulUrl;

            if (String.IsNullOrWhiteSpace(context.ServiceRequest.Folder))
            {
                restFulUrl = context.ServiceRequest.OnlineResource.ToLower()
                             .Replace("/ogc/" + context.ServiceRequest.Service, "/tilewmts/" + context.ServiceRequest.Service);
            }
            else
            {
                string fromServiceFullname = context.ServiceRequest.Folder + "@" + context.ServiceRequest.Service;
                string toServiceFullname   = context.ServiceRequest.Folder + "/" + context.ServiceRequest.Service;

                restFulUrl = context.ServiceRequest.OnlineResource.ToLower()
                             .Replace("/ogc/" + fromServiceFullname.ToLower(), "/tilewmts/" + toServiceFullname.ToLower());
            }

            #region OperationsMetadata

            capabilities.OperationsMetadata = new gView.Framework.OGC.WMTS.Version_1_0_0.OperationsMetadata();

            var getCapOperation = new gView.Framework.OGC.WMTS.Version_1_0_0.Operation()
            {
                name = "GetCapabilities"
            };
            getCapOperation.DCP               = new gView.Framework.OGC.WMTS.Version_1_0_0.DCP[] { new gView.Framework.OGC.WMTS.Version_1_0_0.DCP() };
            getCapOperation.DCP[0].Item       = new gView.Framework.OGC.WMTS.Version_1_0_0.HTTP();
            getCapOperation.DCP[0].Item.Items = new gView.Framework.OGC.WMTS.Version_1_0_0.RequestMethodType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.RequestMethodType() };

            getCapOperation.DCP[0].Item.Items[0].href                        = context.ServiceRequest.OnlineResource + "?SERVICE=WMTS&VERSION=1.0.0" + "&";
            getCapOperation.DCP[0].Item.Items[0].Constraint                  = new gView.Framework.OGC.WMTS.Version_1_0_0.DomainType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.DomainType() };
            getCapOperation.DCP[0].Item.Items[0].Constraint[0].name          = "GetEncoding";
            getCapOperation.DCP[0].Item.Items[0].Constraint[0].AllowedValues = new object[] { new gView.Framework.OGC.WMTS.Version_1_0_0.ValueType()
                                                                                              {
                                                                                                  Value = "KVP"                                                      /*"RESTful"*/
                                                                                              } };
            getCapOperation.DCP[0].Item.ItemsElementName = new gView.Framework.OGC.WMTS.Version_1_0_0.ItemsChoiceType[] { gView.Framework.OGC.WMTS.Version_1_0_0.ItemsChoiceType.Get };


            var getTileOperation = new gView.Framework.OGC.WMTS.Version_1_0_0.Operation()
            {
                name = "GetTile"
            };
            getTileOperation.DCP               = new gView.Framework.OGC.WMTS.Version_1_0_0.DCP[] { new gView.Framework.OGC.WMTS.Version_1_0_0.DCP() };
            getTileOperation.DCP[0].Item       = new gView.Framework.OGC.WMTS.Version_1_0_0.HTTP();
            getTileOperation.DCP[0].Item.Items = new gView.Framework.OGC.WMTS.Version_1_0_0.RequestMethodType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.RequestMethodType() };

            getTileOperation.DCP[0].Item.Items[0].href                        = restFulUrl;
            getTileOperation.DCP[0].Item.Items[0].Constraint                  = new gView.Framework.OGC.WMTS.Version_1_0_0.DomainType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.DomainType() };
            getTileOperation.DCP[0].Item.Items[0].Constraint[0].name          = "GetEncoding";
            getTileOperation.DCP[0].Item.Items[0].Constraint[0].AllowedValues = new object[] { new gView.Framework.OGC.WMTS.Version_1_0_0.ValueType()
                                                                                               {
                                                                                                   Value = "RESTful"
                                                                                               } };
            getTileOperation.DCP[0].Item.ItemsElementName = new gView.Framework.OGC.WMTS.Version_1_0_0.ItemsChoiceType[] { gView.Framework.OGC.WMTS.Version_1_0_0.ItemsChoiceType.Get };

            capabilities.OperationsMetadata.Operation = new gView.Framework.OGC.WMTS.Version_1_0_0.Operation[]
            {
                getCapOperation, getTileOperation
            };

            #endregion

            #region Contents

            capabilities.Contents = new gView.Framework.OGC.WMTS.Version_1_0_0.ContentsType();

            List <gView.Framework.OGC.WMTS.Version_1_0_0.LayerType>     layers     = new List <gView.Framework.OGC.WMTS.Version_1_0_0.LayerType>();
            List <gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrixSet> matrixSets = new List <gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrixSet>();

            ISpatialReference sRef4326 = SpatialReference.FromID("epsg:4326");

            foreach (var epsg in metadata.EPSGCodes)
            {
                IEnvelope extent = metadata.GetEPSGEnvelope(epsg);
                if (extent == null)
                {
                    Console.WriteLine($"EPSG { epsg }: Envelope not exits");
                    continue;
                }

                IPoint origin = metadata.GetOriginUpperLeft(epsg);
                if (origin == null)
                {
                    Console.WriteLine($"EPSG { epsg }: Origin not exits");
                    continue;
                }

                ISpatialReference sRef       = SpatialReference.FromID("epsg:" + epsg);
                IEnvelope         extent4326 = GeometricTransformerFactory.Transform2D(extent, sRef, sRef4326).Envelope;

                if (double.IsInfinity(extent4326.minx))
                {
                    extent4326.minx = -180D;
                }

                if (double.IsInfinity(extent4326.miny))
                {
                    extent4326.miny = -90D;
                }

                if (double.IsInfinity(extent4326.maxx))
                {
                    extent4326.maxx = 180D;
                }

                if (double.IsInfinity(extent4326.maxy))
                {
                    extent4326.maxy = 90D;
                }

                foreach (string cacheType in new string[] { "classic", "compact" })
                {
                    string epsgPath = _mapServer.TileCachePath + @"/" + MapName(context) + @"/_alllayers/" + (cacheType == "compact" ? @"compact/" : "") +
                                      TileServiceMetadata.EpsgPath(GridOrientation.UpperLeft, epsg);

                    if (!new DirectoryInfo(epsgPath).Exists)
                    {
                        Console.WriteLine($"Path { epsgPath }: not exists");
                        continue;
                    }

                    #region Layer

                    string layerName = /*Capabilities*/ MapName(context) + " EPSG:" + epsg + " " + cacheType;
                    string layerId   = /*Capabilities*/ MapName(context).ToLower().Replace(" ", "_") + "_" + epsg + "_" + cacheType;

                    var layer = new gView.Framework.OGC.WMTS.Version_1_0_0.LayerType();

                    layer.Title = new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType()
                                                                                                    {
                                                                                                        Value = layerName
                                                                                                    } };
                    layer.Identifier = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType()
                    {
                        Value = layerId
                    };

                    List <gView.Framework.OGC.WMTS.Version_1_0_0.Style> styles = new List <Framework.OGC.WMTS.Version_1_0_0.Style>();
                    //styles.Add(new gView.Framework.OGC.WMTS.Version_1_0_0.Style()
                    //{
                    //    Title = new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType() { Value = "Default Style" } },
                    //    Identifier = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType() { Value = "default" }
                    //});
                    foreach (FilterImplementations styleVal in Enum.GetValues(typeof(FilterImplementations)))
                    {
                        string name = Enum.GetName(typeof(FilterImplementations), styleVal);
                        styles.Add(new Framework.OGC.WMTS.Version_1_0_0.Style()
                        {
                            isDefault = styleVal == FilterImplementations.Default,
                            Title     = new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType()
                                                                                                          {
                                                                                                              Value = name
                                                                                                          } },
                            Identifier = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType()
                            {
                                Value = name.ToLower()
                            }
                        });
                    }

                    layer.Style = styles.ToArray();

                    #region BoundingBox

                    layer.BoundingBox = new gView.Framework.OGC.WMTS.Version_1_0_0.BoundingBoxType[]
                    {
                        new gView.Framework.OGC.WMTS.Version_1_0_0.BoundingBoxType()
                        {
                            crs         = "urn:ogc:def:crs:EPSG::" + epsg,
                            LowerCorner = PointToString(extent.LowerLeft, sRef),
                            UpperCorner = PointToString(extent.UpperRight, sRef)
                        }
                    };
                    layer.WGS84BoundingBox = new gView.Framework.OGC.WMTS.Version_1_0_0.WGS84BoundingBoxType[]
                    {
                        new gView.Framework.OGC.WMTS.Version_1_0_0.WGS84BoundingBoxType()
                        {
                            crs         = "urn:ogc:def:crs:OGC:2:84", // urn:ogc:def:crs:OGC:2:84
                            LowerCorner = PointToString(extent4326.LowerLeft, /*sRef4326*/ null),
                            UpperCorner = PointToString(extent4326.UpperRight, /*sRef4326*/ null)
                        }
                    };

                    #endregion

                    layer.TileMatrixSetLink = new gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrixSetLink[]
                    {
                        new gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrixSetLink()
                        {
                            TileMatrixSet = layerId + "_default_matrixset"
                        }
                    };

                    List <string> formats = new List <string>();
                    if (metadata.FormatJpg)
                    {
                        formats.Add("image/jpg");
                    }

                    if (metadata.FormatPng)
                    {
                        formats.Add("image/png");
                    }

                    layer.Format = formats.ToArray();

                    List <Framework.OGC.WMTS.Version_1_0_0.URLTemplateType> resourceURLs = new List <Framework.OGC.WMTS.Version_1_0_0.URLTemplateType>();
                    if (metadata.FormatJpg)
                    {
                        resourceURLs.Add(new Framework.OGC.WMTS.Version_1_0_0.URLTemplateType()
                        {
                            resourceType = Framework.OGC.WMTS.Version_1_0_0.URLTemplateTypeResourceType.tile,
                            format       = "image/jpg",
                            template     = restFulUrl + "/" + cacheType + "/ul/" + epsg + "/{Style}/{TileMatrix}/{TileRow}/{TileCol}.jpg"
                        });
                    }
                    if (metadata.FormatPng)
                    {
                        resourceURLs.Add(new Framework.OGC.WMTS.Version_1_0_0.URLTemplateType()
                        {
                            resourceType = Framework.OGC.WMTS.Version_1_0_0.URLTemplateTypeResourceType.tile,
                            format       = "image/png",
                            template     = restFulUrl + "/" + cacheType + "/ul/" + epsg + "/{Style}/{TileMatrix}/{TileRow}/{TileCol}.png"
                        });
                    }
                    layer.ResourceURL = resourceURLs.ToArray();

                    layers.Add(layer);

                    #endregion

                    #region Matrix Set

                    double matrixSetWidth  = Math.Abs(extent.maxx - origin.X); // extent.Width;
                    double matrixSetHeight = Math.Abs(origin.Y - extent.miny); // extent.Height;

                    var matrixSet = new gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrixSet();

                    matrixSet.Title = new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType[] { new gView.Framework.OGC.WMTS.Version_1_0_0.LanguageStringType()
                                                                                                        {
                                                                                                            Value = layerName + " Default Matrix Set"
                                                                                                        } };
                    matrixSet.Identifier = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType()
                    {
                        Value = layerId + "_default_matrixset"
                    };
                    matrixSet.SupportedCRS = "urn:ogc:def:crs:EPSG::" + epsg;

                    matrixSet.TileMatrix = new gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrix[metadata.Scales.Count];

                    #region DPI

                    double inchMeter = 0.0254;                    /* 0.0254000508001016;*/
                    double dpi       = inchMeter * 1000D / 0.28D; // wmts 0.28mm -> 1 Pixel;
                    double dpm       = dpi / inchMeter;

                    #endregion

                    for (int s = 0, to = metadata.Scales.Count; s < to; s++)
                    {
                        string scalePath = _mapServer.TileCachePath + @"/" + MapName(context) + @"/_alllayers/" + (cacheType == "compact" ? @"compact/" : "") +
                                           TileServiceMetadata.ScalePath(GridOrientation.UpperLeft, epsg, metadata.Scales[s]);

                        if (!new DirectoryInfo(scalePath).Exists)
                        {
                            break;
                        }

                        double resolution = metadata.Scales[s] / (metadata.Dpi / inchMeter);

                        matrixSet.TileMatrix[s]            = new gView.Framework.OGC.WMTS.Version_1_0_0.TileMatrix();
                        matrixSet.TileMatrix[s].Identifier = new gView.Framework.OGC.WMTS.Version_1_0_0.CodeType()
                        {
                            Value = s.ToString()
                        };
                        matrixSet.TileMatrix[s].TopLeftCorner = PointToString(origin, sRef);
                        matrixSet.TileMatrix[s].TileWidth     = metadata.TileWidth.ToString();
                        matrixSet.TileMatrix[s].TileHeight    = metadata.TileHeight.ToString();

                        double tileWidth  = metadata.TileWidth * resolution;
                        double tileHeight = metadata.TileHeight * resolution;

                        int matrixWidth  = (int)Math.Round(matrixSetWidth / tileWidth + 0.5);
                        int matrixHeight = (int)Math.Round(matrixSetHeight / tileHeight + 0.5);

                        matrixSet.TileMatrix[s].MatrixWidth      = matrixWidth.ToString();
                        matrixSet.TileMatrix[s].MatrixHeight     = matrixHeight.ToString();
                        matrixSet.TileMatrix[s].ScaleDenominator = resolution * dpm;
                    }

                    matrixSets.Add(matrixSet);

                    #endregion
                }
            }

            capabilities.Contents.DatasetDescriptionSummary = layers.ToArray();
            capabilities.Contents.TileMatrixSet             = matrixSets.ToArray();

            #endregion

            XsdSchemaSerializer <gView.Framework.OGC.WMTS.Version_1_0_0.Capabilities> ser = new XsdSchemaSerializer <gView.Framework.OGC.WMTS.Version_1_0_0.Capabilities>();
            string xml = ser.Serialize(capabilities, null);

            xml = xml.Replace(@"<ows:DatasetDescriptionSummary xsi:type=""LayerType"">", "<Layer>");
            xml = xml.Replace(@"</ows:DatasetDescriptionSummary>", "</Layer>");

            context.ServiceRequest.ResponseContentType = "text/xml";
            context.ServiceRequest.Response            = xml;
        }
Esempio n. 49
0
        /// <summary>
        /// Here we need to create the lines of sight and determine is a target can be seen or not
        /// Visualize the visible targets with GREEN circles
        /// Visualize the non visible targets with RED circles
        /// Visualize the number of observers that can see a target with a label #
        /// Visualize an observer that can see no targets with a RED circle on top of a BLUE circle
        /// Visualize an observer that can see at least one target with a GREEN circle on top of a BLUE circle
        /// </summary>
        internal override void CreateMapElement()
        {
            try
            {
                IsRunning = true;
                IPolyline longestLine = new PolylineClass();



                ILayer surfaceLayer = GetLayerFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName);
                if (surfaceLayer == null)
                {
                    System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgSurfaceLayerNotFound, VisibilityLibrary.Properties.Resources.CaptionError);
                    return;
                }

                IsValidSurface = ValidateElevationSurface();
                if (!IsValidSurface)
                {
                    return;
                }

                // Issue warning if layer is ImageServerLayer
                if (surfaceLayer is IImageServerLayer)
                {
                    MessageBoxResult mbr = MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgLayerIsImageService,
                                                           VisibilityLibrary.Properties.Resources.CaptionLayerIsImageService, MessageBoxButton.YesNo);

                    if (mbr == MessageBoxResult.No)
                    {
                        System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
                        return;
                    }
                }

                // Determine if selected surface is projected or geographic
                var geoDataset = surfaceLayer as IGeoDataset;
                if (geoDataset == null)
                {
                    System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.MsgTryAgain, VisibilityLibrary.Properties.Resources.CaptionError);
                    return;
                }

                SelectedSurfaceSpatialRef = geoDataset.SpatialReference;

                if (SelectedSurfaceSpatialRef is IGeographicCoordinateSystem)
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSUserPrompt, VisibilityLibrary.Properties.Resources.LLOSUserPromptCaption);
                    return;
                }

                if (ArcMap.Document.FocusMap.SpatialReference.FactoryCode != geoDataset.SpatialReference.FactoryCode)
                {
                    MessageBox.Show(VisibilityLibrary.Properties.Resources.LOSDataFrameMatch, VisibilityLibrary.Properties.Resources.LOSSpatialReferenceCaption);
                    SetErrorTemplate(false);
                    return;
                }

                if (!CanCreateElement || ArcMap.Document == null || ArcMap.Document.FocusMap == null || string.IsNullOrWhiteSpace(SelectedSurfaceName))
                {
                    return;
                }

                SetErrorTemplate(true);
                ReadSelectedLayerPoints();


                if ((LLOS_ObserversInExtent.Any() || ObserverAddInPoints.Any()) &&
                    LLOS_TargetsInExtent.Any() || TargetAddInPoints.Any())
                {
                    // take your observer and target points and get lines of sight
                    var observerPoints = new ObservableCollection <AddInPoint>(LLOS_ObserversInExtent.Select(x => x.AddInPoint).Union(ObserverInExtentPoints));
                    var targetPoints   = new ObservableCollection <AddInPoint>(LLOS_TargetsInExtent.Select(x => x.AddInPoint).Union(TargetInExtentPoints));
                    var surface        = GetSurfaceFromMapByName(ArcMap.Document.FocusMap, SelectedSurfaceName);

                    if (surface == null)
                    {
                        return;
                    }



                    SelectedSurfaceSpatialRef = geoDataset.SpatialReference;

                    var geoBridge = (IGeoDatabaseBridge2) new GeoDatabaseHelperClass();

                    IPoint    pointObstruction = null;
                    IPolyline polyVisible      = null;
                    IPolyline polyInvisible    = null;
                    bool      targetIsVisible  = false;

                    double finalObserverOffset = GetOffsetInZUnits(ObserverOffset.Value, surface.ZFactor, OffsetUnitType);
                    double finalTargetOffset   = GetOffsetInZUnits(TargetOffset.Value, surface.ZFactor, OffsetUnitType);

                    var DictionaryTargetObserverCount = new Dictionary <IPoint, int>();

                    foreach (var observerPoint in observerPoints)
                    {
                        // keep track of visible targets for this observer
                        var CanSeeAtLeastOneTarget = false;

                        var z1 = surface.GetElevation(observerPoint.Point) + finalObserverOffset;

                        if (double.IsNaN(z1))
                        {
                            System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSPointsOutsideOfSurfaceExtent, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
                            return;
                        }

                        foreach (var targetPoint in targetPoints)
                        {
                            var z2 = surface.GetElevation(targetPoint.Point) + finalTargetOffset;

                            if (double.IsNaN(z2))
                            {
                                System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.LLOSPointsOutsideOfSurfaceExtent, VisibilityLibrary.Properties.Resources.MsgCalcCancelled);
                                return;
                            }

                            var fromPoint = new PointClass()
                            {
                                Z = z1, X = observerPoint.Point.X, Y = observerPoint.Point.Y, ZAware = true
                            } as IPoint;
                            var toPoint = new PointClass()
                            {
                                Z = z2, X = targetPoint.Point.X, Y = targetPoint.Point.Y, ZAware = true
                            } as IPoint;

                            geoBridge.GetLineOfSight(surface, fromPoint, toPoint,
                                                     out pointObstruction, out polyVisible, out polyInvisible, out targetIsVisible, false, false);

                            var pcol = new PolylineClass() as IPointCollection;
                            pcol.AddPoint(fromPoint);
                            pcol.AddPoint(toPoint);
                            IPolyline pcolPolyline = pcol as IPolyline;

                            longestLine = (longestLine != null && longestLine.Length < pcolPolyline.Length) ? pcolPolyline : longestLine;

                            // set the flag if we can see at least one target
                            if (targetIsVisible)
                            {
                                CanSeeAtLeastOneTarget = true;

                                // update target observer count
                                UpdateTargetObserverCount(DictionaryTargetObserverCount, targetPoint.Point);
                            }

                            // First Add "SightLine" so it appears behind others
                            // Black = Not visible -or- White = Visible
                            if (targetIsVisible)
                            {
                                AddGraphicToMap(pcolPolyline, new RgbColorClass()
                                {
                                    RGB = 0xFFFFFF
                                }, false,
                                                size: 6); //  white line
                            }
                            else
                            {
                                AddGraphicToMap(pcolPolyline, new RgbColorClass()
                                {
                                    RGB = 0x000000
                                }, false,
                                                size: 6); //  black line
                            }
                            if (polyVisible != null)
                            {
                                AddGraphicToMap(polyVisible, new RgbColorClass()
                                {
                                    Green = 255
                                }, size: 5);
                            }

                            if (polyInvisible != null)
                            {
                                AddGraphicToMap(polyInvisible, new RgbColorClass()
                                {
                                    Red = 255
                                }, size: 3);
                            }

                            if (polyVisible == null && polyInvisible == null)
                            {
                                if (targetIsVisible)
                                {
                                    AddGraphicToMap(pcol as IPolyline, new RgbColorClass()
                                    {
                                        Green = 255
                                    }, size: 3);
                                }
                                else
                                {
                                    AddGraphicToMap(pcol as IPolyline, new RgbColorClass()
                                    {
                                        Red = 255
                                    }, size: 3);
                                }
                            }
                        }

                        // visualize observer

                        // add blue dot
                        AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                        {
                            Blue = 255
                        }, size: 10);

                        if (CanSeeAtLeastOneTarget)
                        {
                            // add green dot
                            AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                            {
                                Green = 255
                            });
                        }
                        else
                        {
                            // add red dot
                            AddGraphicToMap(observerPoint.Point, new RgbColorClass()
                            {
                                Red = 255
                            });
                        }
                    }

                    VisualizeTargets(DictionaryTargetObserverCount, targetPoints);

                    if ((ObserverInExtentPoints.Any() || LLOS_ObserversInExtent.Any()) &&
                        (TargetInExtentPoints.Any() || LLOS_TargetsInExtent.Any()))
                    {
                        ZoomToExtent(longestLine);
                    }

                    DisplayOutOfExtentMsg();

                    //display points present out of extent
                    var colorObserver = new RgbColorClass()
                    {
                        Blue = 255
                    };
                    var colorTarget = new RgbColorClass()
                    {
                        Red = 255
                    };
                    var colorObserverBorder = new RgbColorClass()
                    {
                        Red = 255, Blue = 255, Green = 255
                    };
                    var colorTargetBorder = new RgbColorClass()
                    {
                        Red = 0, Blue = 0, Green = 0
                    };
                    var observerOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_ObserversOutOfExtent.Select(x => x.AddInPoint).Union(ObserverOutExtentPoints));
                    foreach (var point in observerOutOfExtent)
                    {
                        AddGraphicToMap(point.Point, colorObserver, markerStyle: esriSimpleMarkerStyle.esriSMSX, size: 10, borderColor: colorObserverBorder);
                    }
                    var targetOutOfExtent = new ObservableCollection <AddInPoint>(LLOS_TargetsOutOfExtent.Select(x => x.AddInPoint).Union(TargetOutExtentPoints));
                    foreach (var point in targetOutOfExtent)
                    {
                        AddGraphicToMap(point.Point, colorTarget, markerStyle: esriSimpleMarkerStyle.esriSMSX, size: 10, borderColor: colorTargetBorder);
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show(VisibilityLibrary.Properties.Resources.OutOfExtentMsg, VisibilityLibrary.Properties.Resources.OutOfExtentHeader);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                System.Windows.Forms.MessageBox.Show(VisibilityLibrary.Properties.Resources.ExceptionSomethingWentWrong,
                                                     VisibilityLibrary.Properties.Resources.CaptionError);
            }
            finally
            {
                IsRunning = false;
                ClearLLOSCollections();
                ValidateLLOS_LayerSelection();
            }
        }
Esempio n. 50
0
        async private Task <byte[]> GetCompactTile(IServiceRequestContext context, TileServiceMetadata metadata, int epsg, double scale, int row, int col, string format, GridOrientation orientation)
        {
            if (!metadata.EPSGCodes.Contains(epsg))
            {
                throw new ArgumentException("Wrong epsg argument");
            }

            if (orientation != GridOrientation.UpperLeft)
            {
                throw new ArgumentException("Compact Tiles Orientation must bei Upper Left!");
            }

            scale = metadata.Scales.GetScale(scale);
            if (scale <= 0.0)
            {
                throw new ArgumentException("Wrong scale argument");
            }

            //IEnvelope bounds = metadata.GetEGPSEnvelope(epsg);
            //if (bounds == null || bounds.Width == 0.0 || bounds.Height == 0.0)
            //    throw new Exception("No bounds defined for EPSG:" + epsg);
            IPoint origin = metadata.GetOriginUpperLeft(epsg);

            if (origin == null)
            {
                throw new Exception("No origin defined for EPSG:" + epsg);
            }

            format = format.ToLower();
            if (format != ".png" && format != ".jpg")
            {
                throw new Exception("Unsupported image format");
            }

            if (format == ".png" && metadata.FormatPng == false)
            {
                throw new Exception("Format image/png not supported");
            }

            if (format == ".jpg" && metadata.FormatJpg == false)
            {
                throw new Exception("Format image/jpeg no supported");
            }

            string path = _mapServer.TileCachePath + @"/" + MapName(context) + @"/_alllayers/compact/" +
                          TileServiceMetadata.ScalePath(orientation, epsg, scale);

            string compactTileName = CompactTileName(row, col);

            string bundleFilename     = path + @"/" + compactTileName + ".tilebundle";
            string bundleDoneFilename = path + @"/" + compactTileName + ".tilebundle.done";
            string bundleCalcFilename = path + @"/" + compactTileName + ".tilebundle.calc";

            if (new FileInfo(bundleFilename).Exists)
            {
                return(await GetCompactTileBytes(context, path, row, col, format));
            }

            if (IsDirectoryEmpty(path))
            {
                #region On The Fly

                using (IServiceMap map = await context.CreateServiceMapInstance())
                {
                    ISpatialReference sRef = SpatialReference.FromID("epsg:" + epsg);

                    map.Display.SpatialReference = sRef;
                    map.Display.dpi = metadata.Dpi;

                    map.Display.iWidth  = metadata.TileWidth;
                    map.Display.iHeight = metadata.TileHeight;

                    double res = scale / (metadata.Dpi / 0.0254);
                    if (map.Display.MapUnits != GeoUnits.Meters)
                    {
                        GeoUnitConverter converter = new GeoUnitConverter();
                        res = converter.Convert(res, GeoUnits.Meters, map.Display.MapUnits);
                    }

                    origin = orientation == GridOrientation.UpperLeft ? metadata.GetOriginUpperLeft(epsg) : metadata.GetOriginLowerLeft(epsg);

                    double H = metadata.TileHeight * res;
                    double y = (orientation == GridOrientation.UpperLeft ?
                                origin.Y - H * (row + 1) :
                                origin.Y + H * row);

                    double W = metadata.TileWidth * res;
                    double x = origin.X + W * col;

                    map.Display.ZoomTo(new Envelope(x, y, x + W, y + H));
                    await map.Render();

                    bool maketrans = map.Display.MakeTransparent;
                    map.Display.MakeTransparent = true;
                    MemoryStream ms = new MemoryStream();
                    await map.SaveImage(ms, format == ".jpg"?ImageFormat.Jpeg : ImageFormat.Png);

                    map.Display.MakeTransparent = maketrans;

                    return(ms.ToArray());
                }

                #endregion
            }


            return(null);
        }
Esempio n. 51
0
 public abstract void DrawStart(IPoint p);
Esempio n. 52
0
        public static IFeature CutOffPolylineByPoint(IFeatureClass featureClass, IFeature polylineFeature,
                                                     IFeature pointFeature, string keyValue, string sKeyValue, string eKeyValue)
        {
            int idxKeyField  = pointFeature.Fields.FindField(keyValue);
            int idxSKeyField = polylineFeature.Fields.FindField(sKeyValue);
            int idxEKeyField = polylineFeature.Fields.FindField(eKeyValue);

            if (idxKeyField == -1 || idxSKeyField == -1 || idxEKeyField == -1)
            {
                return(null);
            }
            bool   hasZ  = FeatureClassUtil.CheckHasZ(featureClass);
            bool   hasM  = FeatureClassUtil.CheckHasM(featureClass);
            IPoint point = pointFeature.Shape as IPoint;

            if (point == null)
            {
                return(null);
            }
            IPolyline polyline1 = polylineFeature.ShapeCopy as IPolyline;

            if (polyline1 == null)
            {
                return(null);
            }
            IPolyline firstPolyline = new PolylineClass
            {
                FromPoint = GeometryHelper.CreatePoint(polyline1.FromPoint.X, polyline1.FromPoint.Y, polyline1.FromPoint.Z, polyline1.FromPoint.M, hasZ, hasM),
                ToPoint   = GeometryHelper.CreatePoint(point.X, point.Y, point.Z, point.M, hasZ, hasM)
            };

            if (hasZ)
            {
                IZAware pZAware = firstPolyline as IZAware;
                pZAware.ZAware = true;
            }
            if (hasM)
            {
                IMAware pMAware = firstPolyline as IMAware;
                pMAware.MAware = true;
            }
            polylineFeature.Shape = firstPolyline;
            polylineFeature.Store();
            IFeature  secondFeature  = featureClass.CreateFeature();
            IPolyline secondPolyline = new PolylineClass
            {
                FromPoint = GeometryHelper.CreatePoint(point.X, point.Y, point.Z, point.M, hasZ, hasM),
                ToPoint   = GeometryHelper.CreatePoint(polyline1.ToPoint.X, polyline1.ToPoint.Y, polyline1.ToPoint.Z, polyline1.ToPoint.M, hasZ, hasM),
            };

            if (hasZ)
            {
                IZAware pZAware = secondPolyline as IZAware;
                pZAware.ZAware = true;
            }
            if (hasM)
            {
                IMAware pMAware = secondPolyline as IMAware;
                pMAware.MAware = true;
            }
            secondFeature.Shape = secondPolyline;
            IField pField;

            for (int i = 0; i < featureClass.Fields.FieldCount; i++)
            {
                pField = featureClass.Fields.Field[i];
                if (pField.Type == esriFieldType.esriFieldTypeGeometry)
                {
                    continue;
                }
                int idx = secondFeature.Fields.FindField(pField.Name);
                if (pField.Editable && idx != -1)
                {
                    secondFeature.Value[idx] = polylineFeature.Value[idx];
                }
            }
            secondFeature.Store();

            polylineFeature.Value[idxEKeyField] = pointFeature.Value[idxKeyField];
            polylineFeature.Store();
            secondFeature.Value[idxSKeyField] = pointFeature.Value[idxKeyField];
            secondFeature.Store();
            return(secondFeature);
        }
Esempio n. 53
0
        public static void MovePointWithLine(IFeature pointFeature, List <IFeature> lineFeatures, IPoint targetPoint, double tolerance)
        {
            IPoint linkPoint = pointFeature.Shape as IPoint;

            foreach (IFeature lineFeature in lineFeatures)
            {
                IPolyline linkPolyline = lineFeature.Shape as IPolyline;
                if (linkPolyline == null)
                {
                    continue;
                }
                IPointCollection pointCollection = linkPolyline as IPointCollection;
                if (CommonHelper.GetDistance(linkPolyline.FromPoint, linkPoint) < tolerance)
                {
                    IPoint fromPoint = pointCollection.Point[0];
                    fromPoint.PutCoords(targetPoint.X, targetPoint.Y);
                    pointCollection.UpdatePoint(0, fromPoint);
                }
                else if (CommonHelper.GetDistance(linkPolyline.ToPoint, linkPoint) < tolerance)
                {
                    IPoint toPoint = pointCollection.Point[pointCollection.PointCount - 1];
                    toPoint.PutCoords(targetPoint.X, targetPoint.Y);
                    pointCollection.UpdatePoint(pointCollection.PointCount - 1, toPoint);
                }
                lineFeature.Shape = pointCollection as IPolyline;
                lineFeature.Store();
            }

            linkPoint.PutCoords(targetPoint.X, targetPoint.Y);
            pointFeature.Shape = linkPoint;
            pointFeature.Store();
        }
Esempio n. 54
0
 public static bool IsFromPoint(IPolyline polyline, IPoint point)
 {
     return(GetDistance(polyline.FromPoint, point) <= GetDistance(polyline.ToPoint, point));
 }
Esempio n. 55
0
 /// <summary>Gets the squared distance between this and the other position.</summary>
 public Distance GetDistance(IPoint other)
 {
     return(Distance.Between(this, other));
 }
Esempio n. 56
0
        public static List <IPolygon> GetMovedPoints(List <IFeature> features, IPoint point,
                                                     enumAnnotationDirection direction)
        {
            List <IPolygon> list = new List <IPolygon>();

            if (features.Count <= 0)
            {
                return(list);
            }
            IPoint originPoint = new PointClass
            {
                X = point.X,
                Y = point.Y - features[0].Extent.Height / 2
            };

            for (int i = 0; i < features.Count; i++)
            {
                IFeature         pFeature        = features[i];
                IPolygon         tempPolygon     = new PolygonClass();
                IPointCollection pointCollection = tempPolygon as IPointCollection;
                IPoint           point1          = new PointClass();
                IPoint           point2          = new PointClass();
                IPoint           point3          = new PointClass();
                IPoint           point4          = new PointClass();
                switch (direction)
                {
                case enumAnnotationDirection.LeftUp:
                {
                    point1 = new PointClass
                    {
                        X = originPoint.X - pFeature.Extent.Width,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - 1 - i)
                    };
                    point2 = new PointClass
                    {
                        X = originPoint.X - pFeature.Extent.Width,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - i)
                    };
                    point3 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - i)
                    };
                    point4 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - 1 - i)
                    };
                }
                break;

                case enumAnnotationDirection.RightUp:
                {
                    point1 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - 1 - i)
                    };
                    point2 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - i)
                    };
                    point3 = new PointClass
                    {
                        X = originPoint.X + pFeature.Extent.Width,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - i)
                    };
                    point4 = new PointClass
                    {
                        X = originPoint.X + pFeature.Extent.Width,
                        Y = originPoint.Y + pFeature.Extent.Height * (features.Count - 1 - i)
                    };
                }
                break;

                case enumAnnotationDirection.RightDown:
                {
                    point1 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y - pFeature.Extent.Height * (i + 1)
                    };
                    point2 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y - pFeature.Extent.Height * (i)
                    };
                    point3 = new PointClass
                    {
                        X = originPoint.X + pFeature.Extent.Width,
                        Y = originPoint.Y - pFeature.Extent.Height * (i)
                    };
                    point4 = new PointClass
                    {
                        X = originPoint.X + pFeature.Extent.Width,
                        Y = originPoint.Y - pFeature.Extent.Height * (i + 1)
                    };
                }
                break;

                case enumAnnotationDirection.LeftDown:
                {
                    point1 = new PointClass
                    {
                        X = originPoint.X - pFeature.Extent.Width,
                        Y = originPoint.Y - pFeature.Extent.Height * (i + 1)
                    };
                    point2 = new PointClass
                    {
                        X = originPoint.X - pFeature.Extent.Width,
                        Y = originPoint.Y - pFeature.Extent.Height * (i)
                    };
                    point3 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y - pFeature.Extent.Height * (i)
                    };
                    point4 = new PointClass
                    {
                        X = originPoint.X,
                        Y = originPoint.Y - pFeature.Extent.Height * (i + 1)
                    };
                }
                break;
                }
                pointCollection.AddPoint(point1);
                pointCollection.AddPoint(point2);
                pointCollection.AddPoint(point3);
                pointCollection.AddPoint(point4);
                pointCollection.AddPoint(point1);
                list.Add(tempPolygon);
            }

            return(list);
        }
Esempio n. 57
0
 public void Rotate(IPoint Origin, double rotationAngle)
 {
     (this.m_pGroupElement as ITransform2D).Rotate(Origin, rotationAngle);
 }
Esempio n. 58
0
        public void CreateTable(IActiveView pAV, IPoint Leftdown, object tabcell)
        {
            IPoint y;
            int    i;

            this.m_tabcellText = tabcell as SortedList <int, SortedList <int, string> >;
            IGroupElement groupElementClass = new GroupElement() as IGroupElement;

            (groupElementClass as IElementProperties).Name = "表格";
            (groupElementClass as IElementProperties).Type = "表格";
            IEnvelope envelope1 = new Envelope() as IEnvelope;

            envelope1.XMin = Leftdown.X;
            envelope1.YMin = Leftdown.Y;
            envelope1.XMax = Leftdown.X + this.Width;
            envelope1.YMax = Leftdown.Y + this.Height;
            IEnvelope   envelopeClass         = envelope1 as IEnvelope;
            IEnvelope   envelope              = envelopeClass;
            IFillSymbol simpleFillSymbolClass = new SimpleFillSymbol();

            (simpleFillSymbolClass as ISimpleFillSymbol).Style = esriSimpleFillStyle.esriSFSNull;
            IRectangleElement rectangleElement = new RectangleElement() as IRectangleElement;

            ((IElement)rectangleElement).Geometry        = envelope;
            ((IFillShapeElement)rectangleElement).Symbol = simpleFillSymbolClass;
            IRectangleElement rectangleElementClass = rectangleElement as IRectangleElement;

            groupElementClass.AddElement(rectangleElement as IElement);
            IPoint pointClass = new Point()
            {
                X = Leftdown.X,
                Y = Leftdown.Y + this.Height
            };
            IPoint point  = pointClass;
            double height = this.Height / (double)this.RowNumber;
            double width  = this.Width / (double)this.ColumnNumber;

            if (this.HasUpperBoundLine)
            {
                groupElementClass.AddElement(this.CreateHLine(point));
            }
            if (this.HasLowerBoundLine)
            {
                groupElementClass.AddElement(this.CreateHLine(Leftdown));
            }
            if (this.HasInnerHorizontalLine)
            {
                IPoint pointClass1 = new Point()
                {
                    X = point.X,
                    Y = point.Y - height
                };
                y = pointClass1;
                groupElementClass.AddElement(this.CreateHLine(y));
                if (!this.OnlyFirstHorizontalLine)
                {
                    for (i = 0; i < this.RowNumber - 2; i++)
                    {
                        y.Y = y.Y - height;
                        groupElementClass.AddElement(this.CreateHLine(y));
                    }
                }
            }
            if (this.HasLeftBoundLine)
            {
                groupElementClass.AddElement(this.CreateVLine(Leftdown));
            }
            if (this.HasRightBoundLine)
            {
                IPoint pointClass2 = new Point()
                {
                    X = Leftdown.X + this.Width,
                    Y = Leftdown.Y
                };
                groupElementClass.AddElement(this.CreateVLine(pointClass2));
            }
            if (this.HasInnerVerticalLine)
            {
                IPoint pointClass3 = new Point()
                {
                    X = Leftdown.X + width,
                    Y = Leftdown.Y
                };
                y = pointClass3;
                groupElementClass.AddElement(this.CreateVLine(y));
                if (!this.OnlyFirstVerticalLine)
                {
                    for (i = 0; i < this.ColumnNumber - 2; i++)
                    {
                        y.X = y.X + width;
                        groupElementClass.AddElement(this.CreateVLine(y));
                    }
                }
            }
            IPoint pointClass4 = new Point()
            {
                X = point.X,
                Y = point.Y
            };
            IPoint y1 = pointClass4;

            for (i = 0; i < this.RowNumber; i++)
            {
                IPoint pointClass5 = new Point()
                {
                    X = y1.X,
                    Y = y1.Y
                };
                IPoint x = pointClass5;
                for (int j = 0; j < this.ColumnNumber; j++)
                {
                    string cellText = this.GetCellText(i, j);
                    if (cellText.Length > 0)
                    {
                        IElement element = this.CreateTabTextElement(pAV, cellText, x.X, x.Y - height / 2);
                        groupElementClass.AddElement(element);
                        this.SetTableCell(i, j, element);
                    }
                    x.X = x.X + width;
                }
                y1.Y = y1.Y - height;
            }
            this.m_pGroupElement = groupElementClass as IElement;
        }
Esempio n. 59
0
 public void Scale(IPoint Origin, double sx, double sy)
 {
     (this.m_pGroupElement as ITransform2D).Scale(Origin, sx, sy);
 }
 public AnchorParameter(IPortLocationModel model, IPoint anchor)
 {
     this.model  = model;
     this.anchor = anchor;
 }