Example #1
0
        private SimpleFeature.GeomtryTypes.Point GetPoint(string wkt)
        {
            OpenSMIL.Server.SimpleFeature.IO.SimpleWKTReader wktReader = new SimpleWKTReader();
            ISimpleGeometry geometry = wktReader.Parse(wkt);

            return(geometry.Centroid);
        }
        private static Binary GetBinary(ISimpleGeometry geometry)
        {
            if (geometry == null)
            {
                return(null);
            }

            Binary ret = null;

            var sgw = geometry as SqlServer.SqlGeography;

            if ((sgw == null) || !sgw.CoordinateSystem.IsEquivalentTo(ServiceLocator.Current.GetInstance <ICoordinateSystemProvider>().Wgs84))
            {
                var b = new SqlServer.SqlGeometryBuilder(ServiceLocator.Current.GetInstance <ICoordinateSystemProvider>().Wgs84);
                geometry.Populate(b);
                sgw = (SqlServer.SqlGeography)b.ConstructedGeometry;
            }

            using (var ms = new MemoryStream())
                using (var bw = new BinaryWriter(ms))
                {
                    ((SqlTypes.SqlGeography)sgw).Write(bw);
                    ret = new Binary(ms.ToArray());
                }

            return(ret);
        }
Example #3
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            // Transform into SqlGeometry, then calculate
            // We would do this if we dealt with geometries anyway. Not sure it makes much sense, though...

            return(SqlGeometry.ToGeometry(this).Contains(geometry));
        }
Example #4
0
        private void ConvertFullRecordField(Types.AbstractRecord fullRecord, IRecord record, Filter.XPathTypeNavigator navigator)
        {
            var r = fullRecord as Types.Record;

            if (navigator.LocalName == "BoundingBox")
            {
                object value = navigator.GetValue(record);
                if (value == null)
                {
                    return;
                }

                // Covariance is a feature of .NET 4.0 http://msdn.microsoft.com/en-us/library/dd233059.aspx
                var ensg = value as IEnumerable <ISimpleGeometry>;
                if (ensg == null)
                {
                    var geom = value as ISimpleGeometry;
                    if (geom != null)
                    {
                        ensg = new ISimpleGeometry[] { geom }
                    }
                    ;
                }

                foreach (ISimpleGeometry g in ensg)
                {
                    try
                    {
                        var box = new Ows100.BoundingBox();
                        box.InitFromGeometry(g);
                        r.BoundingBox.Add(box);
                    } catch (Exception ex)
                    {
                        try
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while creating bounding box for geometry \"{1}\". Message: \"{2}\".", ex.GetType(), g, ex.Message));
                        } catch (Exception eex)
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while logging exception {1}. Message: \"{2}\".", eex.GetType(), ex.GetType(), eex.Message));
                        }
                    }
                }

                return;
            }

            IList <DC11.DCelement> elements = CreateRecordField(record, navigator);

            foreach (DC11.DCelement e in elements)
            {
                r.Content.DCelement.Add(e);
            }
        }
Example #5
0
        private static SharpGeometry Convert(ISimpleGeometry geometry)
        {
            var sg = geometry as SharpGeometry;

            if (sg != null)
            {
                return(sg);
            }

            var sgb = new SharpGeometryBuilder();

            geometry.Populate(sgb);
            return((SharpGeometry)sgb.ConstructedGeometry);
        }
Example #6
0
        /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SpatialGeography" />.</summary>
        /// <param name="geometry">The geometry to convert.</param>
        /// <returns>The converted geometry.</returns>
        public static SpatialGeography ToGeography(ISimpleGeometry geometry)
        {
            var sg = geometry as SpatialGeography;

            if (sg != null)
            {
                return(sg);
            }

            var sgb = new SpatialGeometryBuilder();

            geometry.Populate(sgb);
            return(sgb.ConstructedGeometry as SpatialGeography);
        }
Example #7
0
        /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SqlGeometry" />.</summary>
        /// <param name="geometry">The geometry to convert.</param>
        /// <returns>The converted geometry.</returns>
        public static SqlGeometry ToGeometry(ISimpleGeometry geometry)
        {
            var sg = geometry as SqlGeometry;

            if (sg != null)
            {
                return(sg);
            }

            var sgb = new SqlGeometryBuilderWrapper();

            geometry.Populate(sgb);
            return(sgb.ConstructedGeometry);
        }
Example #8
0
        /// <summary>Fills the current bounding box with the specified geometry information.</summary>
        /// <param name="g">THe geometry to fill this bounding box with.</param>
        public void InitFromGeometry(ISimpleGeometry g)
        {
            if (g == null)
            {
                LowerCorner = null;
                UpperCorner = null;
                return;
            }

            CoordinateSystem = g.CoordinateSystem;

            var lc = new List <double>(2);
            var uc = new List <double>(2);

            ISimpleGeometry env = g.Envelope();

            var envelope = env as Gml.V311.Envelope;

            if (envelope == null)
            {
                envelope = new Gml.V311.Envelope();
                env.Populate(envelope);
            }
            Debug.Assert(envelope != null);

            lc.Add(envelope.lowerCorner.TypedValue[0]);
            lc.Add(envelope.lowerCorner.TypedValue[1]);
            uc.Add(envelope.upperCorner.TypedValue[0]);
            uc.Add(envelope.upperCorner.TypedValue[1]);

            // Bug in LinqToXsd : serialization is culture dependent...
            //LowerCorner=lc;
            //UpperCorner=uc;
            LowerCorner = new List <double>();
            foreach (XElement el in Untyped.Descendants("{http://www.opengis.net/ows}LowerCorner"))
            {
                el.Value = string.Join(
                    " ",
                    lc.Select <double, string>(d => d.ToString(CultureInfo.InvariantCulture))
                    );
            }
            UpperCorner = new List <double>();
            foreach (XElement el in Untyped.Descendants("{http://www.opengis.net/ows}UpperCorner"))
            {
                el.Value = string.Join(
                    " ",
                    uc.Select <double, string>(d => d.ToString(CultureInfo.InvariantCulture))
                    );
            }
        }
Example #9
0
        private static FdoGeometry Convert(ISimpleGeometry geometry)
        {
            var sg = geometry as FdoGeometry;

            if (sg != null)
            {
                return(sg.Clone());
            }

            var sgb = new FdoGeometryBuilder();

            geometry.Populate(sgb);
            return(sgb.ConstructedGeometry);
        }
