Ejemplo n.º 1
0
void P2gWriter::done(PointTableRef table)
{

    double adfGeoTransform[6];
    adfGeoTransform[0] = m_bounds.minx - 0.5*m_GRID_DIST_X;
    adfGeoTransform[1] = m_GRID_DIST_X;
    adfGeoTransform[2] = 0.0;
    adfGeoTransform[3] = m_bounds.maxy + 0.5*m_GRID_DIST_Y;
    adfGeoTransform[4] = 0.0;
    adfGeoTransform[5] = -1 * m_GRID_DIST_Y;

    SpatialReference const& srs = table.spatialReference();

    log()->get(LogLevel::Debug) << "Output SRS  :'" << srs.getWKT() << "'" <<
        std::endl;

    // Strip off the extension if it was provided so that we don't get
    // file.asc.type.asc or file.asc.asc, as point2grid appends a file
    // extension.
    std::string extension = FileUtils::extension(m_filename);
    if (extension == ".asc" || extension == ".grid" || extension == ".tif")
        m_filename = m_filename.substr(0, m_filename.find_last_of("."));

    if (m_interpolator->finish(m_filename.c_str(), m_outputFormat,
        m_outputTypes, adfGeoTransform, srs.getWKT().c_str()) < 0)
    {
        ostringstream oss;

        oss << getName() << ": interp->finish() error";
        throw pdal_error(oss.str());
    }
    getMetadata().addList("filename", m_filename);
}
Ejemplo n.º 2
0
void P2gWriter::done(PointTableRef table)
{
    // If we never got any points, we're done.
    if (! m_coordinates.size()) return;

    m_GRID_SIZE_X = (int)(ceil((m_bounds.maxx - m_bounds.minx)/m_GRID_DIST_X)) + 1;
    m_GRID_SIZE_Y = (int)(ceil((m_bounds.maxy - m_bounds.miny)/m_GRID_DIST_Y)) + 1;

    log()->get(LogLevel::Debug) << "X grid size: " << m_GRID_SIZE_X << std::endl;
    log()->get(LogLevel::Debug) << "Y grid size: " << m_GRID_SIZE_Y << std::endl;


    log()->floatPrecision(6);
    log()->get(LogLevel::Debug) << "X grid distance: " << m_GRID_DIST_X << std::endl;
    log()->get(LogLevel::Debug) << "Y grid distance: " << m_GRID_DIST_Y << std::endl;
    log()->clearFloat();

    std::unique_ptr<OutCoreInterp> p(new OutCoreInterp(m_GRID_DIST_X,
                                       m_GRID_DIST_Y,
                                       m_GRID_SIZE_X,
                                       m_GRID_SIZE_Y,
                                       m_RADIUS * m_RADIUS,
                                       m_bounds.minx,
                                       m_bounds.maxx,
                                       m_bounds.miny,
                                       m_bounds.maxy,
                                       m_fill_window_size));
    m_interpolator.swap(p);

    if (m_interpolator->init() < 0)
    {
        throw p2g_error("unable to initialize interpolator");
    }

    for (auto coord : m_coordinates)
    {
        double x = coord.x - m_bounds.minx;
        double y = coord.y - m_bounds.miny;
        double z = coord.z;

        if (m_interpolator->update(x, y, z) < 0)
            throw p2g_error("interp->update() error while processing ");
    }

    double adfGeoTransform[6];
    adfGeoTransform[0] = m_bounds.minx - 0.5*m_GRID_DIST_X;
    adfGeoTransform[1] = m_GRID_DIST_X;
    adfGeoTransform[2] = 0.0;
    adfGeoTransform[3] = m_bounds.maxy + 0.5*m_GRID_DIST_Y;
    adfGeoTransform[4] = 0.0;
    adfGeoTransform[5] = -1 * m_GRID_DIST_Y;

    SpatialReference const& srs = table.spatialReference();

    log()->get(LogLevel::Debug) << "Output SRS  :'" << srs.getWKT() << "'" <<
        std::endl;
    if (m_interpolator->finish(const_cast<char*>(m_filename.c_str()),
        m_outputFormat, m_outputTypes, adfGeoTransform,
        srs.getWKT().c_str()) < 0)
    {
        throw p2g_error("interp->finish() error");
    }
}