|
NXPlanetLayerCompositesHitTest Method
|
화면에 도시된 XDMComposite 중에서 특정 위치에 Hitting 되는 가장 상위의 XDMComposite 를 가져온다.(Planet2D 모드에서만 가능하다.)
Namespace: Pixoneer.NXDL.NXPlanetAssembly: NXPlanet (in NXPlanet.dll) Version: 3.0.0.0
Syntaxpublic bool HitTest(
XVertex3d vWorld,
ref XDMComposite pHitComp
)
Parameters
- vWorld XVertex3d
- 테스트를 위한 월드 좌표(위경도 또는 WebMercator 좌표)
- pHitComp XDMComposite
- [out] Hitting 되는 최상위 XDMComposite
Return Value
Boolean성공이면 true, 실패하면 false를 반환한다.
Example
예제 #1: 컨트롤 화면을 클릭할 시 화면에 도시된 XDMComposite들 중 해당 위치에 Hitting 되는 가장 상위의 XDMComposite 를 가져온다.
using Pixoneer.NXDL;
using Pixoneer.NXDL.NXPlanet;
using Pixoneer.NXDL.NRS;
using Pixoneer.NXDL.NIO;
namespace XDL_PlanetView
{
public partial class MainWindow : Window
{
public XRasterIO RasterIO;
public MainWindow()
{
InitializeComponent();
nxPlanetView1.MouseDown += NxPlanetView1_MouseDown;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
RasterIO = new XRasterIO();
String StrError;
if (RasterIO.Initialize(out StrError) == false)
{
MessageBox.Show(StrError);
}
String strFilePathLoad1 = "C:\\Pixoneer\\PG-STEAMER 5.0\\data\\IKONOS.xdm";
String strFilePathLoad2 = "C:\\Pixoneer\\PG-STEAMER 5.0\\data\\DEM.xdm";
XRSLoadFile xrsFileInput1 = new XRSLoadFile();
XRSLoadFile xrsFileInput2 = new XRSLoadFile();
xrsFileInput1 = RasterIO.LoadFile(strFilePathLoad2, out StrError, false, eIOCreateXLDMode.All_NoMsg);
xrsFileInput2 = RasterIO.LoadFile(strFilePathLoad1, out StrError, false, eIOCreateXLDMode.All_NoMsg);
if (xrsFileInput1 == null && xrsFileInput2 == null) return;
XDMComposite newComp1 = CreateComposite(xrsFileInput1, 0, 1, 2);
XDMComposite newComp2 = CreateComposite(xrsFileInput2, 0, 1, 2);
XDMCompManager xdmCompManager = nxPlanetLayerComposites1.GetXDMCompManager();
nxPlanetLayerComposites1.Lock();
xdmCompManager.AddXDMComposite(ref newComp1);
xdmCompManager.AddXDMComposite(ref newComp2);
nxPlanetLayerComposites1.ZoomFit();
nxPlanetLayerComposites1.Invalidate();
nxPlanetLayerComposites1.UnLock();
nxPlanetView1.RefreshScreen();
nxPlanetView1.SetCameraPosition(XGeoPoint.FromDegree(127.37, 36.37, 50000), XAngle.FromDegree(0));
}
private void NxPlanetView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
XDMComposite newComp = null;
if (nxPlanetView1.Planet2DProjection == NXPlanetView.ePlanet2DProjection.EEC)
{
XGeoPoint geoPos = nxPlanetView1.ScreenToGeographic(e.X, e.Y);
XVertex3d vtPos = new XVertex3d(geoPos.lond, geoPos.latd, geoPos.hgt);
nxPlanetLayerComposites1.HitTest(vtPos, ref newComp);
}
else if (nxPlanetView1.Planet2DProjection == NXPlanetView.ePlanet2DProjection.WebMercator)
{
XVertex3d mercatorPos = nxPlanetView1.ScreenToWorld(e.X, e.Y);
nxPlanetLayerComposites1.HitTest(mercatorPos, ref newComp);
}
if (newComp != null && !string.IsNullOrEmpty(newComp.Name))
{
System.Windows.MessageBox.Show($"선택된 Composite 이름: {newComp.Name}\n모드: {newComp.Mode}");
}
else
{
System.Windows.MessageBox.Show("해당 위치에 Composite가 없습니다.");
}
}
XDMComposite CreateComposite(XRSLoadFile xrsFileInput, int nBandIdx0, int nBandIdx1, int nBandIdx2)
{
XDMComposite newComp = new XDMComposite();
int nNumBand = xrsFileInput.NumBand;
if (nNumBand < 3)
{
XDMBand band = xrsFileInput.GetBandAt(0);
newComp.Name = band.BandName;
newComp.Mode = eCompMode.Gray;
newComp.SetBand(ref band, 0);
newComp.SetCutType(eCompCutType.Ct95, 0);
newComp.SetStretchCoverage(eCompStretchCoverage.Band, 0);
newComp.SetStretchType(eCompStretchType.Gaussian, 0);
}
else
{
XDMBand band1 = xrsFileInput.GetBandAt(0);
XDMBand band2 = xrsFileInput.GetBandAt(1);
XDMBand band3 = xrsFileInput.GetBandAt(2);
newComp.Name = xrsFileInput.FileName;
newComp.Mode = eCompMode.RGB;
newComp.SetBand(ref band3, nBandIdx0);
newComp.SetBand(ref band2, nBandIdx1);
newComp.SetBand(ref band1, nBandIdx2);
for (int i = 0; i < 3; i++)
{
newComp.SetCutType(eCompCutType.Ct95, i);
newComp.SetStretchCoverage(eCompStretchCoverage.Band, i);
newComp.SetStretchType(eCompStretchType.Gaussian, i);
}
}
return newComp;
}
private void Window_Closed(object sender, EventArgs e)
{
Xfn.Close();
}
}
See Also