Esempio n. 1
0
   int getRasterLayerStatistics(Layer* pLayer, uint32_t channel,
                                uint32_t component, struct RasterStatistics* pStatistics)
   {
      RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer);
      RasterChannelType chan(static_cast<RasterChannelTypeEnum>(channel));
      ComplexComponent comp(static_cast<ComplexComponentEnum>(component));
      if (pRaster == NULL || pStatistics == NULL || !chan.isValid() || !comp.isValid())
      {
         setLastError(SIMPLE_BAD_PARAMS);
         return 1;
      }
      Statistics* pStats = pRaster->getStatistics(chan);
      if (pStats == NULL || !pStats->areStatisticsCalculated(comp))
      {
         setLastError(SIMPLE_OTHER_FAILURE);
         return 1;
      }
      pStatistics->min = pStats->getMin(comp);
      pStatistics->max = pStats->getMax(comp);
      pStatistics->mean = pStats->getAverage(comp);
      pStatistics->stddev = pStats->getStandardDeviation(comp);
      const double* pTmp = NULL;
      const unsigned int* pTmp2 = NULL;
      pStats->getHistogram(pTmp, pTmp2, comp);
      pStatistics->pHistogramCenters = const_cast<double*>(pTmp);
      pStatistics->pHistogramCounts = const_cast<unsigned int*>(pTmp2);
      pStatistics->pPercentiles = const_cast<double*>(pStats->getPercentiles(comp));
      pStatistics->resolution = pStats->getStatisticsResolution();

      setLastError(SIMPLE_NO_ERROR);
      return 0;
   }