diff --git a/geoportal/geoportailv3_geoportal/static-ngeo/js/query/QueryController.js b/geoportal/geoportailv3_geoportal/static-ngeo/js/query/QueryController.js index 0464120d5..bf7f94409 100644 --- a/geoportal/geoportailv3_geoportal/static-ngeo/js/query/QueryController.js +++ b/geoportal/geoportailv3_geoportal/static-ngeo/js/query/QueryController.js @@ -707,7 +707,7 @@ exports.prototype.singleclickEvent_ = function(evt, infoMymaps) { var layers = this.map_.getLayers().getArray(); var layersList = []; var layerLabel = {}; - + var layersTimeList = []; for (var i = layers.length - 1; i >= 0; i--) { var metadata = layers[i].get('metadata'); if (metadata !== undefined && metadata !== null) { @@ -715,6 +715,12 @@ exports.prototype.singleclickEvent_ = function(evt, infoMymaps) { var queryableId = layers[i].get('queryable_id'); layersList.push(queryableId); layerLabel[queryableId] = layers[i].get('label'); + //const time = layers[i].get('time'); + //layersTimeList.push(time.minValue+"/"+time.maxValue); + const time = layers[i].get('current_time'); + if (time !== undefined) { + layersTimeList.push(time); + } } } } @@ -743,7 +749,8 @@ exports.prototype.singleclickEvent_ = function(evt, infoMymaps) { 'box1': big_box.join(), 'box2': small_box.join(), 'srs': 'EPSG:3857', - 'zoom': this.map_.getView().getZoom() + 'zoom': this.map_.getView().getZoom(), + 'time': layersTimeList.join() }; if (!this.map_.get('ol3dm').is3dEnabled()) { var size = this.map_.getSize(); diff --git a/geoportal/geoportailv3_geoportal/views/getfeatureinfo.py b/geoportal/geoportailv3_geoportal/views/getfeatureinfo.py index f6c1e6eea..31175759b 100644 --- a/geoportal/geoportailv3_geoportal/views/getfeatureinfo.py +++ b/geoportal/geoportailv3_geoportal/views/getfeatureinfo.py @@ -263,7 +263,7 @@ def get_feature_info(self): fids = self.request.params.get('fids', None) query_limit = self.request.params.get('max_features', '20') offset = self.request.params.get('start_index', None) - + time = self.request.params.get('time', None) fids_array = [] if fids is not None: fids_array = fids.split(',') @@ -275,7 +275,7 @@ def get_feature_info(self): layers, fid = fid.split('_', 1) if layers is None or fid is None: return HTTPBadRequest() - self.get_info(fid, None, None, results, layers, None, None, zoom, query_limit, offset) + self.get_info(fid, None, None, results, layers, None, None, zoom, query_limit, offset, time) return results layers = self.request.params.get('layers', None) @@ -294,7 +294,7 @@ def get_feature_info(self): if geometry is not None and len(geometry) > 0: fc = self.get_info( fid, None, - None, results, layers, None, geometry, zoom, query_limit, offset) + None, results, layers, None, geometry, zoom, query_limit, offset, time) if len(fc) > 0 and 'features' in fc[0]: s = shape(wkt_loads(geometry)) for feature in fc[0]['features']: @@ -319,7 +319,7 @@ def get_feature_info(self): return HTTPBadRequest("Wrong box2 value : " + small_box) return self.get_info( fid, coordinates_big_box, - coordinates_small_box, results, layers, big_box, None, zoom, query_limit, offset) + coordinates_small_box, results, layers, big_box, None, zoom, query_limit, offset, time) def is_zoom_ok(self, cur_zoom, zoom_definition): if cur_zoom is None or len(cur_zoom) == 0: @@ -340,7 +340,7 @@ def is_zoom_ok(self, cur_zoom, zoom_definition): return False def get_info(self, fid, coordinates_big_box, coordinates_small_box, - results, layers, big_box, p_geometry=None, p_zoom=None, p_query_limit='20', offset=None): + results, layers, big_box, p_geometry=None, p_zoom=None, p_query_limit='20', offset=None, time=None): rows_cnt = 0 luxgetfeaturedefinitions = self.get_lux_feature_definition(layers) for luxgetfeaturedefinition in luxgetfeaturedefinitions: @@ -367,7 +367,7 @@ def get_info(self, fid, coordinates_big_box, coordinates_small_box, None, None, None, None, None, use_auth=luxgetfeaturedefinition.use_auth, - p_geometry=the_box.centroid.wkt, srs_geometry="2169") + p_geometry=the_box.centroid.wkt, srs_geometry="2169", time=time) if len(features) > 0: f.append(self.to_feature(luxgetfeaturedefinition.layer, None, geometry, @@ -614,7 +614,7 @@ def get_info(self, fid, coordinates_big_box, coordinates_small_box, None, None, None, None, luxgetfeaturedefinition.columns_order, use_auth=luxgetfeaturedefinition.use_auth, - p_geometry=p_geometry, srs_geometry=self.request.params.get('srs', self.request.params.get('geometry_srs', '2169'))) + p_geometry=p_geometry, srs_geometry=self.request.params.get('srs', self.request.params.get('geometry_srs', '2169')), time=time) else : features = self._get_external_data( luxgetfeaturedefinition.layer, @@ -622,7 +622,7 @@ def get_info(self, fid, coordinates_big_box, coordinates_small_box, luxgetfeaturedefinition.id_column, big_box, None, None, None, luxgetfeaturedefinition.columns_order, - use_auth=luxgetfeaturedefinition.use_auth) + use_auth=luxgetfeaturedefinition.use_auth, time=time) else: features = self._get_external_data( luxgetfeaturedefinition.layer, @@ -630,7 +630,7 @@ def get_info(self, fid, coordinates_big_box, coordinates_small_box, luxgetfeaturedefinition.id_column, None, fid, None, None, luxgetfeaturedefinition.columns_order, - use_auth=luxgetfeaturedefinition.use_auth) + use_auth=luxgetfeaturedefinition.use_auth, time=time) if len(features) > 0: if (luxgetfeaturedefinition.additional_info_function @@ -1464,7 +1464,7 @@ def get_additional_external_data( def _get_external_data(self, layer_id, url, id_column='objectid', bbox=None, featureid=None, cfg=None, attributes_to_remove=None, columns_order=None, - where_clause=None, use_auth=False, p_geometry=None, srs_geometry=None): + where_clause=None, use_auth=False, p_geometry=None, srs_geometry=None, time=None): # ArcGIS Server REST API: # http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/query.html # form example: @@ -1506,6 +1506,18 @@ def _get_external_data(self, layer_id, url, id_column='objectid', 'where': '', 'outFields': '*', 'objectIds': ''} + if time is not None and len(time) > 0: + # WMS time format is / + # this shall be parsed into , for arcgis REST + time_values = time.split("/") + str_time_integers = [ + str(int(dateutil.parser.parse(time_val).timestamp()*1000)) + for time_val in time_values + ] + # Bypass arcgis bug when time layers are queried with timestamp + if len(str_time_integers) == 1: + str_time_integers.append(str(int(str_time_integers[0]) + 3600000)) + body['time'] = ",".join(str_time_integers) splitted_url = url.split('f=geojson') url = splitted_url[0] if id_column is None: diff --git a/geoportal/geoportailv3_geoportal/views/luxthemes.py b/geoportal/geoportailv3_geoportal/views/luxthemes.py index ddc08dc39..dec40d589 100644 --- a/geoportal/geoportailv3_geoportal/views/luxthemes.py +++ b/geoportal/geoportailv3_geoportal/views/luxthemes.py @@ -137,12 +137,19 @@ def _wms_layers_internal(self): ti = data["timeInfo"] start = datetime.fromtimestamp(ti['timeExtent'][0]/1000) end = datetime.fromtimestamp(ti['timeExtent'][1]/1000) - if ti['defaultTimeIntervalUnits'] in ESRI_TIME_CONSTANTS: + if 'defaultTimeIntervalUnits' in ti and ti['defaultTimeIntervalUnits'] in ESRI_TIME_CONSTANTS: layer_dict['timepositions'] = ['%s/%s/%s' % (start.isoformat(), end.isoformat(), ESRI_TIME_CONSTANTS[ti['defaultTimeIntervalUnits']] % ti['defaultTimeInterval'])] + elif 'timeIntervalUnits' in ti and ti['timeIntervalUnits'] in ESRI_TIME_CONSTANTS: + layer_dict['timepositions'] = ['%s/%s/%s' + % (start.isoformat(), + end.isoformat(), + ESRI_TIME_CONSTANTS[ti['timeIntervalUnits']] + % ti['timeInterval'])] + layers[layer.name + '__' + sublayer] = layer_dict # if no esri time layer defined => standard WMS server else: diff --git a/geoportal/geoportailv3_geoportal/views/wms.py b/geoportal/geoportailv3_geoportal/views/wms.py index e190d555b..a1d4edec4 100644 --- a/geoportal/geoportailv3_geoportal/views/wms.py +++ b/geoportal/geoportailv3_geoportal/views/wms.py @@ -96,6 +96,9 @@ def _process_arcgis_server(self, internal_wms: LuxLayerInternalWMS) -> str: str(int(dateutil.parser.parse(time_val).timestamp()*1000)) for time_val in time_values ] + # Bypass arcgis bug when time layers are queried with timestamp + if len(str_time_integers) == 1: + str_time_integers.append(str(int(str_time_integers[0]) + 3600000)) query_params["time"] = ",".join(str_time_integers) elif lparam == 'layers': query_params["layers"] = 'show:' + internal_wms.layers