1
0
Fork 0

Don't crash when area type is unknown

This commit is contained in:
Frederic Bouvier 2009-03-14 14:35:53 +01:00 committed by Ralf Gerlich
parent 0518643893
commit 379f629611

View file

@ -200,8 +200,14 @@ string get_shapefile_type(DBFHandle& hDBF, int rec) {
#endif
string area = DBFReadStringAttribute( hDBF, rec, area_column );
string code = DBFReadStringAttribute( hDBF, rec, code_column );
const char *v = DBFReadStringAttribute( hDBF, rec, area_column );
if ( v == 0 )
return "";
string area = v;
string code;
v = DBFReadStringAttribute( hDBF, rec, code_column );
if ( v != 0 )
code = v;
cout << "next record = " << code << endl;
// strip leading spaces
@ -814,6 +820,11 @@ int main( int argc, char **argv ) {
if ( force_area_type.length() == 0 ) {
area = get_shapefile_type(hDBF, i);
SG_LOG( SG_GENERAL, SG_DEBUG, " area type = " << area);
if ( area.empty() )
{
area = "Default";
SG_LOG( SG_GENERAL, SG_ALERT, "No area type specified" );
}
} else {
area = force_area_type;
}