Example #10
0
        /// <summary>Fills the current bounding box with the specified geometry information.</summary>
        /// <param name="g">THe geometry to fill this bounding box with.</param>
        public void InitFromGeometry(ISimpleGeometry g)
        {
            if (g==null)
            {
                LowerCorner=null;
                UpperCorner=null;
                return;
            }

            CoordinateSystem=g.CoordinateSystem;

            var lc=new List<double>(2);
            var uc=new List<double>(2);

            ISimpleGeometry env=g.Envelope();

            var envelope=env as Gml.V311.Envelope;
            if (envelope==null)
            {
                envelope=new Gml.V311.Envelope();
                env.Populate(envelope);
            }
            Debug.Assert(envelope!=null);

            lc.Add(envelope.lowerCorner.TypedValue[0]);
            lc.Add(envelope.lowerCorner.TypedValue[1]);
            uc.Add(envelope.upperCorner.TypedValue[0]);
            uc.Add(envelope.upperCorner.TypedValue[1]);

            // Bug in LinqToXsd : serialization is culture dependent...
            //LowerCorner=lc;
            //UpperCorner=uc;
            LowerCorner=new List<double>();
            foreach (XElement el in Untyped.Descendants("{http://www.opengis.net/ows}LowerCorner"))
                el.Value=string.Join(
                    " ",
                    lc.Select<double, string>(d => d.ToString(CultureInfo.InvariantCulture))
                );
            UpperCorner=new List<double>();
            foreach (XElement el in Untyped.Descendants("{http://www.opengis.net/ows}UpperCorner"))
                el.Value=string.Join(
                    " ",
                    uc.Select<double, string>(d => d.ToString(CultureInfo.InvariantCulture))
                );
        }
        /// <summary>Fills the current bounding box with the specified geometry information.</summary>
        /// <param name="g">THe geometry to fill this bounding box with.</param>
        public void InitFromGeometry(ISimpleGeometry g)
        {
            if (g == null)
            {
                westBoundLongitude = null;
                eastBoundLongitude = null;
                southBoundLatitude = null;
                northBoundLatitude = null;
                return;
            }

            var lc = new List <decimal>(2);
            var uc = new List <decimal>(2);

            // Make sure it is WGS 84, and a GML 3.1.1 instance
            var builder = new Ogc.Gml.V311.GmlGeometryBuilder(CommonServiceLocator.GetCoordinateSystemProvider().Wgs84);

            g.Populate(builder);

            var envelope = builder.ConstructedGeometry.Envelope() as Ogc.Gml.V311.Envelope;

            lc.Add(Convert.ToDecimal(envelope.lowerCorner.TypedValue[0]));
            lc.Add(Convert.ToDecimal(envelope.lowerCorner.TypedValue[1]));
            uc.Add(Convert.ToDecimal(envelope.upperCorner.TypedValue[0]));
            uc.Add(Convert.ToDecimal(envelope.upperCorner.TypedValue[1]));

            westBoundLongitude = new Gco.Decimal_PropertyType()
            {
                Decimal = new Gco.Decimal(lc[0])
            };
            eastBoundLongitude = new Gco.Decimal_PropertyType()
            {
                Decimal = new Gco.Decimal(uc[0])
            };
            southBoundLatitude = new Gco.Decimal_PropertyType()
            {
                Decimal = new Gco.Decimal(lc[1])
            };
            northBoundLatitude = new Gco.Decimal_PropertyType()
            {
                Decimal = new Gco.Decimal(uc[1])
            };
        }
Example #12
0
            private void _WriteBox()
            {
                var geometry = _Tap as ISimpleGeometry;

                if (geometry != null)
                {
                    ISimpleGeometry envelope = null;
                    try
                    {
                        envelope = geometry.Envelope();
                    } catch
                    {
                        // Empty
                    }
                    if (envelope != null)
                    {
                        var sink = new JsonEnvelopeSink(_Writer);
                        envelope.Populate(sink);
                    }
                }
            }
        /// <summary>Fills the current bounding box with the specified geometry information.</summary>
        /// <param name="g">THe geometry to fill this bounding box with.</param>
        public void InitFromGeometry(ISimpleGeometry g)
        {
            if (g==null)
            {
                westBoundLongitude=null;
                eastBoundLongitude=null;
                southBoundLatitude=null;
                northBoundLatitude=null;
                return;
            }

            var lc=new List<decimal>(2);
            var uc=new List<decimal>(2);

            // Make sure it is WGS 84, and a GML 3.1.1 instance
            var builder=new Ogc.Gml.V311.GmlGeometryBuilder(CommonServiceLocator.GetCoordinateSystemProvider().Wgs84);
            g.Populate(builder);

            var envelope=builder.ConstructedGeometry.Envelope() as Ogc.Gml.V311.Envelope;

            lc.Add(Convert.ToDecimal(envelope.lowerCorner.TypedValue[0]));
            lc.Add(Convert.ToDecimal(envelope.lowerCorner.TypedValue[1]));
            uc.Add(Convert.ToDecimal(envelope.upperCorner.TypedValue[0]));
            uc.Add(Convert.ToDecimal(envelope.upperCorner.TypedValue[1]));

            westBoundLongitude=new Gco.Decimal_PropertyType() {
                Decimal=new Gco.Decimal(lc[0])
            };
            eastBoundLongitude=new Gco.Decimal_PropertyType() {
                Decimal=new Gco.Decimal(uc[0])
            };
            southBoundLatitude=new Gco.Decimal_PropertyType() {
                Decimal=new Gco.Decimal(lc[1])
            };
            northBoundLatitude=new Gco.Decimal_PropertyType() {
                Decimal=new Gco.Decimal(uc[1])
            };
        }
