|
From: <ai...@us...> - 2013-11-27 06:09:51
|
Revision: 12758
http://sourceforge.net/p/plplot/code/12758
Author: airwin
Date: 2013-11-27 06:09:46 +0000 (Wed, 27 Nov 2013)
Log Message:
-----------
Use an approach suggested by Frank Warmerdam <war...@po...>,
the developer of shapelib to quiet the misleading "Unable to open"
error messages generated by shapelib due to our method of
searching several directories until the shapelib routine SHPOpenLL
returns a non-NULL result indicating shapelib has found shapefiles
with the correct basename.
Tested by Alan W. Irwin <ai...@us...> with variants
of the final CustomErrors to prove this function was being called
and was correctly suppressing "Unable to open" error messages.
Modified Paths:
--------------
trunk/src/plmap.c
Modified: trunk/src/plmap.c
===================================================================
--- trunk/src/plmap.c 2013-11-26 20:59:05 UTC (rev 12757)
+++ trunk/src/plmap.c 2013-11-27 06:09:46 UTC (rev 12758)
@@ -50,6 +50,9 @@
SHPHandle
OpenShapeFile( const char *fn );
+static void
+CustomErrors(const char *message);
+
#endif
//--------------------------------------------------------------------------
@@ -470,19 +473,32 @@
//! found
//--------------------------------------------------------------------------
#ifdef HAVE_SHAPELIB
+// Our thanks to Frank Warmerdam, the developer of shapelib for suggesting
+// this approach for quieting shapelib "Unable to open" error messages.
+static
+void CustomErrors(const char *message)
+{
+ if (strstr(message,"Unable to open") == NULL)
+ fprintf( stderr, "%s\n", message );
+}
+
SHPHandle
OpenShapeFile( const char *fn )
{
SHPHandle file;
char *fs = NULL, *dn = NULL;
+ SAHooks sHooks;
+ SASetupDefaultHooks( &sHooks );
+ sHooks.Error = CustomErrors;
+
//*** search build tree ***
if ( plInBuildTree() == 1 )
{
plGetName( SOURCE_DIR, "data", fn, &fs );
- if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
goto done;
}
@@ -493,7 +509,7 @@
{
plGetName( dn, "", fn, &fs );
- if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
goto done;
fprintf( stderr, PLPLOT_LIB_ENV "=\"%s\"\n", dn ); // what IS set?
}
@@ -501,7 +517,7 @@
//*** search current directory ***
- if ( ( file = SHPOpen( fn, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fn, "rb", &sHooks ) ) != NULL )
{
pldebug( "OpenShapeFile", "Found file %s in current directory.\n", fn );
free_mem( fs );
@@ -515,7 +531,7 @@
{
plGetName( dn, "lib", fn, &fs );
- if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
goto done;
fprintf( stderr, PLPLOT_HOME_ENV "=\"%s\"\n", dn ); // what IS set?
}
@@ -526,7 +542,7 @@
#if defined ( DATA_DIR )
plGetName( DATA_DIR, "", fn, &fs );
- if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
goto done;
#endif // DATA_DIR
@@ -535,7 +551,7 @@
#ifdef PLLIBDEV
plGetName( PLLIBDEV, "", fn, &fs );
- if ( ( file = SHPOpen( fs, "rb" ) ) != NULL )
+ if ( ( file = SHPOpenLL( fs, "rb", &sHooks ) ) != NULL )
goto done;
#endif // PLLIBDEV
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|