Home > Software engineering >  Turn on recursive optimization or iteration, can have a great spirit guide?
Turn on recursive optimization or iteration, can have a great spirit guide?

Time:09-23

Recent projects using recursive tiles map, local figure high level and no pictures at the next lower level, the efficiency of the recursive becomes quite slow, need a card for a long time to react, consider the code to do optimization, try to iteration, found that there are not that easy, there are a great god can guide the experience in this respect? Be very grateful! In only 100 points, and thank you!!!!!
The following is a source code, for the convenience of reading, saves some irrelevant things:
Void CDrawImageDrawer: : drawImages (int iHdc, double dLeft, double dTop, double dRight, double dBottom, int iZoom)
{
If (iZoom & lt; 0)
{
return;
}

IImageSource * pImageSource=m_imageSourceMap [m_curImageSource];
If (pImageSource - & gt; _bNeedCheckSource)
{
PImageSource - & gt; _bNeedCheckSource=false;
CheckImageSourceIsExsit ();
}

if(! PImageSource - & gt; _bExsitImageSource)
{
return;
}

MapServerDiskImageSource * pMapServerDiskImageSource=0;

IImageSource: : IMAGESOURCE_TYPE imageType=pImageSource - & gt; GetType ();
The switch (imageType)
{
Case IImageSource: : IMAGESOURCE_TYPE_MapServerDisk:
{
PMapServerDiskImageSource=(MapServerDiskImageSource *) pImageSource;
break;
}
}

//draw
Int minX=long2tilex (dLeft iZoom);
Int minY=lat2tiley (dTop iZoom);
Int maxX=long2tilex (dRight, iZoom);
Int maxY=lat2tiley (dBottom iZoom);

For (int I=minX; i <=maxX; + + I)
{
For (int j=minY; J & lt;=maxY; + + j)
{
Double dImageLeft=tilex2long (I, iZoom);
Double dImageTop=tiley2lat (j, iZoom);
Double dImageRight=tilex2long (I + 1, iZoom);
Double dImageBottom=tiley2lat (j + 1, iZoom);

//use the current layer image map
Bool bIsValid=false;
If (pMapServerDiskImageSource)
{
//use the memory the bitmap to draw
If (m_memoryImage [iZoom] isValid ())
{
Int iLDest=0;
Int iRDest=0;
Int iTDest=0;
Int iBDest=0;
IGF_Display * pDisplay=m_pMain - & gt; GetDisplayPtr ();
IGIS_SpatialReference * pSpatialReferenceBJ54=m_pSpatialReferenceFactory - & gt; GetPredefinedSpatialReferenceByIndex (GIS_BJ54_SPATIALREFERENCE_INDEX);
PDisplay - & gt; WorldToClient ((int) (dImageLeft * m_xyScale), (int) (dImageTop * m_xyScale), & amp; ILDest, & amp; ITDest pSpatialReferenceBJ54);
PDisplay - & gt; WorldToClient ((int) (dImageRight * m_xyScale), (int) (dImageBottom * m_xyScale), & amp; IRDest, & amp; IBDest pSpatialReferenceBJ54);
PSpatialReferenceBJ54 - & gt; Release ();

BIsValid=m_memoryImage [iZoom] drawMemoryToScreen (iHdc iZoom, I, j, iLDest, iTDest, iRDest, iBDest);
}

//to draw from the file
if(! BIsValid)
{
//if (tileIsInRangeEx (I, j, iZoom) | | pMapServerDiskImageSource - & gt; _levelRange. Empty ())
{
Char imagePath [512]={0};
Sprintf_s (imagePath, "% s", pMapServerDiskImageSource - & gt; _imageDirectory. C_str ());
BIsValid=drawImageFromFileEx (iHdc, imagePath, dImageLeft dImageTop, dImageRight, dImageBottom, pMapServerDiskImageSource - & gt; _bImageEncrypt pMapServerDiskImageSource - & gt; _dSaturation iZoom, I, j);
}
}
}

If (iZoom 1 & lt; 0)
{
continue;
}

//use the pictures on a layer of paint
if(! BIsValid)
{
/* if (iZoom==m_iRealZoom & amp; &
M_memoryImage [iZoom - 1]. IsValid ()) */
If (m_memoryImage [iZoom - 1]. IsValid ())
{
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
7 8 | | | 1 | | |
| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - |
| | | | | | | |
-- -- -- -- -- - | -- - -- -- -- -- -- -- -- -- -- -- - | -- -- -- -- -- --
| |
-- -- -- -- -- - | -- - | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
| | | memory bitmap area | | | | |
4 | | 3 | | | | | | 9
| | | | | | | |
-- -- -- -- -- - | -- - | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- - | -- - -- -- -- -- -- -- -- -- -- -- - | -- -- -- -- -- --
| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - |
2 6 | | | | | | 5
| | | | | |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
//use the bitmap to draw on a layer of memory
DrawImageFromMemory (iHdc dImageLeft, dImageTop dImageRight, dImageBottom, iZoom - 1);

Double dLeftEx=0;
Double dTopEx=0;
Double dRightEx=0;
Double dBottomEx=0;
M_memoryImage [iZoom - 1]. GetZXYValidRange (dLeftEx dTopEx, dRightEx, dBottomEx);
Bool bLTInRect=ptInRect (dImageLeft dImageTop, dLeftEx, dTopEx, dRightEx, dBottomEx);
Bool bRTInRect=ptInRect (dImageRight dImageTop, dLeftEx, dTopEx, dRightEx, dBottomEx);
Bool bLBInRect=ptInRect (dImageLeft dImageBottom, dLeftEx, dTopEx, dRightEx, dBottomEx);
Bool bRBInRect=ptInRect (dImageRight dImageBottom, dLeftEx, dTopEx, dRightEx, dBottomEx);
//1. The lower left corner points and the lower right corner in
If (bLBInRect & amp; & BRBInRect & amp; & ! BLTInRect & amp; & ! BRTInRect)
{
DrawImages (iHdc dImageLeft, dImageTop dImageRight, m_dTop, (iZoom - 1));
}
//2. The upper left corner points and the upper right corner of the two points in a
Else if (bLTInRect & amp; & BRTInRect & amp; & ! BLBInRect & amp; & ! BRBInRect)
{
DrawImages (iHdc dImageLeft, m_dBottom dImageRight, dImageBottom, (iZoom - 1));
}
//,,,
}
The else
{
DrawImages (iHdc dImageLeft, dImageTop dImageRight, dImageBottom, (iZoom - 1));
}
}
nullnullnullnullnullnullnullnull
  • Related