Skip to content
Panayiotis edited this page Apr 3, 2016 · 4 revisions

# Get filtered results

For extracting information from the database based on different filters we can use this API function. To use it you need to submit via POST a JSON object describing the currently set filters on the param field on backend/src/api/internal/filter.php.

Example:

    $.ajax({
        url:     "../backend/src/api/internal/filter.php",
        type:    "POST",
        data:    {"params": JSON.stringify(yourfilterobject)}
    });
The filter object:

The filter object is a simple JSON object {} containing different OPTIONAL parameters (in fact even the empty {} one works and returns ALL results in the database).

The different filters:

  • scientist_dataset : Scientists have a separate table for storing results. If we want to filter on that we need to set this field to true
  • species_include/species_exclude : Include/Exclude only images containing these species ids.
  • users_include / users_exclude : Include/Exclude only images containing these user ids. (user uploaders)
  • no_of_classifications : Include/Exclude only images having this number of classifications
  • no_of_classifications_from / no_of_classifications_to : Range based version of the above.
  • photo_id : Include only images matching this image photo id (List or single integer).
  • habitat_id : Include only images matching this image habitat id (List or single integer).
  • site_id : Include only images matching this image site id (List or single integer).
  • flagged : Include only flagged images (true).
  • contains_human : Include only images that contain humans (true).
  • taken_start : Include only images taken after this date (Strictly YYYY-MM-DD HH:MM:SS)
  • taken_end : Include only images taken before this date (Strictly YYYY-MM-DD HH:MM:SS)
  • page: The page (if a limit of results per page is specified).
  • limit: The limit of results per page.
{
    "species_include": [],
    "species_exclude": [],
    "users_include": [],
    "users_exclude": [],
    "no_of_classifications": 9,
    "no_of_classifications_from": 5,
    "no_of_classifications_to":10,
    "no_of_species" : 1,
    "habitat_id": 104,
    "flagged": false,
    "photo_id": 1039,
    "site_id": 2,
    "taken_start": "2014-04-19 14:55:22",
    "taken_end": "2015-04-19 14:55:22",
    "contains_human": false,
    "scientist_dataset": false,
    "limit" : 10,
    "page" : 1
}
Response
{
   "csv":"AMzwv2NZd0.csv",
   "results":[
      {
         "photo_id":"123",
         "species":"87",
         "flagged":"0",
         "time_classified":"2016-02-17 19:45:27",
         "taken":"2015-04-15 14:19:26",
         "person_id":"182",
         "site_id":"2",
         "contains_human":"1",
         "habitat_id":"104",
         "site_name":"SBBS Little High Wood",
         "species_name":"Human <span class='fa fa-male'/>",
         "evenness_species":"0",
         "evenness_count":"0",
         "habitat_name":"woodland - low density forest less than 60% canopy cover",
         "url":"http://www.mammalweb.org/biodivimages/person_182/site_2/52964ab57e40e7b371aa301ee37bc5fc.jpg"
      },
      {
         "photo_id":"124",
         "species":"86",
         "flagged":"0",
         "time_classified":"2016-02-17 19:45:33",
         "taken":"2015-04-15 14:19:27",
         "person_id":"182",
         "site_id":"2",
         "contains_human":"0",
         "habitat_id":"104",
         "site_name":"SBBS Little High Wood",
         "species_name":"Nothing <span class='fa fa-ban'/>",
         "evenness_species":"0",
         "evenness_count":"0",
         "habitat_name":"woodland - low density forest less than 60% canopy cover",
         "url":"http://www.mammalweb.org/biodivimages/person_182/site_2/0073904af3b7307759194dbd92cd9130.jpg"
      },
      {
         "photo_id":"126",
         "species":"86",
         "flagged":"0",
         "time_classified":"2016-02-17 19:45:33",
         "taken":"2015-04-15 14:19:28",
         "person_id":"182",
         "site_id":"2",
         "contains_human":"0",
         "habitat_id":"104",
         "site_name":"SBBS Little High Wood",
         "species_name":"Nothing <span class='fa fa-ban'/>",
         "evenness_species":"0",
         "evenness_count":"0",
         "habitat_name":"woodland - low density forest less than 60% canopy cover",
         "url":"http://www.mammalweb.org/biodivimages/person_182/site_2/72b771d8dd8b6acb2fb47bfcf13f383e.jpg"
      }
   ]
}

Clone this wiki locally