Use correct error type in geojsoncomponent; Check for (0,0,0) camera vectors in navigator; Fix issue with non-ASCII characters when making identifiers

This commit is contained in:
Alexander Bock
2023-08-17 01:59:26 +02:00
committed by Alexander Bock
parent f692b8a7a4
commit bd153b3f4f
5 changed files with 21 additions and 9 deletions

View File

@@ -698,12 +698,13 @@ void GeoJsonComponent::parseSingleFeature(const geos::io::GeoJSONFeature& featur
_featuresPropertyOwner.addPropertySubOwner(_features.back().get());
}
catch (const ghoul::MissingCaseException&) {
catch (const ghoul::RuntimeError& error) {
LERROR(fmt::format(
"Error creating GeoJson layer with identifier '{}'. Problem reading "
"feature {} in GeoJson file '{}'.",
identifier(), indexInFile, _geoJsonFile
));
LERRORC(error.component, error.message);
// Do nothing
}
}

View File

@@ -232,18 +232,18 @@ void GlobeGeometryFeature::createFromSingleGeosGeometry(const geos::geom::Geomet
_type = GeometryType::Polygon;
}
catch (geos::util::IllegalStateException& e) {
LERROR(fmt::format(
throw ghoul::RuntimeError(fmt::format(
"Non-simple (e.g. self-intersecting) polygons not supported yet. "
"GEOS error: '{}'", e.what()
));
throw ghoul::MissingCaseException();
// TODO: handle self-intersections points
// https://www.sciencedirect.com/science/article/pii/S0304397520304199
}
catch (geos::util::GEOSException& e) {
LERROR(fmt::format("Unknown geos error: {}", e.what()));
throw ghoul::MissingCaseException();
throw ghoul::RuntimeError(fmt::format(
"Unknown geos error: {}", e.what()
));
}
break;
}

View File

@@ -739,9 +739,8 @@ void VideoPlayer::handleMpvProperties(mpv_event* event) {
}
break;
}
default: {
default:
throw ghoul::MissingCaseException();
}
}
}

View File

@@ -746,6 +746,12 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) {
.rotation = _camera->rotationQuaternion()
};
if (glm::length(pose.position) == 0.0) {
// If the position is 0.0, a lot of the calculations downstairs will fail as we
// calculate relative offsets from the center of the anchor node
return;
}
const bool hasPreviousPositions =
_previousAnchorNodePosition.has_value() &&
_previousAimNodePosition.has_value();
@@ -872,6 +878,11 @@ void OrbitalNavigator::updateCameraScalingFromAnchor(double deltaTime) {
const glm::dvec3 anchorPos = _anchorNode->worldPosition();
const glm::dvec3 cameraPos = _camera->positionVec3();
if (glm::length(cameraPos) == 0.0) {
// Calculating the surface position fails for (0,0,0) vectors
return;
}
SurfacePositionHandle posHandle =
calculateSurfacePositionHandle(*_anchorNode, cameraPos);
@@ -1123,7 +1134,8 @@ void OrbitalNavigator::setRetargetInterpolationTime(float durationInSeconds) {
bool OrbitalNavigator::shouldFollowAnchorRotation(const glm::dvec3& cameraPosition) const
{
if (!_anchorNode || !_followAnchorNodeRotation) {
if (!_anchorNode || !_followAnchorNodeRotation || glm::length(cameraPosition) == 0.0)
{
return false;
}

View File

@@ -888,7 +888,7 @@ std::string makeIdentifier(std::string s) {
std::replace_if(
s.begin(),
s.end(),
[](char c) { return std::ispunct(c) != 0; },
[](unsigned char c) { return std::ispunct(c) != 0; },
'-'
);
std::replace(s.begin(), s.end(), ' ', '_');