wreasy 于 2016.01.20 11:21 提问

4个回答

91program      2016.01.20 12:01
caozhy      2016.01.20 11:35

John_ToStr   2016.01.23 16:06

gischenjun04   2016.01.29 21:17

long CVectorToGrid::RegionNumber(int regionx,int regiony)
{
return (long)regiony*Cols+regionx;
}
int CVectorToGrid::RealRegionX(double X)
{
return (X-FullExtent.Left)/CellSize;
}
int CVectorToGrid::RealRegionY(double Y)
{
return (FullExtent.Top-Y)/CellSize;
}
int CVectorToGrid::RegionX(double X)
{
int x=(X-FullExtent.Left)/CellSize;
if(x x=0;
else if(x>=Cols)
x=Cols-1;
return x;
}
int CVectorToGrid::RegionY(double Y)
{
int y=(FullExtent.Top-Y)/CellSize;
if(y y=0;
else if(y>=Rows)
y=Rows-1;
return y;
}
void CVectorToGrid::ConvertRing(IPoints*pnts,IMemFourValueArray*pArray)
{
double XMin,YMin,XMax,YMax;
IEnvelope*ext;
pnts->get_Envelope(&ext);
ext->GetCoord(&XMin,&YMax,&XMax,&YMin);
ext->Release();
int RegionX1=RealRegionX(XMin);
int RegionY1=RealRegionY(YMax);
int RegionX2=RealRegionX(XMax);
int RegionY2=RealRegionY(YMin);
double X1,Y1,X2,Y2;
long RegionN;
int rx1,rx2,ry1,ry2,j,min;
LONG ptCount;
pnts->get_Count(&ptCount);
if(ptCount pnts->GetItem(0,&X1,&Y1);
rx1=RealRegionX(X1);ry1=RealRegionY(Y1);
double InterX;
double centery;
double lx=FullExtent.Left+CellSize*RegionX1;
double rx=FullExtent.Left+CellSize*(RegionX2+1);
int leftr;
int FormerY;
int FormerDeri=0;
bool IsIntersect;
int V;
float fV;
for(long k=1;k {
if(k==ptCount-1)
pnts->GetItem(0,&X2,&Y2);
else
pnts->GetItem(k,&X2,&Y2);
rx2=RealRegionX(X2);ry2=RealRegionY(Y2);
if(Y1>Y2)
{
if((FormerDeri==1)&&(FormerY>=ry1)) ry1=FormerY+1;
double r=(X2-X1)/(Y2-Y1);
for(int p=ry1;p<=ry2;p++)
{
centery=FullExtent.Top-CellSize/2-p*CellSize;
IsIntersect=false;
if((centery>=Y2-DifFuzzy)&&(centery<=Y1+DifFuzzy))
{
FormerY=p;
FormerDeri=1;
IsIntersect=true;
InterX=r*(centery-Y1)+X1;
}
if((IsIntersect)&&(p>=0)&&(p<=Rows-1))
{
leftr=RealRegionX(InterX);
if(InterX>FullExtent.Left+CellSize/2+CellSize*leftr)
{
leftr++;
}
if(leftr>0)
{
RegionN=RegionNumber(max(RegionX1,0),p);
min=min(leftr,Cols);
for(j=max(RegionX1,0);j {
pArray->get_ValueAsFloat(RegionN,&fV);
V=(int)fV-1;
if(V pArray->put_ValueAsFloat(RegionN,V);
RegionN++;
}
}
if(leftr if(leftr {
RegionN=RegionNumber(leftr,p);
min=min(RegionX2,Cols-1);
for(j=leftr;j {
pArray->get_ValueAsFloat(RegionN,&fV);
V=(int)fV+1;
if(V>3) V-=4;
pArray->put_ValueAsFloat(RegionN,V);
RegionN++;
}
}
}
}
}
else if(Y1 {
if((FormerDeri==-1)&&(FormerY double r=(X2-X1)/(Y2-Y1);
for(int p=ry1;p>=ry2;p--)
{
centery=FullExtent.Top-CellSize/2-p*CellSize;
IsIntersect=false;
if((centery>=Y1-DifFuzzy)&&(centery<=Y2+DifFuzzy))
{
FormerY=p;
FormerDeri=-1;
IsIntersect=true;
InterX=r*(centery-Y1)+X1;
}
if((IsIntersect)&&(p>=0)&&(p<=Rows-1))
{
leftr=RealRegionX(InterX);
if(InterX>FullExtent.Left+CellSize/2+CellSize*leftr)
{
leftr++;
}
if(leftr>0)
{
RegionN=RegionNumber(max(RegionX1,0),p);
min=min(leftr,Cols);
for(j=max(RegionX1,0);j {
pArray->get_ValueAsFloat(RegionN,&fV);
V=(int)fV+1;
if(V>3) V-=4;
pArray->put_ValueAsFloat(RegionN,V);
RegionN++;
}
}
if(leftr if(leftr {
RegionN=RegionNumber(leftr,p);
min=min(RegionX2,Cols-1);
for(j=leftr;j {
pArray->get_ValueAsFloat(RegionN,&fV);
V=(int)fV-1;
if(V pArray->put_ValueAsFloat(RegionN,V);
RegionN++;
}
}
}
}
}
X1=X2;Y1=Y2;
rx1=rx2;ry1=ry2;
}
}