protected ILineString ReadLineString(XmlReader reader)
{
List<Coordinate> coordinates = new List<Coordinate>();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (IsStartElement(reader, "coord"))
{
coordinates.Add(ReadCoordinate(reader));
}
else if (IsStartElement(reader, "pos"))
{
reader.Read();
string ordinates = reader.ReadContentAsString();
coordinates.Add(ReadPosAsCoordinate(ordinates.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)));
}
else if (IsStartElement(reader, "coordinates"))
{
reader.Read(); // Jump to values
string value = reader.Value;
string cleaned = value.Replace("\n", " ").Replace("\t", " ");
string[] coords = cleaned.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string coord in coords)
{
if (String.IsNullOrEmpty(coord))
continue;
Coordinate c = ReadCoordinates(coord);
coordinates.Add(c);
}
return Factory.CreateLineString(coordinates.ToArray());
}
else if (IsStartElement(reader, "posList"))
{
string tmp = reader.GetAttribute("srsDimension");
if (string.IsNullOrEmpty(tmp)) tmp = "2";
reader.Read();
coordinates.AddRange(ReadPosListAsCoordinates(XmlConvert.ToInt32(tmp), reader.ReadContentAsString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)));
reader.ReadEndElement();
return Factory.CreateLineString(coordinates.ToArray());
}
break;
case XmlNodeType.EndElement:
return Factory.CreateLineString(coordinates.ToArray());
}
}
throw new ArgumentException("ShouldNeverReachHere!");
}