Пример #1
0
        /// <summary>
        /// Writes to the given stream the equilivent shape file record given a Geometry object.
        /// </summary>
        /// <param name="geometry">The geometry object to write.</param>
        /// <param name="file">The stream to write to.</param>
        /// <param name="geometryFactory">The geometry factory to use.</param>
        public override void Write(Geometry geometry, System.IO.BinaryWriter file, GeometryFactory geometryFactory)
        {
            MultiLineString multi = (MultiLineString)geometry;

            file.Write(int.Parse(Enum.Format(typeof(ShapeType), this.ShapeType, "d")));

            Envelope box = multi.GetEnvelopeInternal();

            file.Write(box.MinX);
            file.Write(box.MinY);
            file.Write(box.MaxX);
            file.Write(box.MaxY);

            int numParts  = multi.GetNumGeometries();
            int numPoints = multi.GetNumPoints();

            file.Write(numParts);
            file.Write(numPoints);

            //LineString[] lines = new LineString[numParts];

            // write the offsets
            int offset = 0;

            for (int i = 0; i < numParts; i++)
            {
                Geometry g = multi.GetGeometryN(i);
                file.Write(offset);
                offset = offset + g.GetNumPoints();
            }

            Coordinate external;

            for (int part = 0; part < numParts; part++)
            {
                Coordinates points = multi.GetGeometryN(part).GetCoordinates();
                for (int i = 0; i < points.Count; i++)
                {
                    external = geometryFactory.PrecisionModel.ToExternal(points[i]);
                    file.Write(external.X);
                    file.Write(external.Y);
                }
            }
        }