• 实现图像添加label


    void CmapwingisTest2View::OnToolsAddTiffLayer()

    {

             TCHAR szFilters[]= _T("TIFF Files (*.tif)|*.tif||");  

             CFileDialog fileDlg (TRUE,_T("tif"),_T("*.tif"),  

                       OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);  

             if( fileDlg.DoModal ()!=IDOK )   return;

             CString m_strFilePath = fileDlg.GetPathName();  

             if (_T("")!=m_strFilePath)  

             {  

                       // 先删除所有图层  

                       //m_map.RemoveAllLayers();  

                       // 获取后缀名判断文件是tif图像还是shp文件  

                       CString strExt = m_strFilePath.Right(3);  

                       if (_T("tif")==strExt)  

                       {  

                                // 创建图像接口打开图像加入地图  

                                mapWindow::IImagePtr pImage;  

                                pImage.CreateInstance(__uuidof(mapWindow::Image));  

                                pImage->Open(_bstr_t(m_strFilePath),mapWindow::USE_FILE_EXTENSION,TRUE,NULL);  

                                m_map.AddLayer(pImage,true);  

                                mapWindow::ILabelsPtr labels;

                                pImage->get_Labels( &labels );

                                labels->PutFontSize(12);

                                labels->PutFontBold(true);

                                labels->PutFontOutlineVisible(true);

                                labels->PutFontOutlineWidth(4);

                                mapWindow::ILabelCategoryPtr cat;

                                labels->AddCategory("Red");

                                //cat->PutFontColor(RGB(255,0,0));

                                mapWindow::IExtentsPtr ext = pImage->GetExtents();

                                double xmin,xmax,ymin,ymax;

                                ext->get_xMax(&xmax);

                                ext->get_xMin(&xmin);

                                ext->get_yMax(&ymax);

                                ext->get_yMin(&ymin);

                                double  xRange = xmax-xmin;

                                double  yRange = ymax-ymin;

                                CString str;

                                for (int i = 0; i < 100; i++)

                                {

                                         double x=xRange*(rand()%9)*0.1;

                                         double y=yRange* ( rand()%9 )/10.0;

                                         int categoryIndex = i % 3;

                                         str.Format("%d",i);(http://www.amjmh.com/v/BIBRGZ_558768/)

                                         labels->AddLabel( _bstr_t(str ),xmin+x,ymin+y,i*3.6,categoryIndex);

                                }

                     }

             }

             return;

    }

  • 相关阅读:
    生成一个uuid字符串,并去除多余的符号
    Jackson错误:Can not deserialize instance of java.lang.String out of START_OBJECT token
    jdk1.8换成11,启动项目报错java.net.MalformedURLException: unknown protocol: jrt
    RSA算法
    springboot集成thymeleaf中遇到不能反悔页面,只能反悔字符串
    Caused by: java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [VCodeModel]
    [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
    Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'phone' at row 1
    jstl是自动就有的吗,不是的Unknown tag (c:if).
    mysql 设置编码 Incorrect string value: 'xE9x98xBFxE4xB8x89...' for column 'cont,mysql乱码
  • 原文地址:https://www.cnblogs.com/ly570/p/11491438.html
Copyright © 2020-2023  润新知