67 int CSG_Grid_System::m_Precision = 16;
77 m_Precision = Decimals;
79 return( m_Precision );
90 return( m_Precision );
107 Create(System, Precision);
113 Create(Cellsize, Extent, Precision);
119 Create(Cellsize, xMin, yMin, xMax, yMax, Precision);
125 Create(Cellsize, xMin, yMin, NX, NY, Precision);
149 m_NCells = System.m_NCells;
151 m_Cellsize = System.m_Cellsize;
152 m_Cellarea = System.m_Cellarea;
153 m_Diagonal = System.m_Diagonal;
155 m_Extent = System.m_Extent;
156 m_Extent_Cells = System.m_Extent_Cells;
166 int nx = 1 + (int)(0.5 + Extent.
Get_XRange() / Cellsize);
167 int ny = 1 + (int)(0.5 + Extent.
Get_YRange() / Cellsize);
172 return(
Create(Cellsize, x, y, nx, ny, Precision) );
183 return(
Create(Cellsize,
CSG_Rect(xMin, yMin, xMax, yMax), Precision) );
189 if( Cellsize > 0. && NX > 0 && NY > 0 )
191 Cellsize =
SG_Get_Rounded(Cellsize, Precision == -1 ? m_Precision : Precision);
192 xMin =
SG_Get_Rounded(xMin , Precision == -1 ? m_Precision : Precision);
193 yMin =
SG_Get_Rounded(yMin , Precision == -1 ? m_Precision : Precision);
199 m_NCells = (
sLong)NY * NX;
201 m_Cellsize = Cellsize;
202 m_Cellarea = Cellsize * Cellsize;
203 m_Diagonal = Cellsize * sqrt(2.);
205 m_Extent.
xMin = xMin;
206 m_Extent.
yMin = yMin;
207 m_Extent.
xMax = xMin + (NX - 1.) * Cellsize;
208 m_Extent.
yMax = yMin + (NY - 1.) * Cellsize;
210 m_Extent_Cells = m_Extent;
211 m_Extent_Cells.
Inflate(0.5 * Cellsize,
false);
233 m_Extent .
Create(0., 0., 0., 0.);
234 m_Extent_Cells.
Create(0., 0., 0., 0.);
241 {
return(
Create(System) ); }
244 {
return(
Create(Cellsize, Extent) ); }
247 {
return(
Create(Cellsize, xMin, yMin, xMax, yMax) ); }
250 {
return(
Create(Cellsize, xMin, yMin, NX, NY) ); }
260 return( m_Cellsize > 0. && m_NX > 0 && m_NY > 0 );
270 m_Name.
Printf(
"%.*f; %dx %dy; %.*fx %.*fy",
279 m_Name.
Printf(
"%s: %f, %s: %dx/%dy, %s: %fx/%fy",
288 m_Name =
_TL(
"<not set>");
315 return(
is_Equal(System) ==
false );
326 return( m_Cellsize == System.m_Cellsize
327 && m_NX == System.m_NX
328 && m_NY == System.m_NY
329 && m_Extent.
xMin == System.m_Extent.
xMin
330 && m_Extent.
yMin == System.m_Extent.
yMin
337 return( m_Cellsize == Cellsize && m_Extent == Extent );
399 Parameters.
Add_Choice(Parent,
"KERNEL_TYPE",
_TL(
"Kernel Type"),
400 _TL(
"The kernel's shape."),
413 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_INNER" ,
_TL(
"Inner Radius"), Unit_Radius, 0., 0.,
true);
416 Parameters .
Add_Double(
"KERNEL_TYPE",
"KERNEL_RADIUS",
_TL(
"Radius"), Unit_Radius, 1., 0.,
true);
422 Parameters.
Add_Int (
"KERNEL_TYPE",
"KERNEL_INNER" ,
_TL(
"Inner Radius"), Unit_Radius, 0 , 0 ,
true);
425 Parameters .
Add_Int (
"KERNEL_TYPE",
"KERNEL_RADIUS",
_TL(
"Radius"), Unit_Radius, 2 , 0 ,
true);
431 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_DIRECTION",
_TL(
"Direction"),
_TL(
"degree"), 0., -360.,
true, 360.,
true);
432 Parameters.
Add_Double(
"KERNEL_TYPE",
"KERNEL_TOLERANCE",
_TL(
"Tolerance"),
_TL(
"degree"), 5., 0.,
true, 180.,
true);
438 Parameters(
"KERNEL_TYPE")->is_Enabled() ?
CSG_String(
"KERNEL_TYPE") : Parent
448 if( Type == 0 && Parameters(
"KERNEL_TYPE") )
450 Parameters(
"KERNEL_TYPE")->asChoice()->Get_Data(Type);
457 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
463 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
469 Parameters(
"KERNEL_INNER" )->
asDouble(),
470 Parameters(
"KERNEL_RADIUS" )->
asDouble()
475 Parameters(
"KERNEL_RADIUS" )->
asDouble(),
498 if( Parameters(
"KERNEL_TYPE") )
500 int Type = Parameters(
"KERNEL_TYPE")->asChoice()->Get_Item_Data(Parameters(
"KERNEL_TYPE")->
asInt()).asInt();
518 bool CSG_Grid_Cell_Addressor::_Set_Kernel(
int Type,
double Radius,
double Radius_Inner,
double Direction,
double Tolerance)
524 m_Radius_0 = Radius_Inner;
525 m_Direction = fmod(Direction,
M_PI_360);
if( Direction < 0. ) Direction +=
M_PI_360;
526 m_Tolerance = fmod(Tolerance,
M_PI_180);
if( Tolerance < 0. ) Tolerance +=
M_PI_180;
528 if( m_Radius < 0. || m_Radius < m_Radius_0 )
537 Sector[0] = fmod(Direction - Tolerance,
M_PI_360);
if( Sector[0] < 0. ) Sector[0] +=
M_PI_360;
538 Sector[1] = fmod(Direction + Tolerance,
M_PI_360);
if( Sector[1] < 0. ) Sector[1] +=
M_PI_360;
542 #define ADD_CELL(x, y, Distance) {\
543 CSG_Table_Record &Cell = *Kernel.Add_Record();\
544 Cell.Set_Value(0, x);\
545 Cell.Set_Value(1, y);\
546 Cell.Set_Value(2, Distance);\
547 Cell.Set_Value(3, m_Weighting.Get_Weight(d));\
552 int Size = (int)ceil(m_Radius);
555 for(
int y=-Size; y<=Size; y++)
557 if( abs(y) > m_Radius )
560 for(
int x=-Size; x<=Size; x++)
562 if( abs(x) > m_Radius )
581 if( d <= m_Radius && d >= m_Radius_0 )
598 if( Kernel.Get_Count() < 1 )
605 for(
int i=0; i<Kernel.Get_Count(); i++)
607 m_Kernel.
Add_Record(Kernel.Get_Record_byIndex(i));
622 return( _Set_Kernel(0, Radius, 0., 0., 0.) );
628 return( _Set_Kernel(1, Radius, 0., 0., 0.) );
634 return( _Set_Kernel(2, Radius_Outer, Radius_Inner, 0., 0.) );
640 return( _Set_Kernel(3, Radius, 0., Direction, Tolerance) );