コード例 #1
0
        /// <summary>
        /// Tests whether the envelope defined by p1-p2
        /// and the envelope defined by q1-q2
        /// intersect.
        /// </summary>
        /// <param name="p1">One extrema point of the envelope Point.</param>
        /// <param name="p2">Another extrema point of the envelope Point.</param>
        /// <param name="q1">One extrema point of the envelope Q.</param>
        /// <param name="q2">Another extrema point of the envelope Q.</param>
        /// <returns><c>true</c> if Q intersects Point</returns>
        public static bool Intersects(IGeoEntity p1, IGeoEntity p2, IGeoEntity q1, IGeoEntity q2)
        {
            double minp = Math.Min(p1.X, p2.X);
            double maxq = Math.Max(q1.X, q2.X);

            if (minp > maxq)
            {
                return(false);
            }

            double minq = Math.Min(q1.X, q2.X);
            double maxp = Math.Max(p1.X, p2.X);

            if (maxp < minq)
            {
                return(false);
            }

            minp = Math.Min(p1.Y, p2.Y);
            maxq = Math.Max(q1.Y, q2.Y);
            if (minp > maxq)
            {
                return(false);
            }

            minq = Math.Min(q1.Y, q2.Y);
            maxp = Math.Max(p1.Y, p2.Y);
            if (maxp < minq)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: GeoEntityRegionMgr.cs プロジェクト: xiaoyj/Space
 private void AddMeaningfulGraphicsPath(GraphicsPath gp, IGeoEntity entity)
 {
     if ((gp != null) && (gp.PointCount > 0))
     {
         this.m_PathElementDict.Add(gp, entity);
     }
 }
コード例 #3
0
ファイル: GeoPoint.cs プロジェクト: PlumpMath/GeoObject.Net
        /// <summary>
        /// Initializes a new instance of the <see cref="Point"/> class.
        /// </summary>
        /// <param name="entity">The Position.</param>
        public GeoPoint(IGeoEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            this.Entity = entity;
            this.Type   = GeoObjectType.Point;
        }
コード例 #4
0
ファイル: GeoEntity.cs プロジェクト: PlumpMath/GeoObject.Net
 /// <summary>
 /// Determines whether the specified <see cref="GeoEntity" />, is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="GeoEntity" /> to compare with this instance.</param>
 /// <returns>
 ///   <c>true</c> if the specified <see cref="GeoEntity" /> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public bool Equals(IGeoEntity other)
 {
     if (other is GeoEntity &&
         double.Equals(other.X, this.X) &&
         double.Equals(other.Y, this.Y) &&
         ((other.Z == null && this.Z == null) || double.Equals(other.Z, this.Z)))
     {
         return(true);
     }
     return(false);
 }
コード例 #5
0
 static string GeometryToWkt(IGeoEntity position)
 {
     if (position.Z.HasValue)
     {
         return(string.Format(ci, "{0} {1} {2}", position.X, position.Y, position.Z));
     }
     else
     {
         return(string.Format(ci, "{0} {1}", position.X, position.Y));
     }
 }
コード例 #6
0
     public static List <double> GetCoordinates(this IGeoEntity entity)
     {
         if (entity == null)
         {
             return(new List <double>(0));
         }
         if (entity.Z.HasValue)
         {
             return new List <double>()
                    {
                        entity.X, entity.Y, entity.Z.Value
                    }
         }
         ;
         else
         {
             return new List <double>()
                    {
                        entity.X, entity.Y
                    }
         };
     }
 }
コード例 #7
0
 /// <summary>
 /// Initialize an <c>Envelope</c> for a region defined by two Coordinates.
 /// </summary>
 /// <param name="p1">The first Coordinate.</param>
 /// <param name="p2">The second Coordinate.</param>
 public void Init(IGeoEntity p1, IGeoEntity p2)
 {
     Init(p1.X, p2.X, p1.Y, p2.Y);
 }
コード例 #8
0
 /// <summary>
 /// Creates an <c>Envelope</c> for a region defined by a single Coordinate.
 /// </summary>
 /// <param name="p">The Coordinate.</param>
 public Envelope(IGeoEntity p)
 {
     Init(p.X, p.X, p.Y, p.Y);
 }
コード例 #9
0
 /// <summary>
 /// Creates an <c>Envelope</c> for a region defined by two Coordinates.
 /// </summary>
 /// <param name="p1">The first Coordinate.</param>
 /// <param name="p2">The second Coordinate.</param>
 public Envelope(IGeoEntity p1, IGeoEntity p2)
 {
     Init(p1.X, p2.X, p1.Y, p2.Y);
 }
