📄 shape.cpp
字号:
#include <iostream>
#include <fstream>
#include "Shape.h"
using namespace std;
#define ZOOM_SIZE 0.1
#define ARRAY_NUMBER 10000
void readshape()
{
fstream binfile,boutfile;
int n_ShapeType=0;
int px=0;
boutfile.open("d:\\1.htm",ios::out);//打开要写的文件,并先写好其实标签.
boutfile<<"<HTML xmlns:v>"<<endl;
boutfile<<"<STYLE>v\\:*{behavior:url(#default#VML);}</STYLE>"<<endl;
boutfile<<"<BODY bgcolor=\"#eeeeee\">"<<endl;
binfile.open("D:\\work6\\Line.shp",ios::in|ios::binary);if (!binfile){cerr<<"error!";}//打开shp文件
binfile.seekg (32,ios::beg);
binfile.read ((char*)&n_ShapeType,4);
PolyLine Polyline_real;
for(int i=0;i<4;i++)
{binfile.read ((char*)&Polyline_real.Box[i],8);}
binfile.seekg(100,ios::beg);//已跳过mainfile文件头
switch (n_ShapeType)
{Point Point_real;
case 1:{
while (!binfile.eof())
{
boutfile<<"<v:polyline style=\"Z-INDEX:1;LEFT:"<<181+px++<<"px;POSITION:absolute;TOP:151px\" points=\"";
binfile.seekg(12,ios::cur);
binfile.read((char*)&Point_real.X,8);
binfile.read((char*)&Point_real.Y,8);
boutfile<<Point_real.X<<","<<Point_real.Y<<"\"";
boutfile<<"filled=\"f\" fillcolor=\"white\"/>"<<endl;
}
break;}
case 3:case 5:
{
while (!binfile.eof())
{
binfile.seekg(44,ios::cur);
binfile.read((char*)&Polyline_real.NumParts,4);
binfile.read((char*)&Polyline_real.NumPoints,4);
int n_Partbegin[ARRAY_NUMBER]={0};
binfile.read((char*)&n_Partbegin[0],4);
for (int i=0;i<Polyline_real.NumParts;i++)
{
if (i!=Polyline_real.NumParts-1)
binfile.read((char*)&n_Partbegin[i+1],4);
else n_Partbegin[i+1]=Polyline_real.NumPoints;
}
int k=0;
while(n_Partbegin[k+1])
{
boutfile<<"<v:polyline style=\"Z-INDEX:"<<1<<";LEFT:"<<Polyline_real.Box[1]*ZOOM_SIZE+300<<";POSITION:absolute;TOP:"<<Polyline_real.Box[3]*ZOOM_SIZE<<"\"points=\""<<endl;
for(int j=0;j<n_Partbegin[k+1]-n_Partbegin[k];j++)
{
binfile.read((char*)&Point_real.X,8);
binfile.read((char*)&Point_real.Y,8);
boutfile<<Point_real.X*ZOOM_SIZE<<","<<Point_real.Y*ZOOM_SIZE<<",";
}
boutfile<<"\"filled=\"t\" fillcolor=\"white\"/>"<<endl;
k++;
}
}
break;}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -