#include "graticulecreator.h" #include #include #include #include #include GraticuleCreator::GraticuleCreator(QString theOutputFileName, double theXIntervalDouble, double theYIntervalDouble) { std::cout << "GraticuleCreator constructor called with " << theOutputFileName << " for output file and " << theXIntervalDouble << "," << theYIntervalDouble << " for x,y interval " << std::endl; DBFHandle myDbfHandle; /* handle for dBase file */ SHPHandle myShapeHandle; /* handle for shape files .shx and .shp */ /* Open and prepare output files */ myDbfHandle = createDbf(theOutputFileName); myShapeHandle = createShapeFile(theOutputFileName); //test the write point routine.... //generatePoints(theInputFileName,myDbfHandle,myShapeHandle); generateGraticule(myDbfHandle,myShapeHandle,theXIntervalDouble,theYIntervalDouble); DBFClose( myDbfHandle ); SHPClose( myShapeHandle ); return; } /* DbfName need not include the file extension. */ DBFHandle GraticuleCreator::createDbf (QString theDbfName ) { DBFHandle myDbfHandle; //remove the path part of the dbf name QFileInfo myFileInfo( theDbfName ); QString myBaseString = myFileInfo.dirPath()+QString("/")+myFileInfo.baseName(); // excludes any extension //create the dbf myDbfHandle = DBFCreate( myBaseString+".dbf" ); //create an index field named after the base part of the file name DBFAddField( myDbfHandle, myBaseString+"_id", FTInteger, 11, 0 ); //create a second arbitary attribute field DBFAddField( myDbfHandle, "Date", FTString, 12, 0 ); //close the dbf DBFClose( myDbfHandle ); //reopen myDbfHandle = DBFOpen( myBaseString+".dbf", "r+b" ); //exit this fn giving return myDbfHandle; } SHPHandle GraticuleCreator::createShapeFile(QString theFileName ) { SHPHandle myShapeHandle; //myShapeHandle = SHPCreate(theFileName, SHPT_POINT ); myShapeHandle = SHPCreate(theFileName, SHPT_ARC ); return myShapeHandle; } void GraticuleCreator::writeDbfRecord (DBFHandle theDbfHandle, int theRecordIdInt, QString theLabel) { std::cerr << "writeDbfRecord : " << theRecordIdInt << " - " << theLabel; if (! DBFWriteIntegerAttribute(theDbfHandle, theRecordIdInt, 0, theRecordIdInt)) { std::cerr << "DBFWriteIntegerAttribute failed. : " << theRecordIdInt << " - " << theRecordIdInt << std::endl; //exit(ERR_DBFWRITEINTEGERATTRIBUTE); } if (theLabel != NULL) { if (! DBFWriteStringAttribute(theDbfHandle, theRecordIdInt, 1, theLabel)) { std::cerr << "DBFWriteStringAttribute failed. : " << theRecordIdInt << " - " << theLabel <