cesium加载arcgis离线松散瓦片(EPSG:4326, EPSG:4490)

现有ArcGIS离线瓦片文件,如下图所示:

 

 

 

需要在Cesium中加载显示,切片规则定义(Conf.xml),可以看出为EPSG:4490,详细参数如下:

<?xml version="1.0" encoding="utf-8" ?>
<CacheInfo xsi:type='typens:CacheInfo'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.1'>
    <TileCacheInfo xsi:type='typens:TileCacheInfo'>
        <SpatialReference xsi:type='typens:GeographicCoordinateSystem'>
            <WKT>GEOGCS[&quot;GCS_China_Geodetic_Coordinate_System_2000&quot;,DATUM[&quot;D_China_2000&quot;,SPHEROID[&quot;CGCS2000&quot;,6378137.0,298.257222101]],PRIMEM[&quot;Greenwich&quot;,0.0],UNIT[&quot;Degree&quot;,0.0174532925199433],AUTHORITY[&quot;EPSG&quot;,4490]]</WKT>
            <XOrigin>-399.99999999999989</XOrigin>
            <YOrigin>-399.99999999999989</YOrigin>
            <XYScale>11258999068426.24</XYScale>
            <ZOrigin>-100000</ZOrigin>
            <ZScale>10000</ZScale>
            <MOrigin>-100000</MOrigin>
            <MScale>10000</MScale>
            <XYTolerance>8.9831528411952117e-009</XYTolerance>
            <ZTolerance>0.001</ZTolerance>
            <MTolerance>0.001</MTolerance>
            <HighPrecision>true</HighPrecision>
            <LeftLongitude>-180</LeftLongitude>
            <WKID>4490</WKID>
            <LatestWKID>4490</LatestWKID>
        </SpatialReference>
        <TileOrigin xsi:type='typens:PointN'>
            <X>-180</X>
            <Y>90</Y>
        </TileOrigin>
        <TileCols>256</TileCols>
        <TileRows>256</TileRows>
        <DPI>96</DPI>
        <PreciseDPI>96</PreciseDPI>
        <LODInfos xsi:type='typens:ArrayOfLODInfo'>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>0</LevelID>
                <Scale>590995197.14166796</Scale>
                <Resolution>1.406250026231578</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>1</LevelID>
                <Scale>295497598.57083398</Scale>
                <Resolution>0.70312501311578901</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>2</LevelID>
                <Scale>147748799.28541699</Scale>
                <Resolution>0.35156250655789451</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>3</LevelID>
                <Scale>73874399.642708704</Scale>
                <Resolution>0.17578125327894775</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>4</LevelID>
                <Scale>36937199.821354397</Scale>
                <Resolution>0.087890626639473987</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>5</LevelID>
                <Scale>18468599.910677198</Scale>
                <Resolution>0.043945313319736994</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>6</LevelID>
                <Scale>9234299.9553385898</Scale>
                <Resolution>0.021972656659868472</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>7</LevelID>
                <Scale>4617149.9776692903</Scale>
                <Resolution>0.010986328329934226</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>8</LevelID>
                <Scale>2308574.9888346498</Scale>
                <Resolution>0.0054931641649671242</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>9</LevelID>
                <Scale>1154287.49441732</Scale>
                <Resolution>0.0027465820824835504</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>10</LevelID>
                <Scale>577143.74720866198</Scale>
                <Resolution>0.0013732910412417797</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>11</LevelID>
                <Scale>288571.87360433099</Scale>
                <Resolution>0.00068664552062088987</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>12</LevelID>
                <Scale>144285.936802165</Scale>
                <Resolution>0.0003433227603104438</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>13</LevelID>
                <Scale>72142.968401082704</Scale>
                <Resolution>0.00017166138015522239</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>14</LevelID>
                <Scale>36071.484200541403</Scale>
                <Resolution>8.5830690077611316e-005</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>15</LevelID>
                <Scale>18035.742100270701</Scale>
                <Resolution>4.2915345038805658e-005</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>16</LevelID>
                <Scale>9017.8710501353398</Scale>
                <Resolution>2.1457672519402802e-005</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>17</LevelID>
                <Scale>4508.9355250676699</Scale>
                <Resolution>1.0728836259701401e-005</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>18</LevelID>
                <Scale>2254.46776253384</Scale>
                <Resolution>5.3644181298507123e-006</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>19</LevelID>
                <Scale>1127.23388126692</Scale>
                <Resolution>2.6822090649253562e-006</Resolution>
            </LODInfo>
            <LODInfo xsi:type='typens:LODInfo'>
                <LevelID>20</LevelID>
                <Scale>563.61694063345999</Scale>
                <Resolution>1.3411045324626781e-006</Resolution>
            </LODInfo>
        </LODInfos>
    </TileCacheInfo>
    <TileImageInfo xsi:type='typens:TileImageInfo'>
        <CacheTileFormat>PNG24</CacheTileFormat>
        <CompressionQuality>0</CompressionQuality>
        <Antialiasing>false</Antialiasing>
    </TileImageInfo>
    <CacheStorageInfo xsi:type='typens:CacheStorageInfo'>
        <StorageFormat>esriMapCacheStorageModeExploded</StorageFormat>
        <PacketSize>0</PacketSize>
    </CacheStorageInfo>