コード例 #10
0
ファイル: GeoDataMgr.cs プロジェクト: xiaoyj/Space
 public Feature GetFeatureByVector(IGeoEntity vector, string featureName)
 {
     Feature feature = null;
     feature = GetFeatureByVector(this.m_TextVectorData, vector, featureName);
     if (feature != null)
     {
         return feature;
     }
     feature = GetFeatureByVector(this.m_GeometryVectorData, vector, featureName);
     if (feature != null)
     {
         return feature;
     }
     List<IGeoVectorData> datas = new List<IGeoVectorData>();
     datas.Add(this.m_UserShapeData);
     feature = GetFeatureByVector(datas, vector, featureName);
     if (feature != null)
     {
         return feature;
     }
     return null;
 }
コード例 #11
0
 ///<summary>
 /// Tests if the given point lies in or on the envelope.
 ///</summary>
 /// <remarks>
 /// Note that this is <b>not</b> the same definition as the SFS <i>contains</i>,
 /// which would exclude the envelope boundary.
 /// </remarks>
 /// <param name="p">the point which this <c>Envelope</c> is being checked for containing</param>
 /// <returns><c>true</c> if the point lies in the interior or on the boundary of this <c>Envelope</c>. </returns>
 /// <see cref="Covers(Coordinate)"/>
 public bool Contains(IGeoEntity p)
 {
     return(Covers(p));
 }
コード例 #12
0
 /// <summary>
 /// Check if the point <c>p</c> overlaps (lies inside) the region of this <c>Envelope</c>.
 /// </summary>
 /// <param name="p"> the <c>Coordinate</c> to be tested.</param>
 /// <returns><c>true</c> if the point overlaps this <c>Envelope</c>.</returns>
 public bool Intersects(IGeoEntity p)
 {
     return(Intersects(p.X, p.Y));
 }
コード例 #13
0
ファイル: TrafficMapVectorData.cs プロジェクト: xiaoyj/Space
 public Feature GetFeatureByVector(IGeoEntity vector, string featureName)
 {
     return null;
 }
コード例 #14
0
ファイル: GeoEntityRegionMgr.cs プロジェクト: xiaoyj/Space
 public bool IsVectorSelected(Point mousePoint, ref IGeoEntity vector)
 {
     foreach (GraphicsPath path in this.m_PathElementDict.Keys)
     {
         if (path.IsVisible(mousePoint))
         {
             vector = this.m_PathElementDict[path];
             return true;
         }
     }
     return false;
 }
コード例 #15
0
ファイル: GeoDataMgr.cs プロジェクト: xiaoyj/Space
 public static Feature GetFeatureByVector(List<IGeoVectorData> datas, IGeoEntity vector, string featureName)
 {
     foreach (IGeoVectorData data in datas)
     {
         Feature featureByVector = data.GetFeatureByVector(vector, featureName);
         if (featureByVector != null)
         {
             return featureByVector;
         }
     }
     return null;
 }
コード例 #16
0
 /// <summary>
 /// Initialize an <c>Envelope</c> for a region defined by a single Coordinate.
 /// </summary>
 /// <param name="p">The Coordinate.</param>
 public void Init(IGeoEntity p)
 {
     Init(p.X, p.X, p.Y, p.Y);
 }
コード例 #17
0
 /// <summary>
 /// Enlarges this <code>Envelope</code> so that it contains
 /// the given <see cref="Coordinate"/>.
 /// Has no effect if the point is already on or within the envelope.
 /// </summary>
 /// <param name="p">The Coordinate.</param>
 public void ExpandToInclude(IGeoEntity p)
 {
     ExpandToInclude(p.X, p.Y);
 }
コード例 #18
0
ファイル: GeoInfo.cs プロジェクト: xiaoyj/Space
 private List<IGeoRasterData> CheckRasterData(List<IGeoRasterData> rasterDataList, IGeoEntity shape, double calcPrecise)
 {
     Dictionary<double, IGeoRasterData> dictionary = new Dictionary<double, IGeoRasterData>();
     List<double> list = new List<double>();
     Dictionary<double, IGeoRasterData> dictionary2 = new Dictionary<double, IGeoRasterData>();
     foreach (IGeoRasterData data in rasterDataList)
     {
         if (this.IsShapeIntersectGeoXYRect(data.Bound, shape))
         {
             double resolution = data.Resolution;
             while (dictionary.ContainsKey(resolution))
             {
                 resolution += 0.01;
             }
             dictionary.Add(resolution, data);
             list.Add(resolution);
         }
     }
     if (this.m_CurrentReadStyle == ReadStyle.ClosestResolution)
     {
         list = this.SortClosestResolution(new List<double>(dictionary.Keys), calcPrecise);
     }
     else
     {
         list.Sort();
     }
     foreach (double num2 in list)
     {
         dictionary2.Add(num2, dictionary[num2]);
     }
     foreach (double num3 in dictionary2.Keys)
     {
         if (this.IsShapeInsideGeoXYRect(dictionary2[num3].Bound, shape))
         {
             List<IGeoRasterData> list2 = new List<IGeoRasterData>();
             list2.Add(dictionary2[num3]);
             return list2;
         }
     }
     return new List<IGeoRasterData>(dictionary2.Values);
 }
