76 Create(pTable, Field, Normalize, bPercent);
88 m_pObject = NULL; m_nValues = 0; m_Field = -1; m_Normalized.Destroy(); m_bPercent =
false;
135 if( pTable && Field >= 0 && Field < pTable->Get_Field_Count() )
137 if( Normalize >= 0 && Normalize < pTable->Get_Field_Count() )
143 double Value, Divisor;
145 if( pTable->
Get_Value(i, Normalize, Divisor) && Divisor && pTable->
Get_Value(i, Field, Value) )
147 m_Normalized.Add_Record()->Set_Value(0, Value / Divisor);
151 m_pObject = &m_Normalized; m_Field = 0; m_nValues = m_Normalized.Get_Count(); m_bPercent = bPercent;
155 m_pObject = pTable; m_Field = Field; m_nValues = pTable->
Get_Count();
180 _TL(
"Unique Values" ),
181 _TL(
"Equal Interval" ),
182 _TL(
"Defined Interval" ),
184 _TL(
"Geometric Interval"),
185 _TL(
"Natural Breaks" ),
186 _TL(
"Standard Deviation"),
187 _TL(
"Manual Interval" )
201 if( !
is_Okay() || m_Classes.Get_Count() < 1 )
212 for(
int i=0; i<m_Classes.Get_Count(); i++)
221 #define VALUE2STRING(value) (m_bPercent ? SG_Get_String(100. * value, NumPrecision) : SG_Get_String(value, NumPrecision))
223 double Minimum = m_Classes[i].asDouble(0);
224 double Maximum = m_Classes[i].asDouble(1);
231 if( m_bPercent ) {
Name +=
" %"; }
250 if( m_pObject->Get_Max_Samples()
251 && ((m_pObject->asTable(
true) && m_pObject->Get_Max_Samples() < m_pObject->asTable(
true)->Get_Count ())
252 || (m_pObject->asGrid (
true) && m_pObject->Get_Max_Samples() < m_pObject->asGrid (
true)->Get_NCells())
253 || (m_pObject->asGrids(
true) && m_pObject->Get_Max_Samples() < m_pObject->asGrids(
true)->Get_NCells())) )
255 double Minimum = m_Classes[0].asDouble(0),
Maximum = m_Classes[m_Classes.Get_Count() - 1].asDouble(1);
262 const double Epsilon = 1.e-012;
double Maximum = m_Classes[m_Classes.Get_Count() - 1].asDouble(1);
277bool CSG_Map_Classify::_is_Numeric(
void)
const
283bool CSG_Map_Classify::_Create_Classes(
void)
296 return( m_pObject && m_nValues > 0 );
300inline bool CSG_Map_Classify::_Set_Progress(
sLong i)
const
311inline bool CSG_Map_Classify::_Get_Value(
sLong i,
double &Value,
bool bIndexed)
const
317 if( i < m_pObject->asTable(
true)->Get_Count() )
319 return( m_pObject->asTable(
true)->Get_Value(bIndexed ? m_pObject->asTable(
true)->Get_Index(i) : i, m_Field, Value) );
323 if( m_pObject->asGrid() )
325 if( i < m_pObject->asGrid ()->Get_NCells() )
327 if( bIndexed ) { i = m_pObject->asGrid ()->Get_Sorted(i,
false,
false); }
329 if( !m_pObject->asGrid ()->is_NoData(i) )
331 Value = m_pObject->asGrid ()->asDouble(i);
338 if( m_pObject->asGrids() )
340 if( i < m_pObject->asGrids()->Get_NCells() )
342 if( bIndexed ) { i = m_pObject->asGrids()->Get_Sorted(i,
false,
false); }
344 if( !m_pObject->asGrids()->is_NoData(i) )
346 Value = m_pObject->asGrids()->asDouble(i);
358inline bool CSG_Map_Classify::_Get_Value(
sLong i,
CSG_String &Value,
bool bIndexed)
const
360 return( m_Field >= 0 && m_pObject->asTable(
true)->Get_Value(bIndexed ? m_pObject->asTable(
true)->Get_Index(i) : i, m_Field, Value) );
368 Statistics = m_pObject->asTable(
true)->Get_Statistics(m_Field);
370 else if( m_pObject->asGrid () )
372 Statistics = m_pObject->asGrid ()->Get_Statistics();
374 else if( m_pObject->asGrids() )
376 Statistics = m_pObject->asGrids()->Get_Statistics();
383bool CSG_Map_Classify::_Get_Histogram(
CSG_Histogram &Histogram)
const
387 Histogram = m_pObject->asTable(
true)->Get_Histogram(m_Field);
389 else if( m_pObject->asGrid () )
391 Histogram = m_pObject->asGrid ()->Get_Histogram();
393 else if( m_pObject->asGrids() )
395 Histogram = m_pObject->asGrids()->Get_Histogram();
402bool CSG_Map_Classify::_Set_Index(
void)
406 return( m_pObject->asTable(
true)->Set_Index(m_Field) );
408 else if( m_pObject->asGrid () )
410 return( m_pObject->asGrid ()->Set_Index() );
412 else if( m_pObject->asGrids() )
414 return( m_pObject->asGrids()->Set_Index() );
438 for(
sLong i=0; i<m_nValues && Statistics.
Get_Count()<=maxCount && _Set_Progress(i); i++)
440 double Value;
if( _Get_Value(i, Value) ) { Statistics += Value; }
445 for(
int i=0; i<Statistics.
Get_Count(); i++)
459 for(
sLong i=0; i<m_nValues && Statistics.
Get_Count()<=maxCount && _Set_Progress(i); i++)
461 CSG_String Value;
if( _Get_Value(i, Value) ) { Statistics += Value; }
466 for(
int i=0; i<Statistics.
Get_Count(); i++)
478 return( m_Classes.Get_Count() > 0 );
489 if( Count < 1 || _Minimum >= _Maximum )
496 double Maximum = _Minimum, Interval = (_Maximum - _Minimum) / Count;
498 for(
int i=0; i<Count; i++)
534 Interval /= 100.; Offset /= 100.;
537 if( Interval <= 0. || !_Get_Statistics(Statistics) || Offset >= Statistics.
Get_Maximum() )
581 if( m_nValues < Count )
583 Count = (int)m_nValues;
592 if( _Get_Histogram(Histogram) )
598 for(
int i=0; i<Count; i++)
617 if( _Set_Index() && _Get_Statistics(Statistics) )
621 for(
int i=0; i<Count; i++)
623 double Value,
Quantile = (1. + i) / (
double)Count;
625 if( _Get_Value((
sLong)(
Quantile * (m_nValues - 1)), Value,
true) )
644 return( m_Classes.Get_Count() > 0 );
657 if( Count < 1 || !_Get_Statistics(Statistics) || !Statistics.
Get_Range() )
664 double k = (log(1. + Statistics.
Get_Range())) / Count;
668 for(
int i=0; i<Count; i++)
671 ? (Statistics.
Get_Minimum() + (exp(k * (
double)( i + 1)) - 1.))
672 : (Statistics.
Get_Maximum() - (exp(k * (
double)(Count - i - 1)) - 1.));
703 Breaks.
Create(m_pObject->asTable(
true), m_Field, Count, m_nValues > 4096 ? 256 : 0);
705 else if( m_pObject->asGrid () )
707 Breaks.
Create(m_pObject->asGrid (), Count, m_nValues > 4096 ? 256 : 0);
709 else if( m_pObject->asGrids() )
711 Breaks.
Create(m_pObject->asGrids(), Count, m_nValues > 4096 ? 256 : 0);
725 for(
int i=0; i<Count; i++)
749 if(
StdDev <= 0. || !_Get_Statistics(Statistics) )
bool SG_UI_Process_Set_Progress(int Position, int Range)
bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
bool Set_Count(int nColors)
class CSG_Grids * asGrids(bool bPolymorph=false) const
class CSG_Grid * asGrid(bool bPolymorph=false) const
class CSG_Table * asTable(bool bPolymorph=false) const
sLong Get_NCells(void) const
sLong Get_NCells(void) const
const CSG_Simple_Statistics & Get_Statistics(void) const
size_t Get_Class_Count(void) const
double Get_Quantile(double Quantile) const
bool Classify_StdDev(double StdDev, double StdDev_Max=4.)
bool Classify_Unique(int maxCount=1024)
bool Classify_Equal(int Count, double Minimum, double Maximum)
bool Set_LUT(CSG_Table &LUT, CSG_Colors Colors, int Labeling, int NumPrecision=-2) const
const CSG_String & Get_Name(Classifier Classifier) const
bool Classify_Defined(double Interval, double Offset)
bool Create(CSG_Data_Object *pObject)
virtual ~CSG_Map_Classify(void)
bool Classify_Geometric(int Count, bool bIncreasing=true)
bool Classify_Quantile(int Count, bool bHistogram=true)
bool Classify_Natural(int Count)
bool Create(class CSG_Table *pTable, int Field, int nClasses, int Histogram=0)
int Get_Count(void) const
sLong Get_Count(void) const
bool Set_Value(int Field, const CSG_String &Value)
virtual bool Set_Value(sLong Index, int Field, const SG_Char *Value)
sLong Get_Count(void) const
virtual bool Del_Records(void)
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
TSG_Data_Type Get_Field_Type(int Field) const
virtual bool Set_Field_Type(int Field, TSG_Data_Type Type)
double Get_Value(int Index) const
const SG_Char * Get_Value(int Index) const
int Get_Count(void) const
#define VALUE2STRING(value)