Example #14
0
 /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Contains(ISimpleGeometry geometry)
 {
     SharpGeometry other=Convert(geometry);
     return _Geometry.Contains(other._Geometry);
 }
Example #15
0
        /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
        public bool Intersects(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STIntersects(other._Geometry).Value);
        }
Example #16
0
        /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Within(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STWithin(other._Geometry).Value);
        }
Example #17
0
        /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
        public bool Disjoint(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STDisjoint(other._Geometry).Value);
        }
Example #18
0
        /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SpatialGeometry" />.</summary>
        /// <param name="geometry">The geometry to convert.</param>
        /// <returns>The converted geometry.</returns>
        public static SpatialGeometry ToGeometry(ISimpleGeometry geometry)
        {
            var sg=geometry as SpatialGeometry;
            if (sg!=null)
                return sg;

            var sgb=new SpatialGeometryBuilder();
            geometry.Populate(sgb);
            return sgb.ConstructedGeometry as SpatialGeometry;
        }
Example #19
0
 /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Within(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Within(other._Geometry);
 }
Example #20
0
 /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
 public bool Intersects(ISimpleGeometry geometry)
 {
     SqlGeography other=ToGeography(geometry);
     return _Geography.STIntersects(other._Geography).Value;
 }
Example #21
0
 /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
 /// <param name="geometry">The geometry to calculate the distance from.</param>
 /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
 public double Distance(ISimpleGeometry geometry)
 {
     throw new NotSupportedException();
 }
Example #22
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Contains(other._Geometry));
        }
Example #23
0
        /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
        public bool Intersects(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Intersects(other._Geometry));
        }
Example #24
0
        /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Overlaps(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Overlaps(other._Geometry));
        }
Example #25
0
        /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Within(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Within(other._Geometry));
        }
Example #26
0
        /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
        public bool Touches(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Touches(other._Geometry));
        }
Example #27
0
        /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
        public bool Disjoint(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Disjoint(other._Geometry));
        }
Example #28
0
 /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
 public bool Intersects(ISimpleGeometry geometry)
 {
     SharpGeometry other=Convert(geometry);
     return _Geometry.Intersects(other._Geometry);
 }
Example #29
0
 /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
 /// <param name="geometry">The geometry to calculate the distance from.</param>
 /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
 public double Distance(ISimpleGeometry geometry)
 {
     SqlGeography other=ToGeography(geometry);
     return _Geography.STDistance(other._Geography).Value;
 }
Example #30
0
 /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
 /// <param name="geometry">The geometry to calculate the distance from.</param>
 /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
 public double Distance(ISimpleGeometry geometry)
 {
     throw new NotSupportedException();
 }
Example #31
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            // Transform into SqlGeometry, then calculate
            // We would do this if we dealt with geometries anyway. Not sure it makes much sense, though...

            return SpatialGeometry.ToGeometry(this).Contains(geometry);
        }
Example #32
0
 /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Contains(ISimpleGeometry geometry)
 {
     using (FdoGeometry other=Convert(geometry))
         return FSpatial.SpatialUtility.Evaluate(_Geometry, FFilter.SpatialOperations.SpatialOperations_Contains, other._Geometry);
 }
Example #33
0
 /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
 public bool Intersects(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Intersects(other._Geometry);
 }
Example #34
0
        private static FdoGeometry Convert(ISimpleGeometry geometry)
        {
            var sg=geometry as FdoGeometry;
            if (sg!=null)
                return sg.Clone();

            var sgb=new FdoGeometryBuilder();
            geometry.Populate(sgb);
            return sgb.ConstructedGeometry;
        }
Example #35
0
        /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
        /// <param name="geometry">The geometry to calculate the distance from.</param>
        /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
        public double Distance(ISimpleGeometry geometry)
        {
            SharpGeometry other = Convert(geometry);

            return(_Geometry.Distance(other._Geometry));
        }
