Dear Andrew
Thank you for your help !. This routine, works propertly with any coordinate system ?. I thouth mitab could have a method to obteing this but at any rate this is very usefull for me.
King Regards
Alejandro
"Canfield, Andrew" <[EMAIL PROTECTED]> escribió:
Is this what you are wanting to know?
int IsPtInPoly(Point dPtIn, std::vector< double > Xpts, std::vector< double > Ypts)
{
double Ax = dPtIn.x;
double Ay = dPtIn.y;
double Xl;
double Yl;
double Xr;
double Yr;
const double Fx = Xpts[0];
const double Fy = Ypts[0];
double Yc;
long lLoopCtrl = 0;
long lCrossings = 0;
double Xtemp;
double Ytemp;
//int intRes;
const int iNumEntry = Xpts.size();
for(lLoopCtrl = 0; lLoopCtrl < iNumEntry; )
{
Xl = Xpts[lLoopCtrl];
Yl= Ypts[lLoopCtrl];
if(!(lLoopCtrl + 1 > iNumEntry - 1))
{
Xr = Xpts[lLoopCtrl + 1];
Yr = Ypts[lLoopCtrl + 1];
}
else
{
Xr = Fx;
Yr = Fy;
}
if((Xl < Ax) && (Xr < Ax))
{
lLoopCtrl=lLoopCtrl + 1;
continue;
}
if((Xl > Ax) && (Xr > Ax))
{
lLoopCtrl=lLoopCtrl + 1;
continue;
}
if((Yl < Ay) && (Yr < Ay))
{
lLoopCtrl=lLoopCtrl + 1;
continue;
}
if(((Yl > Ay) && (Yr > Ay)) && ((Xl > Ax) || (Xr > Ax)))
{
lCrossings = lCrossings + 1;
lLoopCtrl=lLoopCtrl + 1;
continue;
}
if(Xl > Xr)
{
Xtemp = Xl;
Ytemp = Yl;
Xl = Xr;
Yl = Yr;
Xr = Xtemp;
Yr = Ytemp;
}
Yc = Yl + (((Yr - Yl) / (Xr - Xl)) * (Ax - Xl));
if(Yc > Ay)
{
lCrossings = lCrossings + 1;
}
lLoopCtrl=lLoopCtrl + 1;
}
return lCrossings & 1;
}
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of
sagent100
Sent: Friday, April 07, 2006 1:04 PM
To: [email protected]
Subject: [mitab] How to know if a point object is Within a polygon
Hi all!
Is it possible to know if a point object (x-y coordinates) is within a
polygon object ?
I will appreciate a lot an example using VB or in other case C.
Thanks !!
Alejandro
Yahoo! Groups Links
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
YAHOO! GROUPS LINKS
- Visit your group "mitab" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
