Пример #1
0
        private void WriteCoordinate(Coordinate coordinate, WkbBinaryWriter writer)
        {
            writer.Write(coordinate.Longitude);
            writer.Write(coordinate.Latitude);

            if (coordinate.Is3D && _settings.MaxDimesions > 2)
            {
                writer.Write(((Is3D)coordinate).Elevation);
            }

            if (coordinate.IsMeasured && _settings.MaxDimesions > 3)
            {
                writer.Write(((IsMeasured)coordinate).Measure);
            }
        }
Пример #2
0
        private void WritePolygonInner(Polygon polygon, WkbBinaryWriter writer)
        {
            if (polygon.IsEmpty)
            {
                writer.Write(0u);
            }
            else
            {
                writer.Write((uint)(1 + polygon.Holes.Count));
                WriteCoordinates(polygon.Shell.Coordinates, writer);

                foreach (var hole in polygon.Holes)
                {
                    WriteCoordinates(hole.Coordinates, writer);
                }
            }
        }
Пример #3
0
 private void WriteMultiPolygon(MultiPolygon multiPolygon, WkbBinaryWriter writer)
 {
     WriteGeometryType(multiPolygon, WkbGeometryType.MultiPolygon, writer);
     writer.Write((uint)multiPolygon.Geometries.Count);
     foreach (var polygon in multiPolygon.Geometries.Cast <Polygon>())
     {
         WritePolygonInner(polygon, writer);
     }
 }
Пример #4
0
 private void WriteMultiLineString(MultiLineString multiLineString, WkbBinaryWriter writer)
 {
     WriteGeometryType(multiLineString, WkbGeometryType.MultiLineString, writer);
     writer.Write((uint)multiLineString.Geometries.Count);
     foreach (var linestring in multiLineString.Geometries.Cast <LineString>())
     {
         WriteCoordinates(linestring.Coordinates, writer);
     }
 }
Пример #5
0
        private void WriteCoordinates(CoordinateSequence coordinates, WkbBinaryWriter writer)
        {
            writer.Write((uint)coordinates.Count);

            foreach (var coordinate in coordinates)
            {
                WriteCoordinate(coordinate, writer);
            }
        }
Пример #6
0
 private void WriteMultiPolygon(MultiPolygon multiPolygon, WkbBinaryWriter writer)
 {
     WriteEncoding(writer, _settings.Encoding);
     WriteGeometryType(multiPolygon, WkbGeometryType.MultiPolygon, writer);
     writer.Write((uint)multiPolygon.Geometries.Count);
     foreach (var polygon in multiPolygon.Geometries.Cast <Polygon>())
     {
         Write(polygon, writer);
     }
 }
Пример #7
0
 private void WriteMultiLineString(MultiLineString multiLineString, WkbBinaryWriter writer)
 {
     WriteEncoding(writer, _settings.Encoding);
     WriteGeometryType(multiLineString, WkbGeometryType.MultiLineString, writer);
     writer.Write((uint)multiLineString.Geometries.Count);
     foreach (var linestring in multiLineString.Geometries.Cast <LineString>())
     {
         Write(linestring, writer);
     }
 }
Пример #8
0
        private void WriteGeometryCollection(GeometryCollection collection, WkbBinaryWriter writer)
        {
            WriteGeometryType(collection, WkbGeometryType.GeometryCollection, writer);
            var geometries = collection.Geometries.Where(x => !(x is Point) || !x.IsEmpty).ToList();

            writer.Write((uint)geometries.Count);
            foreach (var geometry in geometries)
            {
                Write(geometry, writer);
            }
        }
Пример #9
0
        private void WriteMultiPoint(MultiPoint multipoint, WkbBinaryWriter writer)
        {
            WriteGeometryType(multipoint, WkbGeometryType.MultiPoint, writer);
            var points = multipoint.Geometries.Cast <Point>().Where(x => !x.IsEmpty).ToList();

            writer.Write((uint)points.Count);
            foreach (var point in points)
            {
                WriteCoordinate(point.Coordinate, writer);
            }
        }
Пример #10
0
        private void WriteGeometryType(IOgcGeometry geometry, WkbGeometryType baseType, WkbBinaryWriter writer)
        {
            if (geometry.IsEmpty)
            {
                writer.Write((uint)baseType);
            }
            else
            {
                var typeCode = (uint)baseType;

                if (geometry.Is3D && _settings.MaxDimesions > 2)
                {
                    typeCode += 1000;
                }

                if (geometry.IsMeasured && _settings.MaxDimesions > 3)
                {
                    typeCode += 2000;
                }

                writer.Write(typeCode);
            }
        }
Пример #11
0
 private void WriteEncoding(WkbBinaryWriter writer, WkbEncoding encoding)
 {
     writer.Write((byte)encoding);
 }