Example #36
0
        /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
        public bool Disjoint(ISimpleGeometry geometry)
        {
            SpatialGeography other = ToGeography(geometry);

            return(_Geography.Disjoint(other._Geography));
        }
Example #37
0
        /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
        public bool Touches(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STTouches(other._Geometry).Value);
        }
Example #38
0
        /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
        /// <param name="geometry">The geometry to calculate the distance from.</param>
        /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
        public double Distance(ISimpleGeometry geometry)
        {
            SpatialGeography other = ToGeography(geometry);

            return(_Geography.Distance(other._Geography).Value);
        }
Example #39
0
        /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Overlaps(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STOverlaps(other._Geometry).Value);
        }
Example #40
0
        /// <summary>Indicates whether the 2 geometries intersect or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the 2 geometries intersect, or else <c>false</c>.</returns>
        public bool Intersects(ISimpleGeometry geometry)
        {
            SpatialGeography other = ToGeography(geometry);

            return(_Geography.Intersects(other._Geography));
        }
Example #41
0
        /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
        /// <param name="geometry">The geometry to test against.</param>
        /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
        public bool Contains(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STContains(other._Geometry).Value);
        }
Example #42
0
        private static SharpGeometry Convert(ISimpleGeometry geometry)
        {
            var sg=geometry as SharpGeometry;
            if (sg!=null)
                return sg;

            var sgb=new SharpGeometryBuilder();
            geometry.Populate(sgb);
            return (SharpGeometry)sgb.ConstructedGeometry;
        }
        private static byte[] GetBinary(ISimpleGeometry geometry)
        {
            if (geometry==null)
                return null;

            byte[] ret=null;

            var sgw=geometry as SqlServer.SqlGeometry;
            if ((sgw==null) || !sgw.CoordinateSystem.IsEquivalentTo(ServiceLocator.Current.GetInstance<ICoordinateSystemProvider>().Wgs84))
            {
                var b=new SqlServer.SqlGeometryBuilder(ServiceLocator.Current.GetInstance<ICoordinateSystemProvider>().Wgs84);
                geometry.Populate(b);
                sgw=(SqlServer.SqlGeometry)b.ConstructedGeometry;
            }

            using (var ms=new MemoryStream())
                using (var bw=new BinaryWriter(ms))
                {
                    ((SqlTypes.SqlGeometry)sgw).Write(bw);
                    ret=ms.ToArray();
                }

            return ret;
        }
Example #44
0
 /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
 public bool Disjoint(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Disjoint(other._Geometry);
 }
Example #45
0
 /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Overlaps(ISimpleGeometry geometry)
 {
     SharpGeometry other=Convert(geometry);
     return _Geometry.Overlaps(other._Geometry);
 }
Example #46
0
 /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Within(ISimpleGeometry geometry)
 {
     SharpGeometry other=Convert(geometry);
     return _Geometry.Within(other._Geometry);
 }
Example #47
0
 /// <summary>Indicates whether the 2 geometries are disjoint or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries are disjoint, or else <c>false</c>.</returns>
 public bool Disjoint(ISimpleGeometry geometry)
 {
     SqlGeography other=ToGeography(geometry);
     return _Geography.STDisjoint(other._Geography).Value;
 }
Example #48
0
 /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
 public bool Touches(ISimpleGeometry geometry)
 {
     SqlGeometry other=ToGeometry(geometry);
     return _Geometry.STTouches(other._Geometry).Value;
 }
Example #49
0
        /// <summary>Converts the specified <paramref name="geometry" /> into a <see cref="SqlGeography" />.</summary>
        /// <param name="geometry">The geometry to convert.</param>
        /// <returns>The converted geometry.</returns>
        public static SqlGeography ToGeography(ISimpleGeometry geometry)
        {
            var sg=geometry as SqlGeography;
            if (sg!=null)
                return sg;

            var sgb=new SqlGeographyBuilderWrapper();
            geometry.Populate(sgb);
            return sgb.ConstructedGeometry;
        }
Example #50
0
 /// <summary>Indicates whether the current geometry is within the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry is within the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Within(ISimpleGeometry geometry)
 {
     SqlGeometry other=ToGeometry(geometry);
     return _Geometry.STWithin(other._Geometry).Value;
 }