コード例 #19
0
 /// <summary>
 /// Test the point q to see whether it intersects the Envelope
 /// defined by p1-p2.
 /// </summary>
 /// <param name="p1">One extrema point of the envelope.</param>
 /// <param name="p2">Another extrema point of the envelope.</param>
 /// <param name="q">Point to test for intersection.</param>
 /// <returns><c>true</c> if q intersects the envelope p1-p2.</returns>
 public static bool Intersects(IGeoEntity p1, IGeoEntity p2, IGeoEntity q)
 {
     return(((q.X >= (p1.X < p2.X ? p1.X : p2.X)) && (q.X <= (p1.X > p2.X ? p1.X : p2.X))) &&
            ((q.Y >= (p1.Y < p2.Y ? p1.Y : p2.Y)) && (q.Y <= (p1.Y > p2.Y ? p1.Y : p2.Y))));
 }
コード例 #20
0
ファイル: GeoInfo.cs プロジェクト: xiaoyj/Space
 private bool IsShapeIntersectGeoXYRect(GeoXYRect geoRect, IGeoEntity shape)
 {
     if (shape is GeoXYRect)
     {
         return geoRect.IsRectJoinGeoXYRect(shape as GeoXYRect);
     }
     if (shape is GeoXYLine)
     {
         return geoRect.IsLineIntersectRect(shape as GeoXYLine);
     }
     return ((shape is GeoXYPoint) && geoRect.IsPointInGeoXYRect(shape as GeoXYPoint));
 }
コード例 #21
0
 ///<summary>
 /// Tests if the given point lies in or on the envelope.
 ///</summary>
 /// <param name="p">the point which this <c>Envelope</c> is being checked for containing</param>
 /// <returns><c>true</c> if the point lies in the interior or on the boundary of this <c>Envelope</c>.</returns>
 public bool Covers(IGeoEntity p)
 {
     return(Covers(p.X, p.Y));
 }
コード例 #22
0
ファイル: GeoSHPData.cs プロジェクト: xiaoyj/Space
 public override Feature GetFeatureByVector(IGeoEntity vector, string featureName)
 {
     if (vector is GeoXYPoint)
     {
         return this.GetFeatureByPoint(vector as GeoXYPoint, featureName);
     }
     if (vector is GeoXYLine)
     {
         return this.GetFeatureByLine(vector as GeoXYLine, featureName);
     }
     if (vector is GeoPolygonRegion)
     {
         return this.GetFeatureByRegion(vector as GeoPolygonRegion, featureName);
     }
     return null;
 }
コード例 #23
0
ファイル: GlassPanel.cs プロジェクト: xiaoyj/Space
 public Feature GetFeatureByVector(IGeoEntity vector, string featureName)
 {
     throw new NotImplementedException();
 }
コード例 #24
0
ファイル: GeometryTextOperator.cs プロジェクト: xiaoyj/Space
 public void MouseDown(object sender, GeoOperatorMouseEventArgs e)
 {
     if (this.m_NeedRefresh)
     {
         this.m_NeedRefresh = false;
         Control control = sender as Control;
         if (control != null)
         {
             this.m_GeoEntityRegionMgr.RefreshGraphicsPathDict(control.ClientRectangle);
         }
     }
     this.m_SelectedVector = null;
     this.m_GlassPanel.RemoveVectors(this.m_SelectedVectorIdCollection);
     this.m_SelectedVectorIdCollection.Clear();
     if (this.m_GeoEntityRegionMgr.IsVectorSelected(e.Location, ref this.m_SelectedVector))
     {
         this.m_SelectedVectorIdCollection.Add(this.m_SelectedVector.ID);
         if (this.m_SelectedVector is GeoXYPoint)
         {
             GeoPointStyle pointStyle = this.GetPointStyleById(this.m_VectorDatas, this.m_SelectedVector.ID).Clone() as GeoPointStyle;
             pointStyle.SetSelectedStyleForGlassPanel();
             this.m_GlassPanel.AddPoint(this.m_SelectedVector as GeoXYPoint, pointStyle);
         }
         else if (this.m_SelectedVector is GeoXYLine)
         {
             GeoLineStyle lineStyle = this.GetLineStyleById(this.m_VectorDatas, this.m_SelectedVector.ID).Clone() as GeoLineStyle;
             lineStyle.SetSelectedStyleForGlassPanel();
             this.m_GlassPanel.AddLine(this.m_SelectedVector as GeoXYLine, lineStyle);
         }
         else if (this.m_SelectedVector is GeoPolygonRegion)
         {
             GeoPolygonStyle polygonStyle = this.GetPolygonStyleById(this.m_VectorDatas, this.m_SelectedVector.ID).Clone() as GeoPolygonStyle;
             polygonStyle.SetSelectedStyleForGlassPanel();
             this.m_GlassPanel.AddPolygonRegion(this.m_SelectedVector as GeoPolygonRegion, polygonStyle);
         }
         e.Handled = true;
     }
 }