Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maplibre-gl-enhance 的style->sources->type: 'raster'设置tileSize: 512无效 #487

Open
Baikaler opened this issue Sep 26, 2024 · 9 comments

Comments

@Baikaler
Copy link

Baikaler commented Sep 26, 2024

如题,在使用maplibre-gl-enhance,���载wtms服务时设置tileSize: 512,经验证设置为256或者不设置或者设置512,地图都只能加载256的wtms服务

@songyumeng
Copy link
Member

谢谢你提的issue。
你是说OGC的WMTS服务吗?可以先确定下你的服务是否支持512的瓦片。
请提供下下你的代码和WMTS服务的能力文档,便于我们跟踪问题。

@Baikaler
Copy link
Author

使用的标准的EPSG:4498坐标系,代码如下:

<script type="text/javascript"> var WKT = 'PROJCS["CGCS2000 / Gauss-Kruger zone 20",GEOGCS["China Geodetic Coordinate System 2000",DATUM["China 2000",SPHEROID["CGCS2000", 6378137.0, 298.257222101, AUTHORITY["EPSG","1024"]],AUTHORITY["EPSG","1043"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic longitude", EAST],AXIS["Geodetic latitude", NORTH],AUTHORITY["EPSG","4490"]],PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]],PARAMETER["central_meridian", 117.0],PARAMETER["latitude_of_origin", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting", 20500000.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["Easting", EAST], AXIS["Northing", NORTH],AUTHORITY["EPSG","4498"]]'; // var Proj4 =' +proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000.0 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs' var map = new maplibregl.Map({ container: 'map', style: { version: 8, sources: { bj_dist: { type: 'raster', tileSize: 512, tiles: [ "http://localhost:9090/geoserver/postgis/gwc/service/wmts?layer=postgis:bjcgcs20&style=&tilematrixset=EPSG:4498x2&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix=EPSG:4498x2:{z}&TileCol={x}&TileRow={y}", ], }, }, layers: [ { id: 'bj_dist', type: 'raster', source: 'bj_dist', minzoom: 0, maxzoom: 19 }, ] }, crs: new maplibregl.CRS('EPSG:4498', WKT, [20184047.248447325,2103881.962779923,20815952.751552675,5714206.250336334]), center: [116.5, 39.9], pitch: 45, zoom: 9, renderWorldCopies: false, }); map.addControl(new maplibregl.FullscreenControl()); map.addControl(new maplibregl.NavigationControl()); map.addControl(new maplibregl.ScaleControl()); </script>
@songyumeng
Copy link
Member

你的wmts服务能出512的瓦片吗,通常情况下wmts都只是256的瓦片,请提供下你的wmts capabilities文档

@Baikaler
Copy link
Author

Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
<script/>
ows:ServiceIdentification
ows:TitleGeoServer Web Map Tile Service</ows:Title>
ows:AbstractA compliant implementation of WMTS service.</ows:Abstract>
ows:Keywords
ows:KeywordWMTS</ows:Keyword>
</ows:Keywords>
ows:ServiceTypeOGC WMTS</ows:ServiceType>
ows:ServiceTypeVersion1.0.0</ows:ServiceTypeVersion>
ows:FeesNONE</ows:Fees>
ows:AccessConstraintsNONE</ows:AccessConstraints>
</ows:ServiceIdentification>
ows:ServiceProvider
ows:ProviderNamehttp://geoserver.org/com</ows:ProviderName>
<ows:ProviderSite xlink:href="http://geoserver.org"/>
ows:ServiceContact
ows:IndividualNameClaudius Ptolomaeus</ows:IndividualName>
ows:PositionNameChief Geographer</ows:PositionName>
ows:ContactInfo
ows:Address
ows:CityAlexandria</ows:City>
ows:CountryRoman Empire</ows:Country>
ows:ElectronicMailAddressclaudius.ptolomaeus@mercury.olympus.gov</ows:ElectronicMailAddress>
</ows:Address>
</ows:ContactInfo>
</ows:ServiceContact>
</ows:ServiceProvider>
ows:OperationsMetadata
<ows:Operation name="GetCapabilities">
ows:DCP
ows:HTTP
<ows:Get xlink:href="http://localhost:9090/geoserver/gwc/service/wmts?">
<ows:Constraint name="GetEncoding">
ows:AllowedValues
ows:ValueKVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetTile">
ows:DCP
ows:HTTP
<ows:Get xlink:href="http://localhost:9090/geoserver/gwc/service/wmts?">
<ows:Constraint name="GetEncoding">
ows:AllowedValues
ows:ValueKVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
<ows:Operation name="GetFeatureInfo">
ows:DCP
ows:HTTP
<ows:Get xlink:href="http://localhost:9090/geoserver/gwc/service/wmts?">
<ows:Constraint name="GetEncoding">
ows:AllowedValues
ows:ValueKVP</ows:Value>
</ows:AllowedValues>
</ows:Constraint>
</ows:Get>
</ows:HTTP>
</ows:DCP>
</ows:Operation>
</ows:OperationsMetadata>


