Skip to content

Commit 910d725

Browse files
committed
Georeferencing: Use substitution for '+init=epsg:5514'
Fixes #542.
1 parent 6e6e940 commit 910d725

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/core/georeferencing.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ namespace
114114
*pj_get_errno_ref() = 0;
115115
return pj_init_plus(spec_latin1);
116116
}
117+
118+
119+
/**
120+
* List of substitutions for specifications which are known to be broken in Proj.4.
121+
*/
122+
std::vector< std::pair<QString, QString> > spec_substitutions {
123+
// #542, S-JTSK (Greenwich) / Krovak East North
124+
{ "+init=epsg:5514", "+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 "
125+
"+ellps=bessel +towgs84=542.5,89.2,456.9,5.517,2.275,5.516,6.96 +pm=greenwich +units=m +no_defs" },
126+
};
117127
}
118128

119129

@@ -577,11 +587,20 @@ void Georeferencing::setTransformationDirectly(const QTransform& transform)
577587
}
578588
}
579589

580-
bool Georeferencing::setProjectedCRS(const QString& id, const QString& spec, std::vector< QString > params)
590+
bool Georeferencing::setProjectedCRS(const QString& id, QString spec, std::vector< QString > params)
581591
{
582592
// Default return value if no change is neccessary
583593
bool ok = (state == Normal || projected_crs_spec.isEmpty());
584594

595+
for (const auto& substitution : spec_substitutions)
596+
{
597+
if (substitution.first == spec)
598+
{
599+
spec = substitution.second;
600+
break;
601+
}
602+
}
603+
585604
// Changes in params shall already be recorded in spec
586605
if (projected_crs_id != id
587606
|| projected_crs_spec != spec

src/core/georeferencing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ friend QDebug operator<<(QDebug dbg, const Georeferencing& georef);
315315
* @param params parameter values (ignore for empty spec)
316316
* @return true if the specification is valid or empty, false otherwise
317317
*/
318-
bool setProjectedCRS(const QString& id, const QString& spec = "", std::vector< QString > params = std::vector< QString >());
318+
bool setProjectedCRS(const QString& id, QString spec = QString::null, std::vector< QString > params = std::vector< QString >());
319319

320320
/**
321321
* Calculates the meridian convergence at the reference point.

test/georeferencing_t.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ void GeoreferencingTest::testCRSTemplates()
8282
QCOMPARE(epsg_template->parameters().size(), (std::size_t)1);
8383

8484
georef.setProjectedCRS("EPSG", epsg_template->specificationTemplate().arg("5514"), { "5514" });
85-
if (PJ_VERSION < 490)
86-
QEXPECT_FAIL("", "EPSG 5514 is undefined in specifications supplied by proj < 4.9.0", Continue);
8785
QVERIFY(georef.isValid());
8886
}
8987

@@ -122,8 +120,6 @@ void GeoreferencingTest::testProjection()
122120
#endif
123121

124122
QFETCH(QString, proj);
125-
if (PJ_VERSION < 490)
126-
QEXPECT_FAIL("EPSG 5514 ČÚZK Dolní Temenice", "EPSG 5514 is undefined in specifications supplied by proj < 4.9.0", Abort);
127123
QVERIFY2(georef.setProjectedCRS(proj, proj), proj.toLatin1());
128124
QCOMPARE(georef.getErrorText(), QString(""));
129125

@@ -138,7 +134,6 @@ void GeoreferencingTest::testProjection()
138134
QPointF proj_coord = georef.toProjectedCoords(lat_lon, &ok);
139135
QVERIFY(ok);
140136

141-
QEXPECT_FAIL("EPSG 5514 ČÚZK Dolní Temenice", "EPSG 5514 is broken in proj-supplied specifications", Abort);
142137
if (fabs(proj_coord.x() - easting) > max_dist_error)
143138
QCOMPARE(QString::number(proj_coord.x(), 'f'), QString::number(easting, 'f'));
144139
if (fabs(proj_coord.y() - northing) > max_dist_error)

0 commit comments

Comments
 (0)