GetSelectedFeatures.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. Lib::loadClass('FeatureAttrSelected');
  3. Lib::loadClass('FeatureAttrContextSelected');
  4. class Api_Process_P5_GetSelectedFeatures { // TODO: extends Api_ProcessBase
  5. static function run($args, $responseForm) {
  6. DBG::log($args, 'array', "Run WPS Process 'p5:getSelectedFeatures'");
  7. $typeName = (!empty($args['typeName'][0])) ? $args['typeName'][0] : '';
  8. if (!$typeName) throw new Api_OwsException("Missing value for 'typeName'", 501, null, 'MissingParameterValue', 'request');
  9. $listPrimaryKeys = (!empty($args['primaryKey'])) ? $args['primaryKey'] : [];
  10. if (empty($listPrimaryKeys)) throw new Api_OwsException("Missing value for 'primaryKey'", 501, null, 'MissingParameterValue', 'request');
  11. $context = (!empty($args['context'])) ? $args['context'][0] : '';
  12. if (!empty($context)) {
  13. $idContext = (is_numeric($context)) ? $context : FeatureAttrContextSelected::getIdContext($context);
  14. DBG::log($args, 'array', "Run WPS Process 'p5:getSelectedFeatures' with context '{$context}' (ID: {$idContext})");
  15. $listSelectedState = FeatureAttrContextSelected::getSelectState($idContext, $typeName, $listPrimaryKeys);
  16. $totalSelected = FeatureAttrContextSelected::getTotalSelected($idContext, $typeName);
  17. } else {
  18. $listSelectedState = FeatureAttrSelected::getSelectState($typeName, $listPrimaryKeys);
  19. $totalSelected = FeatureAttrSelected::getTotalSelected($typeName);
  20. }
  21. header('Content-Type: application/json');
  22. echo json_encode([
  23. 'type' => "success",
  24. 'msg' => "done",
  25. 'body' => [
  26. 'selected' => $listSelectedState,
  27. 'totalSelected' => $totalSelected,
  28. ]
  29. ]);
  30. exit;
  31. }
  32. }