Project

General

Profile

« Previous | Next » 

Revision aa63dfb4

Added by Andreas Kohlbecker about 10 years ago

#3977 (allow defining the MarkerType to filter out excluded NamedAreas from distributions)

View differences:

7.x/modules/cdm_dataportal/includes/descriptions.inc
26 26
 * @param $description_elements
27 27
 *   An array of CDM DescriptionElementBase instances
28 28
 * @return only the computed description elements otherwise all others.
29
 * @deprecated this is replaced by the cdmlib DistributionUtil class!!!
29 30
 */
30 31
function cdm_description_elements_prefer_computed($description_elements){
31 32

  
......
49 50
  }
50 51
}
51 52

  
53
function cdm_distribution_filter_query(){
54
  $cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
55
  $query = array();
56

  
57
  if($cdm_distribution_filter['filter_rules']['statusOrderPreference']){
58
    $query['statusOrderPreference'] = 1;
59
  }
60
  if($cdm_distribution_filter['filter_rules']['subAreaPreference']){
61
    $query['subAreaPreference'] = 1;
62
  }
63
  if(is_array($cdm_distribution_filter['hideMarkedAreas']) && count($cdm_distribution_filter['hideMarkedAreas']) > 0){
64
    $query['hideMarkedAreas'] = '';
65
    foreach ($cdm_distribution_filter['hideMarkedAreas'] as $marker_type => $enabled)
66
      if($enabled){
67
        $query['hideMarkedAreas'] .= ($query['hideMarkedAreas'] ? ',' : '') . $marker_type;
68
      }
69
  }
70

  
71
  return $query;
72
}
73

  
52 74
/**
53 75
 * Merge the fields 'annotations', 'markers', 'sources', 'media' from the source CDM DescriptionElement into  the target.
54 76
 *
......
148 170
    $footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
149 171
  }
150 172
  return $footnoteKeyListStr;
151
}
173
}
174

  
7.x/modules/cdm_dataportal/includes/maps.inc
258 258
}
259 259

  
260 260

  
261
/**
262
 * Composes the render array for a distribution map of the given taxon.
263
 *
264
 * The distribution map can either be a plain image or a dynamic open layers map
265
 * depending on the settings.
266
 *
267
 * compose_hook() implementation
268
 *
269
 * @param $taxon
270
 *   The CDM Taxon instance to create the distribution map for.
271
 * @return array
272
 *    A drupal render array
273
 *
274
 * Similar compose function compose_map()
275
 *
276
 * @ingroup compose
277
 */
278
function compose_distribution_map($taxon) {
279

  
280
  $out = '';
281
  $settings = get_edit_map_service_settings();
282

  
283
  $fontStyles = array(
284
      0 => "plane",
285
      1 => "italic",
286
  );
287

  
288
  // Query cdm server for map service uri parameters.
289
  $query_string = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid, queryString(cdm_distribution_filter_query()));
290
  $query_string = $query_string->String;
291
  $out .= "<!-- map_data_parameters:" . print_r($query_string, TRUE) . " -->";
292
  if (!$query_string) {
293
    // The $query_string is empty if there are no distribution areas defined.
294
    return;
295
  }
296

  
297
  /* ------ choose the display mode, either openlayers or static image ------ */
298

  
299
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
300

  
301
  if ($map_settings['map_type'] == 1) {
302

  
303
    /* =========== display distributions using the openlayers map viewer =========== */
304

  
305
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png"
306
        . "&TRANSPARENT=TRUE"
307
            . "&WIDTH=" . $map_settings['legend']['icon_width']
308
            . "&HEIGHT=" . $map_settings['legend']['icon_height']
309
            // TODO why is the layer=topp:tdwg_level_4 parameter needed at all here??
310
    // AK: i think the tdwg_level_4 is used as place holder and will be replaced later on
311
    // => search for "tdwg_level_4" in the code
312
    . "&layer=topp" . urlencode(':') . "tdwg_level_4"
313
        . "&LEGEND_OPTIONS=forceLabels" . urlencode(':') . "on"
314
            . ";fontStyle" . urlencode(':') . $fontStyles[$map_settings['legend']['font_style']]
315
            . ";fontSize" . urlencode(':') .  $map_settings['legend']['font_size']
316
            . "&SLD=";
317

  
318
    $out .= get_openlayers_map(
319
        $map_settings['width'],
320
        $map_settings['height'],
321
        $map_settings['bbox'],
322
        NULL,
323
        $query_string,
324
        $legendFormatQueryStr,
325
        $map_settings['caption']
326
    );
327
  }
