Skip to content

Commit

Permalink
Improve consistency in georeferencing setup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dg0yt committed May 14, 2020
1 parent 07524fb commit fc8d1d7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fileformats/ocd_georef_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void OcdGeorefFields::setupGeoref(Georeferencing& georef,

QPointF proj_ref_point(x, y);
georef.setProjectedRefPoint(proj_ref_point, false, false);

georef.setCombinedScaleFactor(1.0);
georef.setGrivation(qIsFinite(a) ? a : 0);
}

Expand Down
2 changes: 2 additions & 0 deletions src/fileformats/xml_file_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ bool XMLFileImporter::importImplementation()
auto ref_point = MapCoordF { georef.getMapRefPoint() };
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
georef.setProjectedRefPoint(new_projected, false, false);
georef.setCombinedScaleFactor(georef.getCombinedScaleFactor()); // keep combined scale factor
georef.setGrivation(georef.getGrivation()); // keep grivation, update declination
map->setGeoreferencing(georef);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/gdal/ogr_file_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,8 @@ bool OgrFileImport::importImplementation()
auto ref_point = MapCoordF { georef.getMapRefPoint() };
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
georef.setProjectedRefPoint(new_projected, false, false);
georef.setCombinedScaleFactor(georef.getCombinedScaleFactor()); // keep combined scale factor
georef.setGrivation(georef.getGrivation()); // keep grivation, update declination
map->setGeoreferencing(georef);
}
}
Expand Down Expand Up @@ -971,6 +973,7 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
.arg(latitude, 0, 'f')
.arg(longitude, 0, 'f') );
ortho_georef.setProjectedRefPoint({}, false, false);
ortho_georef.setCombinedScaleFactor(1.0);
ortho_georef.setDeclination(map->getGeoreferencing().getDeclination());
map->setGeoreferencing(ortho_georef);
return srsFromMap();
Expand Down
4 changes: 4 additions & 0 deletions src/gdal/ogr_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ std::unique_ptr<Georeferencing> OgrTemplate::makeOrthographicGeoreferencing(cons
QString::fromLatin1("+proj=ortho +datum=WGS84 +ellps=WGS84 +units=m +lat_0=%1 +lon_0=%2 +no_defs")
.arg(center.latitude()).arg(center.longitude()));
georef->setProjectedRefPoint({}, false, false);
georef->setCombinedScaleFactor(1.0);
georef->setGrivation(0.0);
}
else
{
Expand Down Expand Up @@ -368,6 +370,8 @@ try
explicit_georef->setScaleDenominator(int(map_georef.getScaleDenominator()));
explicit_georef->setProjectedCRS(QString{}, projected_crs_spec);
explicit_georef->setProjectedRefPoint({}, false, false);
explicit_georef->setCombinedScaleFactor(1.0);
explicit_georef->setGrivation(0.0);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/template_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ bool TemplateImage::postLoadConfiguration(QWidget* dialog_parent, bool& out_cent
calculateGeoreferencing();
auto const center_pixel = MapCoordF(0.5 * (image.width() - 1), 0.5 * (image.height() - 1));
initial_georef.setProjectedRefPoint(georef->toProjectedCoords(center_pixel));
initial_georef.setCombinedScaleFactor(1.0);
initial_georef.setGrivation(0.0);
}

GeoreferencingDialog dialog(dialog_parent, map, &initial_georef, false);
Expand Down
2 changes: 2 additions & 0 deletions src/templates/template_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ void TemplateTrack::applyProjectedCrsSpec()
georef.setScaleDenominator(int(map->getScaleDenominator()));
georef.setProjectedCRS(QString{}, projected_crs_spec);
georef.setProjectedRefPoint({});
georef.setCombinedScaleFactor(1.0);
georef.setGrivation(0.0);
track.changeMapGeoreferencing(georef);
}

Expand Down

0 comments on commit fc8d1d7

Please sign in to comment.