Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-01-13 Thread Bob Moskovitz
Is there a bug tracker for osg?  I've seen the trac openscenegraph website but 
the registration page seems to be broke.

Cheers,
Bob

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=62304#62304





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-01-14 Thread Bob Moskovitz
Hi,

This is information I got from the GDAL devs:

>  hello all.  I was trying to compile OpenSceneGraph-3.0.1 and 
> got this error http://pastebin.com/raw.php?i=c1MAC1rQ . Is this related to 
> api changes in GDAL 2.0?  How do I fix it?
>cgs_bob: yes. see 
> http://svn.osgeo.org/gdal/trunk/gdal/MIGRATION_GUIDE.TXT
>  EvenR: thanks for the tip.  I'll give it  a try
>using OGROpen(), and the C API, if you want it to be compabile 
> with both GDAL 1.X and 2.X is probably the best solution 
>I guess this will bite a few people, but would have been 
> awkward to let that as a left-over
>  I'll have to see what requires the least amount of work.
>  EvenR: OpenSceneGraph is a C++ library.  How could I use the  
> OGROpen(), and the C API to solve this compiler error?
>this is described in http://gdal.org/ogr_apitut.html (or 
> http://gdal.org/1.11/ogr/ogr_apitut.html if you want GDAL 1.X compatibilty as 
> well)
> 

The pastebin url refers to the error message in the first post.
Thank you!

Cheers,
Bob[/quote][/url]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=62313#62313





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-01-14 Thread Jordi Torres
Hi Bob,

AFAIK There is not a bug tracker for OSG. The trac is not open for
registration intentionally, it is out of date and it is up for
backup/historical purposes only.

Cheers.

2015-01-12 19:32 GMT+01:00 Bob Moskovitz :

> Is there a bug tracker for osg?  I've seen the trac openscenegraph website
> but the registration page seems to be broke.
>
> Cheers,
> Bob
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62304#62304
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jordi Torres
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-01-14 Thread Robert Osfield
Hi Bob,

On 12 January 2015 at 18:32, Bob Moskovitz  wrote:

> Is there a bug tracker for osg?  I've seen the trac openscenegraph website
> but the registration page seems to be broke.
>

I've deliberately avoiding bug trackers so that issues are reported
osg-users so that many eye balls can respond/chip in with their suggestions.

Cheers,
Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-01-14 Thread Robert Osfield
Hi Bob,

How far have you got with porting? BTW, could you try working on at least
OSG-3.2.1, or preferably the svn/trunk so that you are testing against the
latest OSG - this is also where any fixes you have will be checked in.

Retaining backwards compatibility with compiling against GDAL-1.x is
important as lot of others users will have this on their systems.

Cheers,
Robert.

On 14 January 2015 at 07:16, Bob Moskovitz  wrote:

> Hi,
>
> This is information I got from the GDAL devs:
>
> >  hello all.  I was trying to compile OpenSceneGraph-3.0.1
> and got this error http://pastebin.com/raw.php?i=c1MAC1rQ . Is this
> related to api changes in GDAL 2.0?  How do I fix it?
> >cgs_bob: yes. see
> http://svn.osgeo.org/gdal/trunk/gdal/MIGRATION_GUIDE.TXT
> >  EvenR: thanks for the tip.  I'll give it  a try
> >using OGROpen(), and the C API, if you want it to be
> compabile with both GDAL 1.X and 2.X is probably the best solution
> >I guess this will bite a few people, but would have been
> awkward to let that as a left-over
> >  I'll have to see what requires the least amount of work.
> >  EvenR: OpenSceneGraph is a C++ library.  How could I use
> the  OGROpen(), and the C API to solve this compiler error?
> >this is described in http://gdal.org/ogr_apitut.html (or
> http://gdal.org/1.11/ogr/ogr_apitut.html if you want GDAL 1.X
> compatibilty as well)
> >
>
> The pastebin url refers to the error message in the first post.
> Thank you!
>
> Cheers,
> Bob[/quote][/url]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62313#62313
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-25 Thread Tony Vasile
Hi,
I get a similar problem with GDAL 2.0 and the OpenSceneGraph 3.2.1

Code:

home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp: 
In member function ‘virtual osgDB::ReaderWriter::ReadResult 
ReaderWriterOGR::readFile(const std::string&, const 
osgDB::ReaderWriter::Options*) const’:
/home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp:137:
 warning: ‘static OGRSFDriverRegistrar* OGRSFDriverRegistrar::GetRegistrar()’ 
is deprecated (declared at /usr/local/include/ogrsf_frmts.h:320)
/home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp:137:
 warning: ‘int OGRSFDriverRegistrar::GetDriverCount()’ is deprecated (declared 
at /usr/local/include/ogrsf_frmts.h:324)
/home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp:141:
 error: ‘Open’ is not a member of ‘OGRSFDriverRegistrar’
/home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp:161:
 warning: ‘virtual const char* OGRDataSource::GetName()’ is deprecated 
(declared at /usr/local/include/ogrsf_frmts.h:243)
/home/avasile/src/OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp:165:
 warning: ‘static void OGRDataSource::DestroyDataSource(OGRDataSource*)’ is 
deprecated (declared at /usr/local/include/ogrsf_frmts.h:245)





It seems that the GDAL API In 2.0 has changed so the code no longer compiles. 
If one looks at the appropriate OGR header file there is a comment to indicate 
that OGRSFDriverRegistrar is also deprecated and should be replace by 


Code:

//
/* OGRSFDriverRegistrar */
//

/**
 * LEGACY class. Use GDALDriverManager in your new code ! This class may be
 * removed in a later release.
 *
 * Singleton manager for OGRSFDriver instances that will be used to try
 * and open datasources.  Normally the registrar is populated with 
 * standard drivers using the OGRRegisterAll() function and does not need
 * to be directly accessed.  The driver registrar and all registered drivers
 * may be cleaned up on shutdown using OGRCleanupAll().
 *
 * @deprecated 
 */




The only open calls in 
Code:
ogr_api.h

 have  extra parameters 
Code:
OGRDataSourceH CPL_DLL OGROpen( const char *, int, OGRSFDriverH * ) 
CPL_WARN_UNUSED_RESULT;




to what is called from ReaderWriterOGR.cpp.
... 


Thank you!

Cheers,
Tony

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64188#64188





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-25 Thread Tony Vasile
Hi,

I have this patch so that it compiles but I don't have a ogr source file to 
test it against. But this allows OpenSceneGraph 3.2.1 to compile.

... 


Thank you!

Cheers,
Tony

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64190#64190



--- OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp 2012-03-22 
04:36:20.0 +1100
+++ ../OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp  
2015-06-25 17:53:58.462196833 +1000
@@ -134,11 +134,13 @@
 
 virtual ReadResult readFile(const std::string& fileName, const 
osgDB::ReaderWriter::Options* options) const
 {
-if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0)
-OGRRegisterAll();
+if (GDALGetDriverCount() == 0)
+GDALAllRegister();
 
 // Try to open data source
-OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str());
+//OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str());
+GDALDataset   *file;
+file = (GDALDataset*) GDALOpenEx( fileName.c_str(), GDAL_OF_VECTOR, 
NULL, NULL, NULL );
 if (!file)
 return 0;
 
@@ -156,13 +158,14 @@
 
 osg::Group* group = new osg::Group;
 
-for (int i = 0; i < file->GetLayerCount(); i++)
+for (int i = 0; i < GDALDatasetGetLayerCount(file); i++)
 {
-osg::Group* node = readLayer(file->GetLayer(i), file->GetName(), 
useRandomColorByFeature, addGroupPerFeature);
+OGRLayer* layer = (OGRLayer *)GDALDatasetGetLayer(file, i); 
+osg::Group* node = readLayer(layer, layer->GetName(), 
useRandomColorByFeature, addGroupPerFeature);
 if (node)
 group->addChild( node );
 }
-OGRDataSource::DestroyDataSource( file );
+GDALClose( file );
 return group;
 }
 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-26 Thread Robert Osfield
 Hi Tony,

You suggested changed breaks the build for GDAL<2.0.

I have changed the ReaderWriterOGR.cpp to contain both the original code
blocks and the ones modified by you with a GDAL_VERSION_MAJOR<2 check.
Attached is the modified file.  Could you try this out, if it works fine
I'll check it into svn/trunk and the OSG-3.2 branch.

Robert.

On 25 June 2015 at 09:01, Tony Vasile  wrote:

> Hi,
>
> I have this patch so that it compiles but I don't have a ogr source file
> to test it against. But this allows OpenSceneGraph 3.2.1 to compile.
>
> ...
>
>
> Thank you!
>
> Cheers,
> Tony
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64190#64190
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-26 Thread Tony Vasile
Hi Robert,
  Am I going blind I can see your attachment with your modified patch?

... 


Thank you!

Cheers,
Tony

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64200#64200





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-26 Thread Tony Vasile
Hi Robert

Not sure if you came up with this but since I couldn't see your version of the 
patch I recreated it.

... 


Thank you!

Cheers,
Tony

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64201#64201



--- OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp 2012-03-22 
04:36:20.0 +1100
+++ ../OpenSceneGraph-3.2.1/src/osgPlugins/ogr/ReaderWriterOGR.cpp  
2015-06-26 21:53:33.349709134 +1000
@@ -134,11 +134,21 @@
 
 virtual ReadResult readFile(const std::string& fileName, const 
osgDB::ReaderWriter::Options* options) const
 {
+#if GDAL_VERSION_MAJOR < 2
 if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0)
 OGRRegisterAll();
+#else
+if (GDALGetDriverCount() == 0)
+GDALAllRegister();
+#endif
 
 // Try to open data source
+#if GDAL_VERSION_MAJOR < 2
 OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str());
+#else
+GDALDataset   *file;
+file = (GDALDataset*) GDALOpenEx( fileName.c_str(), GDAL_OF_VECTOR, 
NULL, NULL, NULL );
+#endif
 if (!file)
 return 0;
 
@@ -156,6 +166,7 @@
 
 osg::Group* group = new osg::Group;
 
+#if GDAL_VERSION_MAJOR < 2
 for (int i = 0; i < file->GetLayerCount(); i++)
 {
 osg::Group* node = readLayer(file->GetLayer(i), file->GetName(), 
useRandomColorByFeature, addGroupPerFeature);
@@ -163,6 +174,16 @@
 group->addChild( node );
 }
 OGRDataSource::DestroyDataSource( file );
+#else
+for (int i = 0; i < file->GetLayerCount(); i++)
+{
+OGRLayer* layer = (OGRLayer *)GDALDatasetGetLayer(file, i); 
+osg::Group* node = readLayer(layer, layer->GetName(), 
useRandomColorByFeature, addGroupPerFeature);
+if (node)
+group->addChild( node );
+}
+GDALClose( file );
+#endif
 return group;
 }
 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.3.4 with GDAL 2.0

2015-06-26 Thread Robert Osfield
On 26 June 2015 at 13:39, Tony Vasile  wrote:

> Not sure if you came up with this but since I couldn't see your version of
> the patch I recreated it.
>

Oppps. Must have missed attaching the file...

You file looks roughly the same.  In my change I cleaned up one of the
commented out lines in your code.

Robert.
/* -*- mode: c++; c-default-style: k&r; tab-width: 4; c-basic-offset: 4; -*-
 * Copyright (C) 2007 Cedric Pinson - morni...@plopbyte.net
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define SERIALIZER() OpenThreads::ScopedLock lock(_serializerMutex)

void CPL_STDCALL CPLOSGErrorHandler( CPLErr eErrClass, int nError,
 const char * pszErrorMsg )
{
if( eErrClass == CE_Debug )
{
OSG_DEBUG << pszErrorMsg << std::endl;
}
else if( eErrClass == CE_Warning )
{
OSG_WARN << nError << " " << pszErrorMsg << std::endl;
}
else
{
OSG_FATAL << nError << " " << pszErrorMsg << std::endl;
}
}

static osg::Material* createDefaultMaterial()
{
osg::Vec4 color;
for (int i = 0; i < 3; i++)
color[i] = (1.0 * (rand() / (1.0*RAND_MAX)));
color[3] = 1;
osg::Material* mat = new osg::Material;
mat->setDiffuse(osg::Material::FRONT_AND_BACK, color);
return mat;
}

struct TriangulizeFunctor
{
osg::Vec3Array* _vertexes;

// do nothing
void operator ()(const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool treatVertexDataAsTemporary) {
_vertexes->push_back(v1);
_vertexes->push_back(v2);
_vertexes->push_back(v3);
}
};

static osg::Vec3Array* triangulizeGeometry(osg::Geometry* src)
{
if (src->getNumPrimitiveSets() == 1 &&
src->getPrimitiveSet(0)->getType() == osg::PrimitiveSet::DrawArraysPrimitiveType &&
src->getVertexArray() &&
src->getVertexArray()->getType() == osg::Array::Vec3ArrayType)
return static_cast(src->getVertexArray());

osg::TriangleFunctor functor;
osg::Vec3Array* array = new osg::Vec3Array;
functor._vertexes = array;
src->accept(functor);
return array;
}


class ReaderWriterOGR : public osgDB::ReaderWriter
{

public:
ReaderWriterOGR()
{
supportsExtension("ogr","OGR file reader");
supportsOption("useRandomColorByFeature", "Assign a random color to each feature.");
supportsOption("addGroupPerFeature", "Places each feature in a separate group.");
oldHandler = CPLSetErrorHandler(CPLOSGErrorHandler);
}

virtual ~ReaderWriterOGR()
{
CPLSetErrorHandler(oldHandler);
}

virtual const char* className() const { return "OGR file reader"; }

virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
OSG_INFO<<"OGR::readNode("< lock(_serializerMutex);
return readFile(osgDB::getNameLessExtension(file), options);
}

OpenThreads::ScopedLock lock(_serializerMutex);
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return readFile(file, options); // ReadResult::FILE_NOT_FOUND;

return readFile(fileName, options);
}

virtual ReadResult readFile(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
{
#if GDAL_VERSION_MAJOR<2
if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0)
OGRRegisterAll();

// Try to open data source
OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str());
#else
if (GDALGetDriverCount() == 0)
GDALAllRegister();

// Try to open data source
GDALDataset* file  = (GDALDataset*) GDALOpenEx( fileName.c_str(), GDAL_OF_VECTOR, NULL, NULL, NULL );
#endif

if (!file)
return 0;

bool useRandomColorByFeature = false;
bool addGroupPerFeature = false;
if (options)
{
if (options->getOptionString().find("UseRandomColorByFeature") != std::string::npos)
useRandomColorByFeature = true;
if (options->getOptionString().find("useRandomColorByFeature") != std::string::npos)
useRandomColorByFeature = true;
if (options->getOpti