328
  else {
329
    $legendFormatQueryStr = '';
330
    $out = get_image_map(
331
        $map_settings['width'],
332
        $map_settings['height'],
333
        $map_settings['bbox'],
334
        NULL,
335
        $query_string,
336
        $legendFormatQueryStr,
337
        $map_settings['caption']
338
    );
339
  }
340
  return markup_to_render_array($out);
341
}
342

  
343

  
344

  
261 345

  
262 346
/**
263 347
 * @todo Enter description here ...
7.x/modules/cdm_dataportal/settings.php
249 249
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
250 250
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
251 251

  
252
define('CDM_DISTRIBUTION_FILTER', 'cdm_distribution_filter');
253
define('CDM_DISTRIBUTION_FILTER_DEFAULT', serialize(
254
      array(
255
      'filter_rules' => array(
256
        'statusOrderPreference' => 0,
257
        'subAreaPreference' => 0,
258
      ),
259
      'hideMarkedAreas' => array()
260
     )
261
));
262

  
263

  
252 264
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
253 265
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
254 266
    array(
......
646 658
      level of the tree structure.'),
647 659
  );
648 660

  
661
  $form['distribution'] = array(
662
      '#type' => 'fieldset',
663
      '#title' => t('Distributions'),
664
      '#collapsible' => FALSE,
665
      '#description' => 'This section covers general settings regarding distributions, map related settings are found in the '
666
          . l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
667
          '<p>
668
          </p>',
669
  );
670

  
671
  $form['distribution'][CDM_DISTRIBUTION_FILTER] = array(
672
      '#type' => 'fieldset',
673
      '#title' => 'Distribution filter',
674
      '#collapsible' => FALSE,
675
      '#collapsed' => FALSE,
676
      '#tree' => TRUE,
677
      '#description' => 'The Distribution filter offers the following options
678
      <ul>
679
      <li><strong>Status order preference rule:</strong> In case of multiple distribution status (PresenceAbsenceTermBase) for the same area the status with the highest order is preferred, see OrderedTermBase.compareTo(OrderedTermBase).</li>
680
      <li><strong>Sub area preference rule:</strong>If there is an area with a direct sub area and both areas have the same computed status only the information on the sub area should be reported, whereas the super area should be ignored.</li>
681
      <li><strong>Marked area filter:</strong>Skip distributions where the area has a Marker with one of the specified MarkerTypes</li>
682
      </ul>'
683
  );
684

  
685
  $cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
686
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['filter_rules'] = array(
687
      '#type' => 'checkboxes',
688
      '#title' => 'Filter rules',
689
      '#default_value' => $cdm_distribution_filter['filter_rules'],
690
      '#options' => array(
691
          'statusOrderPreference' => 'Status order preference rule',
692
          'subAreaPreference' => 'Sub area preference rule'
693
      ),
694
  );
695

  
696
  $marker_type_options = cdm_terms_as_options( cdm_ws_fetch_all('term', array('class' => 'MarkerType' )) );
697
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['hideMarkedAreas'] = array(
698
      '#type' => 'checkboxes',
699
      '#title' => 'Hide marked area filter',
700
      '#default_value' => $cdm_distribution_filter['hideMarkedAreas'],
701
      '#options' => $marker_type_options,
702
      '#description' => 'Check one or more MarkerTypes to define the "hide marked area" filter .',
703
  );
704

  
649 705
  $form['aggregation'] = array(
650 706
      '#type' => 'fieldset',
651 707
      '#title' => t('Aggregation of data'),
652 708
      '#collapsible' => FALSE,
653
      '#description' => t("This section covers the different aspects of aggregating information.
709
      '#description' => 'This section covers the different aspects of aggregating information.
654 710
          <p>
655
          </p>"),
656

  
711
          </p>',
657 712
  );
658 713

  
659 714
  $form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
87 87
         */
