???shapefile???С??Χ???ε?c++????
???????????? ???????[ 2014/2/28 9:35:56 ] ????????c++ shapefile
// 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();
}
??????????????????£?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11