public void TestAtomic()
 {
     IPolygon g = (IPolygon)Read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))");
     GeometryCollectionEnumerator i = new GeometryCollectionEnumerator(g);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is IPolygon);
     Assert.IsTrue(!i.MoveNext());
 }
        public void TestAtomic()
        {
            IPolygon g = (IPolygon)Read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))");
            GeometryCollectionEnumerator i = new GeometryCollectionEnumerator(g);

            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is IPolygon);
            Assert.IsTrue(!i.MoveNext());
        }
 public void TestGeometryCollection()
 {
     IGeometryCollection g = (IGeometryCollection)Read(
           "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (10 10)))");
     GeometryCollectionEnumerator i = new GeometryCollectionEnumerator(g);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is IGeometryCollection);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is IGeometryCollection);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is IPoint);
     Assert.IsTrue(!i.MoveNext());
 }
        public void TestGeometryCollection()
        {
            IGeometryCollection g = (IGeometryCollection)Read(
                "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (10 10)))");
            GeometryCollectionEnumerator i = new GeometryCollectionEnumerator(g);

            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is IGeometryCollection);
            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is IGeometryCollection);
            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is IPoint);
            Assert.IsTrue(!i.MoveNext());
        }
Example #5
0
        public void TestAtomic()
        {
            var g = (Polygon)Read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))");
            var i = new GeometryCollectionEnumerator(g);

            Assert.IsTrue(i.MoveNext());
            var current = i.Current;

            Assert.IsTrue(i.Current is Polygon);
            Assert.DoesNotThrow(() => current = i.Current);
            Assert.IsTrue(i.Current is Polygon);

            Assert.IsTrue(!i.MoveNext());
        }
        private static Location LocateInGeometry(Coordinate p, IGeometry geom)
        {
            if (geom is IPolygon)
            {
                return(LocatePointInPolygon(p, (IPolygon)geom));
            }

            if (geom is IGeometryCollection)
            {
                IEnumerator <IGeometry> geomi = new GeometryCollectionEnumerator((IGeometryCollection)geom);
                while (geomi.MoveNext())
                {
                    IGeometry g2 = geomi.Current;
                    if (g2 != geom)
                    {
                        var loc = LocateInGeometry(p, g2);
                        if (loc != Location.Exterior)
                        {
                            return(loc);
                        }
                    }
                }
            }
            return(Location.Exterior);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <param name="geom"></param>
        /// <returns></returns>
        private static bool ContainsPoint(ICoordinate p, IGeometry geom)
        {
            if (geom is IPolygon)
            {
                return(ContainsPointInPolygon(p, (IPolygon)geom));
            }

            if (geom is IGeometryCollection)
            {
                IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection)geom);
                while (geomi.MoveNext())
                {
                    IGeometry g2 = (IGeometry)geomi.Current;
                    // if(g2 != geom)  --- Diego Guidi say's: Java code tests reference equality: in C# with operator overloads we tests the object.equals()... more slower!
                    if (!ReferenceEquals(g2, geom))
                    {
                        if (ContainsPoint(p, g2))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 public void TestGeometryCollectionIterator()
 {
     GeometryCollection g = (GeometryCollection)reader.Read(
           "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (10 10)))");
     GeometryCollectionEnumerator i = new GeometryCollectionEnumerator(g);
     //The NTS GeometryCollectionEnumerator does not have a HasNext property, and the interfaces is slightly different
     //assertTrue(i.hasNext());
     //assertTrue(i.next() instanceof GeometryCollection);
     //assertTrue(i.next() instanceof GeometryCollection);
     //assertTrue(i.next() instanceof Point);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is GeometryCollection);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is GeometryCollection);
     Assert.IsTrue(i.MoveNext());
     Assert.IsTrue(i.Current is Point);
 }
Example #9
0
        public void TestGeometryCollectionIterator()
        {
            var g = (GeometryCollection)reader.Read(
                "GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (10 10)))");
            var i = new GeometryCollectionEnumerator(g);

            //The NTS GeometryCollectionEnumerator does not have a HasNext property, and the interfaces is slightly different
            //assertTrue(i.hasNext());
            //assertTrue(i.next() instanceof GeometryCollection);
            //assertTrue(i.next() instanceof GeometryCollection);
            //assertTrue(i.next() instanceof Point);
            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is GeometryCollection);
            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is GeometryCollection);
            Assert.IsTrue(i.MoveNext());
            Assert.IsTrue(i.Current is Point);
        }
        private static Boolean ContainsPoint(Coordinate p, IGeometry geom)
        {
            if (geom is IPolygon)
                return ContainsPointInPolygon(p, (IPolygon)geom);

            if (geom is IGeometryCollection)
            {
                IEnumerator<IGeometry> geomi = new GeometryCollectionEnumerator((IGeometryCollection)geom);
                while (geomi.MoveNext())
                {
                    IGeometry g2 = geomi.Current;
                    if (g2 != geom)
                        if (ContainsPoint(p, g2))
                            return true;
                }
            }
            return false;
        }
        public static IGeometry toGeometryCollection(IGeometry g)
        {
            if (!(g is IGeometryCollection))
            {
                return g.Factory.CreateGeometryCollection(new[] { g });
            }

            var atomicGeoms = new List<IGeometry>();
            var it = new GeometryCollectionEnumerator(g as IGeometryCollection);
            while (it.MoveNext())
            {
                var g2 = it.Current;
                if (!(g2 is IGeometryCollection))
                    atomicGeoms.Add(g2);
            }

            return g.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(atomicGeoms));
        }
Example #12
0
 private void ComputeLocation(Coordinate p, Geometry geom)
 {
     if (geom is Point)
     {
         UpdateLocationInfo(LocateOnPoint(p, (Point)geom));
     }
     if (geom is LineString)
     {
         UpdateLocationInfo(LocateOnLineString(p, (LineString)geom));
     }
     else if (geom is Polygon)
     {
         UpdateLocationInfo(LocateInPolygon(p, (Polygon)geom));
     }
     else if (geom is MultiLineString)
     {
         var ml = (MultiLineString)geom;
         foreach (LineString l in ml.Geometries)
         {
             UpdateLocationInfo(LocateOnLineString(p, l));
         }
     }
     else if (geom is MultiPolygon)
     {
         var mpoly = (MultiPolygon)geom;
         foreach (Polygon poly in mpoly.Geometries)
         {
             UpdateLocationInfo(LocateInPolygon(p, poly));
         }
     }
     else if (geom is GeometryCollection)
     {
         var geomi = new GeometryCollectionEnumerator((GeometryCollection)geom);
         while (geomi.MoveNext())
         {
             var g2 = (Geometry)geomi.Current;
             if (g2 != geom)
             {
                 ComputeLocation(p, g2);
             }
         }
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="p"></param>
 /// <param name="geom"></param>
 private void ComputeLocation(Coordinate p, IGeometry geom)
 {
     if (geom is IPoint)
     {
         UpdateLocationInfo(Locate(p, (IPoint)geom));
     }
     if (geom is ILineString)
     {
         UpdateLocationInfo(Locate(p, (ILineString)geom));
     }
     else if (geom is Polygon)
     {
         UpdateLocationInfo(Locate(p, (IPolygon)geom));
     }
     else if (geom is IMultiLineString)
     {
         IMultiLineString ml = (IMultiLineString)geom;
         foreach (ILineString l in ml.Geometries)
         {
             UpdateLocationInfo(Locate(p, l));
         }
     }
     else if (geom is IMultiPolygon)
     {
         IMultiPolygon mpoly = (IMultiPolygon)geom;
         foreach (IPolygon poly in mpoly.Geometries)
         {
             UpdateLocationInfo(Locate(p, poly));
         }
     }
     else if (geom is IGeometryCollection)
     {
         IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection)geom);
         while (geomi.MoveNext())
         {
             IGeometry g2 = (IGeometry)geomi.Current;
             if (g2 != geom)
             {
                 ComputeLocation(p, g2);
             }
         }
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="p"></param>
 /// <param name="geom"></param>
 /// <returns></returns>
 private static bool ContainsPoint(ICoordinate p, IGeometry geom)
 {
     if (geom is IPolygon) 
         return ContainsPointInPolygon(p, (IPolygon) geom);
     
     if(geom is IGeometryCollection) 
     {
         IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection) geom);
         while (geomi.MoveNext()) 
         {
             IGeometry g2 = (IGeometry) geomi.Current;
             // if(g2 != geom)  --- Diego Guidi say's: Java code tests reference equality: in C# with operator overloads we tests the object.equals()... more slower!                    
             if (!ReferenceEquals(g2, geom)) 
                 if (ContainsPoint(p, g2))
                     return true;
         }
     }
     return false;
 }
        public static Geometry toGeometryCollection(Geometry g)
        {
            if (!(g is GeometryCollection))
            {
                return(g.Factory.CreateGeometryCollection(new[] { g }));
            }

            var atomicGeoms = new List <Geometry>();
            var it          = new GeometryCollectionEnumerator(g as GeometryCollection);

            while (it.MoveNext())
            {
                var g2 = it.Current;
                if (!(g2 is GeometryCollection))
                {
                    atomicGeoms.Add(g2);
                }
            }

            return(g.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(atomicGeoms)));
        }
        private static Boolean ContainsPoint(Coordinate p, IGeometry geom)
        {
            if (geom is IPolygon)
            {
                return(ContainsPointInPolygon(p, (IPolygon)geom));
            }

            if (geom is IGeometryCollection)
            {
                IEnumerator <IGeometry> geomi = new GeometryCollectionEnumerator((IGeometryCollection)geom);
                while (geomi.MoveNext())
                {
                    IGeometry g2 = geomi.Current;
                    if (g2 != geom)
                    {
                        if (ContainsPoint(p, g2))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="p"></param>
 /// <param name="geom"></param>
 private void ComputeLocation(Coordinate p, IGeometry geom)
 {
     if (geom is IPoint)
         UpdateLocationInfo(Locate(p, (IPoint) geom));
     if (geom is ILineString) 
         UpdateLocationInfo(Locate(p, (ILineString) geom));                                  
     else if(geom is Polygon) 
         UpdateLocationInfo(Locate(p, (IPolygon) geom));            
     else if(geom is IMultiLineString) 
     {
         IMultiLineString ml = (IMultiLineString) geom;
         foreach (ILineString l in ml.Geometries)                     
             UpdateLocationInfo(Locate(p, l));                
     }
     else if(geom is IMultiPolygon)
     {
         IMultiPolygon mpoly = (IMultiPolygon) geom;
         foreach (IPolygon poly in mpoly.Geometries) 
             UpdateLocationInfo(Locate(p, poly));
     }
     else if (geom is IGeometryCollection) 
     {
         IEnumerator geomi = new GeometryCollectionEnumerator((IGeometryCollection) geom);
         while(geomi.MoveNext()) 
         {
             IGeometry g2 = (IGeometry) geomi.Current;
             if (g2 != geom)
                 ComputeLocation(p, g2);
         }
     }
 }