Skip to content

Commit fc8d1d7

Browse files
committed
Improve consistency in georeferencing setup
After calling Georeferencing::setProjectedRefPoint(..., false, false), consistently configure scaling and rotation explicitly. In most cases, this means simply preserving the current values of combined scale factor and grivation (which affect the transformation to paper coordinates directly), causing calculated updates to auxiliary scale factor and declination. Given that transformation is preserved, there shall be no visible effect. However, the Georeferencing objects are put into a consistent state with regard to the scaling and rotation variables, similar to what is otherwise achieved by calling setProjectedRefPoint(...). This relevant at least where Georeferencing objects are saved/loaded as member of template configuration etc.
1 parent 07524fb commit fc8d1d7

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

src/fileformats/ocd_georef_fields.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void OcdGeorefFields::setupGeoref(Georeferencing& georef,
852852

853853
QPointF proj_ref_point(x, y);
854854
georef.setProjectedRefPoint(proj_ref_point, false, false);
855-
855+
georef.setCombinedScaleFactor(1.0);
856856
georef.setGrivation(qIsFinite(a) ? a : 0);
857857
}
858858

src/fileformats/xml_file_format.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ bool XMLFileImporter::importImplementation()
594594
auto ref_point = MapCoordF { georef.getMapRefPoint() };
595595
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
596596
georef.setProjectedRefPoint(new_projected, false, false);
597+
georef.setCombinedScaleFactor(georef.getCombinedScaleFactor()); // keep combined scale factor
598+
georef.setGrivation(georef.getGrivation()); // keep grivation, update declination
597599
map->setGeoreferencing(georef);
598600
}
599601
}

src/gdal/ogr_file_format.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ bool OgrFileImport::importImplementation()
851851
auto ref_point = MapCoordF { georef.getMapRefPoint() };
852852
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
853853
georef.setProjectedRefPoint(new_projected, false, false);
854+
georef.setCombinedScaleFactor(georef.getCombinedScaleFactor()); // keep combined scale factor
855+
georef.setGrivation(georef.getGrivation()); // keep grivation, update declination
854856
map->setGeoreferencing(georef);
855857
}
856858
}
@@ -971,6 +973,7 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
971973
.arg(latitude, 0, 'f')
972974
.arg(longitude, 0, 'f') );
973975
ortho_georef.setProjectedRefPoint({}, false, false);
976+
ortho_georef.setCombinedScaleFactor(1.0);
974977
ortho_georef.setDeclination(map->getGeoreferencing().getDeclination());
975978
map->setGeoreferencing(ortho_georef);
976979
return srsFromMap();

src/gdal/ogr_template.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ std::unique_ptr<Georeferencing> OgrTemplate::makeOrthographicGeoreferencing(cons
194194
QString::fromLatin1("+proj=ortho +datum=WGS84 +ellps=WGS84 +units=m +lat_0=%1 +lon_0=%2 +no_defs")
195195
.arg(center.latitude()).arg(center.longitude()));
196196
georef->setProjectedRefPoint({}, false, false);
197+
georef->setCombinedScaleFactor(1.0);
198+
georef->setGrivation(0.0);
197199
}
198200
else
199201
{
@@ -368,6 +370,8 @@ try
368370
explicit_georef->setScaleDenominator(int(map_georef.getScaleDenominator()));
369371
explicit_georef->setProjectedCRS(QString{}, projected_crs_spec);
370372
explicit_georef->setProjectedRefPoint({}, false, false);
373+
explicit_georef->setCombinedScaleFactor(1.0);
374+
explicit_georef->setGrivation(0.0);
371375
}
372376
}
373377
}

src/templates/template_image.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ bool TemplateImage::postLoadConfiguration(QWidget* dialog_parent, bool& out_cent
235235
calculateGeoreferencing();
236236
auto const center_pixel = MapCoordF(0.5 * (image.width() - 1), 0.5 * (image.height() - 1));
237237
initial_georef.setProjectedRefPoint(georef->toProjectedCoords(center_pixel));
238+
initial_georef.setCombinedScaleFactor(1.0);
239+
initial_georef.setGrivation(0.0);
238240
}
239241

240242
GeoreferencingDialog dialog(dialog_parent, map, &initial_georef, false);

src/templates/template_track.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ void TemplateTrack::applyProjectedCrsSpec()
609609
georef.setScaleDenominator(int(map->getScaleDenominator()));
610610
georef.setProjectedCRS(QString{}, projected_crs_spec);
611611
georef.setProjectedRefPoint({});
612+
georef.setCombinedScaleFactor(1.0);
613+
georef.setGrivation(0.0);
612614
track.changeMapGeoreferencing(georef);
613615
}
614616

0 commit comments

Comments
 (0)