error fixed
This commit is contained in:
parent
a3c6e5ce7c
commit
86fd7f7886
6 changed files with 7342 additions and 7025 deletions
|
@ -1,4 +1,9 @@
|
|||
/*
|
||||
The program is based on:
|
||||
https://groups.google.com/forum/#!topic/lastools/kfYP00fzYtI
|
||||
|
||||
It extracts the NGS points to XYZ text file.
|
||||
|
||||
http://shapelib.maptools.org/dbf_api.html
|
||||
|
||||
basic funtionality taken from dbfdump.c
|
||||
|
@ -16,13 +21,16 @@ using namespace std;
|
|||
#include "shapefil.h"
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{ string dbf_filename;
|
||||
{
|
||||
string dbf_filename;
|
||||
string txt_filename;
|
||||
if (argc == 1)
|
||||
{
|
||||
// no arguments given, print help
|
||||
cout << "No input and output files defined!" << endl;
|
||||
cout << "example: shp_2_txt -i MA.dbf -o MA.txt" << endl;
|
||||
cout << "example: shp_2_txt -i MA.dbf" << endl;
|
||||
cout << "It will output a text file with the same name" << endl;
|
||||
cout << "and inside the dbf file folder." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,19 +44,28 @@ int main(int argc, char const *argv[])
|
|||
else if (strcmp(argv[i],"-i") == 0)
|
||||
{
|
||||
dbf_filename = argv[i + 1];
|
||||
|
||||
}
|
||||
else if (strcmp(argv[i],"-o") == 0 )
|
||||
{
|
||||
txt_filename = argv[i + 1];
|
||||
}
|
||||
// else if (strcmp(argv[i],"-o") == 0 )
|
||||
// {
|
||||
// txt_filename = argv[i + 1];
|
||||
// }
|
||||
}
|
||||
|
||||
DBFHandle dbfh;
|
||||
int i, iRecord;
|
||||
char szTitle[12];
|
||||
int nWidth, nDecimals;
|
||||
|
||||
cout << dbf_filename << " " << txt_filename << endl;
|
||||
if (dbf_filename.find("dbf"))
|
||||
{
|
||||
txt_filename = dbf_filename.substr(0, dbf_filename.find("dbf")) + "txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cout << endl << "A Simple program to extract NGS points from dbf files." << endl;
|
||||
cout << endl << "Extracting info from " << dbf_filename << " to " << txt_filename << endl;
|
||||
|
||||
// open textfile and dbf handle
|
||||
ofstream txt_file(txt_filename);
|
||||
|
@ -66,15 +83,19 @@ int main(int argc, char const *argv[])
|
|||
{
|
||||
// loop over fields of record
|
||||
for( i = 0; i < DBFGetFieldCount(dbfh); i++ )
|
||||
{
|
||||
// DBFFieldType eType;
|
||||
// eType = DBFGetFieldInfo( dbfh, i, szTitle, &nWidth, &nDecimals );
|
||||
{
|
||||
// get field information
|
||||
DBFFieldType eType;
|
||||
eType = DBFGetFieldInfo( dbfh, i, szTitle, &nWidth, &nDecimals );
|
||||
|
||||
// parser values
|
||||
string dec_lat = "DEC_LAT";
|
||||
string dec_lon = "DEC_LON";
|
||||
string ellip_h = "ELLIP_HT";
|
||||
string ortho_h = "ORTHO_HT";
|
||||
|
||||
// char to string for matching
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue