Пример #1
0
 private bool HitTestByLine(ShapePolyline shapePolyline, double tolerance)
 {
     if (this is ShapePoint)
     {
         return(GeometryMathLib.GetDistance(shapePolyline, this as ShapePoint) < tolerance);
     }
     else if (this is ShapePolyline)
     {
         return(GeometryMathLib.IsCrossed2Lines(this as ShapePolyline, shapePolyline));
     }
     else if (this is ShapePolygon)
     {
         return((this as ShapePolygon).Contains(shapePolyline));
     }
     else
     {
         throw new NotSupportedException("暂不支持对\"" + this.GetType().ToString() + "\"进行点击测试。");
     }
 }
Пример #2
0
 public override bool Contains(Shape geometry)
 {
     if (geometry is ShapePoint)
     {
         return(GeometryMathLib.GetDistance(this, geometry as ShapePoint) < double.Epsilon);
     }
     else if (geometry is ShapePolyline)
     {
         return(false);
     }
     else if (geometry is ShapePolygon)
     {
         return(false);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
 public override bool Contains(Shape geometry)
 {
     if (!Envelope.Contains(geometry.Envelope))
     {
         return(false);
     }
     if (geometry is ShapePoint)
     {
         return(GeometryMathLib.IsPointInPolygon(geometry as ShapePoint, this));
     }
     else if (geometry is ShapePolyline)
     {
         ShapePolyline line = geometry as ShapePolyline;
         foreach (ShapeLineString part in line.Parts)
         {
             foreach (ShapePoint pt in part.Points)
             {
                 if (!GeometryMathLib.IsPointInPolygon(pt, this))
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
     else if (geometry is ShapePolygon)
     {
         ShapePolygon ply = geometry as ShapePolygon;
         foreach (ShapeRing ring in ply.Rings)
         {
             foreach (ShapePoint pt in ring.Points)
             {
                 if (!GeometryMathLib.IsPointInPolygon(pt, this))
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Пример #4
0
 private bool HitTestByPoint(ShapePoint shapePoint, double tolerance)
 {
     if (this is ShapePoint)
     {
         Envelope evp = Envelope.Clone() as Envelope;
         evp = evp.Expand((float)tolerance);
         return(evp.Contains(shapePoint.Envelope));
     }
     else if (this is ShapePolyline)
     {
         return(GeometryMathLib.GetDistance(this as ShapePolyline, shapePoint) < tolerance);
     }
     else if (this is ShapePolygon)
     {
         return((this as ShapePolygon).Contains(shapePoint));
     }
     else
     {
         throw new NotSupportedException("暂不支持对\"" + this.GetType().ToString() + "\"进行点击测试。");
     }
 }