Skip to content

Commit

Permalink
Merge GH-1621 (Set reference point correctly)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored May 15, 2020
2 parents ece92f5 + fc8d1d7 commit 47abfcf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/fileformats/ocd_georef_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ void OcdGeorefFields::setupGeoref(Georeferencing& georef,
applyGridAndZone(georef, i, warning_handler);

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

georef.setProjectedRefPoint(proj_ref_point, false, false);
georef.setCombinedScaleFactor(1.0);
georef.setGrivation(qIsFinite(a) ? a : 0);
}

Expand Down
4 changes: 3 additions & 1 deletion src/fileformats/xml_file_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ bool XMLFileImporter::importImplementation()
auto georef = map->getGeoreferencing();
auto ref_point = MapCoordF { georef.getMapRefPoint() };
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
georef.setProjectedRefPoint(new_projected, false);
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
7 changes: 5 additions & 2 deletions src/gdal/ogr_file_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,9 @@ bool OgrFileImport::importImplementation()
auto georef = map->getGeoreferencing();
auto ref_point = MapCoordF { georef.getMapRefPoint() };
auto new_projected = georef.toProjectedCoords(ref_point + offset_f);
georef.setProjectedRefPoint(new_projected, false);
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 @@ -970,7 +972,8 @@ ogr::unique_srs OgrFileImport::importGeoreferencing(OGRDataSourceH data_source)
QString::fromLatin1("+proj=ortho +datum=WGS84 +ellps=WGS84 +units=m +lat_0=%1 +lon_0=%2 +no_defs")
.arg(latitude, 0, 'f')
.arg(longitude, 0, 'f') );
ortho_georef.setProjectedRefPoint({}, false);
ortho_georef.setProjectedRefPoint({}, false, false);
ortho_georef.setCombinedScaleFactor(1.0);
ortho_georef.setDeclination(map->getGeoreferencing().getDeclination());
map->setGeoreferencing(ortho_georef);
return srsFromMap();
Expand Down
8 changes: 6 additions & 2 deletions src/gdal/ogr_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ std::unique_ptr<Georeferencing> OgrTemplate::makeOrthographicGeoreferencing(cons
georef->setProjectedCRS(QString{},
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);
georef->setProjectedRefPoint({}, false, false);
georef->setCombinedScaleFactor(1.0);
georef->setGrivation(0.0);
}
else
{
Expand Down Expand Up @@ -367,7 +369,9 @@ try
explicit_georef = std::make_unique<Georeferencing>();
explicit_georef->setScaleDenominator(int(map_georef.getScaleDenominator()));
explicit_georef->setProjectedCRS(QString{}, projected_crs_spec);
explicit_georef->setProjectedRefPoint({}, false);
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
2 changes: 1 addition & 1 deletion test/georef_ocd_mapping_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private slots:
}

georef.setProjectedCRS(georef_result.crs_id, spec, crs_params);
georef.setProjectedRefPoint(georef_result.ref_point, false);
georef.setProjectedRefPoint(georef_result.ref_point, false, false);
georef.setScaleDenominator(georef_result.scale);
georef.setDeclination(georef_result.declination);
georef.setGrivation(georef_result.grivation);
Expand Down

0 comments on commit 47abfcf

Please sign in to comment.