/// <inheritdoc cref="IGeometryReader{TSource}.Read(Stream)"/>>
        public IGeometry Read(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var reader = new BinaryReader(stream))
            {
                var header   = GeoPackageBinaryHeader.Read(reader);
                var services = new NtsGeometryServices(_coordinateSequenceFactory,
                                                       _precisionModel, HandleSRID ? header.SrsId : -1);
                // NOTE: GeoPackage handle SRID in header, so no need to read this also in wkb;
                const bool dontHandleSRID = false;
                var        wkbReader      = new WKBReader(services)
                {
                    HandleSRID      = dontHandleSRID,
                    HandleOrdinates = HandleOrdinates,
                    RepairRings     = RepairRings
                };
                var geom = wkbReader.Read(stream);
                if (HandleSRID)
                {
                    geom.SRID = header.SrsId;
                }
                return(geom);
            }
        }
Ejemplo n.º 2
0
        private static bool TestWktWkb(int number, IGeometryFactory factory, string wkt, string wkb)
        {
            WKTReader r = new WKTReader(factory);
            IGeometry wktGeom = r.Read(wkt);
            WKBReader s = new WKBReader(factory);
            IGeometry wkbGeom = s.Read(WKBReader.HexToBytes(wkb));

            try
            {
                Assert.AreEqual(wkb, WKBWriter.ToHex(wktGeom.AsBinary()), "wkb's don't match");
                Assert.IsTrue(DiscreteHausdorffDistance.Distance(wktGeom, wkbGeom) < 1e-9, number + ": DiscreteHausdorffDistance.Distance(wktGeom, wkbGeom) < 1e-9");
                if (!wktGeom.EqualsExact(wkbGeom))
                {
                    Assert.AreEqual(wkt, wktGeom.AsText(), number + ": wkt.Equals(wktGeom.AsText())");
                    var wktGeom2 = s.Read(wktGeom.AsBinary());
                    Assert.AreEqual(wkt, wktGeom2.AsText(), number + ": wkt.Equals(wktGeom2.AsText())");
                    var diff = wkbGeom.Difference(wktGeom);
                    Assert.IsTrue(false, number + ": wktGeom.EqualsExact(wkbGeom)\n" + diff.AsText());
                }
                return false;
            }
            catch (AssertionException ex)
            {
                Console.WriteLine(ex.Message);
                return true;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Method to read
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="wkbReader"></param>
 /// <returns></returns>
 public static GpkgStandardBinary Read(BinaryReader reader, WKBReader wkbReader)
 {
     return new GpkgStandardBinary
     {
         Header = GpkgBinaryHeader.Read(reader),
         WellKnownBytes = reader.ReadBytes((int) (reader.BaseStream.Length - reader.BaseStream.Position)),
         _wkbReader = wkbReader
     };
 }
Ejemplo n.º 4
0
 private static IGeometry FromWkb(string wkb, IGeometry clip = null)
 {
     WKBReader reader = new WKBReader(GeometryFactory.Default);
     byte[] bytes = WKBReader.HexToBytes(wkb);
     IGeometry geom =  reader.Read(bytes);
     if (clip != null) 
         geom = geom.Intersection(clip);
     return geom;
 }
        public void Setup()
        {
            wkbreader = new WKBReader(factory);

            geometry0 = wkbreader.Read(test00_Geom0_WkbByteArray);
            Debug.WriteLine(geometry0.ToString());
            geometry1 = wkbreader.Read(test00_Geom1_WkbByteArray);
            Debug.WriteLine(geometry1.ToString());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new <see cref="WKBHexFileReader"/> given the
        /// <see cref="WKBReader"/> to use to parse the geometries.
        /// </summary>
        /// <param name="wkbReader">The geometry reader to use</param>
        public WKBHexFileReader(WKBReader wkbReader)
        {
            if (wkbReader == null)
            {
                throw new ArgumentNullException("wkbReader");
            }

            Limit      = -1;
            _wkbReader = wkbReader;
        }
Ejemplo n.º 7
0
 public void OracleWKBBigEndianReadTest()
 {
     IGeometry result = null;
     using (Stream stream = new FileStream(blobFile, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         WKBReader wkbreader = new WKBReader();
         result = wkbreader.Read(stream);
     }
     Debug.WriteLine(result.ToString());
     Assert.IsNotNull(result);
 }
Ejemplo n.º 8
0
        public static IGeometry ReadGeometriesFromWkbHexString(String wkb, IGeometryFactory geomFact)
        {
            var reader = new WKBReader(geomFact);
            var fileReader = new WKBHexFileReader(reader);
            var geomList = new List<IGeometry>();
            using (var ms = new MemoryStream())
            {
                new StreamWriter(ms).Write(wkb);
                geomList.AddRange(fileReader.Read(ms));
            }

            if (geomList.Count == 1)
                return geomList[1];

            return geomFact.CreateGeometryCollection(GeometryFactory.ToGeometryArray(geomList));
        }
Ejemplo n.º 9
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; 
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Convert hex-coded WKB to geometry object
        /// </summary>
        /// <param name="hexString"></param>
        /// <returns></returns>
        public static IGeometry WKBhex2Geom(string hexString)
        {
            if (String.IsNullOrWhiteSpace(hexString))
            {
                return(null);
            }

            try
            {
                var       reader         = new NetTopologySuite.IO.WKBReader();
                var       geometryBinary = NetTopologySuite.IO.WKBReader.HexToBytes(hexString);
                IGeometry result         = reader.Read(geometryBinary);
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Reads a sequence of geometries.<br/>
        /// If an <see cref="Offset"/> is specified, geometries read up to the offset count are skipped.
        /// If a <see cref="Limit"/> is specified, no more than <see cref="Limit"/> geometries are read.
        /// </summary>
        /// <param name="streamReader">The stream reader to use.</param>
        /// <exception cref="IOException">Thrown if an I/O exception was encountered</exception>
        /// <exception cref="ParseException">Thrown if an error occured reading a geometry</exception>
        private ReadOnlyCollection <Geometry> Read(StreamReader streamReader)
        {
            var geoms = new List <Geometry>();
            int count = 0;

            while (!IsAtEndOfFile(streamReader) && !IsAtLimit(geoms))
            {
                string line = streamReader.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var g = _wkbReader.Read(WKBReader.HexToBytes(line));
                if (count >= Offset)
                {
                    geoms.Add(g);
                }
                count++;
            }
            return(geoms.AsReadOnly());
        }
Ejemplo n.º 12
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;
            }
        }       
Ejemplo n.º 13
0
 public WKTOrWKBReader(GeometryFactory geomFactory)
 {
     _wktReader = new WKTReader(geomFactory);
     _wkbReader = new WKBReader(geomFactory);
 }
Ejemplo n.º 14
0
 private static IGeometry ReadGeometryFromWkbHexString(String wkbHexFile, IGeometryFactory geomFact)
 {
     var reader = new WKBReader();
     var wkbHex = CleanHex(wkbHexFile);
     return reader.Read(WKBReader.HexToBytes(wkbHex));
 }
 public MultiFormatReader(GeometryFactory geomFactory)
 {
     _wktReader = new WKTReader(geomFactory);
     _wkbReader = new WKBReader(geomFactory);
     _factory = geomFactory;
 }
Ejemplo n.º 16
0
        public void TestMaximumPrecisionDigitsFormatting()
        {
            IGeometryFactory factory = GeometryFactory.Default;

            WKBReader wkbreader = new WKBReader(factory);
            IGeometry wkb1 = wkbreader.Read(test00_Geom0_WkbByteArray);            
            Assert.IsNotNull(wkb1);
            TestValid(wkb1);

            IGeometry wkb2 = wkbreader.Read(test00_Geom1_WkbByteArray);
            Assert.IsNotNull(wkb2);
            TestValid(wkb2);

            Exception ex = TryOverlay(wkb1, wkb2);
            Assert.IsNotNull(ex);
            Assert.IsTrue(ex.GetType() == typeof(TopologyException));

            string tos1 = writer.Write(wkb1);
            Assert.IsNotNull(tos1);            
            string tos2 = writer.Write(wkb2);
            Assert.IsNotNull(tos2);            

            WKTReader reader = new WKTReader(factory);
            IGeometry wkt1 = reader.Read(tos1);
            Assert.IsNotNull(wkt1);
            Assert.IsTrue(wkt1.IsValid);

            IGeometry wkt2 = reader.Read(tos2);
            Assert.IsNotNull(wkt2);
            Assert.IsTrue(wkt2.IsValid);

            Assert.IsTrue(wkb1.EqualsExact(wkt1), "First geometry pair must be equal!");
            Assert.IsTrue(wkb2.EqualsExact(wkt2), "Second geometry pair must be equal!");

            ex = TryOverlay(wkt1, wkt2);
            Assert.IsNotNull(ex, "Operation must fail!");
            Assert.IsTrue(ex.GetType() == typeof(TopologyException));          
        }
Ejemplo n.º 17
0
        /**
           * Reads a shape from a byte array, using an internal format written by
           * {@link #writeShapeToBytes(com.spatial4j.core.shape.Shape)}.
           */
        public Shape ReadShapeFromBytes(byte[] array, int offset, int length)
        {
            using (var stream = new MemoryStream(array, offset, length, false))
            using (var bytes = new BinaryReader(stream))
            {

                var type = bytes.ReadByte();
                if (type == TYPE_POINT)
                {
                    return new NtsPoint(((NtsSpatialContext)Ctx).GetGeometryFactory().CreatePoint(new Coordinate(bytes.ReadDouble(), bytes.ReadDouble())), Ctx);
                }

                if (type == TYPE_BBOX)
                {
                    return new RectangleImpl(
                        bytes.ReadDouble(), bytes.ReadDouble(),
                        bytes.ReadDouble(), bytes.ReadDouble(), Ctx);
                }

                if (type == TYPE_GEOM)
                {
                    var reader = new WKBReader(((NtsSpatialContext)Ctx).GetGeometryFactory());
                    try
                    {
                        IGeometry geom = reader.Read(stream);

                        CheckCoordinates(geom);
                        return new NtsGeometry(geom, (NtsSpatialContext)Ctx, true);
                    }
                    catch (ParseException ex)
                    {
                        throw new InvalidShapeException("error reading WKT", ex);
                    }
                    catch (IOException ex)
                    {
                        throw new InvalidShapeException("error reading WKT", ex);
                    }
                }

                throw new InvalidShapeException("shape not handled: " + type);
            }
        }
        /// <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 Coordinate[] { new Coordinate(23, 32.2), new Coordinate(922, 11) });
            ILineString anotherLine = Factory.CreateLineString(new Coordinate[] { 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;
            }
        }        
Ejemplo n.º 19
0
        /// <summary>
        /// Creates a <see cref="GeoAPI.Geometries.IGeometry"/> based on the Well-known binary representation.
        /// </summary>
        /// <param name="reader">A <see cref="System.IO.BinaryReader">BinaryReader</see> used to read the Well-known binary representation.</param>
        /// <param name="factory">The factory to create the result geometry</param>
        /// <returns>A <see cref="GeoAPI.Geometries.IGeometry"/> based on the Well-known binary representation.</returns>
        public static IGeometry Parse(BinaryReader reader, IGeometryFactory factory)
        {
            WKBReader wkb = new WKBReader();
            return wkb.Read(reader.BaseStream);

            /*
            // Get the first Byte in the array. This specifies if the WKB is in
            // XDR (big-endian) format of NDR (little-endian) format.
            var byteOrder = reader.ReadByte();

            // Get the type of this geometry.
            var type = ReadUInt32(reader, (WkbByteOrder) byteOrder);

            switch ((WKBGeometryType) type)
            {
                case WKBGeometryType.wkbPoint:
                    return CreateWKBPoint(reader, (WkbByteOrder) byteOrder, factory);

                case WKBGeometryType.wkbLineString:
                    return CreateWKBLineString(reader, (WkbByteOrder)byteOrder, factory);

                case WKBGeometryType.wkbPolygon:
                    return CreateWKBPolygon(reader, (WkbByteOrder)byteOrder, factory);

                case WKBGeometryType.wkbMultiPoint:
                    return CreateWKBMultiPoint(reader, (WkbByteOrder)byteOrder, factory);

                case WKBGeometryType.wkbMultiLineString:
                    return CreateWKBMultiLineString(reader, (WkbByteOrder)byteOrder, factory);

                case WKBGeometryType.wkbMultiPolygon:
                    return CreateWKBMultiPolygon(reader, (WkbByteOrder)byteOrder, factory);

                case WKBGeometryType.wkbGeometryCollection:
                    return CreateWKBGeometryCollection(reader, (WkbByteOrder)byteOrder, factory);

                default:
                    if (!Enum.IsDefined(typeof (WKBGeometryType), type))
                        throw new ArgumentException("Geometry type not recognized");
                    else
                        throw new NotSupportedException("Geometry type '" + type + "' not supported");
            }
            */
        }
Ejemplo n.º 20
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 Coordinate[] { new Coordinate(23, 32.2), new Coordinate(10, 222) });
            ILineString anotherLine = Factory.CreateLineString(new Coordinate[] { new Coordinate(0, 1), new Coordinate(30, 30) });
            ILineString intersectLine = Factory.CreateLineString(new Coordinate[] { 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;
            }
        }        
Ejemplo n.º 21
0
 internal GpkgStandardBinaryReader(IGeometryServices services)
 {
     _wkbReader = new WKBReader(services);
 }