#include "simple_feature.h"

#include <fstream>		// for test output only
using std::ofstream;

int main()
{
	ofstream file("SimpleFeature.txt");

	CSimpleFeature	*SimpleFeature;
	SimpleFeature = new CSimpleFeature(conn, tablename.c_str());

	// test output to file SimpleFeature.txt
	file << "FeatureName: " << SimpleFeature->GetFeatureName() << endl;
	file << "TableCatalog: " << SimpleFeature->GetTableCatalog() << endl;
	file << "TableSchema: " << SimpleFeature->GetTableSchema() << endl;
	file << "GeometryColumnName: " << SimpleFeature->GetGeometryColumnName() << endl;
	file << "GeometryColumnNumber: " << SimpleFeature->GetGeometryColumnNumber() << endl;
	file << "CoordDimension: " << SimpleFeature->GetCoordDimension() << endl;
	file << "SRID: " << SimpleFeature->GetSRID() << endl;
	file << "SRID_asString: " << SimpleFeature->GetSRID_asString() << endl;
	file << "GeoType_asString: " << SimpleFeature->GetGeoType_asString() <<  endl;
	file << "GeoType: " << SimpleFeature->GetGeoType() << endl;
	file << "NN: " << SimpleFeature->GetNN() << endl;
	file << "SRID_PK: " << SimpleFeature->GetSRID_PK() << endl;
	file << "Auth_Name: " << SimpleFeature->GetAuth_Name() << endl;
	file << "Auth_SRID: " << SimpleFeature->GetAuth_SRID() << endl;
	file << "srText: " << SimpleFeature->GetsrText() << endl;
	file << "proj4text: " << SimpleFeature->Getproj4text() << endl << endl;
	file << "Feature Table Attributes" << endl;

	for (int col = 0; col < SimpleFeature->Get_ncols(); col++)
	{
		file << "ColumnName: " << SimpleFeature->GetFieldName(col);
		file << ",  ColumnType: " << SimpleFeature->GetFieldType(col);
		for (int row = 0; row < SimpleFeature->Get_nrows(); row++)
			file << ",  Value: " << SimpleFeature->GetValue(col,row) << endl;
	}

	file << endl;
	file << "Geometry Features" << endl;
	file << "Number of Features: " << SimpleFeature->GetNumFeatures() << endl;
	file << "Total Number of Points: " << SimpleFeature->GetTotalNumPoints() << endl;
	file << "WKT: " << SimpleFeature->GetWKT() << endl;
	file << "ETYPE: " << SimpleFeature->GetETYPE() << endl << endl;

	for (int feature = 0; feature < SimpleFeature->GetNumFeatures(); feature++)
	{
		file << "Feature Number: " << feature << endl;
		for (int point = 0; point < SimpleFeature->GetNumPointsFeature(feature); point++)
		{
			file << "x: " << SimpleFeature->Get_X_Value(feature,point);
			file << ",  y: " << SimpleFeature->Get_Y_Value(feature,point) << endl;
		}
	}

	return(0);
}