Skip to content

Commit 47abfcf

Browse files
authored
Merge GH-1621 (Set reference point correctly)
2 parents ece92f5 + fc8d1d7 commit 47abfcf

7 files changed

+21
-8
lines changed

src/fileformats/ocd_georef_fields.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ void OcdGeorefFields::setupGeoref(Georeferencing& georef,
851851
applyGridAndZone(georef, i, warning_handler);
852852

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

src/fileformats/xml_file_format.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ bool XMLFileImporter::importImplementation()
593593
auto georef = map->getGeoreferencing();
594594
auto ref_point = MapCoordF { georef.getMapRefPoint() };
595595
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
596-
georef.setProjectedRefPoint(new_projected, false);
596+
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,9 @@ bool OgrFileImport::importImplementation()
850850
auto georef = map->getGeoreferencing();
851851
auto ref_point = MapCoordF { georef.getMapRefPoint() };
852852
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
853-
georef.setProjectedRefPoint(new_projected, false);
853+
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
}
@@ -970,7 +972,8 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
970972
QString::fromLatin1("+proj=ortho +datum=WGS84 +ellps=WGS84 +units=m +lat_0=%1 +lon_0=%2 +no_defs")
971973
.arg(latitude, 0, 'f')
972974
.arg(longitude, 0, 'f') );
973-
ortho_georef.setProjectedRefPoint({}, false);
975+
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

+6-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ std::unique_ptr<Georeferencing> OgrTemplate::makeOrthographicGeoreferencing(cons
193193
georef->setProjectedCRS(QString{},
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()));
196-
georef->setProjectedRefPoint({}, false);
196+
georef->setProjectedRefPoint({}, false, false);
197+
georef->setCombinedScaleFactor(1.0);
198+
georef->setGrivation(0.0);
197199
}
198200
else
199201
{
@@ -367,7 +369,9 @@ try
367369
explicit_georef = std::make_unique<Georeferencing>();
368370
explicit_georef->setScaleDenominator(int(map_georef.getScaleDenominator()));
369371
explicit_georef->setProjectedCRS(QString{}, projected_crs_spec);
370-
explicit_georef->setProjectedRefPoint({}, false);
372+
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

+2
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

+2
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

test/georef_ocd_mapping_t.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private slots:
266266
}
267267

268268
georef.setProjectedCRS(georef_result.crs_id, spec, crs_params);
269-
georef.setProjectedRefPoint(georef_result.ref_point, false);
269+
georef.setProjectedRefPoint(georef_result.ref_point, false, false);
270270
georef.setScaleDenominator(georef_result.scale);
271271
georef.setDeclination(georef_result.declination);
272272
georef.setGrivation(georef_result.grivation);

0 commit comments

Comments
 (0)