(1) xmemory0(881): error C2440: “初始化”: 无法从“std::pair<const _Kty,_Ty>”转换为 to _Objty:
解决办法:
修改osgearth-2.x\src\osgEarthFeatures\
FeatureSourceIndexNode.cpp相应代码
30行附近:
namespace
{
// nifty template to iterate over a map's keys
template<typename T>
struct KeyIter : public T::iterator
{
KeyIter() : T::iterator() { }
KeyIter(typename T::iterator i) : T::iterator(i) { }
typename T::key_type* operator->() { return (typename T::key_type* const)&(T::iterator::operator->()->first); }
typename T::key_type operator*() { return T::iterator::operator*().first; }
};
template<typename T>
struct ConstKeyIter : public T::const_iterator
{
ConstKeyIter() : T::const_iterator() { }
ConstKeyIter(typename T::const_iterator i) : T::const_iterator(i) { }
typename T::key_type* operator->() { return (typename T::key_type* const)&(T::const_iterator::operator->()->first); }
typename T::key_type operator*() { return T::const_iterator::operator*().first; }
};
}
修改为:
namespace
{
// nifty template to iterate over a map's keys
template<typename T>
struct KeyIter : public std::iterator<std::input_iterator_tag, typename T::value_type>
{
typename T::const_iterator it;
KeyIter(typename T::const_iterator i) : it(i) { }
KeyIter &operator++() { ++it; return *this; }
KeyIter operator++(int) { KeyIter t = *this; ++*this; return t; }
typename T::key_type const *operator->() const { return &(it->first); }
typename T::key_type const &operator*() const { return it->first; }
friend bool operator==(KeyIter const &a, KeyIter const &b) { return a.it == b.it; }
friend bool operator!=(KeyIter const &a, KeyIter const &b) { return a.it != b.it; }
};
}
123行(上一步修改后的行数)附近:
bool
FeatureSourceIndexNode::getAllFIDs(std::vector<FeatureID>& output) const
{
ConstKeyIter<FIDMap> start( _fids.begin() );
ConstKeyIter<FIDMap> end ( _fids.end() );
for(ConstKeyIter<FIDMap> i = start; i != end; ++i )
{
output.push_back( *i );
}
return true;
}
修改为:
bool
FeatureSourceIndexNode::getAllFIDs(std::vector<FeatureID>& output) const
{
KeyIter<FIDMap> start( _fids.begin() );
KeyIter<FIDMap> end ( _fids.end() );
for(KeyIter<FIDMap> i = start; i != end; ++i )
{
output.push_back( *i );
}
return true;
}
(2)GEOS高版本引起的问题::
解决办法:
修改osgearth-2.x\src\osgEarthSymbology\GEOS.cpp相应代码
63行:
geom::CoordinateSequence* seq = factory->create( coords );
修改为:
geom::CoordinateSequence* seq = factory->create( coords ).get();
137行:
if ( shell )
{
const Symbology::Polygon* poly = static_cast<const Symbology::Polygon*>(input);
std::vector<geom::Geometry*>* holes = poly->getHoles().size() > 0 ? new std::vector<geom::Geometry*>() : 0L;
for( Symbology::RingCollection::const_iterator r = poly->getHoles().begin(); r != poly->getHoles().end(); ++r )
{
geom::Geometry* hole = import( r->get(), f );
if ( hole ) holes->push_back( hole );
}
if ( holes && holes->size() == 0 )
{
delete holes;
holes = 0L;
}
output = f->createPolygon( shell, holes );
}
修改为:
if ( shell )
{
const Symbology::Polygon* poly = static_cast<const Symbology::Polygon*>(input);
std::vector<geom::LinearRing*>* holes = poly->getHoles().size() > 0 ? new std::vector<geom::LinearRing*>() : 0L;
for( Symbology::RingCollection::const_iterator r = poly->getHoles().begin(); r != poly->getHoles().end(); ++r )
{
geom::LinearRing* hole = dynamic_cast<geom::LinearRing*>(import( r->get(), f ));
if ( hole ) holes->push_back( hole );
}
if ( holes && holes->size() == 0 )
{
delete holes;
holes = 0L;
}
output = f->createPolygon( shell, holes );
}
215行:
// Factory will clone the PM
_factory = new geos::geom::GeometryFactory( pm );
修改为:
// Factory will clone the PM
_factory = geos::geom::GeometryFactory::create( pm ).get();
224行:
delete _factory;
修改为:
//delete _factory;
_factory->destroy();
334行(上一步执行后):
delete f;
修改为:
f->destroy();//delete f;
(3)无法打开输入文件optimized.lib debug.lib
解决办法:
从OpenSceneGraph-3.4.0\CMakeModules拷贝一份FindZLIB.cmake放到osgEarth2.x\CMakeModules中,并删除14-20行代码。
if(EXISTS ${CMAKE_ROOT}/Modules/FindZLIB.cmake)
include(${CMAKE_ROOT}/Modules/FindZLIB.cmake)
if(ZLIB_FOUND)
return()
endif()
endif()