Skip to content

Commit

Permalink
ISO19111: Handle database area objects with no bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Feb 6, 2019
1 parent 149bd81 commit 457b173
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,12 @@ AuthorityFactory::createExtent(const std::string &code) const {
try {
const auto &row = res.front();
const auto &name = row[0];
if (row[1].empty()) {
auto extent = metadata::Extent::create(
util::optional<std::string>(name), {}, {}, {});
d->context()->d->cache(code, extent);
return extent;
}
double south_lat = c_locale_stod(row[1]);
double north_lat = c_locale_stod(row[2]);
double west_lon = c_locale_stod(row[3]);
Expand Down
21 changes: 21 additions & 0 deletions test/unit/test_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ TEST(factory, AuthorityFactory_createExtent) {

// ---------------------------------------------------------------------------

TEST(factory, AuthorityFactory_createExtent_no_bbox) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto extent = factory->createExtent("1361"); // Sudan - south. Deprecated
EXPECT_EQ(*(extent->description()), "Sudan - south");
const auto &geogElts = extent->geographicElements();
EXPECT_TRUE(geogElts.empty());
}

// ---------------------------------------------------------------------------

TEST(factory, AuthorityFactory_createGeodeticDatum) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
EXPECT_THROW(factory->createGeodeticDatum("-1"),
Expand Down Expand Up @@ -414,6 +424,17 @@ TEST(factory, AuthorityFactory_createGeodeticCRS_geographic2D) {

// ---------------------------------------------------------------------------

TEST(factory, AuthorityFactory_createGeodeticCRS_geographic2D_area_no_bbox) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto crs = factory->createGeodeticCRS("4296"); // Sudan - deprecated
auto domain = crs->domains()[0];
auto extent = domain->domainOfValidity();
ASSERT_TRUE(extent != nullptr);
EXPECT_TRUE(extent->isEquivalentTo(factory->createExtent("1361").get()));
}

// ---------------------------------------------------------------------------

TEST(factory, AuthorityFactory_createGeodeticCRS_geographic3D) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto crs = factory->createGeodeticCRS("4979");
Expand Down

0 comments on commit 457b173

Please sign in to comment.