88 88
        if ($node->feature->uuid == UUID_DISTRIBUTION) {
89 89

  
90
          // FIXME cdm_description_elements_prefer_computed() is deprecated and must be replaced by a REST service call wich will retrieve all distribution elements
90 91
          $node->descriptionElements = cdm_description_elements_prefer_computed($node->descriptionElements);
91 92

  
92 93
          if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
......
947 948
  }
948 949

  
949 950
  // Getting the sortered distributions (omitting level ??).
950
  $request_params = array();
951
  $request_params = cdm_distribution_filter_query();
951 952
  $request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
952 953
  $ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',', $descriptions_uuids), queryString($request_params));
953 954
  if (isset($ordered_areas->rootElement->children)) {
......
1080 1081
  $out; }
1081 1082
*/
1082 1083

  
1083
/**
1084
 * Composes the render array for a distribution map of the given taxon.
1085
 *
1086
 * The distribution map can either be a plain image or a dynamic open layers map
1087
 * depending on the settings.
1088
 *
1089
 * compose_hook() implementation
1090
 *
1091
 * @param $taxon
1092
 *   The CDM Taxon instance to create the distribution map for.
1093
 * @return array
1094
 *    A drupal render array
1095
 *
1096
 * Similar compose function compose_map()
1097
 *
1098
 * @ingroup compose
1099
 */
1100
function compose_distribution_map($taxon) {
1101

  
1102
  $out = '';
1103
  $settings = get_edit_map_service_settings();
1104

  
1105
  $fontStyles = array(
1106
    0 => "plane",
1107
    1 => "italic",
1108
  );
1109

  
1110
  // Query cdm server for map service uri parameters.
1111
  $query_string = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
1112
  $query_string = $query_string->String;
1113
  $out .= "<!-- map_data_parameters:" . print_r($query_string, TRUE) . " -->";
1114
  if (!$query_string) {
1115
    // The $query_string is empty if there are no distribution areas defined.
1116
    return;
1117
  }
1118

  
1119
  /* ------ choose the display mode, either openlayers or static image ------ */
1120

  
1121
  $map_settings = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
1122

  
1123
  if ($map_settings['map_type'] == 1) {
1124

  
1125
    /* =========== display distributions using the openlayers map viewer =========== */
1126

  
1127
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png"
1128
         . "&TRANSPARENT=TRUE"
1129
         . "&WIDTH=" . $map_settings['legend']['icon_width']
1130
         . "&HEIGHT=" . $map_settings['legend']['icon_height']
1131
           // TODO why is the layer=topp:tdwg_level_4 parameter needed at all here??
1132
           // AK: i think the tdwg_level_4 is used as place holder and will be replaced later on
1133
           // => search for "tdwg_level_4" in the code
1134
         . "&layer=topp" . urlencode(':') . "tdwg_level_4"
1135
         . "&LEGEND_OPTIONS=forceLabels" . urlencode(':') . "on"
1136
             . ";fontStyle" . urlencode(':') . $fontStyles[$map_settings['legend']['font_style']]
1137
             . ";fontSize" . urlencode(':') .  $map_settings['legend']['font_size']
1138
         . "&SLD=";
1139

  
1140
    $out .= get_openlayers_map(
1141
        $map_settings['width'],
1142
        $map_settings['height'],
1143
        $map_settings['bbox'],
1144
        NULL,
1145
        $query_string,
1146
        $legendFormatQueryStr,
1147
        $map_settings['caption']
1148
     );
1149
  }
1150
  else {
1151
    $legendFormatQueryStr = '';
1152
    $out = get_image_map(
1153
        $map_settings['width'],
1154
        $map_settings['height'],
1155
        $map_settings['bbox'],
1156
        NULL,
1157
        $query_string,
1158
        $legendFormatQueryStr,
1159
        $map_settings['caption']
1160
    );
1161
  }
1162
  return markup_to_render_array($out);
1163
}
1164

  
1165 1084
/**
1166 1085
 * Returns a list of a specific type of IdentificationKeys.
1167 1086
 *

Also available in: Unified diff