Beispiel #1
0
 public override double Distance(Geometry geom)
 {
     if (geom.GetType() == typeof(Point3D))
     {
         Point3D p = geom as Point3D;
         return(Math.Sqrt(Math.Pow(X - p.X, 2) + Math.Pow(Y - p.Y, 2) + Math.Pow(Z - p.Z, 2)));
     }
     return(base.Distance(geom));
 }
Beispiel #2
0
 public override double Distance(Geometry geom)
 {
     if (geom.GetType() == typeof(Point))
     {
         var p = geom as Point;
         return(Math.Sqrt(Math.Pow(X - p.X, 2) + Math.Pow(Y - p.Y, 2)));
     }
     else if (geom is LineString)
     {
         return(geom.Distance(this));
     }
     else if (geom is MultiLineString)
     {
         return(geom.Distance(this));
     }
     else
     {
         throw new Exception("The method or operation is not implemented for this geometry type.");
     }
 }
 public static bool Equals(Geometry g1, Geometry g2)
 {
     if (g1 == null && g2 == null)
     {
         return(true);
     }
     if (g1 == null || g2 == null)
     {
         return(false);
     }
     if (g1.GetType() != g2.GetType())
     {
         return(false);
     }
     if (g1 is Point)
     {
         return((g1 as Point).Equals(g2 as Point));
     }
     if (g1 is LineString)
     {
         return((g1 as LineString).Equals(g2 as LineString));
     }
     if (g1 is Polygon)
     {
         return((g1 as Polygon).Equals(g2 as Polygon));
     }
     if (g1 is MultiPoint)
     {
         return((g1 as MultiPoint).Equals(g2 as MultiPoint));
     }
     if (g1 is MultiLineString)
     {
         return((g1 as MultiLineString).Equals(g2 as MultiLineString));
     }
     if (g1 is MultiPolygon)
     {
         return((g1 as MultiPolygon).Equals(g2 as MultiPolygon));
     }
     throw new ArgumentException("The method or operation is not implemented on this geometry type.");
 }