Skip to content

Commit

Permalink
scaffolding for kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Mar 16, 2015
1 parent 0fb7e95 commit b4b884e
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 0 deletions.
1 change: 1 addition & 0 deletions kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_subdirectory(info)
add_subdirectory(pipeline)
add_subdirectory(random)
add_subdirectory(sort)
add_subdirectory(tindex)
add_subdirectory(translate)

set(PDAL_TARGET_OBJECTS ${PDAL_TARGET_OBJECTS} PARENT_SCOPE)
18 changes: 18 additions & 0 deletions kernels/tindex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# TIndex kernel CMake configuration
#

#
# TIndex Kernel
#

set(srcs
TIndexKernel.cpp
)

set(incs
TIndexKernel.hpp
)

PDAL_ADD_DRIVER(kernel tindex "${srcs}" "${incs}" objects)
set(PDAL_TARGET_OBJECTS ${PDAL_TARGET_OBJECTS} ${objects} PARENT_SCOPE)
139 changes: 139 additions & 0 deletions kernels/tindex/TIndexKernel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/******************************************************************************
* Copyright (c) 2015, Howard Butler (howard@hobu.co)
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
****************************************************************************/

#include "TIndexKernel.hpp"

#include <memory>

#include <pdal/PDALUtils.hpp>
#include <ogr_api.h>

#include <boost/program_options.hpp>



namespace pdal
{

static PluginInfo const s_info = PluginInfo(
"kernels.tindex",
"TIndex Kernel",
"http://pdal.io/kernels/kernels.tindex.html" );

CREATE_STATIC_PLUGIN(1, 0, TIndexKernel, Kernel, s_info)

std::string TIndexKernel::getName() const { return s_info.name; }

TIndexKernel::TIndexKernel()
: Kernel()
, m_outputFilename("")

{}


void TIndexKernel::validateSwitches()
{
if (!m_outputFilename.size())
throw app_runtime_error("No source file given!");
}


void TIndexKernel::addSwitches()
{
namespace po = boost::program_options;

po::options_description* file_options =
new po::options_description("file options");

file_options->add_options()
("directory", po::value<std::string>(&m_indexDirectory), "Directory to index")
("filename", po::value<std::string>(&m_outputFilename), "OGR-writeable tile index output")
;

addSwitchSet(file_options);
po::options_description* processing_options =
new po::options_description("processing options");

processing_options->add_options();

addSwitchSet(processing_options);

addPositionalSwitch("filename", 1);
}


OGRGeometryH fetchGeometry(std::string const& filename)
{
Options readerOptions;

readerOptions.add<std::string>("filename", filename);
// setCommonOptions(readerOptions);
std::unique_ptr<PipelineManager> m_manager;



std::unique_ptr<PipelineManager> manager = std::unique_ptr<PipelineManager>(
KernelSupport::makePipeline(filename));

Stage* stage = manager->getStage();
stage->setOptions(readerOptions);

Stage* hexbinStage = &(m_manager->addFilter("filters.hexbin"));
Options hexOptions;
hexbinStage->setOptions(hexOptions);
hexbinStage->setInput(*stage);

stage = hexbinStage;

PointContext ctx;
stage->prepare(ctx);
stage->execute(ctx);

OGRGeometryH output(0);
return output;



}


int TIndexKernel::execute()
{


return 0;
}

} // namespace pdal

74 changes: 74 additions & 0 deletions kernels/tindex/TIndexKernel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/******************************************************************************
* Copyright (c) 2015, Howard Butler (howard@hobu.co)
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
****************************************************************************/

#pragma once

#include <pdal/Kernel.hpp>
#include <pdal/Stage.hpp>
#include <pdal/util/FileUtils.hpp>
#include <pdal/plugin.h>
#include <pdal/PointBuffer.hpp>


extern "C" int32_t TIndexKernel_ExitFunc();
extern "C" PF_ExitFunc TIndexKernel_InitPlugin();

namespace pdal
{


class PDAL_DLL TIndexKernel : public Kernel
{
public:
static void * create();
static int32_t destroy(void *);
std::string getName() const;
int execute(); // overrride


private:
TIndexKernel();
void addSwitches(); // overrride
void validateSwitches(); // overrride

// MetadataNode m_tree;
std::unique_ptr<PipelineManager> m_manager;

std::string m_outputFilename;
std::string m_indexDirectory;
std::vector<std::string> m_files;
};

} // namespace pdal

0 comments on commit b4b884e

Please sign in to comment.