Added CoordinateSystem::s/getFormat().
This commit is contained in:
@@ -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> _ellipsoidModel;
|
||||
|
||||
};
|
||||
|
||||
@@ -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<<std::endl;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include <osg/Notify>
|
||||
|
||||
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="<<latitude<<"\tlong="<<longitude<<"\theight"<<height<<std::endl;
|
||||
|
||||
_ellipsoidModel->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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -27,6 +27,15 @@ bool CoordinateSystemNode_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
CoordinateSystemNode& csn = static_cast<CoordinateSystemNode&>(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<const CoordinateSystemNode&>(obj);
|
||||
|
||||
fw.indent()<<"Format "<<fw.wrapString(csn.getFormat())<<std::endl;
|
||||
fw.indent()<<"CoordinateSystem "<<fw.wrapString(csn.getCoordinateSystem())<<std::endl;
|
||||
|
||||
if (csn.getEllipsoidModel())
|
||||
|
||||
@@ -191,7 +191,7 @@ DataSet::SourceData* DataSet::SourceData::readData(Source* source)
|
||||
const char* pszSourceSRS = gdalDataSet->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)
|
||||
|
||||
Reference in New Issue
Block a user