首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >L.timeDimension将时间以协调世界时的形式发送到GeoServer,而不是iso8601

L.timeDimension将时间以协调世界时的形式发送到GeoServer,而不是iso8601
EN

Stack Overflow用户
提问于 2018-07-12 10:31:54
回答 1查看 429关注 0票数 1

我真的被困在使用L.timedimension中了。

我的geoserver从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 ash的时候到了,如下所示:

 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>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-16 03:28:31

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51296544

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档