RE: [gdal-dev] How to delete shapefile

2009-06-17 Thread Clay, Bruce
  
C++
OccurrenceTool.exe!COccurrenceToolView::OnInitialUpdate()  Line 316 
C++
mfc80d.dll!CWnd::OnWndMsg(unsigned int message=868, unsigned int 
wParam=0, long lParam=0, long * pResult=0x0012fa2c)  Line 2028 C++
mfc80d.dll!CWnd::WindowProc(unsigned int message=868, unsigned int 
wParam=0, long lParam=0)  Line 1741 + 0x20 bytes C++
mfc80d.dll!AfxCallWndProc(CWnd * pWnd=0x003b96d0, HWND__ * 
hWnd=0x00d91312, unsigned int nMsg=868, unsigned int wParam=0, long lParam=0)  
Line 240 + 0x1c bytes C++
mfc80d.dll!CWnd::SendMessageToDescendants(HWND__ * hWnd=0x00921336, 
unsigned int message=868, unsigned int wParam=0, long lParam=0, int bDeep=1, 
int bOnlyPerm=1)  Line 2524C++
mfc80d.dll!CWnd::SendMessageToDescendants(unsigned int message=868, 
unsigned int wParam=0, long lParam=0, int bDeep=1, int bOnlyPerm=1)  Line 170 + 
0x20 bytes  C++
mfc80d.dll!CFrameWnd::InitialUpdateFrame(CDocument * pDoc=0x003b90b0, 
int bMakeVisible=1)  Line 750 C++
mfc80d.dll!CDocTemplate::InitialUpdateFrame(CFrameWnd * 
pFrame=0x003b9140, CDocument * pDoc=0x003b90b0, int bMakeVisible=1)  Line 330   
C++
mfc80d.dll!CSingleDocTemplate::OpenDocumentFile(const char * 
lpszPathName=0x, int bMakeVisible=1)  Line 200 C++
mfc80d.dll!CDocManager::OnFileNew()  Line 848   C++
mfc80d.dll!CWinApp::OnFileNew()  Line 22C++
mfc80d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x011a57c8, unsigned 
int nID=57600, int nCode=0, void (void)* pfn=0x0079e936, void * 
pExtra=0x, unsigned int nSig=56, AFX_CMDHANDLERINFO * 
pHandlerInfo=0x)  Line 82 C++
mfc80d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=57600, int nCode=0, 
void * pExtra=0x, AFX_CMDHANDLERINFO * pHandlerInfo=0x)  Line 
381 + 0x27 bytes C++
mfc80d.dll!CWinApp::ProcessShellCommand(CCommandLineInfo  
rCmdInfo={...})  Line 24 + 0x20 bytesC++
OccurrenceTool.exe!COccurrenceToolApp::InitInstance()  Line 93 + 0xc 
bytes  C++
mfc80d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x0040, HINSTANCE__ * 
hPrevInstance=0x, char * lpCmdLine=0x00151f39, int nCmdShow=1)  Line 37 
+ 0xd bytes C++
OccurrenceTool.exe!WinMain(HINSTANCE__ * hInstance=0x0040, 
HINSTANCE__ * hPrevInstance=0x, char * lpCmdLine=0x00151f39, int 
nCmdShow=1)  Line 33C++
OccurrenceTool.exe!__tmainCRTStartup()  Line 589 + 0x35 bytes   C
OccurrenceTool.exe!WinMainCRTStartup()  Line 414C
kernel32.dll!7c817067() 
[Frames below may be incorrect and/or missing, no symbols loaded for 
kernel32.dll]  

-Original Message-
From: Frank Warmerdam [mailto:warmer...@pobox.com] 
Sent: Tuesday, June 16, 2009 7:31 PM
To: Clay, Bruce
Cc: gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] How to delete shapefile

Clay, Bruce wrote:
 I am trying to delete a temporary shapefile after running a process with 
 the following code.
...
 The TestCapability always returns FALSE.  If I call DeleteLayer anyway I 
 get an unsupported operation error messege.
 
 I am using GDAL 1.5.3 with Visual Studio 2005.

 Is there an error in my code or a different way to delete a shapefile 
 using GDAL or do I have to go to the operating system and find all of 
 the files that make up the shapefile and delete them that way?

Bruce,

It looks like the DeleteLayer support for the shapefile driver was added
for 1.6.0.  So you need to either upgrade or perhaps just delete the files
yourself with unlink().  Make sure the datasource is closed when you do so.

Best regards,
-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam, warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Programmer for Rent




This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this 
 
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] How to delete shapefile

2009-06-17 Thread Mateusz Loskot

Clay, Bruce wrote:

Mateusz:
  Thanks for your reply.  Unfortunately I can not get far enough to do
that.  The crash is occurring down stream from OGRRegisterAll.  That is
to say, the last call in my code space before the crash is
OGRRegisterAll. I can not get OGR initialized to be able to open a data
source.


Bruce,

Are you saying that you are unable to run this simple program successfully?

#include ogrsf_frmts.h
int main()
{
OGRRegisterAll();
}

If you indeed can not run it, it probably means your GDAL installation
is not configured properly or broken.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


[gdal-dev] How to delete shapefile

2009-06-16 Thread Clay, Bruce
I am trying to delete a temporary shapefile after running a process with
the following code.

 

int GdalWrapper::DeleteDataset(const char *datasetName)

{

  int status = -1;

 

  if (datasetName != NULL)

  {

OGRDataSource *dataSrc = OpenDatasetFile(datasetName);

if (dataSrc != NULL)

{

  try

  {

int refCnt = dataSrc-GetSummaryRefCount();

if (refCnt  0)

{

  dataSrc-Release();

}

int deleteOk =
dataSrc-TestCapability(ODsCDeleteLayer);

if (deleteOk == TRUE)

{

  dataSrc-DeleteLayer(0);

  status = 0;

}

else

{

  mLastErrorMsg = Can not delete requested
dataset;

}

  }

  catch(...)

  {

mLastErrorMsg = Could not delete layer: ;

mLastErrorMsg += datasetName;

  }

 

}

 

  }

 

  return(status);

}

 

The TestCapability always returns FALSE.  If I call DeleteLayer anyway I
get an unsupported operation error messege.

I am using GDAL 1.5.3 with Visual Studio 2005.

 

Is there an error in my code or a different way to delete a shapefile
using GDAL or do I have to go to the operating system and find all of
the files that make up the shapefile and delete them that way?

 

Bruce

 

 




This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this 
 
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] How to delete shapefile

2009-06-16 Thread Frank Warmerdam

Clay, Bruce wrote:
I am trying to delete a temporary shapefile after running a process with 
the following code.

...
The TestCapability always returns FALSE.  If I call DeleteLayer anyway I 
get an unsupported operation error messege.


I am using GDAL 1.5.3 with Visual Studio 2005.

Is there an error in my code or a different way to delete a shapefile 
using GDAL or do I have to go to the operating system and find all of 
the files that make up the shapefile and delete them that way?


Bruce,

It looks like the DeleteLayer support for the shapefile driver was added
for 1.6.0.  So you need to either upgrade or perhaps just delete the files
yourself with unlink().  Make sure the datasource is closed when you do so.

Best regards,
--
---+--
I set the clouds in motion - turn up   | Frank Warmerdam, warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Programmer for Rent

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev