diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 482ab5b36..9f09eb582 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -62,18 +62,24 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind) desc_(*params.get("type"), *params.get("encoding","utf-8")), indexed_(false) { - OGRRegisterAll(); - boost::optional file = params.get("file"); - if (!file) throw datasource_exception("missing parameter"); + boost::optional string = params.get("string"); + if (!file && !string) throw datasource_exception("missing or parameter"); - multiple_geometries_ = *params_.get("multiple_geometries",false); + multiple_geometries_ = *params.get("multiple_geometries",false); - boost::optional base = params_.get("base"); - if (base) - dataset_name_ = *base + "/" + *file; + if (string) + { + dataset_name_ = *string; + } else - dataset_name_ = *file; + { + boost::optional base = params.get("base"); + if (base) + dataset_name_ = *base + "/" + *file; + else + dataset_name_ = *file; + } if (bind) { @@ -81,9 +87,20 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind) } } +ogr_datasource::~ogr_datasource() +{ + if (is_bound_) + { + OGRDataSource::DestroyDataSource (dataset_); + } +} + void ogr_datasource::bind() const { if (is_bound_) return; + + // initialize ogr formats + OGRRegisterAll(); // open ogr driver dataset_ = OGRSFDriverRegistrar::Open ((dataset_name_).c_str(), FALSE); @@ -247,14 +264,6 @@ void ogr_datasource::bind() const is_bound_ = true; } -ogr_datasource::~ogr_datasource() -{ - if (is_bound_) - { - OGRDataSource::DestroyDataSource (dataset_); - } -} - std::string ogr_datasource::name() { return "ogr";