Skip to content

Commit

Permalink
Semi-working tindex.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed May 14, 2015
1 parent 5f33657 commit 23c207c
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 130 deletions.
59 changes: 58 additions & 1 deletion include/pdal/GDALUtils.hpp
Expand Up @@ -48,12 +48,68 @@
#include "gdal.h"
#include <cpl_vsi.h>
#include <ogr_api.h>
#include <ogr_srs_api.h>

namespace pdal
{
namespace gdal
{

typedef std::shared_ptr<void> RefPtr;

class SpatialRef
{
public:
SpatialRef()
{ newRef(OSRNewSpatialReference("")); }
SpatialRef(const std::string& srs)
{
newRef(OSRNewSpatialReference(""));
OSRSetFromUserInput(get(), srs.data());
}

void setFromLayer(OGRLayerH layer)
{ newRef(OSRClone(OGR_L_GetSpatialRef(layer))); }
operator bool () const
{ return m_ref.get() != NULL; }
OGRSpatialReferenceH get() const
{ return m_ref.get(); }

private:
void newRef(void *v)
{
m_ref = RefPtr(v, [](void* t){ OSRDestroySpatialReference(t); } );
}

RefPtr m_ref;
};

class Geometry
{
public:
Geometry()
{}
Geometry(const std::string& wkt, const SpatialRef& srs)
{
OGRGeometryH geom;

char *p_wkt = const_cast<char *>(wkt.data());
OGR_G_CreateFromWkt(&p_wkt, srs.get(), &geom);
newRef(geom);
}

operator bool () const
{ return get() != NULL; }
OGRGeometryH get() const
{ return m_ref.get(); }

private:
void newRef(void *v)
{
m_ref = RefPtr(v, [](void* t){ OGR_G_DestroyGeometry(t); } );
}
RefPtr m_ref;
};

class PDAL_DLL ErrorHandler
{
Expand All @@ -64,7 +120,8 @@ class PDAL_DLL ErrorHandler

static void CPL_STDCALL trampoline(::CPLErr code, int num, char const* msg)
{
ErrorHandler* debug = static_cast<ErrorHandler*>(CPLGetErrorHandlerUserData());
ErrorHandler* debug =
static_cast<ErrorHandler*>(CPLGetErrorHandlerUserData());
if (!debug)
return;

Expand Down
1 change: 1 addition & 0 deletions include/pdal/Kernel.hpp
Expand Up @@ -143,6 +143,7 @@ class PDAL_DLL Kernel
}
bool argumentExists(const std::string& name)
{ return (bool)m_variablesMap.count(name); }
bool argumentSpecified(const std::string& name);

bool m_usestdin;
int m_argc;
Expand Down

0 comments on commit 23c207c

Please sign in to comment.