From a8ce6b01d6a5fb197c21c53a7a81a0dac344c706 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Jun 2004 15:00:03 +0000 Subject: [PATCH] Added CoordinateSystem::s/getFormat(). --- include/osg/CoordinateSystemNode | 17 ++++++++++----- src/osg/ClusterCullingCallback.cpp | 2 ++ src/osg/CoordinateSystemNode.cpp | 23 ++++++++++++++------- src/osgPlugins/ive/CoordinateSystemNode.cpp | 6 +++++- src/osgPlugins/osg/CoordinateSystemNode.cpp | 10 +++++++++ src/osgTerrain/DataSet.cpp | 2 +- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/include/osg/CoordinateSystemNode b/include/osg/CoordinateSystemNode index 5dfaa984c..727f4a649 100644 --- a/include/osg/CoordinateSystemNode +++ b/include/osg/CoordinateSystemNode @@ -84,7 +84,7 @@ class SG_EXPORT CoordinateSystemNode : public Group CoordinateSystemNode(); - CoordinateSystemNode(const std::string& WKT); + CoordinateSystemNode(const std::string& format, const std::string& cs); /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ CoordinateSystemNode(const CoordinateSystemNode&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); @@ -92,11 +92,17 @@ class SG_EXPORT CoordinateSystemNode : public Group META_Node(osg,CoordinateSystemNode); - /** Set the CoordinateSystem reference string, should be stored in OpenGIS Well Know Text form.*/ - void setCoordinateSystem(const std::string& WKT) { _WKT = WKT; } + /** Set the coordinate system format string. Typical values would be WKT, PROJ4, USGS etc.*/ + void setFormat(const std::string& format) { _format = format; } + + /** Get the coordinate system format string.*/ + const std::string& getFormat() const { return _format; } + + /** Set the CoordinateSystem reference string, should be stored form consistent with the Format.*/ + void setCoordinateSystem(const std::string& cs) { _cs = cs; } /** Get the CoordinateSystem reference string.*/ - const std::string& getCoordinateSystem() const { return _WKT; } + const std::string& getCoordinateSystem() const { return _cs; } /** set EllipsoidModel to describe the model used to map lat, long and height into geocentric XYZ and back. */ @@ -118,7 +124,8 @@ class SG_EXPORT CoordinateSystemNode : public Group virtual ~CoordinateSystemNode() {} - std::string _WKT; + std::string _format; + std::string _cs; ref_ptr _ellipsoidModel; }; diff --git a/src/osg/ClusterCullingCallback.cpp b/src/osg/ClusterCullingCallback.cpp index d4e6d1894..11c33372e 100644 --- a/src/osg/ClusterCullingCallback.cpp +++ b/src/osg/ClusterCullingCallback.cpp @@ -144,6 +144,8 @@ void ClusterCullingCallback::set(const osg::Vec3& controlPoint, const osg::Vec3& bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const { + return false; + if (_deviation<=-1.0f) { // osg::notify(osg::NOTICE)<<"ClusterCullingCallback::cull() _deviation="<<_deviation< +#include using namespace osg; @@ -20,16 +21,18 @@ CoordinateSystemNode::CoordinateSystemNode() { } -CoordinateSystemNode::CoordinateSystemNode(const std::string& WKT) +CoordinateSystemNode::CoordinateSystemNode(const std::string& format, const std::string& cs): + _format(format), + _cs(cs) { - _WKT = WKT; } CoordinateSystemNode::CoordinateSystemNode(const CoordinateSystemNode& csn,const osg::CopyOp& copyop): - Group(csn,copyop) + Group(csn,copyop), + _format(csn._format), + _cs(csn._cs), + _ellipsoidModel(csn._ellipsoidModel) { - _WKT = csn._WKT; - _ellipsoidModel = csn._ellipsoidModel; } CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(const Vec3d& position) const @@ -37,14 +40,20 @@ CoordinateFrame CoordinateSystemNode::computeLocalCoordinateFrame(const Vec3d& p if (_ellipsoidModel.valid()) { Matrixd localToWorld; + + double latitude, longitude, height; + _ellipsoidModel->convertXYZToLatLongHeight(position.x(),position.y(),position.z(),latitude, longitude, height); + _ellipsoidModel->computeLocalToWorldTransformFromLatLongHeight(latitude, longitude, 0.0f, localToWorld); + + osg::notify(osg::NOTICE)<<"lat="<computeLocalToWorldTransformFromXYZ(position.x(),position.y(),position.z(), localToWorld); + //_ellipsoidModel->computeLocalToWorldTransformFromXYZ(position.x(),position.y(),position.z(), localToWorld); return localToWorld; } else { - return Matrixd::translate(position); + return Matrixd::translate(position.x(),position.y(),0.0f); } } diff --git a/src/osgPlugins/ive/CoordinateSystemNode.cpp b/src/osgPlugins/ive/CoordinateSystemNode.cpp index beeac2820..aee16adb4 100644 --- a/src/osgPlugins/ive/CoordinateSystemNode.cpp +++ b/src/osgPlugins/ive/CoordinateSystemNode.cpp @@ -30,8 +30,9 @@ void CoordinateSystemNode::write(DataOutputStream* out) } else throw Exception("CoordinateSystemNode::write(): Could not cast this osg::CoordinateSystemNode to an osg::Group."); - // Write CoordinateSystemNode's properties. + // Write CoordinateSystemNode's properties. + out->writeString(getFormat()); out->writeString(getCoordinateSystem()); out->writeBool(getEllipsoidModel()!=0); @@ -58,6 +59,9 @@ void CoordinateSystemNode::read(DataInputStream* in){ throw Exception("CoordinateSystemNode::read(): Could not cast this osg::CoordinateSystemNode to an osg::Group."); // Read CoordinateSystemNode's properties + // Read format string + setFormat( in->readString()); + // Read coord string setCoordinateSystem( in->readString()); diff --git a/src/osgPlugins/osg/CoordinateSystemNode.cpp b/src/osgPlugins/osg/CoordinateSystemNode.cpp index 3e0969cfe..b53171886 100644 --- a/src/osgPlugins/osg/CoordinateSystemNode.cpp +++ b/src/osgPlugins/osg/CoordinateSystemNode.cpp @@ -27,6 +27,15 @@ bool CoordinateSystemNode_readLocalData(Object& obj, Input& fr) CoordinateSystemNode& csn = static_cast(obj); + if (fr.matchSequence("Format %s")) + { + const char* str = fr[1].getStr(); + if (str) csn.setFormat(str); + + iteratorAdvanced = true; + fr+=2; + } + if (fr.matchSequence("CoordinateSystem %s")) { const char* str = fr[1].getStr(); @@ -49,6 +58,7 @@ bool CoordinateSystemNode_writeLocalData(const Object& obj, Output& fw) { const CoordinateSystemNode& csn = static_cast(obj); + fw.indent()<<"Format "<GetProjectionRef(); if (!pszSourceSRS || strlen(pszSourceSRS)==0) pszSourceSRS = gdalDataSet->GetGCPProjection(); - data->_cs = new osg::CoordinateSystemNode(pszSourceSRS); + data->_cs = new osg::CoordinateSystemNode("WKT",pszSourceSRS); double geoTransform[6]; if (gdalDataSet->GetGeoTransform(geoTransform)==CE_None)