示例#1
0
        public static ArcGISTileSystem GetTileSystemFromXmlConf(string xmlPath)
        {
            XDocument xmlDoc         = XDocument.Load(xmlPath);
            var       elmTileOrigin  = xmlDoc.Element("CacheInfo").Element("TileCacheInfo").Element("TileOrigin");
            var       originX        = double.Parse(elmTileOrigin.Element("X").Value);
            var       originY        = double.Parse(elmTileOrigin.Element("Y").Value);
            var       elmTileSize    = xmlDoc.Element("CacheInfo").Element("TileCacheInfo").Element("TileCols");
            var       tileSize       = int.Parse(elmTileSize.Value);
            var       elmLodInfos    = xmlDoc.Element("CacheInfo").Element("TileCacheInfo").Element("LODInfos");
            var       zeroScale      = 0.0;
            var       zeroResolution = 0.0;

            foreach (var elm in elmLodInfos.Elements("LODInfo"))
            {
                if (int.TryParse(elm.Element("LevelID").Value, out int level))
                {
                    if (level == 0)
                    {
                        zeroScale      = double.Parse(elm.Element("Scale").Value);
                        zeroResolution = double.Parse(elm.Element("Resolution").Value);
                        break;
                    }
                }
            }

            var cdiPath = Path.ChangeExtension(xmlPath, ".cdi");

            xmlDoc = XDocument.Load(cdiPath);
            var elmFullExtent = xmlDoc.Element("EnvelopeN");
            var xMin          = double.Parse(elmFullExtent.Element("XMin").Value);
            var yMin          = double.Parse(elmFullExtent.Element("YMin").Value);
            var xMax          = double.Parse(elmFullExtent.Element("XMax").Value);
            var yMax          = double.Parse(elmFullExtent.Element("YMax").Value);

            ArcGISTileSystem tileSystem = new ArcGISTileSystem();

            tileSystem.SetTileSize(tileSize);
            tileSystem.SetXYOrigin(originX, originY);
            tileSystem.SetInitialResolution(zeroResolution);
            tileSystem.SetInitailScale(zeroScale);
            tileSystem.SetExtent(xMin, yMin, xMax, yMax);
            return(tileSystem);
        }
示例#2
0
        public static ArcGISTileSystem GetTileSystemFromJson(string jsonString)
        {
            var root       = JObject.Parse(jsonString);
            var fullExtent = root["fullExtent"];
            var xMin       = fullExtent["xmin"].Value <double>();
            var yMin       = fullExtent["ymin"].Value <double>();
            var xMax       = fullExtent["xmax"].Value <double>();
            var yMax       = fullExtent["ymax"].Value <double>();
            var tileInfo   = root["tileInfo"];
            var tileSize   = tileInfo["rows"].Value <int>();
            var originX    = tileInfo["origin"]["x"].Value <double>();
            var originY    = tileInfo["origin"]["x"].Value <double>();

            var zeroScale      = 0.0;
            var zeroResolution = 0.0;
            var lods           = tileInfo["lods"] as JArray;

            foreach (var lod in lods)
            {
                int level = lod["level"].Value <int>();
                if (level == 0)
                {
                    zeroScale      = lod["scale"].Value <double>();
                    zeroResolution = lod["resolution"].Value <double>();
                    break;
                }
            }
            ArcGISTileSystem tileSystem = new ArcGISTileSystem();

            tileSystem.SetTileSize(tileSize);
            tileSystem.SetXYOrigin(originX, originY);
            tileSystem.SetInitialResolution(zeroResolution);
            tileSystem.SetInitailScale(zeroScale);
            tileSystem.SetExtent(xMin, yMin, xMax, yMax);
            return(tileSystem);
        }