Skip to content

Commit 19f2e8a

Browse files
author
Magnar Eivind Martinsen
committed
Updated metsis-search parent/child handeling, searchmap Pole Projection, and date filter handeling
1 parent 7eee44d commit 19f2e8a

File tree

7 files changed

+229
-92
lines changed

7 files changed

+229
-92
lines changed

metsis/metsis_search/config/install/views.view.metsis_elements.yml

+89-62
Large diffs are not rendered by default.

metsis/metsis_search/config/install/views.view.metsis_search.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ display:
403403
exclude: false
404404
alter:
405405
alter_text: true
406-
text: "{% if is_parent == 'True' %}\r\n<img class=\"align-right\" loading=\"lazy\" src=\"/modules/metsis/metsis_search/images/collection.png\">\r\n{%endif %}"
406+
text: "{% if is_parent == 'True' %}\r\n<a href=\"/metsis/elements/{{ id }}/search\" title=\"Show ALL chiildren in this collection\"> <img class=\"align-right\" loading=\"lazy\" src=\"/modules/metsis/metsis_search/images/collection.png\"></a>\r\n{%endif %}"
407407
make_link: false
408408
path: ''
409409
absolute: false
@@ -1495,7 +1495,7 @@ display:
14951495
element_class: ''
14961496
element_label_type: ''
14971497
element_label_class: ''
1498-
element_label_colon: true
1498+
element_label_colon: false
14991499
element_wrapper_type: ''
15001500
element_wrapper_class: ''
15011501
element_default_classes: true
@@ -1516,7 +1516,7 @@ display:
15161516
- nothing_7
15171517
- nothing_11
15181518
wrapper: fieldset
1519-
legend: 'Data access:'
1519+
legend: 'Data operations / access:'
15201520
classes: datasetOps
15211521
collapsible: true
15221522
collapsed: false
@@ -1532,7 +1532,7 @@ display:
15321532
exclude: false
15331533
alter:
15341534
alter_text: true
1535-
text: "{% if data_access_url_opendap %}\r\n<div id=\"basket\" class=\"basket\">\r\n<a id=\"addtobasket-{{ id }}\" class=\"adc-button adc-sbutton use-ajax\" href=/metsis/basket/add/{{ id}}>Add to Basket</a>\r\n</div>\r\n{% endif %}"
1535+
text: "{% if data_access_url_opendap %}\r\n<div id=\"basket\" class=\"basket\">\r\n<a id=\"addtobasket-{{ id }}\" class=\"adc-button adc-sbutton use-ajax\" title=\"Add product to basket\" href=/metsis/basket/add/{{ id}}>Add to Basket</a>\r\n</div>\r\n{% endif %}"
15361536
make_link: false
15371537
path: ''
15381538
absolute: false
@@ -1581,7 +1581,7 @@ display:
15811581
exclude: false
15821582
alter:
15831583
alter_text: true
1584-
text: "<a class=\"use-ajax adc-button adc-sbutton\" \r\n data-dialog-options=\"{&quot;width&quot;:600, &quot;title&quot;:&quot;Metadata Details&quot;}\" \r\n data-dialog-type=\"dialog\"\r\n data-dialog-renderer=\"off_canvas\"\r\n href=\"/metsis/metadata/{{ id}}\">Show extended metadata</a>"
1584+
text: "<a class=\"use-ajax adc-button adc-sbutton\" \r\n data-dialog-options=\"{&quot;width&quot;:600, &quot;title&quot;:&quot;Metadata Details&quot;}\" \r\n data-dialog-type=\"dialog\"\r\n data-dialog-renderer=\"off_canvas\"\r\n href=\"/metsis/metadata/{{ id}}\"\r\n title=\"Show extended metadata information\"\r\n>Show extended metadata \r\n</a>"
15851585
make_link: false
15861586
path: ''
15871587
absolute: false
@@ -1630,7 +1630,7 @@ display:
16301630
exclude: false
16311631
alter:
16321632
alter_text: true
1633-
text: "{% if is_parent|lower == 'true' %}\r\n<div id=\"metachild\" class=\"metachild\" data-id={{ id }} isparent={{ is_parent }}>\r\n<a id=\"metachildlink\" reference=\"{{ id }}\" class=\"childlink visually-hidden adc-button adc-sbutton\" href=\"/metsis/elements/{{ id }}/search\"></a>\r\n</div>\r\n{% endif %}"
1633+
text: "{% if is_parent|lower == 'true' %}\r\n<div id=\"metachild\" class=\"metachild\" data-id={{ id }} isparent={{ is_parent }}>\r\n<a id=\"metachildlink\" reference=\"{{ id }}\" class=\"childlink visually-hidden adc-button adc-sbutton\" title=\"List children based on search criteria\" href=\"/metsis/elements/{{ id }}/search\"></a>\r\n</div>\r\n{% endif %}"
16341634
make_link: false
16351635
path: ''
16361636
absolute: false
@@ -1679,7 +1679,7 @@ display:
16791679
exclude: false
16801680
alter:
16811681
alter_text: true
1682-
text: "{% if data_access_url_ogc_wms %} \r\n<div id=\"visualise\" class=\"visualise\"><a class=\"adc-button adc-sbutton\" href=\"/metsis/map/wms?dataset={{ id }}\">Visualise</a></div>\r\n{% endif %}"
1682+
text: "{% if data_access_url_ogc_wms %} \r\n<div id=\"visualise\" class=\"visualise\"><a class=\"adc-button adc-sbutton\" title=\"Visualise WMS\" href=\"/metsis/map/wms?dataset={{ id }}\">Visualise</a></div>\r\n{% endif %}"
16831683
make_link: false
16841684
path: ''
16851685
absolute: false
@@ -1728,7 +1728,7 @@ display:
17281728
exclude: false
17291729
alter:
17301730
alter_text: true
1731-
text: "{% if data_access_url_opendap %}\r\n {% if feature_type == 'timeSeries' or feature_type == 'timeSeriesProfile' or feature_type == 'profile' %}\r\n<a class=\"use-ajax adc-button adc-sbutton inline\" href=\"/metsis/tsplot/form?url={{ data_access_url_opendap }}\" data-dialog-options=\"{&quot;width&quot;:1200, &quot;title&quot;:&quot;Timeseries Plot&quot;}\" data-dialog-type=\"modal\">Visualise Timeseries</a>\r\n {% endif %}\r\n{% endif %}"
1731+
text: "{% if data_access_url_opendap %}\r\n {% if feature_type == 'timeSeries' or feature_type == 'timeSeriesProfile' or feature_type == 'profile' %}\r\n<a class=\"use-ajax adc-button adc-sbutton inline\" title=\"Visualise Timeseries\" href=\"/metsis/tsplot/form?url={{ data_access_url_opendap }}\" data-dialog-options=\"{&quot;width&quot;:1200, &quot;title&quot;:&quot;Timeseries Plot&quot;}\" data-dialog-type=\"modal\">Visualise Timeseries</a>\r\n {% endif %}\r\n{% endif %}"
17321732
make_link: false
17331733
path: ''
17341734
absolute: false
@@ -1777,7 +1777,7 @@ display:
17771777
exclude: false
17781778
alter:
17791779
alter_text: true
1780-
text: '<a class="adc-button adc-sbutton inline" href={{ data_access_url_http }}>Download data</a>'
1780+
text: '<a class="adc-button adc-sbutton inline" title="Download data (HTTP)" href={{ data_access_url_http }}>Download data</a>'
17811781
make_link: false
17821782
path: ''
17831783
absolute: false
@@ -1830,7 +1830,7 @@ display:
18301830
exclude: false
18311831
alter:
18321832
alter_text: true
1833-
text: '<a class="adc-button adc-sbutton inline" href={{ data_access_url_ftp }}>Download FTP</a>'
1833+
text: '<a class="adc-button adc-sbutton inline" title="Download data (HTTP)" href={{ data_access_url_ftp }}>Download FTP</a>'
18341834
make_link: false
18351835
path: ''
18361836
absolute: false
@@ -1883,7 +1883,7 @@ display:
18831883
exclude: false
18841884
alter:
18851885
alter_text: true
1886-
text: "{% if data_access_url_opendap %}\r\n<a class=\"adc-button adc-sbutton\" href=\"{{ data_access_url_opendap }}.html\">OPeNDAP</a>\r\n{% endif %}"
1886+
text: "{% if data_access_url_opendap %}\r\n<a class=\"adc-button adc-sbutton\" title=\"Download data (OPeNDAP)\" href=\"{{ data_access_url_opendap }}.html\">OPeNDAP</a>\r\n{% endif %}"
18871887
make_link: false
18881888
path: ''
18891889
absolute: false
@@ -1932,7 +1932,7 @@ display:
19321932
exclude: false
19331933
alter:
19341934
alter_text: true
1935-
text: '<a class="adc-button adc-sbutton inline" href={{ data_access_url_odata }}>Download SAFE product</a>'
1935+
text: '<a class="adc-button adc-sbutton inline" title="Download data as SAFE product" href={{ data_access_url_odata }}>Download SAFE product</a>'
19361936
make_link: false
19371937
path: ''
19381938
absolute: false
@@ -1985,7 +1985,7 @@ display:
19851985
exclude: false
19861986
alter:
19871987
alter_text: true
1988-
text: "{% if data_access_url_opendap %}\r\n {% if feature_type == 'timeSeries' or feature_type == 'timeSeriesProfile' or feature_type == 'profile' %}\r\n<div id=\"download-csv\" class=\"download-csv\">\r\n <a class=\"adc-button adc-sbutton\" href=\"/metsis/bokeh/csv?opendap_urls={{ data_access_url_opendap }}\" >Download as ASCII</a>\r\n</div>\r\n {% endif %}\r\n{% endif %}"
1988+
text: "{% if data_access_url_opendap %}\r\n {% if feature_type == 'timeSeries' or feature_type == 'timeSeriesProfile' or feature_type == 'profile' %}\r\n<div id=\"download-csv\" class=\"download-csv\">\r\n <a class=\"adc-button adc-sbutton\" title=\"Export and download as ASCII format\" href=\"/metsis/bokeh/csv?opendap_urls={{ data_access_url_opendap }}\" >Download as ASCII</a>\r\n</div>\r\n {% endif %}\r\n{% endif %}"
19891989
make_link: false
19901990
path: ''
19911991
absolute: false
@@ -2034,7 +2034,7 @@ display:
20342034
exclude: false
20352035
alter:
20362036
alter_text: true
2037-
text: '<a class="use-ajax ajax adc-button adc-sbutton inline" href="/metsis/export/{{ id }}" data-dialog-options="{&quot;width&quot;:400, &quot;title&quot;:&quot;Export Metadata&quot;}" data-dialog-type="modal">Export Metadata</a>'
2037+
text: '<a class="use-ajax ajax adc-button adc-sbutton inline" title="Export and download metadata as XML" href="/metsis/export/{{ id }}" data-dialog-options="{&quot;width&quot;:400, &quot;title&quot;:&quot;Export Metadata&quot;}" data-dialog-type="modal">Export Metadata</a>'
20382038
make_link: false
20392039
path: ''
20402040
absolute: false
@@ -2822,7 +2822,7 @@ display:
28222822
group_type: group
28232823
admin_label: 'Start date'
28242824
plugin_id: search_api_date
2825-
operator: '>='
2825+
operator: '<='
28262826
value:
28272827
min: ''
28282828
max: ''
@@ -2873,7 +2873,7 @@ display:
28732873
group_type: group
28742874
admin_label: 'End date'
28752875
plugin_id: search_api_date
2876-
operator: '<='
2876+
operator: '>='
28772877
value:
28782878
min: ''
28792879
max: ''

metsis/metsis_search/js/metsis_res_map.js

+47-6
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ console.log("Start of metsis search map script:");
418418
maxZoom: 23,
419419
center: ol.extent.getCenter(featuresExtent),
420420
extent: projObjectforCode[prj].extent,
421+
//maxResolution: 43008.234375,
421422
//projection: projObjectforCode[prj].projection,
422423
projection: selected_proj,
423424
}));
@@ -1937,7 +1938,10 @@ console.log("Start of metsis search map script:");
19371938
$.ajax({
19381939
type: 'GET',
19391940
url: proxyURL + wmsUrlOrig,
1941+
crossDomain: true,
1942+
//xhrFields: { withCredentials: true },
19401943
dataType: 'xml',
1944+
//headers: { "Access-Control-Allow-Origin": '*' },
19411945
//async: false,
19421946
error: function () {
19431947
console.log("Request failed: " + proxyURL + wmsUrlOrig);
@@ -1953,6 +1957,9 @@ console.log("Start of metsis search map script:");
19531957
type: 'GET',
19541958
url: wmsUrl,
19551959
dataType: 'xml',
1960+
crossDomain: true,
1961+
// xhrFields: { withCredentials: true },
1962+
// headers: { "Access-Control-Allow-Origin": '*' },
19561963
//async: false,
19571964
error: function () {
19581965
console.log("Request failed: " + wmsUrl + getCapString);
@@ -1969,6 +1976,9 @@ console.log("Start of metsis search map script:");
19691976
type: 'GET',
19701977
url: wmsUrl + getCapString,
19711978
dataType: 'xml',
1979+
crossDomain: true,
1980+
//xhrFields: { withCredentials: true },
1981+
//headers: { "Access-Control-Allow-Origin": '*'},
19721982
//async: false,
19731983
error: function () {
19741984
console.log("Request failed: " + wmsUrl + getCapString);
@@ -2437,17 +2447,20 @@ console.log("Start of metsis search map script:");
24372447
//build up the point/polygon features
24382448
function buildFeatures(prj) {
24392449
console.log("Building polygons and pins features....");
2440-
//console.log(prj);
24412450
var allFeatures = [];
24422451
var iconFeaturesPol = [];
24432452
var iconFeaturesPin = [];
24442453
var wmsProducts = [];
24452454
if (extracted_info.length === 0) {
2455+
console.log("No extracted Info")
24462456
var featuresExtent = new ol.extent.createEmpty();
2457+
24472458
return featuresExtent;
24482459
}
24492460
for (var i12 = 0; i12 <= extracted_info.length - 1; i12++) {
24502461

2462+
//console.log(extracted_info[i12]);
2463+
24512464
//If we have a geographic extent, create polygon feature
24522465
if ((extracted_info[i12][2][0] !== extracted_info[i12][2][1]) || (extracted_info[i12][2][2] !== extracted_info[i12][2][3])) {
24532466
//Transform boundingbox to selected projection and create a polygon geometry
@@ -2458,6 +2471,33 @@ console.log("Start of metsis search map script:");
24582471
geom = new ol.geom.Polygon([
24592472
[box_tl, box_tr, box_br, box_bl, box_tl]
24602473
]);
2474+
// Handle wide extents in EPSG:32661
2475+
var west = -6378137.0 * Math.PI;
2476+
var east = 6378137.0 * Math.PI;
2477+
2478+
if (extracted_info[i12][2][2] === 180 && selected_proj === "EPSG:32661") {
2479+
extracted_info[i12][2][2] = east;
2480+
}
2481+
if (extracted_info[i12][2][3] === -180 && selected_proj === "EPSG:32661") {
2482+
extracted_info[i12][2][3] = west;
2483+
}
2484+
if (extracted_info[i12][2][2] === 179.9 && selected_proj === "EPSG:32661") {
2485+
extracted_info[i12][2][2] = east;
2486+
}
2487+
if (extracted_info[i12][2][3] === -179.9 && selected_proj === "EPSG:32661") {
2488+
extracted_info[i12][2][3] = west;
2489+
}
2490+
if ((extracted_info[i12][2][3] === west && extracted_info[i12][2][2] === east && selected_proj == "EPSG:32661")
2491+
|| (extracted_info[i12][2][3] === west + 0.1 && extracted_info[i12][2][2] === east - 0.1 && selected_proj == "EPSG:32661")) {
2492+
console.log("Processing wide polygon");
2493+
console.log("wide dataset:" + extracted_info[i12][4][0]);
2494+
// Transform the North and South coordinates to EPSG:32661
2495+
var north = ol.proj.transform([0, extracted_info[i12][2][0]], 'EPSG:4326', prj)[1];
2496+
var south = ol.proj.transform([0, extracted_info[i12][2][1]], 'EPSG:4326', prj)[1];
2497+
2498+
2499+
geom = new ol.geom.Polygon.fromExtent([west, south, east, north]);
2500+
}
24612501

24622502
//Define polygon features
24632503
var iconFeaturePol = new ol.Feature({
@@ -2559,7 +2599,8 @@ console.log("Start of metsis search map script:");
25592599
//projection: prj,
25602600
//style: iconStyle,
25612601
});
2562-
//create a vector layer with all points from the vector source and pins
2602+
2603+
//console.log(newFeature);
25632604

25642605
featureLayersGroup.getLayers().push(polygonsFeatureLayer);
25652606
featureLayersGroup.getLayers().push(pinsFeatureLayer);
@@ -3174,10 +3215,10 @@ console.log("Start of metsis search map script:");
31743215

31753216
//geonorge stedsnavn provider implementation.
31763217
/**
3177-
* Custom provider for OS OpenNames search covering Great Britian.
3178-
* Factory function which returns an object with the methods getParameters
3179-
* and handleResponse called by the Geocoder
3180-
*/
3218+
* Custom provider for OS OpenNames search covering Great Britian.
3219+
* Factory function which returns an object with the methods getParameters
3220+
* and handleResponse called by the Geocoder
3221+
*/
31813222
function geoNorgeSearch(options) {
31823223
const { url } = options;
31833224

metsis/metsis_search/src/Controller/MetsisSearchController.php

+26-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function getChildrenCount(Request $request) {
2828
$end_date = $params['end_date'] ?? NULL;
2929
$fulltext = $params['fulltext'] ?? NULL;
3030
$fulltext_op = $params['search_api_fulltext_op'] ?? NULL;
31+
// dpm($start_date);
3132

3233
/** @var \Drupal\search_api\Entity\Index $index TODO: Change to metsis when prepeare for release */
3334
$index = Index::load('metsis');
@@ -67,16 +68,36 @@ public function getChildrenCount(Request $request) {
6768
$solarium_query->createFilterQuery('statusfilter')->setQuery('metadata_status:Active');
6869
$date_filter = '';
6970
if (NULL != $start_date) {
70-
$date_filter .= '+temporal_extent_start_date:[' . $start_date . 'T00:00:00Z TO *] ';
71-
$date_filter .= 'OR temporal_extent_start_date:[* TO ' . $start_date . 'T00:00:00Z] ';
71+
72+
$date_filter .= '(temporal_extent_start_date:[' . $start_date . 'T00:00:00Z TO *])';
73+
// $date_filter .= ' AND temporal_extent_end_date:[* TO' . $start_date . '])';
74+
$date_filter .= ' OR (temporal_extent_start_date:[* TO ' . $start_date . 'T00:00:00Z]';
75+
$date_filter .= ' AND (*:* -temporal_extent_end_date:* ))';
76+
7277
}
78+
7379
if (NULL != $end_date) {
74-
$date_filter .= '+temporal_extent_end_date:[* TO ' . $end_date . 'T00:00:00Z] ';
75-
$date_filter .= 'OR temporal_extent_end_date:[' . $end_date . 'T00:00:00Z TO *] ';
76-
$date_filter .= 'OR (*:* -temporal_extent_end_date:*) ';
80+
$date_filter .= '(temporal_extent_end_date:[* TO ' . $end_date . 'T23:59:59Z])';
81+
$date_filter .= 'OR (temporal_extent_end_date:[' . $end_date . 'T00:00:00Z TO *] ';
82+
$date_filter .= ' AND temporal_extent_start_date:[ * TO ' . $end_date . 'T00:00:00Z]) ';
83+
$date_filter .= 'OR (*:* -temporal_extent_end_date:*)';
7784

7885
}
86+
if (NULL != $end_date && NULL != $start_date) {
87+
$start = $start_date;
88+
$end = $end_date;
89+
$date_filter = '';
90+
$date_filter = ' ((temporal_extent_start_date:[' . $start . 'T00:00:00Z TO ' . $end . 'T23:59:59Z]';
91+
$date_filter .= ' AND temporal_extent_end_date:[' . $start . 'T00:00:00Z TO ' . $end . 'T23:59:59Z])';
92+
$date_filter .= ' OR (temporal_extent_start_date:[* TO ' . $start . 'T00:00:00Z]';
93+
$date_filter .= ' AND -temporal_extent_end_date:[* TO *]))';
94+
$date_filter .= ' OR ((temporal_extent_start_date:[* TO ' . $start . 'T00:00:00Z]';
95+
$date_filter .= ' AND temporal_extent_end_date:[' . $end . 'T00:00:00Z TO *])';
96+
$date_filter .= ' OR (temporal_extent_start_date:[* TO ' . $start . 'T00:00:00Z]';
97+
$date_filter .= ' AND -temporal_extent_end_date:[* TO *]))';
98+
}
7999
if ('' !== $date_filter) {
100+
// dpm($date_filter, __FUNCTION__);.
80101
$solarium_query->createFilterQuery('datefilter')->setQuery($date_filter);
81102
}
82103
$result = $connector->execute($solarium_query);

0 commit comments

Comments
 (0)