Exemplo n.º 1
0
        static WknMultiLineString ParseMultiLineString(byte[] wkb, ref int pos)
        {
            if (wkb[pos] != 1)
            {
                throw new Exception("Sorry, only Little Endian format is supported");
            }
            var type = BitConverter.ToUInt32(wkb, pos + 1);

            if (type != (uint)WknGeometryType.WknMultiLineString)
            {
                throw new Exception("Invalid object type");
            }
            var nbLineStrings = BitConverter.ToUInt32(wkb, pos + 5);

            pos += 9;

            var lineStrings = new WknLineString[nbLineStrings];

            for (var i = 0; i < nbLineStrings; ++i)
            {
                lineStrings[i] = ParseLineString(wkb, ref pos);
            }

            return(new WknMultiLineString(lineStrings));
        }
Exemplo n.º 2
0
 static void AppendLineString(BinaryWriter wrt, WknLineString lineString)
 {
     wrt.Write(LittleEndian);
     wrt.Write((uint)WknGeometryType.WknLineString);
     wrt.Write((uint)lineString.Points.Length);
     for (var i = 0; i < lineString.Points.Length; ++i)
     {
         var p = lineString.Points[i];
         wrt.Write(p.X);
         wrt.Write(p.Y);
     }
 }