gpt4 book ai didi

postgresql - L.timeDimension 以 UTC 形式将时间发送到 GeoServer 而不是 iso8601

转载 作者:行者123 更新时间:2023-11-29 13:14:07 35 4
gpt4 key购买 nike

我真的陷入了使用 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 Ember :

 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 向我发送正确的日期格式或如何强制 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>

TimeDimension

最佳答案

时间(和海拔)在 WMS 规范中作为特殊参数处理。因此,您需要使用 TIME 参数而不是 CQL 过滤器。

关于postgresql - L.timeDimension 以 UTC 形式将时间发送到 GeoServer 而不是 iso8601,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51296544/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com