[gdal-dev] OGR: read datasources from a database

Even Rouault even.rouault at mines-paris.org
Tue Feb 28 07:32:54 EST 2012


Selon Stefan Röckelein <sroeckelein at gmail.com>:

> Hi,
>
> the usual procedure to open a file with OGR is to use
> OGRSFDriverRegistrar::Open("somefile.dxf",FALSE)
> Now I want to open a DXF-file which was previously stored in a database.
> Therefore I would need some ORG method which reads the drawing not from a
> file, but from a string (containing the whole DXF-file) directly.
> Is it possible to do this somehow?
>
> An alternative could be to save and read an OGRDataSource object inside the
> database. Is this possible?

The DXF driver use the CPL Virtual File I/O API, so you can read from a
in-memory file created with VSIFileFromMemBuffer for example ( see
http://gdal.org/cpl__vsi_8h.html#af9c1b931449d423e7a80bacb75ff0717 )

The code to use would be something like :

char* pszTheDXFContent = "a_string_with_the_dxf_file";
VSILFILE* fpMem = VSIFileFromMemBuffer ("/vsimem/temp.dxf", pszTheDXFContent,
strlen(pszTheDXFContent), FALSE );
VSIFCloseL(fpMem);
OGRDataSource* poDS = OGRSFDriverRegistrar::Open("/vsimem/temp.dxf",FALSE);

/* do something */

OGRSFDriverRegistrar::ReleaseDataSource(poDS);
VSIUnlink("/vsimem/temp.dxf");

>
> Stefan
>




More information about the gdal-dev mailing list