Skip to content

Commit

Permalink
GeoNode getOrigin()
Browse files Browse the repository at this point in the history
  • Loading branch information
timoore committed Dec 25, 2023
1 parent 4116df5 commit 3332d50
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/vsgCs/CRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,21 @@ namespace vsgCs

};

// A no-op CRS. Either the coordinates are ECEF (x, y, z), or there isn't actually a globe.
class EPSG4978 : public CRS::ConversionOperation
{
public:
vsg::dvec3 getECEF(const vsg::dvec3& coord) override
{
return coord;
}

vsg::dmat4 getENU(const vsg::dvec3& coord) override
{
return {};
}
};

// Bog-standard WGS84 longitude, latitude, height to ECEF
class EPSG4979 : public CRS::ConversionOperation
{
Expand Down Expand Up @@ -528,6 +543,10 @@ namespace vsgCs

CRS::CRS(const std::string& name)
{
if (name == "epsg:4978" || name == "null")
{
_converter = std::make_shared<EPSG4978>();
}
if (name == "epsg:4979" || name == "wgs84")
{
_converter = std::make_shared<EPSG4979>();
Expand Down
6 changes: 6 additions & 0 deletions src/vsgCs/GeoNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ GeoNode::GeoNode(const std::string& crs)
void GeoNode::setOrigin(const vsg::dvec3& origin)
{
matrix = _crs->getENU(origin);
_origin = origin;
}

vsg::dvec3 GeoNode::getOrigin() const
{
return _origin;
}

// Try stepping back from runtime environment singleton by passing the environment as an argument.
Expand Down
2 changes: 2 additions & 0 deletions src/vsgCs/GeoNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ namespace vsgCs
public:
GeoNode(const std::string& crs = "epsg:4979");
void setOrigin(const vsg::dvec3& origin);
vsg::dvec3 getOrigin() const;
protected:
std::shared_ptr<CRS> _crs;
vsg::dvec3 _origin;
};

vsg::ref_ptr<vsg::StateGroup> VSGCS_EXPORT createModelRoot(const vsg::ref_ptr<RuntimeEnvironment>& env);
Expand Down

0 comments on commit 3332d50

Please sign in to comment.