</CacheInfo>
View Code

使用Cesium.UrlTemplateImageryProvider自定义瓦片规则进行加载,如下:

// 给8位字符串文件名补0
        function zeroFill(num, len, radix) {
            let str = num.toString(radix || 10)
            while (str.length < len) {
                str = '0' + str
            }
            return str
        }
        window.onload = function () {
            // arcgis离线瓦片 4490
            const arcgis_layer = new Cesium.UrlTemplateImageryProvider({
                url: 'http://172.16.32.214:7098/_alllayers/{mz}/{my}/{mx}.png',
                tilingScheme : new Cesium.GeographicTilingScheme(),
                customTags: {
                    mz: function(imageryProvider, x, y, level) {
                        return 'L' + zeroFill(level + 1, 2, 10) // 注意观测,层级加1了
                    },
                    mx: function(imageryProvider, x, y, level) {
                        return 'C' + zeroFill(x, 8, 16)
                    },
                    my: function(imageryProvider, x, y, level) {
                        return 'R' + zeroFill(y, 8, 16)
                    }
                }
            });
            
            const viewer = new Cesium.Viewer("map", {
                imageryProvider: arcgis_layer
            });
            viewer.scene.backgroundColor = new Cesium.Color(0, 0, 0, 0.0)
            viewer.scene.globe.baseColor = new Cesium.Color(0, 0, 0, 0.0)

            // 定位
            const extent = [117.36378835873523,38.807473120892745,117.44082323316754,38.84205866142972];
            const rect = Cesium.Rectangle.fromDegrees(...extent);
            viewer.camera.setView({
                destination: rect
            });
        }

 

加载EPSG:4326瓦片,EPSG:4326瓦片详细参数如下:

<?xml version="1.0" encoding="UTF-8"?>
<CacheInfo xsi:type="typens:CacheInfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:typens="http://www.esri.com/schemas/ArcGIS/10.0">
    <TileCacheInfo xsi:type="typens:TileCacheInfo">
        <SpatialReference xsi:type="typens:GeographicCoordinateSystem">
            <WKID>4326</WKID>
        </SpatialReference>
        <TileOrigin xsi:type="typens:PointN">
            <X>-180</X>
            <Y>90</Y>
        </TileOrigin>
        <TileCols>256</TileCols>
        <TileRows>256</TileRows>
        <DPI>96</DPI>
        <LODInfos xsi:type="typens:ArrayOfLODInfo">
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>0</LevelID>
                <Scale>591657527.594076</Scale>
                <Resolution>1.406250000000</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>1</LevelID>
                <Scale>295828763.797038</Scale>
                <Resolution>0.703125000000</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>2</LevelID>
                <Scale>147914381.898519</Scale>
                <Resolution>0.351562500000</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>3</LevelID>
                <Scale>73957190.949259</Scale>
                <Resolution>0.175781250000</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>4</LevelID>
                <Scale>36978595.474630</Scale>
                <Resolution>0.087890625000</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>5</LevelID>
                <Scale>18489297.737315</Scale>
                <Resolution>0.043945312500</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>6</LevelID>
                <Scale>9244648.868657</Scale>
                <Resolution>0.021972656250</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>7</LevelID>
                <Scale>4622324.434329</Scale>
                <Resolution>0.010986328125</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>8</LevelID>
                <Scale>2311162.217164</Scale>
                <Resolution>0.005493164062</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>9</LevelID>
                <Scale>1155581.108582</Scale>
                <Resolution>0.002746582031</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>10</LevelID>
                <Scale>577790.554291</Scale>
                <Resolution>0.001373291016</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>11</LevelID>
                <Scale>288895.277146</Scale>
                <Resolution>0.000686645508</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>12</LevelID>
                <Scale>144447.638573</Scale>
                <Resolution>0.000343322754</Resolution>
            </LODInfo>
            <LODInfo xsi:type="typens:LODInfo">
                <LevelID>13</LevelID>
                <Scale>72223.819286</Scale>
                <Resolution>0.000171661377</Resolution>
            </LODInfo>
        </LODInfos>
    </TileCacheInfo>
    <TileImageInfo xsi:type="typens:TileImageInfo">
        <CacheTileFormat>PNG</CacheTileFormat>
        <CompressionQuality>75</CompressionQuality>
        <Antialiasing>false</Antialiasing>
    </TileImageInfo>
    <CacheStorageInfo xsi:type="typens:CacheStorageInfo">
        <StorageFormat>esriMapCacheStorageModeExploded</StorageFormat>
        <PacketSize>0</PacketSize>
    </CacheStorageInfo>
</CacheInfo>
View Code

方法与4490一样。

posted @ 2023-03-07 11:42  Hxxxxxxyyyyyy  阅读(1633)  评论(0编辑  收藏  举报