gisempire100
捉鬼专家
捉鬼专家
  • 注册日期2004-08-13
  • 发帖数552
  • QQ
  • 铜币2462枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1689回复:1

SuperMap5.0平台点状符号数据导出与绘制

楼主#
更多 发布于:2008-01-04 16:58
SuperMap5.0中的资源有三种:符号库,线型库和填充库。即对应平常所说的点状符号,线状符号和面状符号。
<P>     其中点状符号对应着*.sym文件。符号编辑器提供了输出符号库的功能,即可将原始的点状符号文件导出成为ASCII码类型的*.smi文件。分析并读取此文件后,完成绘制功能,即可实现资源共享的目标。</P>
<P>     所需要注意的问题:</P>
<P >1)     颜色。Pen和Brush中颜色的记录方法不是通常直接的RGB颜色,需要进行转换。如Brush中的参数16711680对应蓝色,是在得到此数字后,将此十进制数据转换成十六进制字串FF0000,因为FF对应着十进制数字255,00依旧是十进制数字00,所以此字串对应着颜色BGR(255,0,0),与平时使用的RGB颜色的顺序刚好相反。</P>
<P >2)     Y轴的起点和方向,导出的文件数据中记录的Y轴起点在左上角,方向朝下,与某些系统中采用的Y轴起点在左下角,方向朝上是不同,所以处理时候采用变换:ynew = L – yold.</P>
<P >3)     ARC的数据结构。导出的文件Arc部分,往往记录着四组XY顶点对,第一和第二顶点对表示要提取的椭圆弧的起点和终点,以逆时针方向为准。第三和第四顶点对表示椭圆的长短轴端点,以此可确定椭圆的参数。<BR><BR><FONT face="Courier New"><FONT face="Courier New"></P>
<P>附参考代码:<BR> </P>
<P>void ExportSuperSymbol::AddSuperMapPolygon(Vertex2dVector ;PtList,COLORREF crPen,COLORREF crBrush)<BR>{<BR> m_iPolygonNumbers = m_iPolygonNumbers + 1;<BR> m_geoAtomPolygon =(geoatom::CGeoAtomPolygon**)realloc(m_geoAtomPolygon,m_iPolygonNumbers*sizeof(geoatom::CGeoAtomPolygon*));<BR> m_geoAtomPolygon[m_iPolygonNumbers-1] = new geoatom::CGeoAtomPolygon();  //原子分配内存,由于数组从0开始记数,标记总是比个数少1</P>
<P> for (int m=0;m<PtList.size();m++)<BR> {<BR>  m_geoAtomPolygon[m_iPolygonNumbers-1]->GetPtList()->add(m_fXaddition+m_iSize*PtList.get(m).x,m_fYaddition+m_fLength-m_iSize*PtList.get(m).y);<BR> }<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->SetColor(crPen);<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->SetFilledColor(crBrush);<BR> m_geoSymPoint[m_iPointSymbolNum-1]->AddAtom(m_geoAtomPolygon[m_iPolygonNumbers-1]); //将封闭区要素添加到这个符号中</P>
<P>}</P>
<P>void ExportSuperSymbol::AddSuperMapRectangle(double dLeftTopX,double dLeftTopY,double dRightBottomX,double dRightBottomY,COLORREF crPen,COLORREF crBrush)<BR>{<BR> ///为填充的Rectangle<BR> m_iPolygonNumbers = m_iPolygonNumbers + 1;       //矩形属于Polygon一种<BR> m_geoAtomPolygon =(geoatom::CGeoAtomPolygon**)realloc(m_geoAtomPolygon,m_iPolygonNumbers*sizeof(geoatom::CGeoAtomPolygon*));<BR> m_geoAtomPolygon[m_iPolygonNumbers-1] = new geoatom::CGeoAtomPolygon();  //原子分配内存,由于数组从0开始记数,标记总是比个数少1</P>
<P> //矩形的四个顶点<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->GetPtList()->add(m_fXaddition+m_iSize*dLeftTopX,m_fYaddition+m_fLength-m_iSize*dLeftTopY);<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->GetPtList()->add(m_fXaddition+m_iSize*dRightBottomX,m_fYaddition+m_fLength-m_iSize*dLeftTopY);<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->GetPtList()->add(m_fXaddition+m_iSize*dRightBottomX,m_fYaddition+m_fLength-m_iSize*dRightBottomY);<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->GetPtList()->add(m_fXaddition+m_iSize*dLeftTopX,m_fYaddition+m_fLength-m_iSize*dRightBottomY);</P>
<P> m_geoAtomPolygon[m_iPolygonNumbers-1]->SetColor(crPen);<BR> m_geoAtomPolygon[m_iPolygonNumbers-1]->SetFilledColor(crBrush);<BR> m_geoSymPoint[m_iPointSymbolNum-1]->AddAtom(m_geoAtomPolygon[m_iPolygonNumbers-1]); //将封闭区要素添加到这个符号中<BR>}</P>
<P>void ExportSuperSymbol::AddSuperMapEllipse(double dFirstX,double dFirstY,double dSecondX,double dSecondY,double dMajorRadio,double dMinorRadio,COLORREF crPen,COLORREF crBrush)<BR>{<BR> m_iEllipseNumbers = m_iEllipseNumbers + 1;<BR> m_geoAtomEllipse = (geoatom::CGeoAtomEllipse**)realloc(m_geoAtomEllipse,m_iEllipseNumbers*sizeof(geoatom::CGeoAtomEllipse));<BR> m_geoAtomEllipse[m_iEllipseNumbers-1] = new geoatom::CGeoAtomEllipse();</P>
<P> double dCenterX=0;    //圆心的位置<BR> double dCenterY=0;</P>
<P> if(dFirstX<dSecondX;;dFirstY<dSecondY)<BR> {<BR>  dCenterX = dFirstX+abs(dSecondX - dFirstX)/2;    //圆心的位置<BR>  dCenterY = dFirstY+abs(dSecondY - dFirstY)/2;<BR> }<BR> else if(dFirstX<dSecondX;;dFirstY>dSecondY)<BR> {<BR>  dCenterX = dFirstX+abs(dSecondX - dFirstX)/2;    //圆心的位置<BR>  dCenterY = dSecondY+abs(dSecondY - dFirstY)/2;<BR> }<BR> else if(dFirstX>dSecondX;;dFirstY<dSecondY)<BR> {<BR>  dCenterX = dSecondX+abs(dSecondX - dFirstX)/2;    //圆心的位置<BR>  dCenterY = dFirstY+abs(dSecondY - dFirstY)/2;<BR> }<BR> else<BR> {<BR>  dCenterX = dSecondX+abs(dSecondX - dFirstX)/2;    //圆心的位置<BR>  dCenterY = dSecondY+abs(dSecondY - dFirstY)/2;<BR> }</P>
<P> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetCenterPoint(m_fXaddition+m_iSize*dCenterX,m_fYaddition+m_fLength-m_iSize*dCenterY);<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMajorAxis(dMajorRadio*m_iSize);<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMinorAxis(dMinorRadio*m_iSize);<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(0.0);<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(6.2832);   //360角度与弧度的换算<BR> <BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetColor(crPen);<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetFilled(true);     //要求填充<BR> m_geoAtomEllipse[m_iEllipseNumbers-1]->SetFilledColor(crBrush);<BR> m_geoSymPoint[m_iPointSymbolNum-1]->AddAtom(m_geoAtomEllipse[m_iEllipseNumbers-1]);<BR>}</P>
<P>void ExportSuperSymbol::AddSuperMapArc(double dFirstX,double dFirstY,double dSecondX,double dSecondY,double dThirdX,double dThirdY,double dFourthX,double dFourthY,COLORREF crPen)<BR>{<BR> double dCenterX = 0;    <BR> double dCenterY = 0;<BR> if(abs(dFirstX-dThirdX)<0.00001;;abs(dFirstY-dThirdY)<0.00001 ;; abs(dSecondX-dFourthX)<0.00001;;abs(dSecondY-dFourthY)<0.00001)<BR> {    //此椭圆特殊化为四分只一<BR>  m_iEllipseNumbers = m_iEllipseNumbers + 1;<BR>  m_geoAtomEllipse = (geoatom::CGeoAtomEllipse**)realloc(m_geoAtomEllipse,m_iEllipseNumbers*sizeof(geoatom::CGeoAtomEllipse));<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1] = new geoatom::CGeoAtomEllipse();</P>
<P>  if(dFirstX>dSecondX)          //分情况讨论,好比四个象限<BR>  {<BR>   if(dFirstY>dSecondY)<BR>   {<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(0);  //0角度与弧度的换算,注意圆的旋转方向是逆或顺时针<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(1.5708);   //90角度与弧度的换算<BR>    dCenterX = dSecondX;         //取第二个点的X数值<BR>    dCenterY = dFirstY;          //取较大Y数值<BR>   }<BR>   else<BR>   {<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(1.5708);  //90角度与弧度的换算,注意圆的旋转方向是逆或顺时针<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(3.1416);   //180角度与弧度的换算<BR>    dCenterX = dFirstX;         //取第一个点的X数值<BR>    dCenterY = dSecondY;         //取较大Y数值<BR>   }<BR>  }<BR>  else<BR>  {<BR>   if(dFirstY<dSecondY)<BR>   {<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(3.1416);  //180角度与弧度的换算,注意圆的旋转方向是逆或顺时针<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(4.7124);   //270角度与弧度的换算<BR>    dCenterX = dSecondX;<BR>    dCenterY = dFirstY;             //取较小Y数值<BR>   }<BR>   else<BR>   {<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(4.7124);  //270角度与弧度的换算,注意圆的旋转方向是逆或顺时针<BR>    m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(6.2832);   //360角度与弧度的换算<BR>    dCenterX = dFirstX;<BR>    dCenterY = dSecondY;            //取较小Y数值<BR>   }<BR>  }<BR>  double dMajorRadio = 0;<BR>  double dMinorRadio = 0;<BR>  dMajorRadio = abs(dSecondX - dFirstX);    //得到半径<BR>  dMinorRadio = abs(dSecondY - dFirstY);</P>
<P>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetCenterPoint(m_fXaddition+m_iSize*dCenterX,m_fYaddition+m_fLength-m_iSize*dCenterY);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMajorAxis(dMajorRadio*m_iSize);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMinorAxis(dMinorRadio*m_iSize);</P>
<P>  m_geoSymPoint[m_iPointSymbolNum-1]->AddAtom(m_geoAtomEllipse[m_iEllipseNumbers-1]);     <BR> }<BR> else<BR> {        //给出长短轴端点和起终点的情况<BR>  m_iEllipseNumbers = m_iEllipseNumbers + 1;<BR>  m_geoAtomEllipse = (geoatom::CGeoAtomEllipse**)realloc(m_geoAtomEllipse,m_iEllipseNumbers*sizeof(geoatom::CGeoAtomEllipse));<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1] = new geoatom::CGeoAtomEllipse();</P>
<P>  <BR>  double dAngleStart = 0;<BR>  double dAngleEnd = 3.1416;    //单位为弧度,在函数库中角度均以弧度来表示</P>
<P>  if(dFirstX>dSecondX)     //比较起始点<BR>  {<BR>   if(dThirdX<dFourthX) <BR>   {<BR>    dCenterX = dFourthX;   //得到椭圆的中心<BR>    dCenterY = dThirdY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>   }<BR>   else if(dThirdX>dFourthX;;dThirdY<dFourthY)<BR>   {<BR>    dCenterX = dThirdX;<BR>    dCenterY = dFourthY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>    if(dFirstX>dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart;</P>
<P>    if(dFirstX == dCenterX) dAngleStart = 1.5708;<BR>    if(dFirstX<dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart + 3.1416;</P>
<P>    if(dSecondX<dCenterX;;dSecondY>dCenterY)  dAngleEnd = -dAngleEnd + 3.1416;<BR>    if(dSecondX<dCenterX;;dSecondY<=dCenterY) dAngleEnd = -dAngleEnd+3.1416;<BR>    if(dSecondX==dCenterX) dAngleStart = 3.1416;<BR>   }<BR>   else if(dThirdX>dFourthX;;dThirdY>dFourthY)<BR>   {<BR>    dCenterX = dFourthX;<BR>    dCenterY = dThirdY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>    if(dFirstX>=dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart;<BR>    if(dSecondX<dCenterX;;dSecondY<dCenterY) dAngleEnd = -dAngleEnd+3.1416;</P>
<P>   }<BR>   else<BR>   {<BR>    dCenterX = dThirdX;<BR>    dCenterY = dFourthY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>   }</P>
<P>  }<BR>  else          //dFirstX<dSecondX<BR>  {</P>
<P>   if(dThirdX<dFourthX;;dThirdY>dFourthY)<BR>   {<BR>    dCenterX = dThirdX;<BR>    dCenterY = dFourthY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));   //返回的结果在-1.5708与1.5708之间<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>    if(dFirstX<dCenterX;;dFirstY>dCenterY) dAngleStart = -dAngleStart+3.1416;<BR>    if(dSecondX>dCenterX;;dSecondY>dCenterY) dAngleEnd = - dAngleEnd + 6.2832;<BR>   }<BR>   else if(dThirdX<dFourthX;;dThirdY<dFourthY)<BR>   {<BR>    dCenterX = dFourthX;<BR>    dCenterY = dThirdY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));   //返回的结果在-1.5708与1.5708之间<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));</P>
<P>    if(dFirstX<dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart+3.1416;<BR>    if(dSecondX>=dCenterX;;dSecondY>dCenterY) dAngleEnd = - dAngleEnd + 6.2832;</P>
<P>   }<BR>   else if(dThirdX>dFourthX;;dThirdY<dFourthY)<BR>   {<BR>    dCenterX = dThirdX;<BR>    dCenterY = dFourthY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));<BR>    <BR>    if(dFirstX<dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart+3.1416;<BR>    if(dFirstX>dCenterX;;dFirstY<dCenterY) dAngleStart = -dAngleStart;<BR>    if(dSecondX>dCenterX;;dSecondY>dCenterY) dAngleEnd = - dAngleEnd + 6.2832;<BR>   }<BR>   else<BR>   {<BR>    dCenterX = dFourthX;<BR>    dCenterY = dThirdY;</P>
<P>    dAngleStart = atan((dFirstY - dCenterY)/(dFirstX - dCenterX));<BR>    dAngleEnd = atan((dSecondY - dCenterY)/(dSecondX - dCenterX));<BR>   }</P>
<P>  }</P>
<P>  double dMajorRadio = abs(dThirdX - dFourthX);  //通过第三和第四个点求得<BR>  double dMinorRadio = abs(dThirdY - dFourthY);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetStartAngleRad(dAngleStart);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetEndAngleRad(dAngleEnd);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetCenterPoint(m_fXaddition+m_iSize*dCenterX,m_fYaddition+m_fLength-m_iSize*dCenterY);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMajorAxis(dMajorRadio*m_iSize);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetMinorAxis(dMinorRadio*m_iSize);<BR>  m_geoAtomEllipse[m_iEllipseNumbers-1]->SetColor(crPen);<BR>  m_geoSymPoint[m_iPointSymbolNum-1]->AddAtom(m_geoAtomEllipse[m_iEllipseNumbers-1]);<BR> }<BR>}<BR><BR>附参考图:<BR><IMG src="http://www.cnblogs.com/images/cnblogs_com/wuhanhoutao/116501/r_SuperMAPSymbol1.jpg" border=0></FONT></P></FONT>
喜欢0 评分0
A friend is never known till a man has need. ...CL
engineerup
路人甲
路人甲
  • 注册日期2007-02-27
  • 发帖数129
  • QQ
  • 铜币450枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2008-01-04 21:29
<DIV>谢谢你的信息</DIV>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部