Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: C++ DrawPolygon problem?

$
0
0
Hello!
If the decision of this task interests someone else?
I solved this problem.
It is necessary to transfer to the DrawPolygonEx method VARIANT* to pvarVal;//VT_BYREF|VT_VARIANT.
"A pointer to another VARIANTARG is passed in pvarVal. This referenced VARIANTARG, pvarVal, cannot be another VT_VARIANT|VT_BYREF. This value can be used to support languages that allow functions to change the types of variables passed by reference."

Example:
USES_CONVERSION;
    
            long num_points = sAttribute->points.size();

            SAFEARRAY * vDataX = SafeArrayCreateVector(VT_R8,  0,  num_points); 
            SAFEARRAY * vDataY = SafeArrayCreateVector(VT_R8,  0,   num_points); 
            if(vDataX == NULL || vDataY == NULL) 
                return;

        
            SafeArrayLock(vDataX);
            SafeArrayLock(vDataY);

            for(long i = 0 ;i<num_points;i++)
            {
                double x_proj ;
                double y_proj ;
                m_AxMap.m_MapPtr->DegreesToProj(sAttribute->points[i].Y, sAttribute->points[i].X,&x_proj,&y_proj);


                SafeArrayPutElement(vDataX, &i, (void*)&x_proj);
                SafeArrayPutElement(vDataY, &i, (void*)&y_proj);
        
            }
            
            SafeArrayUnlock(vDataX);
            SafeArrayUnlock(vDataY);
            
            VARIANT vX;
            VARIANT vY;
            vX.vt =  VT_BYREF|VT_ARRAY;
            vY.vt =  VT_BYREF|VT_ARRAY;
            vX.pparray = &(vDataX);
            vY.pparray = &(vDataY);
            
          
            m_AxMap.m_MapPtr->DrawPolygonEx(drawHandle,vX.pvarVal ,vY.pvarVal, num_points,  233,true);


            SafeArrayDestroy(vDataX);
            SafeArrayDestroy(vDataY);

            VariantClear(&vX);
            VariantClear(&vY);
Yours faithfully, Vitaly.

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>