1

Topic: Recent record spatial filtering.

I would like to filter the 'recent records' page to show only records for the LRC area. I've tried editing the PHP code on the Panel but it seems to not want to pick up the location_id.

Can i do this from the panel or do i have to change the query itself somewhere else there doesn't seem to be a corresponding iform i can edit.

<p>
    The following list of records includes verified records and those awaiting verification of species groups you are interested in which have been recently added in your area.</p>
<?php
iform_load_helpers(array('report_helper')); 
global $auth;
if (!isset($auth))
  $auth = report_helper::get_read_auth(variable_get('indicia_website_id',''), variable_get('indicia_password','')); 

echo report_helper::report_grid(array( 
  'id'=>'latest-records', 
  'readAuth' => $auth, 
  'dataSource'=>'library/occurrences/explore_list_using_spatial_index_builder', 
  'location_id'=>'1464',
  'itemsPerPage' => 5, 
  'rowId'=>'occurrence_id',
  'columns'=>array(
    array('fieldname'=>'taxon','template'=>'<div class="status-{record_status} certainty-{certainty} zero-{zero_abundance}">{taxon}</div>','display'=>'Species'),
    array('fieldname'=>'location_name', 'display'=>'Site name'),
    array('fieldname'=>'entered_sref', 'display'=>'Grid Ref'),
    array('fieldname'=>'date', 'display'=>'Date'),
    array('fieldname'=>'recorder', 'display'=>'Recorder'),
    array('fieldname'=>'certainty', 'visible'=>false),
    array('fieldname'=>'geom', 'visible'=>false, 'mappable'=>true)
  ), 
  'includeAllColumns' => false, 
  'pager' => false, 
  'sendOutputToMap'=>true, 
  'rowClass'=>'certainty{certainty}',
  'extraParams' => array( 
    'survey_id'=>'', 
    'taxon_group_id'=>'', 
    'smpattrs'=>'', 
    'occattrs'=>'', 
    'searchArea'=>'', 
    'idlist'=>'', 
    'currentUser'=>0, 
    'ownData'=>0, 
    'location_id'=>'1464',
    'ownLocality'=>0, 
    'taxon_groups'=>'', 
    'ownGroups'=>0) 
));
?>
Natural History & Biodiversity Data Enthusiast

2

Re: Recent record spatial filtering.

Hi

The line

'dataSource'=>'library/occurrences/explore_list_using_spatial_index_builder'

tells me which report is being run on the warehouse.
I can find that in the repository at https://code.google.com/p/indicia/sourc … uilder.xml

I can see from the report that, although there is a location_id parameter, the query does not include a #location_id# replacement token, nor is there a <where> or <join> included with the parameter. This suggests to me that the location_id you have put in the extraParams will be ignored.

There is some documentation at http://indicia-docs.readthedocs.org/en/ … rams-label

Jim Bacon.

3

Re: Recent record spatial filtering.

Cheers Jim thanks for the confirmation!

Natural History & Biodiversity Data Enthusiast

4

Re: Recent record spatial filtering.

If I am understanding how it works, it looks like it would be a fairly simple update to the report to enable it to do what you want.
Are you hosting your own warehouse or using the BRC warehouse?

Jim.

5

Re: Recent record spatial filtering.

I'm using the BRC. I've not tackled creating my own reports yet as the stock ones have been fine. Shouldn't be too much trouble though now i know that's the problem.

Natural History & Biodiversity Data Enthusiast

6

Re: Recent record spatial filtering.

Hi

I just had another look and realise I missed something.
The location_id replacement token is used  in the <join> clause of another parameter.

    <param name="ownLocality" display="My locality only?" datatype="checkbox">
      <join value="1">JOIN index_locations_samples lfilter ON lfilter.sample_id=o.sample_id and lfilter.location_id=#location_id#</join>  
    </param>

I've never created a report this clever but I read it to mean that the location_id is ignored unless the ownLocality parameter is set to 1.

Try modifying your PHP so that the extraParams includes

    'location_id'=>'1464',
    'ownLocality'=>1, 

Jim.

7

Re: Recent record spatial filtering.

Just wanted to add that Jim's suggestion works just as hoped.

Natural History & Biodiversity Data Enthusiast