/// <summary> /// Returns the distance between this geometry instance and another geometry, as /// measured in the spatial reference system of this instance. /// </summary> /// <param name="geom"></param> /// <returns></returns> 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)); }
/// <summary> /// Returns the distance between this geometry instance and another geometry, as /// measured in the spatial reference system of this instance. /// </summary> /// <param name="geom"></param> /// <returns></returns> 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))); } throw new Exception("The method or operation is not implemented for this geometry type."); }
/// <summary> /// Returns the distance between this geometry instance and another geometry, as /// measured in the spatial reference system of this instance. /// </summary> /// <param name="geom"></param> /// <returns></returns> public override double Distance(Geometry geom) { if (geom.GetType() == typeof(SharpMap.Geometries.Point3D)) { Point3D p = geom as Point3D; return(Math.Sqrt(Math.Pow(this.X - p.X, 2) + Math.Pow(this.Y - p.Y, 2) + Math.Pow(this.Z - p.Z, 2))); } else { return(base.Distance(geom)); } }
/// <summary> /// Returns the distance between this geometry instance and another geometry, as /// measured in the spatial reference system of this instance. /// </summary> /// <param name="geom"></param> /// <returns></returns> public override double Distance(Geometry geom) { if (geom.GetType() == typeof(SharpMap.Geometries.Point)) { Point p = geom as Point; return(Math.Sqrt(Math.Pow(this.X - p.X, 2) + Math.Pow(this.Y - p.Y, 2))); } else { throw new Exception("The method or operation is not implemented for this geometry type."); } }
/// <summary> /// Returns true if otherGeometry is of the same type and defines the same point set as the source geometry. /// </summary> /// <param name="g1">source geometry</param> /// <param name="g2">other Geometry</param> /// <returns></returns> 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)); } else if (g1 is LineString) { return((g1 as LineString).Equals(g2 as LineString)); } else if (g1 is Polygon) { return((g1 as Polygon).Equals(g2 as Polygon)); } else if (g1 is MultiPoint) { return((g1 as MultiPoint).Equals(g2 as MultiPoint)); } else if (g1 is MultiLineString) { return((g1 as MultiLineString).Equals(g2 as MultiLineString)); } else if (g1 is MultiPolygon) { return((g1 as MultiPolygon).Equals(g2 as MultiPolygon)); } else { throw new ArgumentException("The method or operation is not implemented on this geometry type."); } }