??????????????shapefile???С??Χ?е?c++??????????????????shapefile?????????????ζ???????????????.dbf?? .exe?? .png????????????????λ?????????????????????????????????????????????????????????????
???????shapefile?洢????????????Ρ?ESRI shapfile???????3 ???????????shp?? .shx ??.dbf??????????????м??????ε?С??Χ???????????shp??????????ο?ESRI Shapefile?????????? .shp ??3???????????????????????????????????????????С??Χ?е?????????????C++??????????????????????????
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <cstdint>
using namespace std;
class ByteConverter
{
public:
//??BigEndian????洢??32??λ???????????????λ???????????????磺??????λ?????
static int32_t bigEndianIntRead(char *fileBuf?? int startIndex)
{
return (((fileBuf[startIndex+0]&0xff)<<24)|
((fileBuf[startIndex+1]&0xff)<<16)|
((fileBuf[startIndex+2]&0xff)<<8)|
((fileBuf[startIndex+3]&0xff)));
}
// ??BigEndian????洢??32λ????????????
static int32_t littleEndianIntRead(char *fileBuf?? int startIndex)
{
return (((fileBuf[startIndex+3]&0xff)<<24)|
((fileBuf[startIndex+2]&0xff)<<16)|
((fileBuf[startIndex+1]&0xff)<<8)|
((fileBuf[startIndex+0]&0xff)));
}
// ??BigEndian????洢??64λ??8?????????????
static double littleEndianDoubleRead(char *fileBuf?? int startIndex)
{
double convert;
char *add;
int j;
add = new char();
j=-1;
for (int i=startIndex; i<startIndex+8; i++)
{
j++;
add[j] = fileBuf[i];
}
convert = *reinterpret_cast<double *const>(add);
return convert;
}
};