Пример #1
0
        public void NotNormalizedGDBOperation()
        {                        
	        byte[] bytes = new GDBWriter().Write(polygon);
            IGeometry test = new GDBReader().Read(bytes);

            Assert.IsNull(test);    
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        public override void Start()
        {
            try
            {
                Write(multiPoint.Area);                
                Write(multiPoint.Boundary);
                Write(multiPoint.BoundaryDimension);
                Write(multiPoint.Centroid);
                Write(multiPoint.Coordinate);
                Write(multiPoint.Coordinates);
                Write(multiPoint.Dimension);
                Write(multiPoint.Envelope);
                Write(multiPoint.EnvelopeInternal);
                Write(multiPoint.Geometries.Length);
                Write(multiPoint.InteriorPoint);
                Write(multiPoint.IsEmpty);
                Write(multiPoint.IsSimple);
                Write(multiPoint.IsValid);
                Write(multiPoint.Length);
                Write(multiPoint.NumGeometries);
                Write(multiPoint.NumPoints);
                
                Write(multiPoint.Buffer(10));
                Write(multiPoint.Buffer(10, BufferStyle.CapButt));
                Write(multiPoint.Buffer(10, BufferStyle.CapSquare));
                Write(multiPoint.Buffer(10, 20));
                Write(multiPoint.Buffer(10, 20, BufferStyle.CapButt));
                Write(multiPoint.Buffer(10, 20, BufferStyle.CapSquare));
                Write(multiPoint.ConvexHull()); 
               
                byte[] bytes = multiPoint.AsBinary();
                IGeometry test1 = new WKBReader().Read(bytes);
                Write(test1.ToString());

                bytes = new GDBWriter().Write(multiPoint);
                test1 = new GDBReader().Read(bytes);
                Write(test1.ToString());
            }
            catch (Exception ex)
            {
                throw ex; 
            }
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        public override void Start()
        {
            IPoint pInterior = Factory.CreatePoint(new Coordinate(100, 100));
            IPoint pExterior = Factory.CreatePoint(new Coordinate(100, 101));

            try
            {
                Write(point.Area);                
                Write(point.Boundary);
                Write(point.BoundaryDimension);                                
                Write(point.Centroid);
                Write(point.Coordinate);
                Write(point.Coordinates);
                Write(point.CoordinateSequence);
                Write(point.Dimension);
                Write(point.Envelope);
                Write(point.EnvelopeInternal);
                Write(point.Factory);
                Write(point.InteriorPoint);
                Write(point.IsEmpty);
                Write(point.IsSimple);
                Write(point.IsValid);
                Write(point.Length);
                Write(point.NumPoints);
                Write(point.PrecisionModel);                          
                Write(point.X);
                Write(point.Y);                               

                Write(point.Contains(pInterior));
                Write(point.Contains(pExterior));

                Write(point.Buffer(10));
                Write(point.Buffer(10, BufferStyle.CapSquare));
                Write(point.Buffer(10, BufferStyle.CapButt));
                Write(point.Buffer(10, 20));                
                Write(point.Buffer(10, 20, BufferStyle.CapSquare));                
                Write(point.Buffer(10, 20, BufferStyle.CapButt)); 

                Write(point.Crosses(pInterior));
                Write(point.Crosses(pExterior));
                Write(point.Difference(pInterior));
                Write(point.Difference(pExterior));   
                Write(point.Disjoint(pInterior));
                Write(point.Disjoint(pExterior));
                Write(point.Equals(pInterior));
                Write(point.Equals(pExterior));
                Write(point.EqualsExact(pInterior));
                Write(point.EqualsExact(pExterior));
                Write(point.ConvexHull());
                Write(point.Intersection(pInterior)); 
                Write(point.Intersection(pExterior)); 
                Write(point.Intersects(pInterior));
                Write(point.Intersects(pExterior));
                Write(point.IsWithinDistance(pInterior, 0.001));
                Write(point.IsWithinDistance(pExterior, 0.001));                
                Write(point.Overlaps(pInterior));
                Write(point.Overlaps(pExterior));
                Write(point.SymmetricDifference(pInterior));
                Write(point.SymmetricDifference(pExterior));
                Write(point.ToString());
                Write(point.AsText());                
                Write(point.Touches(pInterior));
                Write(point.Touches(pExterior));
                Write(point.Union(pInterior));                 
                Write(point.Union(pExterior));         
                Write(point.Within(pInterior));                        
                Write(point.Within(pExterior));
                                
                string pointstring = "POINT (100.22 100.33)";
                string anotherpointstring = "POINT (12345 3654321)";
                IGeometry geom1 = Reader.Read(pointstring);
                Write(geom1.AsText());
                IGeometry geom2 = Reader.Read(anotherpointstring);
                Write(geom2.AsText());

                byte[] bytes = point.AsBinary();
                IGeometry test1 = new WKBReader().Read(bytes);
                Write(test1.ToString());
                
                bytes = Factory.CreatePoint(new Coordinate(Double.MinValue, Double.MinValue)).AsBinary();
                IGeometry testempty = new WKBReader().Read(bytes);
                Write(testempty);

                bytes = new GDBWriter().Write(geom1);
                test1 = new GDBReader().Read(bytes);
                Write(test1.ToString());                 
   
                // Test Empty Geometries
                Write(Point.Empty);
                Write(LineString.Empty);
                Write(Polygon.Empty);
                Write(MultiPoint.Empty);
                Write(MultiLineString.Empty);
                Write(MultiPolygon.Empty);
                Write(GeometryCollection.Empty);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }       
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        public override void Start()
        {
            IPoint pointInLine = Factory.CreatePoint(new Coordinate(20, 10));
            IPoint pointOutLine = Factory.CreatePoint(new Coordinate(20, 31));
            ILineString aLine = Factory.CreateLineString(new ICoordinate[] { new Coordinate(23, 32.2), new Coordinate(922, 11) });
            ILineString anotherLine = Factory.CreateLineString(new ICoordinate[] { new Coordinate(0, 1), new Coordinate(30, 30) });

            try
            {
                Write(line.Area);                
                Write(line.Boundary);
                Write(line.BoundaryDimension);                
                Write(line.Centroid);
                Write(line.Coordinate);
                Write(line.Coordinates);
                Write(line.CoordinateSequence);
                Write(line.Dimension);
                Write(line.EndPoint);
                Write(line.Envelope);
                Write(line.EnvelopeInternal);                
                Write(line.InteriorPoint);
                Write(line.IsClosed);
                Write(line.IsEmpty);
                Write(line.IsRing);
                Write(line.IsSimple);
                Write(line.IsValid);
                Write(line.Length);
                Write(line.NumPoints);                
                Write(line.StartPoint);
                if (line.UserData != null)
                    Write(line.UserData);
                else Write("UserData null");                 

                Write(line.Buffer(10));
                Write(line.Buffer(10, BufferStyle.CapButt));
                Write(line.Buffer(10, BufferStyle.CapSquare));
                Write(line.Buffer(10, 20));                
                Write(line.Buffer(10, 20, BufferStyle.CapButt));                
                Write(line.Buffer(10, 20, BufferStyle.CapSquare));   
                Write(line.Contains(pointInLine));               
                Write(line.Contains(pointOutLine));
                Write(line.Crosses(pointInLine));
                Write(line.Crosses(pointOutLine));
                Write(line.Difference(pointInLine));
                Write(line.Difference(pointOutLine));
                Write(line.Disjoint(pointInLine));
                Write(line.Disjoint(pointOutLine));
                Write(line.Distance(pointInLine));
                Write(line.Distance(pointOutLine));
                Write(line.Equals(line.Clone() as LineString));
                Write(line.EqualsExact(line.Clone() as LineString));
                Write(line.ConvexHull());  
                Write(line.Intersection(pointInLine));
                Write(line.Intersection(pointOutLine));                
                Write(line.Intersection(aLine));                              
                Write(line.Intersects(pointInLine));
                Write(line.Intersects(pointOutLine));
                Write(line.Intersects(aLine));
                Write(line.IsWithinDistance(pointOutLine, 2));
                Write(line.IsWithinDistance(pointOutLine, 222));
                Write(line.Overlaps(pointInLine));
                Write(line.Overlaps(pointOutLine));
                Write(line.Overlaps(aLine));
                Write(line.Overlaps(anotherLine));
                Write(line.Relate(pointInLine));
                Write(line.Relate(pointOutLine));
                Write(line.Relate(aLine));
                Write(line.Relate(anotherLine));
                Write(line.SymmetricDifference(pointInLine));
                Write(line.SymmetricDifference(pointOutLine));
                Write(line.SymmetricDifference(aLine));
                Write(line.SymmetricDifference(anotherLine)); 
                Write(line.ToString());
                Write(line.AsText());                
                Write(line.Touches(pointInLine));
                Write(line.Touches(pointOutLine));
                Write(line.Touches(aLine));
                Write(line.Touches(anotherLine));
                Write(line.Union(pointInLine));
                Write(line.Union(pointOutLine));
                Write(line.Union(aLine));
                Write(line.Union(anotherLine));
                Write(line.Within(pointInLine));
                Write(line.Within(pointOutLine));
                Write(line.Within(aLine));
                Write(line.Within(anotherLine));                
                
                string linestring = "LINESTRING (1.2 3.4, 5.6 7.8, 9.1 10.12)";
                string anotherlinestringg = "LINESTRING (12345 3654321, 685 7777.945677, 782 111.1)";
                IGeometry geom1 = Reader.Read(linestring);
                Write(geom1.AsText());
                IGeometry geom2 = Reader.Read(anotherlinestringg);
                Write(geom2.AsText());

                byte[] bytes = line.AsBinary();
                IGeometry test1 = new WKBReader().Read(bytes);
                Write(test1.ToString());

                bytes = new GDBWriter().Write(line);
                test1 = new GDBReader().Read(bytes);
                Write(test1.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }        
Пример #5
0
        public override void Start()
        {
            IPoint interiorPoint = Factory.CreatePoint(new Coordinate(130, 150));
            IPoint exteriorPoint = Factory.CreatePoint(new Coordinate(650, 1500));
            ILineString aLine = Factory.CreateLineString(new ICoordinate[] { new Coordinate(23, 32.2), new Coordinate(10, 222) });
            ILineString anotherLine = Factory.CreateLineString(new ICoordinate[] { new Coordinate(0, 1), new Coordinate(30, 30) });
            ILineString intersectLine = Factory.CreateLineString(new ICoordinate[] { new Coordinate(0, 1), new Coordinate(300, 300) });            

            try
            {               
                Write(polygon.Area);
                Write(polygon.Boundary);
                Write(polygon.BoundaryDimension);
                Write(polygon.Centroid);
                Write(polygon.Coordinate);
                Write(polygon.Coordinates.Length);
                Write(polygon.Dimension);
                Write(polygon.Envelope);
                Write(polygon.EnvelopeInternal);
                Write(polygon.ExteriorRing);
                Write(polygon.InteriorPoint);
                Write(polygon.InteriorRings.Length);
                Write(polygon.IsEmpty);
                Write(polygon.IsSimple);
                Write(polygon.IsValid);
                Write(polygon.Length);
                Write(polygon.NumInteriorRings);
                Write(polygon.NumPoints);                
                if (polygon.UserData != null)
                    Write(polygon.UserData);
                else Write("UserData null");
             
                Write(polygon.Buffer(10));
                Write(polygon.Buffer(10, BufferStyle.CapButt));                
                Write(polygon.Buffer(10, BufferStyle.CapSquare));
                Write(polygon.Buffer(10, 20));
                Write(polygon.Buffer(10, 20, BufferStyle.CapButt));                
                Write(polygon.Buffer(10, 20, BufferStyle.CapSquare));
                Write(polygon.Contains(interiorPoint));
                Write(polygon.Contains(exteriorPoint));
                Write(polygon.Contains(aLine));
                Write(polygon.Contains(anotherLine));
                Write(polygon.Crosses(interiorPoint));
                Write(polygon.Crosses(exteriorPoint));
                Write(polygon.Crosses(aLine));
                Write(polygon.Crosses(anotherLine));
                Write(polygon.Difference(interiorPoint));
                Write(polygon.Difference(exteriorPoint));
                Write(polygon.Difference(aLine));
                Write(polygon.Difference(anotherLine));
                Write(polygon.Disjoint(interiorPoint));
                Write(polygon.Disjoint(exteriorPoint));
                Write(polygon.Disjoint(aLine));
                Write(polygon.Disjoint(anotherLine));
                Write(polygon.Distance(interiorPoint));
                Write(polygon.Distance(exteriorPoint));
                Write(polygon.Distance(aLine));
                Write(polygon.Distance(anotherLine));
                Write(polygon.Intersection(interiorPoint));
                Write(polygon.Intersection(exteriorPoint));
                Write(polygon.Intersection(aLine));
                Write(polygon.Intersection(anotherLine));
                Write(polygon.Intersects(interiorPoint));
                Write(polygon.Intersects(exteriorPoint));
                Write(polygon.Intersects(aLine));
                Write(polygon.Intersects(anotherLine));
                Write(polygon.IsWithinDistance(interiorPoint, 300));
                Write(polygon.IsWithinDistance(exteriorPoint, 300));
                Write(polygon.IsWithinDistance(aLine, 300));
                Write(polygon.IsWithinDistance(anotherLine, 300));
                Write(polygon.Overlaps(interiorPoint));
                Write(polygon.Overlaps(exteriorPoint));
                Write(polygon.Overlaps(aLine));
                Write(polygon.Overlaps(anotherLine));
                Write(polygon.Relate(interiorPoint));
                Write(polygon.Relate(exteriorPoint));
                Write(polygon.Relate(aLine));
                Write(polygon.Relate(anotherLine));
                Write(polygon.SymmetricDifference(interiorPoint));
                Write(polygon.SymmetricDifference(exteriorPoint));
                Write(polygon.SymmetricDifference(aLine));
                Write(polygon.SymmetricDifference(anotherLine));
                Write(polygon.ToString());
                Write(polygon.AsText());
                Write(polygon.Touches(interiorPoint));
                Write(polygon.Touches(exteriorPoint));
                Write(polygon.Touches(aLine));
                Write(polygon.Touches(anotherLine));
                Write(polygon.Union(interiorPoint));
                Write(polygon.Union(exteriorPoint));
                Write(polygon.Union(aLine));
                Write(polygon.Union(anotherLine));

                string aPoly = "POLYGON ((20 20, 100 20, 100 100, 20 100, 20 20))";
                string anotherPoly = "POLYGON ((20 20, 100 20, 100 100, 20 100, 20 20), (50 50, 60 50, 60 60, 50 60, 50 50))";                
                IGeometry geom1 = Reader.Read(aPoly);
                Write(geom1.AsText());                                
                IGeometry geom2 = Reader.Read(anotherPoly);
                Write(geom2.AsText());

                // ExpandToInclude tests
                Envelope envelope = new Envelope(0, 0, 0, 0);
                envelope.ExpandToInclude(geom1.EnvelopeInternal);
                envelope.ExpandToInclude(geom2.EnvelopeInternal);
                Write(envelope.ToString());

                // The polygon is not correctly ordered! Calling normalize we fix the problem...
                polygon.Normalize();

                byte[] bytes = polygon.AsBinary();
                IGeometry test1 = new WKBReader().Read(bytes);
                Write(test1.ToString());

                bytes = new GDBWriter().Write(polygon);
                test1 = new GDBReader().Read(bytes);
                Write(test1.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }