예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private MultiLineString ReadMultiLineString(XmlReader reader)
        {
            string strSRID = null;
            string strGID  = null;
            int    nSRID   = -1;

            if (reader.Name == GeometryGml2.GmlMultiLineString &&
                reader.HasAttributes)
            {
                ReadGeometryAttributes(reader, ref strSRID, ref strGID);
                if (strSRID != null && strSRID.Length > 0)
                {
                    nSRID = Convert.ToInt32(strSRID);
                }
            }

            GeometryList lineStrings = null;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == GeometryGml2.GmlMultiLineString)
                    {
                        if (reader.HasAttributes)
                        {
                            ReadGeometryAttributes(reader, ref strSRID, ref strGID);
                            if (strSRID != null && strSRID.Length > 0)
                            {
                                nSRID = Convert.ToInt32(strSRID);
                            }
                        }
                    }
                    else if (reader.Name == GeometryGml2.GmlLineStringMember)
                    {
                        if (lineStrings == null)
                        {
                            lineStrings = new GeometryList();
                        }

                        LineString lineString = ReadLineString(reader);
                        if (lineString != null)
                        {
                            lineStrings.Add(lineString);
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.Name == GeometryGml2.GmlMultiLineString)
                    {
                        break;
                    }
                }
            }

            if (lineStrings != null && lineStrings.Count > 0)
            {
                MultiLineString geometry = m_objFactory.CreateMultiLineString(
                    lineStrings.ToLineStringArray());

                if (nSRID > 0 || (strGID != null && strGID.Length > 0))
                {
                    geometry.CreateProperties();
                    if (nSRID > 0)
                    {
                        geometry.Properties.Add("SRID", nSRID);
                    }
                    if (strGID != null && strGID.Length > 0)
                    {
                        geometry.Properties.Add("GID", strGID);
                    }
                }

                return(geometry);
            }

            return(null);
        }