[Gdal-dev] opening dataset of unknown type
s duclos
sylvain_duclos at yahoo.com
Fri Dec 5 16:35:40 EST 2003
Hi Frank & Tyler
Later on you will want to have the driver
name at compile-time :)
I added this to ogrsf_frmts.h:
@@ -307,6 +228,19 @@
* OGRSFDriverRegistrar.
*/
+// GetName() return one of those
+#define AVC_DRIVER_NAME "AVCBin"
+#define DGN_DRIVER_NAME "DGN"
+#define GML_DRIVER_NAME "GML"
+#define TAB_DRIVER_NAME "MapInfo File"
+#define NTF_DRIVER_NAME "UK .NTF"
+#define OGD_DRIVER_NAME "OGDI"
+#define SQL_DRIVER_NAME "PostgreSQL"
+#define S57_DRIVER_NAME "IHO S-57 (ENC)"
+#define STD_DRIVER_NAME "SDTS"
+#define SHP_DRIVER_NAME "ESRI Shapefile"
+#define TGR_DRIVER_NAME "TIGER"
+
class CPL_DLL OGRSFDriver
{
public:
And in the corresponding GetName I replace
the string with the symbol.
For exemple in S57 in
gdal/ogr/ogrsf_frmts/s57/ogrs57driver.cpp
const char *OGRS57Driver::GetName()
{
return S57_DRIVER_NAME;
}
So that when compiling from OpenEV you can
pull-in S57_DRIVER_NAME whitout having to
know what the string is.
I have to do the same trick as bellow in gvogr.c
to get the drive name:
gv_data_set_property( psData, "_ogr_driver_name",
OGR_Dr_GetName(hDriver) );
Then during the layer settup I end up
comparing S57_DRIVER_NAME to the value of
_ogr_driver_name.
Sorry for drifting a bit out of gdal .. :)
Cheers,
Sylvain.
--- Frank Warmerdam <warmerdam at pobox.com> wrote:
> Tyler Mitchell wrote:
> >
> >
> >
> > I really like how you can program ogr to open a
> dataset without explicitly
> > laying out what type it is. I assume it tries to
> open it with a list of
> > drivers until it succeeds, or fails altogether.
> Is that right?
>
> Tyler,
>
> This is correct.
>
> > Can anyone tell me how you can identify which
> driver format was successful?
> > I'm specifically interested in how to do this in
> python. I've got the
> > dataset open but don't know, programatically, what
> type it is. I see
> > ogrinfo returns this information, but I'm not able
> to figure out how it
> > does it.
>
> The short answer, there is no way.
>
> The longer answer is that I have committed changes
> in the gdal/pymod directory
> so that the driver found in ogr.Open() can be
> captured somewhat like in C or
> C++. You can update from CVS to get this
> capability. The new code allows you
> to do the following to get the driver name for a
> dataset.
>
> import ogr
>
> x = ogr.Open( 'openev/polygon.shp' )
>
> print x.GetDriver().GetName()
>
>
> Best regards,
>
> --
>
---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up | Frank
> Warmerdam, warmerdam at 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 at remotesensing.org
> http://remotesensing.org/mailman/listinfo/gdal-dev
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
More information about the Gdal-dev
mailing list