[Gdal-dev] Re: RFC 10

Andrey Kiselev dron at ak4719.spb.edu
Tue Nov 13 12:05:55 EST 2007


On Mon, Nov 12, 2007 at 03:36:51PM -0500, Frank Warmerdam wrote:
> >2. Introduce new mandatory method for format drivers to determine the
> >file format. Now GUI scenario will look like that:
> >
> > - select the file name;
> > - determine a format of that file;
> > - let the user choose open options, specific for that format;
> > - now proceed to GDALOpen(), capable to get options as per RFC 10.
> 
> Note that RFC 11: Fast Format Identify, already provides a mechanism
> to identify the format of a GDAL dataset.  Presumably you are
> suggesting something similar for OGR?

Sorry for messing things up, yes, OGR is my primary concern in this
regard.

> >Frank also suggested to pass encoded open options along with file
> >name instead of having the separate parameter in Open() method. With
> >this approach we will have different names to pass for format
> >identification function and for GDALOpen(): pure file name for the
> >former one and name+options for the last one. This will only work
> >when we know the file format before opening the file, otherwise we
> >just don't know what options are needed.
> 
> Note that the approach of encoding driver specific options into the
> name is already widely used for OGR - mainly for the various RDBMS
> drivers.

Yes, but it is not standartized and weak in many ways. Also it is clear
that we need open options, for example, PG driver uses PGSQL_OGR_FID
variable for some purpose, that is certainly a thing that should be
configured as an per-datasource parameter.

> I'm not clear on why RFC 10 couldn't be altered to provide a standard
> mechanism to encode parameters into the datasource name and go from
> there.  The issue of applications which don't know the format apriori
> is not new.

If the identification function will be added to OGR we will have two
forms of datasource naming. Identification function will accept a pure
dataset name, because we don't know what options are acceptable at this
stage, and we don't need them here anyway. Open function should get
datasource name AND open options: here we know what parameters we need
and already asked our user to set them. Note, that username/password
thing of mentioned PG driver is a part of datasource name and not an
option: we need these things to check database existence and establish
connection.  Though PGSQL_OGR_FID is an optional parameter and it is
only required when the actual data reading starts.

So the programmer will need to use the following code to open datasource
with open options:

 ds_name = "datasource_name";
 format = Identify(ds_name);
 if (format == "OUR_FORMAT") {
  options = AskUserForOptions();
  some_kind_of_new_name = CombineAndQuoteStrings(ds_name, options);
  ds = OGROpen(some_kind_of_new_name);
 }

instead of

 ds_name = "datasource_name";
 format = Identify(ds_name);
 if (format == "OUR_FORMAT") {
  options = AskUserForOptions();
  ds = OGROpen(ds_name, options);
 }

I think it is just clearer and simpler for developer.

Best regards,
Andrey

-- 
Andrey V. Kiselev
ICQ# 26871517



More information about the gdal-dev mailing list