我真的被困在使用L.timedimension .
我的地理服务器从Psql以下列格式询问日期:
TO_TIMESTAMP(cast(cast(bc_issued_date as date) as varchar)|| '00:00:00' ,'YYYY-MM-DD hh24:mi:ss')::timestamp as time
"2013-01-08 00:00:00"
"2022-07-09 00:00:00"
"2021-09-08 00:00:00"
Geoserver正确显示图层,但是当我使用L.timedimension时,没有任何显示 . 我检查了日志,似乎时间到了UTC灰显示如下:
RawKvp = {FORMAT=image/png, STYLES=PolygonVariableThick, WIDTH=256, TIME=2012- 07-24T18:00:00.000Z, ENV=color:#808000, HEIGHT=256, LAYERS=localhost:BuildingConset_TimeSlider_v1_2017, REQUEST=GetMap, SRS=EPSG:4326, BBOX=174.72656250000003,-36.597889133070204,175.078125,-36.3151251474805, VERSION=1.1.0, SERVICE=WMS, TRANSPARENT=true, CQL_FILTER=1=1}
RemoteOwsType = null
RemoteOwsURL = null
Request = GetMap
RequestCharset = UTF-8
ScaleMethod = null
Sld = null
SldBody = null
SldVersion = null
SortBy = null
SortByArrays = null
SRS = EPSG:4326
StartIndex = null
StyleBody = null
StyleFormat = sld
Styles = [StyleImpl[ name=PolygonVariableThick]]
StyleUrl = null
StyleVersion = null
Tiled = false
TilesOrigin = null
*****Time = [Tue Jul 24 18:00:00 UTC 2012]*****
Transparent = true
ValidateSchema = false
Version = 1.1.0
ViewParams = null
Width = 256
所以,我的问题是,如何强制timedimension向我发送正确的dateformat或如何强制GeoServer / Postgresql转换时间?
<!DOCTYPE html>
<html>
<head>
<title>WMS example - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/socib/Leaflet.TimeDimension/master/dist/leaflet.timedimension.control.min.css" />
<script type="text/javascript" src="https://cdn.rawgit.com/nezasa/iso8601-js-period/master/iso8601.min.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/socib/Leaflet.TimeDimension/master/dist/leaflet.timedimension.min.js">
</script><link href="Scripts2/Leaflet.TimeDimension-master/src/leaflet.timedimension.control.css" rel="stylesheet" />
<style>
html, body {
height: 100%;
margin: 0;
}
#map {
width: 1000px;
height: 900px;
}
</style>
</head>
<body>
<div id='map'></div>
<script type="text/javascript">
var startDate = new Date();
startDate.setUTCHours(12, 0, 0, 0);
var map = L.map('map', {
center: [-36.924930, 174.853682],
zoom: 10,
fullscreenControl: true,
timeDimension: true,
timeDimensionControl: true,
timeDimensionOptions: {
//timeInterval: startDate.toISOString() + "/P1W",
timeInterval: "2010-01-01/2018-02-02",
period: "PT6H",
currentTime: startDate.getTime()
},
});
var testLayer = L.tileLayer.wms('https://xxx.yyy/geoserver/localhost/wms',
{
layers: 'localhost:BuildingConset_TimeSlider_v1_2017', format:
'image/png', transparent: true, opacity: 0.4,
version: '1.1.0', styles: 'PolygonVariableThick', env:
'color:#808000', CQL_FILTER: '1=1'//,time:2016
, crs: L.CRS.EPSG4326,
})
var testTimeLayer = L.timeDimension.layer.wms(testLayer, {
updateTimeDimension: false,
});
testTimeLayer.addTo(map);
</script>
1 回答
时间(和高程)作为WMS规范中的特殊参数处理 . 因此,您需要使用
TIME
参数而不是CQL过滤器 .