ows:Title北京地区</ows:Title>
ows:Identifierpostgis:bjcgcs20</ows:Identifier>
<Style isDefault="true">
ows:Identifierpolygon</ows:Identifier>

</Style>
application/vnd.mapbox-vector-tile
image/png
image/jpeg
text/plain
application/vnd.ogc.gml
text/xml
application/vnd.ogc.gml/3.1.1
text/xml
text/html
application/json

EPSG:4498x2


EPSG:4498x2:0
2
2
0
0


EPSG:4498x2:1
4
4
0
1


EPSG:4498x2:2
7
8
1
2


EPSG:4498x2:3
15
17
2
4


EPSG:4498x2:4
30
34
4
9


EPSG:4498x2:5
59
68
9
18


EPSG:4498x2:6
118
136
18
36


EPSG:4498x2:7
237
273
36
72


EPSG:4498x2:8
473
546
73
145


EPSG:4498x2:9
946
1092
146
290


EPSG:4498x2:10
1891
2183
292
580


EPSG:4498x2:11
3783
4366
585
1161


EPSG:4498x2:12
7565
8731
1171
2322


EPSG:4498x2:13
15129
17461
2342
4644


EPSG:4498x2:14
30258
34922
4685
9288


EPSG:4498x2:15
60515
69844
9370
18577


EPSG:4498x2:16
121030
139687
18741
37155


EPSG:4498x2:17
242060
279375
37482
74310


EPSG:4498x2:18
484121
558751
74965
148620


EPSG:4498x2:19
968243
1117502
149931
297240















ows:IdentifierEPSG:4498x2</ows:Identifier>
ows:SupportedCRSurn:ogc:def:crs:EPSG::4498</ows:SupportedCRS>

ows:IdentifierEPSG:4498x2:0</ows:Identifier>
4407822.984830845
5895315.0 2.0184047248447325E7
512
512
1
6


ows:IdentifierEPSG:4498x2:1</ows:Identifier>
2203911.4924154226
5895315.0 2.0184047248447325E7
512
512
2
12


ows:IdentifierEPSG:4498x2:2</ows:Identifier>
1101955.7462077113
5737339.0 2.0184047248447325E7
512
512
4
23


ows:IdentifierEPSG:4498x2:3</ows:Identifier>
550977.8731038556
5737339.0 2.0184047248447325E7
512
512
8
46


ows:IdentifierEPSG:4498x2:4</ows:Identifier>
275488.9365519278
5737339.0 2.0184047248447325E7
512
512
16
92


ows:IdentifierEPSG:4498x2:5</ows:Identifier>
137744.4682759639
5717592.0 2.0184047248447325E7
512
512
32
183


ows:IdentifierEPSG:4498x2:6</ows:Identifier>
68872.23413798196
5717592.0 2.0184047248447325E7
512
512
64
366


ows:IdentifierEPSG:4498x2:7</ows:Identifier>
34436.11706899098
5717592.0 2.0184047248447325E7
512
512
128
732


ows:IdentifierEPSG:4498x2:8</ows:Identifier>
17218.05853449549
5715123.0 2.0184047248447325E7
512
512
256
1463


ows:IdentifierEPSG:4498x2:9</ows:Identifier>
8609.029267247744
5715123.0 2.0184047248447325E7
512
512
512
2926


ows:IdentifierEPSG:4498x2:10</ows:Identifier>
4304.514633623872
5714506.0 2.0184047248447325E7
512
512
1024
5851


ows:IdentifierEPSG:4498x2:11</ows:Identifier>
2152.257316811936
5714506.0 2.0184047248447325E7
512
512
2048
11702


ows:IdentifierEPSG:4498x2:12</ows:Identifier>
1076.128658405968
5714352.0 2.0184047248447325E7
512
512
4096
23403


ows:IdentifierEPSG:4498x2:13</ows:Identifier>
538.064329202984
5714275.0 2.0184047248447325E7
512
512
8192
46805


ows:IdentifierEPSG:4498x2:14</ows:Identifier>
269.0321646014918
5714236.0 2.0184047248447325E7
512
512
16384
93609


ows:IdentifierEPSG:4498x2:15</ows:Identifier>
134.5160823007461
5714217.0 2.0184047248447325E7
512
512
32768
187217


ows:IdentifierEPSG:4498x2:16</ows:Identifier>
67.25804115037286
5714207.0 2.0184047248447325E7
512
512
65536
374433


