internal void ReadShapes(BinaryReader reader)
        {
            while (reader.BaseStream.Length != reader.BaseStream.Position)
            {
                SwapBytes(reader.ReadInt32());
                SwapBytes(reader.ReadInt32());
                switch (reader.ReadInt32())
                {
                case 1:
                {
                    ShapePoint shapePoint = new ShapePoint();
                    shapePoint.Read(reader);
                    Points.Add(shapePoint);
                    break;
                }

                case 8:
                {
                    MultiPoint multiPoint = new MultiPoint();
                    multiPoint.Read(reader);
                    MultiPoints.Add(multiPoint);
                    break;
                }

                case 3:
                {
                    PolyLine polyLine2 = new PolyLine();
                    polyLine2.Read(reader);
                    PolyLines.Add(polyLine2);
                    break;
                }

                case 5:
                {
                    PolyLine polyLine = new PolyLine();
                    polyLine.Read(reader);
                    Polygons.Add(polyLine);
                    break;
                }
                }
            }
        }
示例#2
0
        void ITwentyThreeParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "created":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "alpha":
                    Alpha = reader.ReadContentAsDouble();
                    break;

                case "count_points":
                    PointCount = reader.ReadContentAsInt();
                    break;

                case "count_edges":
                    EdgeCount = reader.ReadContentAsInt();
                    break;

                case "has_donuthole":
                    HasDonutHole = reader.Value == "1";
                    break;

                case "is_donuthole":
                    IsDonutHole = reader.Value == "1";
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "polylines":
                    reader.Read();
                    while (reader.LocalName == "polyline")
                    {
                        var      polyline   = new Collection <PointD>();
                        string   polystring = reader.ReadElementContentAsString();
                        string[] points     = polystring.Split(' ');
                        foreach (string point in points)
                        {
                            string[] xy = point.Split(',');
                            if (xy.Length != 2)
                            {
                                throw new ParsingException("Invalid polypoint found in polyline : '" + polystring +
                                                           "'");
                            }
                            polyline.Add(
                                new PointD(
                                    double.Parse(xy[0], System.Globalization.NumberFormatInfo.InvariantInfo),
                                    double.Parse(xy[1], System.Globalization.NumberFormatInfo.InvariantInfo)));
                        }
                        PolyLines.Add(polyline);
                    }
                    reader.Read();
                    break;

                case "urls":
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }