Skip to content

Commit

Permalink
clean up logs, add develop comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pvgenuchten committed Sep 29, 2024
1 parent 51ef3ef commit 37cf420
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pycsw/ogc/api/templates/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
function facet(val){
location.href="{{updateurl('facets','facetprop')}}".replace('facetprop',val);
}
//if url has a bbox, enable the spatial filter
{% if 'bbox' in attrs.keys() and (attrs['bbox'].split('%2C')|length) == 4 %}
var bbox = [
[{{ attrs['bbox'].split('%2C')[1] }}, {{ attrs['bbox'].split('%2C')[0] }}],
Expand All @@ -219,6 +220,8 @@
{% else %}
var bbox = null;
{% endif %}

//if filter enabled, apply the spatial filter
function apply_spatial_filter(){
if ($('#spatial-filter-check').attr('checked')) {
location.href="{{ updateurl('bbox','tmptmp') }}".replace('tmptmp',yx(rectangle.getBounds()));
Expand Down Expand Up @@ -258,6 +261,7 @@
}
{% endif %}

//set rectangle if page initializes with a spatial filter
if (bbox){
setRectangle(bbox);
map.fitBounds(bbox);
Expand All @@ -268,6 +272,7 @@
dashArray: '',
fillOpacity: 0.5
}

{% if data['features'] %}
$(document).ready(function() {
$('#items-table-table tr').on('mouseenter', function(e){
Expand All @@ -293,6 +298,7 @@
});
{% endif %}
//generates a pycsw bbox from leaflet bounds
function yx (b){
if (b && b._southWest){
return [b._southWest.lng,b._southWest.lat,b._northEast.lng,b._northEast.lat].join(',');
Expand All @@ -301,27 +307,23 @@
var rectangle;
// creates or sets the filter rectangle and adds it to map
function setRectangle(bbox){
if (rectangle){
rectangle.setBounds(bbox)
} else {
rectangle = L.rectangle(bbox);
rectangle.editing.enable();
rectangle.on('edit', function() {
bbox = rectangle.getBounds();
console.log(rectangle.getBounds().toString());
});
rectangle.setStyle({color :'green'});
}
map.addLayer(rectangle);
}

// en/disables the spatial filter, the layer is removed or added at 95% map bounds
function trigger_spatial_filter(){
if (map.hasLayer(rectangle)){
console.log(bbox);
rectangle.remove();
bbox = null;
} else {
console.log(map.getBounds().pad(-0.95));
setRectangle(map.getBounds().pad(-0.95));
}
}
Expand Down

0 comments on commit 37cf420

Please sign in to comment.