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

Stefan Röckelein sroeckelein at gmail.com
Thu Mar 1 06:23:05 EST 2012


Thanks, it works!!

2012/2/28 Even Rouault <even.rouault at mines-paris.org>

> 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
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120301/76513bee/attachment.html


More information about the gdal-dev mailing list