示例#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="writer">The stream to write to.</param>
        /// <param name="factory">The geometry factory to use.</param>
        public override void Write(Geometry geometry, BinaryWriter writer, GeometryFactory factory)
        {
            MultiLineString multi = (MultiLineString)geometry;

            writer.Write((int)this.ShapeType);

            this.WriteBoundingBox(multi.getEnvelopeInternal(), writer);

            int numParts  = multi.getNumGeometries();
            int numPoints = multi.getNumPoints();

            writer.Write(numParts);
            writer.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);
                writer.Write(offset);
                offset = offset + g.getNumPoints();
            }

            for (int part = 0; part < numParts; part++)
            {
                Coordinate[] coords = multi.getGeometryN(part).getCoordinates();

                for (int i = 0; i < coords.Length; i++)
                {
                    factory.getPrecisionModel().makePrecise(coords[i]);

                    writer.Write(coords[i].x);
                    writer.Write(coords[i].y);
                }
            }
        }