Delete 'shp_2_txt.cpp'

This commit is contained in:
zwnk 2019-05-31 22:01:30 +02:00
parent 12a377a9f2
commit 123539e10d
1 changed files with 0 additions and 68 deletions

View File

@ -1,68 +0,0 @@
/*
http://shapelib.maptools.org/dbf_api.html
basic funtionality taken from dbfdump.c
path to libshp.dll has to be added as a PATH var
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <fstream>
using namespace std;
#include "shapefil.h"
int main(int argc, char const *argv[])
{
DBFHandle dbfh;
int i, iRecord;
char *pszFilename = NULL;
int nWidth, nDecimals;
char szTitle[12];
string filename = "f:\\testing\\shp_2_txt\\MA.dbf";
// open textfile and dbf handle
ofstream txt_file("out.txt");
dbfh = DBFOpen(filename.c_str(), "rb");
// check
if (dbfh <= 0)
{
throw string("File " + filename + " not found");
}
else
{
// loop over dbf records
for( iRecord = 0; iRecord < DBFGetRecordCount(dbfh); iRecord++ )
{
// loop over fields of record
for( i = 0; i < DBFGetFieldCount(dbfh); i++ )
{
DBFFieldType eType;
eType = DBFGetFieldInfo( dbfh, i, szTitle, &nWidth, &nDecimals );
string dec_lat = "DEC_LAT";
string dec_lon = "DEC_LON";
string ellip_h = "ELLIP_HT";
string ortho_h = "ORTHO_HT";
string str(szTitle);
string line;
// parse for lat, lon in degrees and orhto height
if (szTitle == dec_lat or szTitle == dec_lon or szTitle == ortho_h)
{
txt_file << DBFReadStringAttribute( dbfh, iRecord, i );
txt_file << " ";
}
}
txt_file << endl;
}
// close dbf handle and textfile
DBFClose( dbfh );
txt_file.close();
}
return 0;
}