1 (edited by namwebs 22-02-2016 10:33:37)

Topic: Set sensitivity automatically for selected species

Hi,

Could someone point me in the right direction here?

For certain species (pangolin, rhino etc) I need to be able to automatically set the sensitivity option so that displayed results are always blurred for these species. I can't depend on contributors remembering to manually set the sensitivity option. Where is the best place to do this? When it is written to the occurrences table, with some PHP like:

<?php if (taxa_taxon_list_id='3780') {[sensitivity_precision]='100000';}?>

or, when the records are displayed?

Ideally it should happen as soon as the records are submitted and not as part of a cron/update task.

Thanks, Alice

2

Re: Set sensitivity automatically for selected species

Hi Alice,

So far as I am aware, following a search of the documentation and the code, this is not a feature that currently exists in Indicia.

There would be several approaches to implementing it. The following come to my mind.

1. A completely generic solution built in to the warehouse which adds a default_sensitivity_precision to the taxa_taxon_lists table. This value could be configured in the warehouse interface and would be applied to all incoming records of a given taxon if no other value is supplied in the submission.

2. A client-side solution in which an additional option is added to the configuration of the recording form that allows a list to be supplied of taxa and their default sensitivity_precision. You could choose to allow recorders to override this if you wanted them to have that option.

3. On the client-side, sub-class the dynamic_sample_occurrence prebuilt_form (if that is what you are using) and override the get_submission() function where you can hard code the values to submit. This is the quick and dirty way.

You definitely want this to occur at the point the record is created in the warehouse so that the sensitivity_precision is stored in the occurrences table and the blurred public_geom is calculated and stored in cache_occurrences. You want the blurred location to be cached for speedy reporting and not calculated when the records are requested for display.

Hope that helps,
Jim Bacon.

3

Re: Set sensitivity automatically for selected species

Hi,

Thanks. I think the first or third option would be the best. I don't mind quick and dirty but I don't have enough understanding of how things work to even attempt option 3.

For the first option, I would guess these would be the first steps:

1. in the postgres database (phppgadmin), add a field 'default_sensitivity_precision' to the table taxa_taxon_lists (and also to cache_occurrences?)
2. for the sensitive species set the value of this field to e.g. 100000 and for everything else leave it null

After that:

- Will the 'default_sensitivity_precision' value be written to the occurrences table automatically and correctly for new records?
- Do I need to amend the code that writes records to the cache_occurrences table so that it will now write the new field? Which code, where?
- Will the Indicia interface automatically reflect the new field in the Species lists so that future species additions can easily be assigned a sensitivity?
- What will happen if the Indicia version updates (currently it is Indicia Version 0.9.1)?

Sorry... I am trying, but there are too many gaps in my understanding.

Alice

4

Re: Set sensitivity automatically for selected species

Hi Alice,

There is some documentation on developing for the warehouse at http://indicia-docs.readthedocs.org/en/ … index.html

To ensure that you could still keep up to date with changes we make to the warehouse code I think there would be three ways to go.
1. You develop the function in a warehouse plugin which isolates, to a large extent, the work you do from what we do.
2. You fork Indicia and maintain your own version, merging in changes we commit.
3. You submit a pull request and we merge your code revisions in to our repository. If we were to go this route I would want to see comments from the other Indicia maintainers on the proposed design first.

Another thing to consider is submitting this as an enhancement request in the Warehouse issue queue, https://github.com/Indicia-Team/warehouse/issues. If there were other users reading this who supported the request that might encourage it to be included in the ongoing development that BRC is funding.

The documentation on client-side development is at http://indicia-docs.readthedocs.org/en/ … index.html

I was proposing a short cut which involves creating a new prebuilt_form based on an existing one. In a new file it would create a new class based on the existing one. Within that it would contain a get_submission() function. In that function you would fiddle with values from the form prior to submitting them to the warehouse. It might work a bit like the following.

<?php>
  class iform_namweb_sample_occurrence extends  iform_dynamic_sample_occurrence{

    public static function get_submission($values, $args, $nid) {
      // Alter $values as needed.

      // Then submit using the function in the parent class
      parent::get_submission($values, $args, $nid);
    }
  }

Regards,
Jim Bacon.

5

Re: Set sensitivity automatically for selected species

Thanks Jim.

In the end I used another method which is probably less correct but is within my current skill levels:

I restricted the data entry form to only show sensitivity level 'Blur to 100km' for sensitive species by modifying /sites/all/modules/iform/client_helpers/data_entry_helper.php. I added an ID to each sensitive species row to indicate which species it is, then added an IF statement to change the options to only show one, for selected species.

Presumably data_entry_helper.php gets overwritten/replaced by warehouse updates but I have documented my changes and can redo them if needed.

Thanks again, Alice

6

Re: Set sensitivity automatically for selected species

Just seen this. I am pushing to open data flow as much as possible via the Indicia site including public viewing of records. Has a sensitive species option been implemented or suggested? If not i will look to Jim's suggestions above.

Natural History & Biodiversity Data Enthusiast

7

Re: Set sensitivity automatically for selected species

Hi

For a long time there has been an option for a recorder to mark a record sensitive at time of data entry so that its public display is blurred. However, there has not been a way to mark a species as sensitive so that all records of it are blurred automatically.

There has been some work done recently that might relate to this but I have almost no knowledge of it and have not been able to track down more than a fleeting reference. I guess I have not managed to hit on the search terms that would find it.

Perhaps related is a workflow module. I infer from comments on a table that it creates that it watches and modifies values in the database when some condition is matched. I.e. it might watch for creation of an occurrence record for a particular species and set its sensitivity.

It seems to be too new to have been documented yet.

Jim Bacon