Ejemplo n.º 1
0
        private MapPackage parseMapXml(string pkgName, string pathToMapXml)
        {
            // load xml document
            XmlDocument docMapXml = new XmlDocument();

            docMapXml.Load(pathToMapXml);
            // get description
            XmlNode descrNode = docMapXml.SelectSingleNode("/map/description");
            string  descr     = "";

            // description isn't required
            if (descrNode != null)
            {
                descr = descrNode.InnerText;
            }
            // get top left corner latitude
            XmlNode topLeftLatitudeNode = docMapXml.SelectSingleNode(
                "/map/coordinates/topLeft/latitude");
            double topLeftLatitude = parseCoordinate(topLeftLatitudeNode.InnerText);
            // get top left corner longitude
            XmlNode topLeftLongitudeNode = docMapXml.SelectSingleNode(
                "/map/coordinates/topLeft/longitude");
            double topLeftLongitude = parseCoordinate(topLeftLongitudeNode.InnerText);
            // get bottom right corner latitude
            XmlNode bottomRightLatitudeNode = docMapXml.SelectSingleNode(
                "/map/coordinates/bottomRight/latitude");
            double bottomRightLatitude = parseCoordinate(bottomRightLatitudeNode.InnerText);
            // get bottom right corner longitude
            XmlNode bottomRightLongitudeNode = docMapXml.SelectSingleNode(
                "/map/coordinates/bottomRight/longitude");
            double bottomRightLongitude = parseCoordinate(bottomRightLongitudeNode.InnerText);
            // get parts image format
            XmlNode partsFormatNode = docMapXml.SelectSingleNode("/map/parts/format");
            string  partsFormat     = "";

            // parts format aren't required
            if (partsFormatNode != null)
            {
                partsFormat = partsFormatNode.InnerText;
            }
            MapPackage mapPkg = new MapPackage(pkgName, topLeftLatitude, topLeftLongitude,
                                               bottomRightLatitude, bottomRightLongitude);

            if (partsFormat != "")
            {
                mapPkg.setPartsFormat(partsFormat);
            }
            return(mapPkg);
        }