Esempio n. 1
0
        public void GetGeometry()
        {
            SqlGeometry geometryPoint;
            WebPoint    point;

            point         = new WebPoint();
            point.X       = 1000;
            point.Y       = 2000;
            geometryPoint = point.GetGeometry();
            Assert.IsNotNull(geometryPoint);
            Assert.AreEqual(SqlGeometryType.Point, geometryPoint.GetGeometryType());
            Assert.AreEqual(point.X, geometryPoint.STX);
            Assert.AreEqual(point.Y, geometryPoint.STY);

            point.IsZSpecified = true;
            point.Z            = 3000;
            geometryPoint      = point.GetGeometry();
            Assert.IsNotNull(geometryPoint);
            Assert.AreEqual(SqlGeometryType.Point, geometryPoint.GetGeometryType());
            Assert.AreEqual(point.X, geometryPoint.STX);
            Assert.AreEqual(point.Y, geometryPoint.STY);
            Assert.AreEqual(point.Z, (Double)geometryPoint.Z);

            point.IsMSpecified = true;
            point.M            = 4000;
            geometryPoint      = point.GetGeometry();
            Assert.IsNotNull(geometryPoint);
            Assert.AreEqual(SqlGeometryType.Point, geometryPoint.GetGeometryType());
            Assert.AreEqual(point.X, geometryPoint.STX);
            Assert.AreEqual(point.Y, geometryPoint.STY);
            Assert.AreEqual(point.Z, (Double)geometryPoint.Z);
            Assert.AreEqual(point.M, (Double)geometryPoint.M);
        }
Esempio n. 2
0
        /// <summary>
        /// Test if point is located inside region.
        /// Currently only two dimensions are handled.
        /// </summary>
        /// <param name="regionGeography">This region geography.</param>
        /// <param name="context">Web service request context.</param>
        /// <param name="coordinateSystem">Coordinate system used in region.</param>
        /// <param name='point'>Point.</param>
        /// <returns>True if point is located inside region.</returns>
        public static Boolean IsPointInsideGeometry(this WebRegionGeography regionGeography,
                                                    WebServiceContext context,
                                                    WebCoordinateSystem coordinateSystem,
                                                    WebPoint point)
        {
            SqlGeometry geometryMultiPolygon, geometryPoint;

            if (regionGeography.BoundingBox.IsPointInside(point))
            {
                geometryPoint        = point.GetGeometry();
                geometryMultiPolygon = regionGeography.GetMultiPolygonGeometry(context, coordinateSystem);
                return(geometryMultiPolygon.STContains(geometryPoint).Value);
            }
            else
            {
                // Species observation can not be inside region
                // since it is not inside the regions bounding box.
                return(false);
            }
        }
 /// <summary>
 /// Test if point is located inside polygon.
 /// Currently only two dimensions are handled.
 /// </summary>
 /// <param name="polygon">This polygon.</param>
 /// <param name='point'>Point.</param>
 /// <returns>True if point is located inside polygon.</returns>
 public static Boolean IsPointInsideGeometry(this WebPolygon polygon,
                                             WebPoint point)
 {
     return(polygon.GetGeometry().STContains(point.GetGeometry()).Value);
 }