ows:IdentifierEPSG:4498x2:17</ows:Identifier>
33.62902057518643
5714207.0 2.0184047248447325E7
512
512
131072
748866


ows:IdentifierEPSG:4498x2:18</ows:Identifier>
16.814510287593215
5714207.0 2.0184047248447325E7
512
512
262144
1497732


ows:IdentifierEPSG:4498x2:19</ows:Identifier>
8.407255143796787
5714207.0 2.0184047248447325E7
512
512
524288
2995464




@Baikaler
Copy link
Author

这是geoserver中自定义网格集后geowebcache.xml中的

EPSG:4498x2

4498



2.0184047248447325E7
2103881.962779923
2.0815952751552675E7
5714206.250336334


false

1234.1904357526364
617.0952178763182
308.5476089381591
154.27380446907955
77.13690223453978
38.56845111726989
19.284225558634944
9.642112779317472
4.821056389658736
2.410528194829368
1.205264097414684
0.602632048707342
0.301316024353671
0.1506580121768355
0.0753290060884177
0.0376645030442089
0.0188322515221044
0.0094161257610522
0.0047080628805261
0.0023540314402631

1.0
2.8E-4

EPSG:4498x2:0
EPSG:4498x2:1
EPSG:4498x2:2
EPSG:4498x2:3
EPSG:4498x2:4
EPSG:4498x2:5
EPSG:4498x2:6
EPSG:4498x2:7
EPSG:4498x2:8
EPSG:4498x2:9
EPSG:4498x2:10
EPSG:4498x2:11
EPSG:4498x2:12
EPSG:4498x2:13
EPSG:4498x2:14
EPSG:4498x2:15
EPSG:4498x2:16
EPSG:4498x2:17
EPSG:4498x2:18
EPSG:4498x2:19

512
512
true

@songyumeng
Copy link
Member

你现在得现象是什么,wmts getTile请求是否发出,回来得是否是512得瓦片?

@songyumeng
Copy link
Member

能否提供在线的wmts服务地址

@Baikaler
Copy link
Author

你现在得现象是什么,wmts getTile请求是否发出,回来得是否是512得瓦片?

返回的瓦片不在范围内,我们数据涉密,不能提供在线的

@songyumeng
Copy link
Member

songyumeng commented Sep 26, 2024

没有能调试的服务,我只能猜测下问题原因:

通过你设置的bounds :2.0184047248447325E7,2103881.962779923,2.0815952751552675E7,5714206.250336334 可得bounds宽度为631905.5031053498,高度为3610324.287556411。

maplibre-gl-enhance 内部的逻辑为,宽高的最大值/512为第0级的分辨率,即3610324.287556411/512=7051.414624133616。r然后用bounds的左上角和计算出的第0级分辨率,构建瓦片金字塔。

但是该WMTS服务的0级分辨率为1234.1904357526364。这可能就是无法请求到正确瓦片的原因,并不是去请求了256的瓦片 。

你提供的WMTS的Capabilities的内容格式错乱了,猜测其中的5714352.0 2.0184047248447325E7是TopLeftCorner,即该WMTS服务的瓦片左上角。根据前面提到的maplibre-gl-enhance 内部的逻辑,要让maplibre-gl-enhance内部的瓦片金字塔与你的WMTS服务的瓦片金字塔匹配,new CRS的bounds左上角需要是TopLeftCorner的值,即bounds应该调整为2.0184047248447325E7,2103881.962779923,2.0815952751552675E7,5714352.0

maplibre-gl-enhance目前不支持自定义级别对应的分辨率。所以为了能出图只有尝试修改new CRS的bounds,让mapboxgl-enhance内部计算的瓦片金字塔0级分辨率与WMTS的0级分辨率对应上。在左上角固定的前提下,WMTS服务的第0级分辨率为1234.1904357526364,可知bounds的最大宽高都应该为1234.1904357526364*512=631905.5031053498。那bounds应该调整为2.0184047248447325E7,5082446.49689465,20815952.751552675,5714352.0。

这个bounds和本身服务的bounds差别很大,需要确定是否能完全包含你的数据,如果没有完全包含的话,就会出现地图加载不完整的情况。

综上:如果根据我的解释计算出的bounds能概括你的数据范围,可以尝试加载。如果没有完全包含,那目前maplibre-gl-enhance无法加载你提供的这个服务。

maplibre-gl-enhance支持自定义级别对应的分辨率的功能我们正在规划中。

不知道我解释的清不清楚,如需更详细交流可以拨打我们的技术支持电话400-8900-866。我们的技术团队会在电话中为您提供一对一的服务,确保您的问题得到妥善解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants