Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 0 additions & 269 deletions data/sql/alias_name.sql

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions data/sql/final_consistency_checks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ FOR EACH ROW BEGIN
AND g1.source_crs_code = g2.source_crs_code
AND g1.target_crs_auth_name = g2.target_crs_auth_name
AND g1.target_crs_code = g2.target_crs_code
WHERE g1.auth_name = 'PROJ'
AND g1.code NOT LIKE '%_RESTRICTED_TO_VERTCRS%'
AND g1.code != 'ED50_TO_ETRS89_CATALONIA'
AND g2.auth_name = 'EPSG'
AND g2.deprecated = 0 AND
((g1.interpolation_crs_auth_name IS NULL AND g2.interpolation_crs_auth_name IS NULL) OR
WHERE g1.auth_name = 'PROJ' AND g1.code NOT LIKE '%_RESTRICTED_TO_VERTCRS%' AND g2.auth_name = 'EPSG' AND g2.deprecated = 0 AND (
(g1.interpolation_crs_auth_name IS NULL AND g2.interpolation_crs_auth_name IS NULL) OR
(g1.interpolation_crs_auth_name IS NOT NULL AND g2.interpolation_crs_auth_name IS NOT NULL AND
g1.interpolation_crs_auth_name = g2.interpolation_crs_auth_name AND
g1.interpolation_crs_code = g2.interpolation_crs_code)))
Expand Down
6 changes: 0 additions & 6 deletions data/sql/grid_transformation_custom.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
INSERT INTO "grid_transformation" VALUES('PROJ','BD72_TO_BEREF2002','BD72 to ETRS89-BEL [BEREF2002] (3)','Copy of BD72 to ETRS89-BEL [BEREF2011] (3) EPSG:8369','EPSG','9615','NTv2','EPSG','4313','EPSG','11063',0.01,'EPSG','8656','Latitude and longitude difference file','bd72lb72_etrs89lb08.gsb',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'IGN-Bel 0.01m',0);
INSERT INTO "usage" VALUES('PROJ','BD72_TO_BEREF2002_USAGE','grid_transformation','PROJ','BD72_TO_BEREF2002','EPSG','1347','EPSG','1150');

-- Catalonia

-- FIXME: remove this record when EPSG has fixed that issue
INSERT INTO "grid_transformation" VALUES('PROJ','ED50_TO_ETRS89_CATALONIA','ED50 to ETRS89 (14)','Copy of ED50 to ETRS89-ESP [REGENTE] (14) EPSG:5661','EPSG','9615','NTv2','EPSG','4230','EPSG','4258',0.05,'EPSG','8656','Latitude and longitude difference file','100800401.gsb',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'ICC-Esp Cat',0);
INSERT INTO "usage" VALUES('PROJ','ED50_TO_ETRS89_CATALONIA_USAGE','grid_transformation','PROJ','ED50_TO_ETRS89_CATALONIA','EPSG','3732','EPSG','1079');

-- Denmark

INSERT INTO "grid_transformation" VALUES(
Expand Down
2 changes: 1 addition & 1 deletion data/sql/proj.db.sql.expected.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
398415c72838764acfc012b2182c5db9
49ee5cee7798112c25b15bc17eafe6f2
11 changes: 11 additions & 0 deletions include/proj/internal/io_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ NS_PROJ_START

namespace io {

// CRS subtypes
#define CRS_SUBTYPE_GEOG_2D "geographic 2D"
#define CRS_SUBTYPE_GEOG_3D "geographic 3D"
#define CRS_SUBTYPE_GEOCENTRIC "geocentric"
#define CRS_SUBTYPE_OTHER "other"
#define CRS_SUBTYPE_PROJECTED "projected"
#define CRS_SUBTYPE_DERIVED_PROJECTED "derived projected"
#define CRS_SUBTYPE_ENGINEERING "engineering"
#define CRS_SUBTYPE_VERTICAL "vertical"
#define CRS_SUBTYPE_COMPOUND "compound"

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

class WKTConstants {
Expand Down
8 changes: 0 additions & 8 deletions include/proj/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,14 +1339,6 @@ class PROJ_GCC_DLL AuthorityFactory {
const metadata::ExtentPtr &intersectingExtent2,
bool skipIntermediateExtentIntersection = false) const;

PROJ_INTERNAL std::vector<operation::CoordinateOperationNNPtr>
getOperationsFromAlias(const std::string &crs1Name,
const std::string &crs2Name,
bool usePROJAlternativeGridNames,
bool discardIfMissingGrid,
bool considerKnownGridsAsAvailable,
bool discardSuperseded) const;

typedef std::pair<common::IdentifiedObjectNNPtr, std::string>
PairObjectName;
PROJ_INTERNAL std::list<PairObjectName>
Expand Down
20 changes: 0 additions & 20 deletions scripts/build_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,26 +1169,6 @@ def fill_alias(proj_db_cursor):
if not match:
print('Cannot find CRS %s in geodetic_crs, projected_crs, vertical_crs or compound_crs' % (code))

proj_db_cursor.execute("SELECT DISTINCT object_code, alias, coord_op_name FROM epsg.epsg_alias, epsg.epsg_coordoperation ON coord_op_code = object_code WHERE object_table_name = 'epsg_coordoperation' AND epsg_coordoperation.deprecated = 0")
for row in proj_db_cursor.fetchall():
code, alt_name, new_name = row
# We could potentially ingest all records, but the only use of them for
# now is to workaround effects of the creation of national ETRS89-XXX
# datums. See https://github.com/OSGeo/PROJ/pull/4736 for more details
if "ETRS89" not in alt_name:
# print('Ignoring alias %s for coordinate operation %s %s' % (alt_name, code, new_name))
continue

proj_db_cursor.execute('SELECT table_name FROM coordinate_operation_view WHERE code = ?', (code,))
row = proj_db_cursor.fetchone()
if row is not None:
table_name = row[0]
if table_name != "conversion":
proj_db_cursor.execute("INSERT INTO alias_name VALUES (?,'EPSG',?,?,'EPSG')", (table_name, code, alt_name))
continue

print('Cannot find coordinate operation %s for alias %s' % (code, alt_name))


def find_table(proj_db_cursor, code):
for table_name in ('helmert_transformation', 'grid_transformation', 'concatenated_operation', 'geodetic_crs', 'projected_crs', 'vertical_crs', 'compound_crs'):
Expand Down
127 changes: 33 additions & 94 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ namespace io {

//! @cond Doxygen_Suppress

// CRS subtypes
#define GEOG_2D "geographic 2D"
#define GEOG_3D "geographic 3D"
#define GEOCENTRIC "geocentric"
#define OTHER "other"
#define PROJECTED "projected"
#define DERIVED_PROJECTED "derived projected"
#define ENGINEERING "engineering"
#define VERTICAL "vertical"
#define COMPOUND "compound"

#define GEOG_2D_SINGLE_QUOTED "'geographic 2D'"
#define GEOG_3D_SINGLE_QUOTED "'geographic 3D'"
#define GEOCENTRIC_SINGLE_QUOTED "'geocentric'"
Expand Down Expand Up @@ -2520,12 +2509,12 @@ std::vector<std::string> DatabaseContext::Private::getInsertStatementsFor(
identifyOrInsert(self, coordinateSystem, "GEODETIC_CRS", authName, code,
csAuthName, csCode, sqlStatements);

const char *type = GEOG_2D;
const char *type = CRS_SUBTYPE_GEOG_2D;
if (coordinateSystem->axisList().size() == 3) {
if (dynamic_cast<const crs::GeographicCRS *>(crs.get())) {
type = GEOG_3D;
type = CRS_SUBTYPE_GEOG_3D;
} else {
type = GEOCENTRIC;
type = CRS_SUBTYPE_GEOCENTRIC;
}
}

Expand Down Expand Up @@ -5538,23 +5527,24 @@ AuthorityFactory::createGeodeticCRS(const std::string &code,

auto ellipsoidalCS =
util::nn_dynamic_pointer_cast<cs::EllipsoidalCS>(cs);
if ((type == GEOG_2D || type == GEOG_3D) && ellipsoidalCS) {
if ((type == CRS_SUBTYPE_GEOG_2D || type == CRS_SUBTYPE_GEOG_3D) &&
ellipsoidalCS) {
auto crsRet = crs::GeographicCRS::create(
props, datum, datumEnsemble, NN_NO_CHECK(ellipsoidalCS));
d->context()->d->cache(cacheKey, crsRet);
return crsRet;
}

auto geocentricCS = util::nn_dynamic_pointer_cast<cs::CartesianCS>(cs);
if (type == GEOCENTRIC && geocentricCS) {
if (type == CRS_SUBTYPE_GEOCENTRIC && geocentricCS) {
auto crsRet = crs::GeodeticCRS::create(props, datum, datumEnsemble,
NN_NO_CHECK(geocentricCS));
d->context()->d->cache(cacheKey, crsRet);
return crsRet;
}

auto sphericalCS = util::nn_dynamic_pointer_cast<cs::SphericalCS>(cs);
if (type == OTHER && sphericalCS) {
if (type == CRS_SUBTYPE_OTHER && sphericalCS) {
auto crsRet = crs::GeodeticCRS::create(props, datum, datumEnsemble,
NN_NO_CHECK(sphericalCS));
d->context()->d->cache(cacheKey, crsRet);
Expand Down Expand Up @@ -6214,23 +6204,23 @@ AuthorityFactory::createCoordinateReferenceSystem(const std::string &code,
code);
}
const auto &type = res.front()[0];
if (type == GEOG_2D || type == GEOG_3D || type == GEOCENTRIC ||
type == OTHER) {
if (type == CRS_SUBTYPE_GEOG_2D || type == CRS_SUBTYPE_GEOG_3D ||
type == CRS_SUBTYPE_GEOCENTRIC || type == CRS_SUBTYPE_OTHER) {
return createGeodeticCRS(code);
}
if (type == VERTICAL) {
if (type == CRS_SUBTYPE_VERTICAL) {
return createVerticalCRS(code);
}
if (type == PROJECTED) {
if (type == CRS_SUBTYPE_PROJECTED) {
return createProjectedCRS(code);
}
if (type == DERIVED_PROJECTED) {
if (type == CRS_SUBTYPE_DERIVED_PROJECTED) {
return createDerivedProjectedCRS(code);
}
if (type == ENGINEERING) {
if (type == CRS_SUBTYPE_ENGINEERING) {
return createEngineeringCRS(code);
}
if (allowCompound && type == COMPOUND) {
if (allowCompound && type == CRS_SUBTYPE_COMPOUND) {
return createCompoundCRS(code);
}
throw FactoryException("unhandled CRS type: " + type);
Expand Down Expand Up @@ -9060,23 +9050,23 @@ std::list<AuthorityFactory::CRSInfo> AuthorityFactory::getCRSInfoList() const {
info.code = row[1];
info.name = row[2];
const auto &type = row[3];
if (type == GEOG_2D) {
if (type == CRS_SUBTYPE_GEOG_2D) {
info.type = AuthorityFactory::ObjectType::GEOGRAPHIC_2D_CRS;
} else if (type == GEOG_3D) {
} else if (type == CRS_SUBTYPE_GEOG_3D) {
info.type = AuthorityFactory::ObjectType::GEOGRAPHIC_3D_CRS;
} else if (type == GEOCENTRIC) {
} else if (type == CRS_SUBTYPE_GEOCENTRIC) {
info.type = AuthorityFactory::ObjectType::GEOCENTRIC_CRS;
} else if (type == OTHER) {
} else if (type == CRS_SUBTYPE_OTHER) {
info.type = AuthorityFactory::ObjectType::GEODETIC_CRS;
} else if (type == PROJECTED) {
} else if (type == CRS_SUBTYPE_PROJECTED) {
info.type = AuthorityFactory::ObjectType::PROJECTED_CRS;
} else if (type == VERTICAL) {
} else if (type == CRS_SUBTYPE_VERTICAL) {
info.type = AuthorityFactory::ObjectType::VERTICAL_CRS;
} else if (type == COMPOUND) {
} else if (type == CRS_SUBTYPE_COMPOUND) {
info.type = AuthorityFactory::ObjectType::COMPOUND_CRS;
} else if (type == ENGINEERING) {
} else if (type == CRS_SUBTYPE_ENGINEERING) {
info.type = AuthorityFactory::ObjectType::ENGINEERING_CRS;
} else if (type == DERIVED_PROJECTED) {
} else if (type == CRS_SUBTYPE_DERIVED_PROJECTED) {
info.type = AuthorityFactory::ObjectType::DERIVED_PROJECTED_CRS;
}
info.deprecated = row[4] == "1";
Expand Down Expand Up @@ -9450,17 +9440,22 @@ AuthorityFactory::createObjectsFromNameEx(
res.emplace_back(TableType("geodetic_crs", std::string()));
break;
case ObjectType::GEOCENTRIC_CRS:
res.emplace_back(TableType("geodetic_crs", GEOCENTRIC));
res.emplace_back(
TableType("geodetic_crs", CRS_SUBTYPE_GEOCENTRIC));
break;
case ObjectType::GEOGRAPHIC_CRS:
res.emplace_back(TableType("geodetic_crs", GEOG_2D));
res.emplace_back(TableType("geodetic_crs", GEOG_3D));
res.emplace_back(
TableType("geodetic_crs", CRS_SUBTYPE_GEOG_2D));
res.emplace_back(
TableType("geodetic_crs", CRS_SUBTYPE_GEOG_3D));
break;
case ObjectType::GEOGRAPHIC_2D_CRS:
res.emplace_back(TableType("geodetic_crs", GEOG_2D));
res.emplace_back(
TableType("geodetic_crs", CRS_SUBTYPE_GEOG_2D));
break;
case ObjectType::GEOGRAPHIC_3D_CRS:
res.emplace_back(TableType("geodetic_crs", GEOG_3D));
res.emplace_back(
TableType("geodetic_crs", CRS_SUBTYPE_GEOG_3D));
break;
case ObjectType::PROJECTED_CRS:
res.emplace_back(TableType("projected_crs", std::string()));
Expand Down Expand Up @@ -10596,62 +10591,6 @@ AuthorityFactory::getPointMotionOperationsFor(
return res;
}

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

std::vector<operation::CoordinateOperationNNPtr>
AuthorityFactory::getOperationsFromAlias(const std::string &crs1Name,
const std::string &crs2Name,
bool usePROJAlternativeGridNames,
bool discardIfMissingGrid,
bool considerKnownGridsAsAvailable,
bool discardSuperseded) const {
std::string sql("SELECT alias.auth_name, alias.code FROM alias_name alias "
"JOIN coordinate_operation_view cov "
"ON alias.table_name = cov.table_name "
"AND alias.auth_name = cov.auth_name "
"AND alias.code = cov.code "
"WHERE alias.table_name IN ('grid_transformation', "
"'helmert_transformation', 'other_transformation', "
"'concatenated_operation') "
"AND (alt_name LIKE ? OR alt_name LIKE ?) "
"AND NOT (alt_name LIKE ? OR alt_name LIKE ? OR alt_name "
"LIKE ? OR alt_name LIKE ?) "
"AND cov.deprecated = 0");
if (discardSuperseded) {
sql += " AND NOT EXISTS (SELECT 1 FROM supersession ss WHERE "
"ss.superseded_table_name = cov.table_name AND "
"ss.superseded_auth_name = cov.auth_name AND "
"ss.superseded_code = cov.code AND "
"ss.superseded_table_name = ss.replacement_table_name AND "
"ss.same_source_target_crs = 1)";
}
ListOfParams params{
std::string(crs1Name).append(" to ").append(crs2Name).append("%"),
std::string(crs2Name).append(" to ").append(crs1Name).append("%"),
// If looking for "MGI to ETRS89", don't match "ETRS89 to ETRS89-XXX"
std::string(crs1Name).append(" to ").append(crs1Name).append("-%"),
std::string(crs2Name).append(" to ").append(crs2Name).append("-%"),
// If looking for "MGI to ETRS89", don't match "MGI to ETRS89-XXX" (not
// an actual example, but just in case)
std::string(crs1Name).append(" to ").append(crs2Name).append("-%"),
std::string(crs2Name).append(" to ").append(crs1Name).append("-%"),
};

std::vector<operation::CoordinateOperationNNPtr> res;
auto sqlRes = d->run(sql, params);
for (const auto &row : sqlRes) {
const auto &auth_name = row[0];
const auto &code = row[1];
auto op = d->createFactory(auth_name)->createCoordinateOperation(
code, usePROJAlternativeGridNames);
if (!discardIfMissingGrid ||
!d->rejectOpDueToMissingGrid(op, considerKnownGridsAsAvailable)) {
res.emplace_back(op);
}
}
return res;
}

//! @endcond

// ---------------------------------------------------------------------------
Expand Down
Loading
Loading