//---------------------------------------------------------
bool CVIEW_Map_Control::_Zoom(const wxPoint &A, const wxPoint &B)
{
	if( A.x == B.x && A.y == B.y )
	{
		return( _Zoom(_Get_Client2World(A), true) );
	}

	m_pMap->Set_Extent(CSG_Rect(_Get_Client2World(A), _Get_Client2World(B)));

	return( true );
}
//---------------------------------------------------------
void CWKSP_Shapes::_Edit_Snap_Point(CSG_Point Point, CSG_Point &snap_Point, double &snap_Dist, CSG_Shapes *pShapes, bool bLine)
{
	CSG_Shape	*pSelected	= pShapes->Get_Selection(m_Edit_Index);

	if( pShapes->Select(CSG_Rect(Point.Get_X() - snap_Dist, Point.Get_Y() - snap_Dist, Point.Get_X() + snap_Dist, Point.Get_Y() + snap_Dist)) )
	{
		for(int i=0; i<pShapes->Get_Selection_Count(); i++)
		{
			if( pShapes != Get_Shapes() || pSelected != pShapes->Get_Selection(i) )
			{
				if( bLine )
				{
					Edit_Snap_Point_ToLine(Point, snap_Point, snap_Dist, pShapes->Get_Selection(i));
				}
				else
				{
					_Edit_Snap_Point      (Point, snap_Point, snap_Dist, pShapes->Get_Selection(i));
				}
			}
		}
	}

	pShapes->Select(pSelected);
}
//---------------------------------------------------------
bool CGrid_Proximity::On_Execute(void)
{
	int				x, y;
	double			z, d;
	TSG_Point		p;
	CSG_Grid		*pFeatures, *pDistance, *pDirection, *pAllocation;
	CSG_PRQuadTree	Search;

	//-----------------------------------------------------
	pFeatures	= Parameters("FEATURES")	->asGrid();
	pDistance	= Parameters("DISTANCE")	->asGrid();
	pDirection	= Parameters("DIRECTION")	->asGrid();
	pAllocation	= Parameters("ALLOCATION")	->asGrid();

	//-----------------------------------------------------
	Process_Set_Text(_TL("preparing distance calculation..."));

	Search.Create(CSG_Rect(-1, -1, Get_NX(), Get_NY()));

	for(y=0; y<Get_NY() && Set_Progress(y); y++)
	{
		for(x=0; x<Get_NX(); x++)
		{
			if( pFeatures->is_NoData(x, y) )
			{
				pDistance->Set_Value(x, y, -1.0);
			}
			else
			{
				pDistance->Set_Value(x, y,  0.0);

				if( pDirection )
				{
					pDirection->Set_NoData(x, y);
				}

				if( pAllocation )
				{
					pAllocation->Set_Value(x, y, pFeatures->asDouble(x, y));
				}

				//-----------------------------------------
				bool	bBorder	= false;

				for(int i=0; i<8 && !bBorder; i++)
				{
					int	ix	= Get_xTo(i, x);
					int	iy	= Get_yTo(i, y);

					if( is_InGrid(ix, iy) && pFeatures->is_NoData(ix, iy) )
					{
						bBorder	= true;
					}
				}

				if( bBorder )
				{
					Search.Add_Point(x, y, pFeatures->asDouble(x, y));
				}
			}
		}
	}

	if( !Search.is_Okay() || Search.Get_Point_Count() <= 0 || Search.Get_Point_Count() >= Get_NCells() )
	{
		Message_Add(_TL("no features to buffer."));

		return( false );
	}

	//-----------------------------------------------------
	Process_Set_Text(_TL("performing distance calculation..."));

	for(y=0; y<Get_NY() && Set_Progress(y); y++)
	{
		for(x=0; x<Get_NX(); x++)
		{
			if( pDistance->asDouble(x, y) < 0.0 && Search.Get_Nearest_Point(x, y, p, z, d) )
			{
				pDistance->Set_Value(x, y, d * Get_Cellsize());

				if( pDirection )
				{
					if( d > 0.0 )
					{
						pDirection->Set_Value(x, y, SG_Get_Angle_Of_Direction(x, y, p.x, p.y) * M_RAD_TO_DEG);
					}
					else
					{
						pDirection->Set_NoData(x, y);
					}
				}

				if( pAllocation )
				{
					pAllocation->Set_Value(x, y, z);
				}
			}
		}
	}

	//-----------------------------------------------------
	return( true );
}
Exemple #4
0
//---------------------------------------------------------
bool CSG_Rects::Add(double xMin, double yMin, double xMax, double yMax)
{
	return( Add(CSG_Rect(xMin, yMin, xMax, yMax)) );
}
Exemple #5
0
//---------------------------------------------------------
bool CSG_Rects::Add(void)
{
	return( Add(CSG_Rect()) );
}
Exemple #6
0
//---------------------------------------------------------
void CGrid_Gaps_Spline_Fill::Close_Gap(void)
{
	int				i, j;
	CSG_PRQuadTree	Search(CSG_Rect(0, 0, Get_NX(), Get_NY()));

	for(i=0; i<m_Spline.Get_Point_Count(); i++)
	{
		TSG_Point_Z	p	= m_Spline.Get_Points().Get_Point(i);

		Search.Add_Point(p.x, p.y, p.z);
	}

	for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
	{
		TSG_Point_Int	p	= m_GapCells[i];

		m_Spline.Destroy();

		for(j=0; j<4; j++)
		{
			Search.Select_Nearest_Points(p.x, p.y, m_nPoints_Local, m_Radius, j);

			for(int k=0; k<Search.Get_Selected_Count(); k++)
			{
				double	x, y, z;

				Search.Get_Selected_Point(k, x, y, z);

				m_Spline.Add_Point(x, y, z);
			}
		}

		if( m_Spline.Create(m_Relaxation, true) )
		{
			m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
		}
	}

/*	for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
	{
		TSG_Point_Int	p	= m_GapCells[i];

		if( Search.Select_Nearest_Points(p.x, p.y, m_nPoints_Local, m_Radius, m_Radius > 0 ? -1 : 4) > 2 )
		{
			m_Spline.Set_Point_Count(Search.Get_Selected_Count());

			for(j=0; j<m_Spline.Get_Point_Count(); j++)
			{
				double	x, y, z;

				Search.Get_Selected_Point(j, x, y, z);

				m_Spline.Set_Point(j, x, y, z);
			}

			if( m_Spline.Create(m_Relaxation, true) )
			{
				m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
			}
		}
	}/**/

/*	m_Spline.Set_Point_Count(m_nPoints_Local);

	for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
	{
		TSG_Point_Int	p	= m_GapCells[i];

		if( Search.Select_Nearest_Points(p.x, p.y, m_Spline.Get_Point_Count()) == m_Spline.Get_Point_Count() )
		{
			for(j=0; j<m_Spline.Get_Point_Count(); j++)
			{
				double	x, y, z;

				Search.Get_Selected_Point(j, x, y, z);

				m_Spline.Set_Point(j, x, y, z);
			}

			if( m_Spline.Create(m_Relaxation, true) )
			{
				m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
			}
		}
	}/**/
}