// shapefile ???????????????shapefile?????????ε????
class HeaderShapefile
{
public:
// ???????????????shapefile???Χ???????
// ??x??y??С???????z??m???С????????
static double dimensionXmin(char *fileBuf?? int startIndex)
{
return ByteConverter::littleEndianDoubleRead(fileBuf??startIndex);
}
static double dimensionYmin(char*fileBuf?? int startIndex)
{
return ByteConverter::littleEndianDoubleRead(fileBuf?? startIndex);
}
static double dimensionXmax(char*fileBuf?? int startIndex)
{
return ByteConverter::littleEndianDoubleRead(fileBuf?? startIndex);
}
static double dimensionYmax(char*fileBuf?? int startIndex)
{
return ByteConverter::littleEndianDoubleRead(fileBuf?? startIndex);
}
};
class SizeOfFile
{
public:
// ?????????С
static long sizeOfFile(FILE *file)
{
long a??b;
a = ftell(file);
fseek(file?? 0?? 2);
b = ftell(file);
fseek(file?? 1?? 0);
return b;
}
};
int main()
{
int32_t filecodes?? fileLength??shapeTypes??versions;
double xmin??ymin??xmax??ymax??mmin??mmax??zmin??zmax;
string shape;
char *filePath = "?????????";
char *fileBuf;
FILE *file = NULL;
//rb???????????????????????????????????
if ((file=fopen(filePath??"rb"))==NULL)
{
cout <<"???????????"<<endl;
}
else
cout <<"???????????"<<endl;
// ????????С
long fileSize = SizeOfFile::sizeOfFile(file);
// ???????????????
fileBuf = new char[fileSize];
//????????????????
fread(fileBuf?? fileSize?? 1?? file);
//????????????????
cout<< "?????С??"<< fileSize;
xmin = HeaderShapefile::dimensionXmin(fileBuf??36);
ymin = HeaderShapefile::dimensionYmin(fileBuf??44);
xmax = HeaderShapefile::dimensionXmax(fileBuf??52);
ymax = HeaderShapefile::dimensionYmax(fileBuf??60);
cout<<" /*************
shapefile???°?Χ??***********/ ";
cout<<"XС?="<<xmin<<endl;
cout<<"YС?="<<ymin<<endl;
cout<<"X???="<<xmax<<endl;
cout<<"Y???="<<ymax<<endl;
cin.get();
delete []fileBuf;
fclose(file);// ???????
return 0;
//char keep_window_open = getchar();
}
??????????????????£?