Get actual X,Y values from MapPolygon
Posted: Mon Apr 26, 2010 6:18 pm
Hi,
I created a Polygon for MapSeries using Lat/Long and tried to retrieve X,Y positions of vertex to get extent of polygon.
And I generated a function as follows. But the X,Y values using GetX() function gave pixel value rather than actual Lat/Long values.
It seems that it is possible if I use ITChartPtr where tPolygon belongs to, then the actual values can be retrieved by using IAxis.
But I don't want to use ITChartPtr in this function.
Is there anyboy who have an idea about this matter?
Thank you in advance.
Dalshin
BOOL TChartConfig::GetExtentOfPolygon(IMapPolygonPtr tPolygon, MapExtent &PolygonExtent)
{
IPointArrayPtr vertexPts = tPolygon->GetPoints;
if(vertexPts->Count==0) return FALSE;
double dXmax=0, dXmin=1.0E+300;
double dYmax=0, dYmin=1.0E+300;
for(int i=0; i<vertexPts->Count; i++)
{
if(vertexPts->Item->GetX() > dXmax) dXmax = vertexPts->Item->GetX();
if(vertexPts->Item->GetX() < dXmin) dXmin = vertexPts->Item->GetX();
if(vertexPts->Item->GetY() > dYmax) dYmax = vertexPts->Item->GetY();
if(vertexPts->Item->GetY() < dYmin) dYmin = vertexPts->Item->GetY();
}
PolygonExtent.XMax = dXmax;
PolygonExtent.XMin = dXmin;
PolygonExtent.YMax = dYmax;
PolygonExtent.YMin = dYmin;
// do quality check of Extent
return TRUE;
}
I created a Polygon for MapSeries using Lat/Long and tried to retrieve X,Y positions of vertex to get extent of polygon.
And I generated a function as follows. But the X,Y values using GetX() function gave pixel value rather than actual Lat/Long values.
It seems that it is possible if I use ITChartPtr where tPolygon belongs to, then the actual values can be retrieved by using IAxis.
But I don't want to use ITChartPtr in this function.
Is there anyboy who have an idea about this matter?
Thank you in advance.
Dalshin
BOOL TChartConfig::GetExtentOfPolygon(IMapPolygonPtr tPolygon, MapExtent &PolygonExtent)
{
IPointArrayPtr vertexPts = tPolygon->GetPoints;
if(vertexPts->Count==0) return FALSE;
double dXmax=0, dXmin=1.0E+300;
double dYmax=0, dYmin=1.0E+300;
for(int i=0; i<vertexPts->Count; i++)
{
if(vertexPts->Item->GetX() > dXmax) dXmax = vertexPts->Item->GetX();
if(vertexPts->Item->GetX() < dXmin) dXmin = vertexPts->Item->GetX();
if(vertexPts->Item->GetY() > dYmax) dYmax = vertexPts->Item->GetY();
if(vertexPts->Item->GetY() < dYmin) dYmin = vertexPts->Item->GetY();
}
PolygonExtent.XMax = dXmax;
PolygonExtent.XMin = dXmin;
PolygonExtent.YMax = dYmax;
PolygonExtent.YMin = dYmin;
// do quality check of Extent
return TRUE;
}