Example #51
0
 /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
 public bool Touches(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Touches(other._Geometry);
 }
Example #52
0
 /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Overlaps(ISimpleGeometry geometry)
 {
     SqlGeometry other=ToGeometry(geometry);
     return _Geometry.STOverlaps(other._Geometry).Value;
 }
Example #53
0
 /// <summary>Indicates whether the current geometry overlaps the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry overlaps the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Overlaps(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Overlaps(other._Geometry);
 }
Example #54
0
 /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Contains(ISimpleGeometry geometry)
 {
     SqlGeometry other=ToGeometry(geometry);
     return _Geometry.STContains(other._Geometry).Value;
 }
Example #55
0
 /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Contains(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Contains(other._Geometry);
 }
Example #56
0
        /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
        /// <param name="geometry">The geometry to calculate the distance from.</param>
        /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
        public double Distance(ISimpleGeometry geometry)
        {
            SqlGeometry other = ToGeometry(geometry);

            return(_Geometry.STDistance(other._Geometry).Value);
        }
Example #57
0
 /// <summary>Returns the shortest distance between any 2 points in the 2 geometries.</summary>
 /// <param name="geometry">The geometry to calculate the distance from.</param>
 /// <returns>The shortest distance between any 2 points in the 2 geometries.</returns>
 public double Distance(ISimpleGeometry geometry)
 {
     SpatialGeometry other=ToGeometry(geometry);
     return _Geometry.Distance(other._Geometry).Value;
 }
Example #58
0
 /// <summary>Indicates whether the current geometry contains the specified <paramref name="geometry" /> or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the current geometry contains the specified <paramref name="geometry" />, or else <c>false</c>.</returns>
 public bool Contains(ISimpleGeometry geometry)
 {
     using (FdoGeometry other = Convert(geometry))
         return(FSpatial.SpatialUtility.Evaluate(_Geometry, FFilter.SpatialOperations.SpatialOperations_Contains, other._Geometry));
 }
Example #59
0
        private void ConvertFullRecordField(Types.AbstractRecord fullRecord, IRecord record, Filter.XPathTypeNavigator navigator)
        {
            var r=fullRecord as Types.Record;

            if (navigator.LocalName=="BoundingBox")
            {
                object value=navigator.GetValue(record);
                if (value==null)
                    return;

                // Covariance is a feature of .NET 4.0 http://msdn.microsoft.com/en-us/library/dd233059.aspx
                var ensg=value as IEnumerable<ISimpleGeometry>;
                if (ensg==null)
                {
                    var geom=value as ISimpleGeometry;
                    if (geom!=null)
                        ensg=new ISimpleGeometry[] { geom };
                }

                foreach (ISimpleGeometry g in ensg)
                {
                    try
                    {
                        var box=new Ows100.BoundingBox();
                        box.InitFromGeometry(g);
                        r.BoundingBox.Add(box);
                    } catch (Exception ex)
                    {
                        try
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while creating bounding box for geometry \"{1}\". Message: \"{2}\".", ex.GetType(), g, ex.Message));
                        } catch (Exception eex)
                        {
                            Logger.Error(CultureInfo.InvariantCulture, m => m("Exception {0} occured while logging exception {1}. Message: \"{2}\".", eex.GetType(), ex.GetType(), eex.Message));
                        }
                    }
                }

                return;
            }

            IList<DC11.DCelement> elements=CreateRecordField(record, navigator);
            foreach (DC11.DCelement e in elements)
                r.Content.DCelement.Add(e);
        }
Example #60
0
 /// <summary>Indicates whether the 2 geometries touch themselves or not.</summary>
 /// <param name="geometry">The geometry to test against.</param>
 /// <returns><c>true</c> if the 2 geometries touch themselves, or else <c>false</c>.</returns>
 public bool Touches(ISimpleGeometry geometry)
 {
     SharpGeometry other=Convert(geometry);
     return _Geometry.Touches(other._Geometry);
 }