Ejemplo n.º 1
0
boost::uint32_t Reader::processBuffer(PointBuffer& data, boost::uint64_t index) const
{
    const Schema& schema = data.getSchema();

    // how many are they asking for?
    boost::uint64_t numPointsWanted = data.getCapacity();

    // we can only give them as many as we have left
    boost::uint64_t numPointsAvailable = getNumPoints() - index;
    if (numPointsAvailable < numPointsWanted)
        numPointsWanted = numPointsAvailable;

    schema::DimensionMap* d = m_buffer.getSchema().mapDimensions(data.getSchema());

    data.setNumPoints(0);

    PointBuffer::copyLikeDimensions(m_buffer, data,
                                    *d,
                                    index,
                                    0,
                                    numPointsWanted);

    data.setNumPoints(numPointsWanted);
    delete d;
    return numPointsWanted;
}
Ejemplo n.º 2
0
void Selector::alterSchema(PointBuffer& buffer)
{
    Schema const& original_schema = buffer.getSchema();

    Schema new_schema = buffer.getSchema();
    
    std::map<std::string, bool> const& ignoredMap = m_selectorFilter.getIgnoredMap();
    // for (std::map<std::string, bool>::const_iterator i = ignoredMap.begin();
    //     i != ignoredMap.end(); ++i)
    // {
    //     boost::optional<Dimension const&> d = original_schema.getDimensionOptional(i->first);
    //     if (d)
    //     {
    //         Dimension d2(*d);
    //         boost::uint32_t flags = d2.getFlags();
    //         if (i->second)
    //             d2.setFlags(flags | dimension::IsIgnored);
    //         new_schema.setDimension(d2);
    //     }
    // }
    // 

    schema::Map dimensions = original_schema.getDimensions();
    schema::index_by_index const& dims = dimensions.get<schema::index>();
    for (schema::index_by_index::const_iterator t = dims.begin(); 
         t != dims.end(); 
         ++t)
    {
        
        std::map<std::string, bool>::const_iterator ignored = ignoredMap.find(t->getName());
        if (ignored != ignoredMap.end())
        {
            if (ignored->second) // marked to be dropped
            {
                // set to ignored
                Dimension d2(*t);
                boost::uint32_t flags = d2.getFlags();
                d2.setFlags(flags | dimension::IsIgnored);
                new_schema.setDimension(d2);
            }
        }
        
        else { // didn't find it in our map of specified dimensions
            
            if (m_selectorFilter.doIgnoreUnspecifiedDimensions())
            {
                // set to ignored
                Dimension d2(*t);
                boost::uint32_t flags = d2.getFlags();
                d2.setFlags(flags | dimension::IsIgnored);
                new_schema.setDimension(d2);
            }
        }

    }

    buffer = PointBuffer(new_schema, buffer.getCapacity());
}
Ejemplo n.º 3
0
boost::uint32_t Predicate::processBuffer(PointBuffer& data, pdal::plang::BufferedInvocation& python) const
{
    python.resetArguments();

    python.beginChunk(data);

    python.execute();

    if (!python.hasOutputVariable("Mask"))
    {
        throw python_error("Mask variable not set in predicate filter function");
    }

    boost::uint8_t* mask = new boost::uint8_t[data.getNumPoints()];

    PointBuffer dstData(data.getSchema(), data.getCapacity());

    python.extractResult("Mask", (boost::uint8_t*)mask, data.getNumPoints(), 1, pdal::dimension::RawByte, 1);

    boost::uint8_t* dst = dstData.getData(0);
    boost::uint8_t* src = data.getData(0);

    const Schema& schema = dstData.getSchema();
    boost::uint32_t numBytes = schema.getByteSize();
    assert(numBytes == data.getSchema().getByteSize());

    boost::uint32_t numSrcPoints = data.getNumPoints();
    boost::uint32_t count = 0;
    for (boost::uint32_t srcIndex=0; srcIndex<numSrcPoints; srcIndex++)
    {
        if (mask[srcIndex])
        {
            memcpy(dst, src, numBytes);
            dst += numBytes;
            ++count;
            dstData.setNumPoints(count);
        }
        src += numBytes;
    }


    data.copyPointsFast(0, 0, dstData, count);
    data.setNumPoints(count);

    delete[] mask;

    return count;
}
Ejemplo n.º 4
0
boost::uint32_t Mosaic::readBufferImpl(PointBuffer& destData)
{
    boost::uint32_t totalNumPointsToRead = destData.getCapacity();
    boost::uint32_t totalNumPointsRead = 0;
    boost::uint32_t destPointIndex = 0;

    // for each stage, we read as many points as we can
    while (totalNumPointsRead < totalNumPointsToRead)
    {
        assert(m_iteratorIndex < m_prevIterators.size());
        m_prevIterator = m_prevIterators[m_iteratorIndex];

        // read as much as we can into temp buffer
        PointBuffer tmp(destData.getSchema(), totalNumPointsToRead-totalNumPointsRead);
        boost::uint32_t numRead = m_prevIterator->read(tmp);
        totalNumPointsRead += numRead;

        // concat the temp buffer on to end of real dest buffer
        destData.copyPointsFast(destPointIndex, 0, tmp, numRead);
        destPointIndex += numRead;
        destData.setNumPoints(destData.getNumPoints() + numRead);

        if (m_prevIterator->atEnd())
        {
            ++m_iteratorIndex;
        }
        if (m_iteratorIndex == m_prevIterators.size())
        {
            break;
        }
    }

    return totalNumPointsRead;
}
Ejemplo n.º 5
0
void Index::readBufferBeginImpl(PointBuffer& buffer)
{
    // Cache dimension positions

    if (!m_xDim && !m_yDim && !m_zDim)
    {
        pdal::Schema const& schema = buffer.getSchema();

        std::string x_name = m_stage.getOptions().getValueOrDefault<std::string>("x_dim", "X");
        std::string y_name = m_stage.getOptions().getValueOrDefault<std::string>("x_dim", "Y");
        std::string z_name = m_stage.getOptions().getValueOrDefault<std::string>("x_dim", "Z");

        m_stage.log()->get(logDEBUG2) << "Indexing PointBuffer with X: '" << x_name 
                                      << "' Y: '" << y_name 
                                      << "' Z: '" << z_name << " with " <<  m_stage.getDimensions() << " dimensions" << std::endl;
        m_xDim = &schema.getDimension(x_name);
        m_yDim = &schema.getDimension(y_name);
        m_zDim = &schema.getDimension(z_name);


        if (!m_stage.getNumPoints())
            throw pdal_error("Unable to create index from pipeline that has an indeterminate number of points!");
    }
        
}
Ejemplo n.º 6
0
void Colorization::readBufferBeginImpl(PointBuffer& buffer)
{
    // Cache dimension positions

    pdal::Schema const& schema = buffer.getSchema();
    m_dimX = &(schema.getDimension(m_stage.getOptions().getValueOrDefault<std::string>("x_dim", "X")));
    m_dimY = &(schema.getDimension(m_stage.getOptions().getValueOrDefault<std::string>("y_dim", "Y")));

    std::map<std::string, boost::uint32_t> band_map = m_stage.getBandMap();
    std::map<std::string, double> scale_map = m_stage.getScaleMap();
    
    m_dimensions.clear();
    m_bands.clear();
    m_scales.clear();
    
    for (std::map<std::string, boost::uint32_t>::const_iterator i = band_map.begin();
            i != band_map.end();
            ++i)
    {
        pdal::Dimension const* dim = &(schema.getDimension(i->first));
        m_dimensions.push_back(dim);
        m_bands.push_back(static_cast<boost::uint32_t>(i->second));
        std::map<std::string, double>::const_iterator t = scale_map.find(i->first);
        double scale(1.0);
        if (t != scale_map.end())
            scale = t->second;
        m_scales.push_back(scale);
    }


}
Ejemplo n.º 7
0
void Reprojection::processBuffer(PointBuffer& data) const
{
    const boost::uint32_t numPoints = data.getNumPoints();

    const Schema& schema = data.getSchema();
    
    Dimension const& dimX = schema.getDimension("X");
    Dimension const& dimY = schema.getDimension("Y");
    Dimension const& dimZ = schema.getDimension("Z");
    

    for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
    {
        double x = data.getField<double>(dimX, pointIndex);
        double y = data.getField<double>(dimY, pointIndex);
        double z = data.getField<double>(dimZ, pointIndex);

        this->transform(x,y,z);

        data.setField<double>(dimX, pointIndex, x);
        data.setField<double>(dimY, pointIndex, y);
        data.setField<double>(dimZ, pointIndex, z);

        data.setNumPoints(pointIndex+1);
    }

    return;
}
Ejemplo n.º 8
0
boost::uint32_t Crop::readBufferImpl(PointBuffer& dstData)
{
    // The client has asked us for dstData.getCapacity() points.
    // We will read from our previous stage until we get that amount (or
    // until the previous stage runs out of points).

    boost::uint32_t numPointsNeeded = dstData.getCapacity();
    assert(dstData.getNumPoints() == 0);

    while (numPointsNeeded > 0)
    {
        if (getPrevIterator().atEnd()) break;

        // set up buffer to be filled by prev stage
        PointBuffer srcData(dstData.getSchema(), numPointsNeeded);

        // read from prev stage
        const boost::uint32_t numSrcPointsRead = getPrevIterator().read(srcData);
        assert(numSrcPointsRead == srcData.getNumPoints());
        assert(numSrcPointsRead <= numPointsNeeded);

        // we got no data, and there is no more to get -- exit the loop
        if (numSrcPointsRead == 0) break;

        // copy points from src (prev stage) into dst (our stage), 
        // based on the CropFilter's rules (i.e. its bounds)
        const boost::uint32_t numPointsProcessed = m_cropFilter.processBuffer(dstData, srcData);

        numPointsNeeded -= numPointsProcessed;
    }

    const boost::uint32_t numPointsAchieved = dstData.getNumPoints();

    return numPointsAchieved;
}
Ejemplo n.º 9
0
boost::uint32_t ByteSwap::processBuffer(PointBuffer& dstData, const PointBuffer& srcData) const
{
    const Schema& dstSchema = dstData.getSchema();

    schema::index_by_index const& dstDims = dstSchema.getDimensions().get<schema::index>();

    dstData.setSpatialBounds(srcData.getSpatialBounds());
    dstData.copyPointsFast(0, 0, srcData, srcData.getNumPoints());

    dstData.setNumPoints(srcData.getNumPoints());

    for (boost::uint32_t i = 0; i != dstData.getNumPoints(); ++i)
    {
        boost::uint8_t* data = dstData.getData(i);
        std::size_t position = 0;
        for (boost::uint32_t n = 0; n < dstDims.size(); ++n)
        {
            const Dimension& d = dstSchema.getDimension(n);
            std::size_t size = d.getByteSize();

            boost::uint8_t* pos = data + position;
            SWAP_ENDIANNESS_N(*pos, size);
            position = position + size;
        }

    }

    return dstData.getNumPoints();
}
Ejemplo n.º 10
0
void IteratorBase::fillUserBuffer(PointBuffer& user_buffer)
{

    Schema const& user_schema = user_buffer.getSchema();
    schema::index_by_index const& idx = user_schema.getDimensions().get<schema::index>();

    boost::int32_t numUserSpace = user_buffer.getCapacity() - user_buffer.getNumPoints();
    if (numUserSpace < 0)
        throw pdal_error("We ran out of space!");

    boost::int32_t numOraclePoints = m_active_buffer->getNumPoints() - m_buffer_position;

    schema::index_by_index::size_type i(0);
    for (i = 0; i < idx.size(); ++i)
    {
        copyDatabaseData(*m_active_buffer,
                         user_buffer,
                         idx[i],
                         m_buffer_position,
                         user_buffer.getNumPoints(),
                         (std::min)(numOraclePoints,numUserSpace));

    }

    bool bSetPointSourceId = getReader().getOptions().getValueOrDefault<bool>("populate_pointsourceid", false);
    if (bSetPointSourceId)
    {
        Dimension const* point_source_field = &(user_buffer.getSchema().getDimensionOptional("PointSourceId").get());
        if (point_source_field)
        {
            for (boost::int32_t i = 0; i < numUserSpace; ++i)
            {
                if (i < 0)
                    throw sqlite_driver_error("point_source_field point index is less than 0!");
                user_buffer.setField(*point_source_field, i, m_active_cloud_id);
            }
        }
    }

    if (numOraclePoints > numUserSpace)
        m_buffer_position = m_buffer_position + numUserSpace;
    else if (numOraclePoints < numUserSpace)
        m_buffer_position = 0;

    boost::uint32_t howManyThisRead = (std::min)(numUserSpace, numOraclePoints);
    user_buffer.setNumPoints(howManyThisRead + user_buffer.getNumPoints());
}
Ejemplo n.º 11
0
void Cache::addToCache(boost::uint64_t pointIndex, const PointBuffer& data) const
{
    PointBuffer* block = new PointBuffer(data.getSchema(), m_cacheBlockSize);
    block->copyPointsFast(0, 0, data, m_cacheBlockSize);

    m_cache->insert(pointIndex, block);

    return;
}
Ejemplo n.º 12
0
PointBuffer* makeTestBuffer()
{
    Dimension d1("Classification", dimension::UnsignedInteger, 1);
    Dimension d2("X", dimension::SignedInteger, 4);
    Dimension d3("Y", dimension::Float, 8);
    Schema schema;
    schema.appendDimension(d1);
    schema.appendDimension(d2);
    schema.appendDimension(d3);

    std::size_t offX = schema.getDimension(0).getByteOffset();
    BOOST_CHECK(offX==0);
    std::size_t offY = schema.getDimension(1).getByteOffset();
    BOOST_CHECK(offY==1);
    std::size_t offZ = schema.getDimension(2).getByteOffset();
    BOOST_CHECK(offZ==5);

    boost::uint32_t capacity = 17;
    PointBuffer* data = new PointBuffer(schema, capacity);

    BOOST_CHECK(data->getCapacity() == capacity);

    Dimension const& dimC = data->getSchema().getDimension("Classification");
    Dimension const& dimX = data->getSchema().getDimension("X");
    Dimension const& dimY = data->getSchema().getDimension("Y");

    // write the data into the buffer
    for (boost::uint32_t i=0; i<data->getCapacity(); i++)
    {
        const boost::uint8_t x = static_cast<boost::uint8_t>(i)+1;
        const boost::int32_t y = i*10;
        const double z = i * 100;

        data->setField(dimC, i, x);
        data->setField(dimX, i, y);
        data->setField(dimY, i, z);
        data->setNumPoints(i+1);

    }
    BOOST_CHECK(data->getCapacity() ==17);
    BOOST_CHECK(data->getNumPoints() ==17);
    return data;
}
Ejemplo n.º 13
0
void Writer::writeBufferBegin(PointBuffer const& data)
{
    if (m_sdo_pc_is_initialized) return;

    CreateCloud(data.getSchema());
    m_sdo_pc_is_initialized = true;

    return;

}
Ejemplo n.º 14
0
static void verifyTestBuffer(const PointBuffer& data)
{
    Dimension const& dimC = data.getSchema().getDimension("Classification");
    Dimension const& dimX = data.getSchema().getDimension("X");
    Dimension const& dimY = data.getSchema().getDimension("Y");

    // read the data back out
    for (int i=0; i<17; i++)
    {
        const boost::uint8_t x = data.getField<boost::uint8_t>(dimC, i);
        const boost::int32_t y = data.getField<boost::int32_t>(dimX, i);
        const double z = data.getField<double>(dimY, i);

        BOOST_CHECK(x == i+1);
        BOOST_CHECK(y == i*10);

        BOOST_CHECK(Utils::compare_approx(z, static_cast<double>(i)*100.0, (std::numeric_limits<double>::min)()) == true);

    }
}
Ejemplo n.º 15
0
Reader::Reader(const Options& options, const PointBuffer& buffer)
    : pdal::Reader(options)
    , m_buffer(buffer)
{
    setNumPoints(buffer.getNumPoints());
    setBounds(buffer.getSpatialBounds());
    setSchema(buffer.getSchema());
    setPointCountType(PointCount_Fixed);

    return;
}
Ejemplo n.º 16
0
void Writer::writeBufferBegin(PointBuffer const& data)
{
    if (m_sdo_pc_is_initialized) return;

    CreatePCEntry(data.getSchema());
    m_trigger_name = ShutOff_SDO_PC_Trigger();
    
    m_sdo_pc_is_initialized = true;

    return;

}
Ejemplo n.º 17
0
    /*! bulk copy all the fields from the given point into this object
        \param destPointIndex the destination point index to copy the data from
                srcPointBuffer at srcPointIndex.
        \param srcPointIndex the point index of the PointBuffer to copy from.
        \param srcPointBuffer the source PointBuffer to copy from
        \verbatim embed:rst
        .. warning::

            This is only legal if the source and destination schemas are
            exactly the same. It is up the caller to ensure this is the case.
            Additionally, if the schemas are the same :cpp:func:`pdal::Schema::getByteSize()` but of
            different compositions, congratulations :)
        \endverbatim
    */
    inline void copyPointFast(boost::uint32_t destPointIndex,
                              boost::uint32_t srcPointIndex,
                              const PointBuffer& srcPointBuffer)
    {
        const boost::uint8_t* src = srcPointBuffer.getData(srcPointIndex);
        boost::uint8_t* dest = getData(destPointIndex);
        
        assert(srcPointBuffer.getSchema().getByteSize() == m_byteSize);
        
        memcpy(dest, src, m_byteSize);

        assert(m_numPoints <= m_capacity);

        return;
    }
Ejemplo n.º 18
0
void PDALtoPCD(PointBuffer& data, CloudT &cloud)
{
#ifdef PDAL_HAVE_PCL
    typedef typename pcl::traits::fieldList<typename CloudT::PointType>::type FieldList;

    const pdal::Schema &buffer_schema = data.getSchema();

    cloud.width = data.getNumPoints();
    cloud.height = 1;  // unorganized point cloud
    cloud.is_dense = false;
    cloud.points.resize(cloud.width);

    const pdal::Dimension &dX = buffer_schema.getDimension("X");
    const pdal::Dimension &dY = buffer_schema.getDimension("Y");
    const pdal::Dimension &dZ = buffer_schema.getDimension("Z");
    
    if (pcl::traits::has_xyz<typename CloudT::PointType>::value)
    {
        for (size_t i = 0; i < cloud.points.size(); ++i)
        {
            float xd = data.getField<int32_t>(dX, i) * dX.getNumericScale();
            float yd = data.getField<int32_t>(dY, i) * dY.getNumericScale();
            float zd = data.getField<int32_t>(dZ, i) * dZ.getNumericScale();

            typename CloudT::PointType p = cloud.points[i];
            p.x = xd; p.y = yd; p.z = zd;
            cloud.points[i] = p;
        }
    }

    boost::optional<pdal::Dimension const &> dI = buffer_schema.getDimensionOptional("Intensity");

    if (pcl::traits::has_intensity<typename CloudT::PointType>::value && dI)
    {
        for (size_t i = 0; i < cloud.points.size(); ++i)
        {
            boost::int32_t vi = data.getField<boost::int32_t>(*dI, i);

            float vd = dI->applyScaling(vi);

            typename CloudT::PointType p = cloud.points[i];
            pcl::for_each_type<FieldList> (pcl::SetIfFieldExists<typename CloudT::PointType, float> (p, "intensity", vd));
            cloud.points[i] = p;
        }
    }
#endif
}
Ejemplo n.º 19
0
void PcQuery::readPoints(   StageSequentialIterator* iter,
                            PointBuffer& data)
{
    const Schema& schema = data.getSchema();
    
    Dimension const& dimX = schema.getDimension("X");
    Dimension const& dimY = schema.getDimension("Y");
    Dimension const& dimZ = schema.getDimension("Z");

    boost::uint64_t id = 0;
    while (!iter->atEnd())
    {
        const boost::uint32_t numRead = iter->read(data);
        
        
    }

}
Ejemplo n.º 20
0
void Writer::PackPointData(PointBuffer const& buffer,
                           boost::uint8_t** point_data,
                           boost::uint32_t& point_data_len,
                           boost::uint32_t& schema_byte_size)

{
    // Creates a new buffer that has the ignored dimensions removed from
    // it.

    schema::index_by_index const& idx = buffer.getSchema().getDimensions().get<schema::index>();

    schema_byte_size = 0;
    schema::index_by_index::size_type i(0);
    for (i = 0; i < idx.size(); ++i)
    {
        if (! idx[i].isIgnored())
            schema_byte_size = schema_byte_size+idx[i].getByteSize();
    }

    log()->get(logDEBUG) << "Packed schema byte size " << schema_byte_size << std::endl;;

    point_data_len = buffer.getNumPoints() * schema_byte_size;
    *point_data = new boost::uint8_t[point_data_len];

    boost::uint8_t* current_position = *point_data;

    for (boost::uint32_t i = 0; i < buffer.getNumPoints(); ++i)
    {
        boost::uint8_t* data = buffer.getData(i);
        for (boost::uint32_t d = 0; d < idx.size(); ++d)
        {
            if (! idx[d].isIgnored())
            {
                memcpy(current_position, data, idx[d].getByteSize());
                current_position = current_position+idx[d].getByteSize();
            }
            data = data + idx[d].getByteSize();

        }
    }


}
Ejemplo n.º 21
0
void IteratorBase::copyDatabaseData(PointBuffer& source,
                                    PointBuffer& destination,
                                    Dimension const& dest_dim,
                                    boost::uint32_t source_starting_position,
                                    boost::uint32_t destination_starting_position,
                                    boost::uint32_t howMany)
{

    boost::optional<Dimension const&> source_dim = source.getSchema().getDimensionOptional(dest_dim.getName());

    if (!source_dim)
    {
        return;
    }

    for (boost::uint32_t i = 0; i < howMany; ++i)
    {
        if (dest_dim.getInterpretation() == source_dim->getInterpretation() &&
                dest_dim.getByteSize() == source_dim->getByteSize() &&
                pdal::Utils::compare_distance(dest_dim.getNumericScale(), source_dim->getNumericScale()) &&
                pdal::Utils::compare_distance(dest_dim.getNumericOffset(), source_dim->getNumericOffset()) &&
                dest_dim.getEndianness() == source_dim->getEndianness()
           )
        {
            // FIXME: This test could produce false positives
            boost::uint8_t* source_position = source.getData(source_starting_position+i) + source_dim->getByteOffset();
            boost::uint8_t* destination_position = destination.getData(destination_starting_position + i) + dest_dim.getByteOffset();
            memcpy(destination_position, source_position, source_dim->getByteSize());
        }
        else
        {
            PointBuffer::scaleData(source,
                                   destination,
                                   *source_dim,
                                   dest_dim,
                                   source_starting_position + i,
                                   destination_starting_position + i);
        }
    }

}
Ejemplo n.º 22
0
boost::uint32_t Writer::writeBuffer(const PointBuffer& data)
{
    const Schema& schema = data.getSchema();
    
    std::string z_name = getOptions().getValueOrDefault<std::string>("Z", "Z");
    pdal::Dimension const& dimX = schema.getDimension("X");
    pdal::Dimension const& dimY = schema.getDimension("Y");
    pdal::Dimension const& dimZ = schema.getDimension(z_name);


    boost::uint32_t numPoints = 0;


    double xd(0.0);
    double yd(0.0);
    double zd(0.0);

    for (boost::uint32_t pointIndex=0; pointIndex < data.getNumPoints(); pointIndex++)
    {
        boost::int32_t x = data.getField<boost::int32_t>(dimX, pointIndex);
        boost::int32_t y = data.getField<boost::int32_t>(dimY, pointIndex);
        boost::int32_t z = data.getField<boost::int32_t>(dimZ, pointIndex);

        xd = dimX.applyScaling<boost::int32_t>(x);
        yd = dimY.applyScaling<boost::int32_t>(y);
        zd = dimZ.applyScaling<boost::int32_t>(z);

        m_bounds.setMinimum(0, (std::min)(xd, m_bounds.getMinimum(0)));
        m_bounds.setMinimum(1, (std::min)(yd, m_bounds.getMinimum(1)));
        m_bounds.setMaximum(0, (std::max)(xd, m_bounds.getMaximum(0)));
        m_bounds.setMaximum(1, (std::max)(yd, m_bounds.getMaximum(1)));

        m_coordinates.push_back(boost::tuple<double, double, double>(xd, yd, zd));
        numPoints++;
    }

    return numPoints;
}
Ejemplo n.º 23
0
pdal::Bounds<double> Writer::CalculateBounds(PointBuffer const& buffer)
{
    pdal::Schema const& schema = buffer.getSchema();

    pdal::Bounds<double> output;

    boost::optional<Dimension const&> dimX = schema.getDimension("X");
    boost::optional<Dimension const&> dimY = schema.getDimension("Y");
    boost::optional<Dimension const&> dimZ = schema.getDimension("Z");


    bool first = true;
    for (boost::uint32_t pointIndex=0; pointIndex<buffer.getNumPoints(); pointIndex++)
    {
        const boost::int32_t xi = buffer.getField<boost::int32_t>(*dimX, pointIndex);
        const boost::int32_t yi = buffer.getField<boost::int32_t>(*dimY, pointIndex);
        const boost::int32_t zi = buffer.getField<boost::int32_t>(*dimZ, pointIndex);

        const double xd = dimX->applyScaling(xi);
        const double yd = dimY->applyScaling(yi);
        const double zd = dimZ->applyScaling(zi);

        Vector<double> v(xd, yd, zd);
        if (first)
        {
            output = pdal::Bounds<double>(xd, yd, zd, xd, yd, zd);
            if (m_pcExtent.empty())
                m_pcExtent = output;
            first = false;
        }
        output.grow(v);
    }

    m_pcExtent.grow(output);
    return output;

}
Ejemplo n.º 24
0
void Delta::outputDetail(PointBuffer& source_data,
                         IndexedPointBuffer& candidate_data,
                         std::map<Point, Point> *points) const
{
    Schema const& candidate_schema = candidate_data.getSchema();
    Dimension const& cDimX = candidate_schema.getDimension("X");
    Dimension const& cDimY = candidate_schema.getDimension("Y");
    Dimension const& cDimZ = candidate_schema.getDimension("Z");

    Schema const& source_schema = source_data.getSchema();
    Dimension const& sDimX = source_schema.getDimension("X");
    Dimension const& sDimY = source_schema.getDimension("Y");
    Dimension const& sDimZ = source_schema.getDimension("Z");
    
    bool bWroteHeader(false);
    
    std::ostream& ostr = m_outputStream ? *m_outputStream : std::cout;
    
    candidate_data.build(m_3d);
    boost::uint32_t count(std::min(source_data.getNumPoints(), candidate_data.getNumPoints()));
    

    for (boost::uint32_t i = 0; i < count; ++i)
    {
        double sx = source_data.applyScaling(sDimX, i);
        double sy = source_data.applyScaling(sDimY, i);
        double sz = source_data.applyScaling(sDimZ, i);                
        
        std::vector<std::size_t> ids = candidate_data.neighbors(sx, sy, sz, 1);
        
        if (!ids.size())
        {
			std::ostringstream oss;
			oss << "unable to find point for id '"  << i <<"'";
            throw app_runtime_error(oss.str() );
		}
        
        std::size_t id = ids[0];
        double cx = candidate_data.applyScaling(cDimX, id);
        double cy = candidate_data.applyScaling(cDimY, id);
        double cz = candidate_data.applyScaling(cDimZ, id);
        
        Point s(sx, sy, sz, id);
        Point c(cx, cy, cz, id);
        
        double xd = sx - cx;
        double yd = sy - cy;
        double zd = sz - cz;

        
        if (!bWroteHeader)
        {
            writeHeader(ostr, m_3d);
            bWroteHeader = true;
        }
        ostr << i << ",";
        boost::uint32_t precision = Utils::getStreamPrecision(cDimX.getNumericScale());
        ostr.setf(std::ios_base::fixed, std::ios_base::floatfield);
        ostr.precision(precision);
        ostr << xd << ",";

        precision = Utils::getStreamPrecision(cDimY.getNumericScale());
        ostr.precision(precision);
        ostr << yd;
        
        if (m_3d)
        {
            ostr << ",";
            precision = Utils::getStreamPrecision(cDimZ.getNumericScale());
            ostr.precision(precision);
            ostr << zd;
        }
        
        ostr << std::endl;

    }



    if (m_outputStream)
    {
        FileUtils::closeFile(m_outputStream);
    }    
}
Ejemplo n.º 25
0
uint32_t MrsidReader::processBuffer(PointBuffer& data, uint64_t index) const
{
    const Schema& schema = data.getSchema();

    // how many are they asking for?
    uint64_t numPointsWanted = data.getCapacity();

    // we can only give them as many as we have left
    uint64_t numPointsAvailable = getNumPoints() - index;
    if (numPointsAvailable < numPointsWanted)
        numPointsWanted = numPointsAvailable;


    LizardTech::PointData points;
    // to do:  specify a PointInfo structure that reads only the channels we will output.
    points.init(m_PS->getPointInfo(), (size_t)numPointsWanted);
    size_t count = m_iter->getNextPoints(points);

    uint32_t cnt = 0;
    data.setNumPoints(0);

    schema::index_by_index const& dims = schema.getDimensions().get<schema::index>();

    for (uint32_t pointIndex=0; pointIndex<count; pointIndex++)
    {
        ++cnt;

        for (unsigned int i=0; i < dims.size(); i++)
        {
            Dimension const& d = dims[i];

            if (d.getName() == "X" && d.getInterpretation() == dimension::Float && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_X))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_X)->getData());
                double value = static_cast<double>(pData[pointIndex]);
                data.setField<double>(d, pointIndex, value);
            }
            else if (d.getName() == "X" && d.getInterpretation() == dimension::SignedInteger && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_X))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_X)->getData());
                int32_t value = static_cast<int32_t>(pData[pointIndex]);
                data.setField<int32_t>(d, pointIndex, value);
            }
            else if (d.getName() == "Y" && d.getInterpretation() == dimension::Float && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_Y))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_Y)->getData());
                double value = static_cast<double>(pData[pointIndex]);
                data.setField<double>(d, pointIndex, value);
            }
            else if (d.getName() == "Y" && d.getInterpretation() == dimension::SignedInteger && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_Y))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_Y)->getData());
                int32_t value = static_cast<int32_t>(pData[pointIndex]);
                data.setField<int32_t>(d, pointIndex, value);
            }
            else if (d.getName() == "Z" && d.getInterpretation() == dimension::Float && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_Z))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_Z)->getData());
                double value = static_cast<double>(pData[pointIndex]);
                data.setField<double>(d, pointIndex, value);
            }
            else if (d.getName() == "Z" && d.getInterpretation() == dimension::SignedInteger && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_Z))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_Z)->getData());
                int32_t value = static_cast<int32_t>(pData[pointIndex]);
                data.setField<int32_t>(d, pointIndex, value);
            }
            else if (d.getName() == "Time" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_GPSTime))
            {
                double *pData = static_cast<double*>(points.getChannel(CHANNEL_NAME_GPSTime)->getData());
                uint64_t  value = static_cast<uint64_t>(pData[pointIndex]);
                data.setField<uint64_t>(d, pointIndex, value);
            }
            else if (d.getName() == "Intensity" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_Intensity))
            {
                uint16_t *pData = static_cast<uint16_t*>(points.getChannel(CHANNEL_NAME_Intensity)->getData());
                uint16_t value = static_cast<uint16_t>(pData[pointIndex]);
                data.setField<uint16_t>(d, pointIndex, value);
            }
            else if (d.getName() == "ReturnNumber" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_ReturnNum))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_ReturnNum)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "NumberOfReturns" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_NumReturns))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "ScanDirectionFlag" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_ScanDir))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "ScanAngleRank" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_ScanAngle))
            {
                int8_t *pData = static_cast<int8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                int8_t value = static_cast<int8_t>(pData[pointIndex]);
                data.setField<int8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "EdgeOfFlightLine" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_EdgeFlightLine))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "Classification" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_ClassId))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "UserData" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_UserData))
            {
                uint8_t *pData = static_cast<uint8_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint8_t value = static_cast<uint8_t>(pData[pointIndex]);
                data.setField<uint8_t>(d, pointIndex, value);
            }
            else if (d.getName() == "PointSourceId" && m_PS->getPointInfo().hasChannel(CHANNEL_NAME_SourceId))
            {
                uint16_t *pData = static_cast<uint16_t*>(points.getChannel(CHANNEL_NAME_NumReturns)->getData());
                uint16_t value = static_cast<uint16_t>(pData[pointIndex]);
                data.setField<uint16_t>(d, pointIndex, value);
            }


        }
    }
    data.setNumPoints(cnt);
    assert(cnt <= data.getCapacity());

    return cnt;
}
Ejemplo n.º 26
0
void IteratorBase::fillUserBuffer(PointBuffer& user_buffer)
{

    Schema const& user_schema = user_buffer.getSchema();
    schema::index_by_index const& idx = user_schema.getDimensions().get<schema::index>();

    boost::int32_t numOraclePoints = m_oracle_buffer->getNumPoints() - m_buffer_position;

    boost::int32_t numUserSpace = user_buffer.getCapacity() - user_buffer.getNumPoints();
    boost::int32_t howManyThisRead = (std::min)(numUserSpace, numOraclePoints);

    if (numUserSpace < 0)
    {
        std::ostringstream oss;
        oss << "numUserSpace < 0! : " << numUserSpace;
        throw pdal_error(oss.str());
    }

    if (numOraclePoints < 0)
    {
        std::ostringstream oss;
        oss << "numOraclePoints < 0! : " << numOraclePoints;
        throw pdal_error(oss.str());
    }

    if (user_buffer.getNumPoints() + howManyThisRead > user_buffer.getCapacity())
    {
        std::ostringstream oss;
        oss << "user_buffer.getNumPoints() + howManyThisRead == " << user_buffer.getNumPoints() + howManyThisRead 
            << " but user_buffer.getCapacity() == " << user_buffer.getCapacity();
        throw pdal_error(oss.str());
    }

 
    PointBuffer::copyLikeDimensions(*m_oracle_buffer, user_buffer,
                                    *m_dimension_map,
                                    m_buffer_position, user_buffer.getNumPoints(),
                                    howManyThisRead);


    Schema const& src = m_oracle_buffer->getSchema();
    Dimension const& src_x = src.getDimension("drivers.oci.reader.X");
    Dimension const& src_y = src.getDimension("drivers.oci.reader.Y");
    Dimension const& src_z = src.getDimension("drivers.oci.reader.Z");

    Schema const& dst = user_buffer.getSchema();
    Dimension const& dst_x = dst.getDimension("drivers.oci.reader.X");
    Dimension const& dst_y = dst.getDimension("drivers.oci.reader.Y");
    Dimension const& dst_z = dst.getDimension("drivers.oci.reader.Z");
    
    bool bDifferentScales = (!pdal::Utils::compare_distance(dst_x.getNumericScale(), src_x.getNumericScale()) ||
                             !pdal::Utils::compare_distance(dst_y.getNumericScale(), src_y.getNumericScale()) ||
                             !pdal::Utils::compare_distance(dst_z.getNumericScale(), src_z.getNumericScale()));

    bool bDifferentOffsets = (!pdal::Utils::compare_distance(dst_x.getNumericOffset(), src_x.getNumericOffset()) ||
                              !pdal::Utils::compare_distance(dst_y.getNumericOffset(), src_y.getNumericOffset()) ||
                              !pdal::Utils::compare_distance(dst_z.getNumericOffset(), src_z.getNumericOffset()));
    
    bool bNormalizeXYZ = getReader().getOptions().getValueOrDefault<bool>("do_normalize_xyz", true);
    if ((bDifferentScales || bDifferentOffsets) && bNormalizeXYZ)
    {
        for (unsigned i =  m_buffer_position; i < howManyThisRead; ++i)
        {
            double x = m_oracle_buffer->applyScaling(src_x, i);
            boost::int32_t xi = dst_x.removeScaling<boost::int32_t>(x);
            user_buffer.setField<boost::int32_t>(dst_x, user_buffer.getNumPoints()+i, xi);

            double y = m_oracle_buffer->applyScaling(src_y, i);
            boost::int32_t yi = dst_y.removeScaling<boost::int32_t>(y);
            user_buffer.setField<boost::int32_t>(dst_y, user_buffer.getNumPoints()+i, yi);
 
            double z = m_oracle_buffer->applyScaling(src_z, i);
            boost::int32_t zi = dst_z.removeScaling<boost::int32_t>(z);
            user_buffer.setField<boost::int32_t>(dst_z, user_buffer.getNumPoints()+i, zi);
        }
    }

    getReader().log()->get(logDEBUG2)   << "IteratorBase::fillUserBuffer m_buffer_position:   " 
                                        << m_buffer_position << std::endl;

    if (numOraclePoints > numUserSpace)
        m_buffer_position = m_buffer_position + numUserSpace;
    else if (numOraclePoints < numUserSpace)
        m_buffer_position = 0;

    getReader().log()->get(logDEBUG2) << "IteratorBase::fillUserBuffer m_buffer_position:   " 
                                      << m_buffer_position << std::endl;



    bool bSetPointSourceId = getReader().getOptions().getValueOrDefault<bool>("populate_pointsourceid", false);
    if (bSetPointSourceId)
    {
        Dimension const* point_source_field = user_buffer.getSchema().getDimensionPtr("PointSourceId");
        if (point_source_field)
        {
            for (boost::int32_t i = m_buffer_position; i < howManyThisRead; ++i)
            {
                assert(user_buffer.getNumPoints() + i < user_buffer.getCapacity());
                if (point_source_field->getByteSize() == 2)
                    user_buffer.setField(*point_source_field,
                                         user_buffer.getNumPoints() + i,
                                         static_cast<boost::uint16_t>(m_active_cloud_id));
                else if (point_source_field->getByteSize() == 4)
                {
                    user_buffer.setField(*point_source_field,
                                         user_buffer.getNumPoints() + i,
                                         m_active_cloud_id);
                }
            }
        }
    }


    user_buffer.setNumPoints(howManyThisRead + user_buffer.getNumPoints());
}
Ejemplo n.º 27
0
Archivo: Diff.cpp Proyecto: SCUSIT/PDAL
void Diff::checkPoints(  StageSequentialIterator* source_iter,
                         PointBuffer& source_data,
                         StageSequentialIterator* candidate_iter,
                         PointBuffer& candidate_data,
                         ptree& errors)
{

    boost::uint32_t i(0);
    boost::uint32_t chunk(0);
    boost::uint32_t MAX_BADBYTES(20);
    boost::uint32_t badbytes(0);
    while (!source_iter->atEnd())
    {
        const boost::uint32_t numSrcRead = source_iter->read(source_data);
        const boost::uint32_t numCandidateRead = candidate_iter->read(candidate_data);
        if (numSrcRead != numCandidateRead)
        {
            std::ostringstream oss;

            oss << "Unable to read same number of points for chunk number";
            errors.put<std::string>("points.error", oss.str());
            errors.put<boost::uint32_t>("points.candidate" , numCandidateRead);
            errors.put<boost::uint32_t>("points.source" , numSrcRead);
        }

        chunk++;

        pdal::pointbuffer::PointBufferByteSize source_byte_length(0);
        pdal::pointbuffer::PointBufferByteSize candidate_byte_length(0);
        source_byte_length =  static_cast<pdal::pointbuffer::PointBufferByteSize>(source_data.getSchema().getByteSize()) *
                              static_cast<pdal::pointbuffer::PointBufferByteSize>(source_data.getNumPoints());

        candidate_byte_length =  static_cast<pdal::pointbuffer::PointBufferByteSize>(candidate_data.getSchema().getByteSize()) *
                                 static_cast<pdal::pointbuffer::PointBufferByteSize>(candidate_data.getNumPoints());

        if (source_byte_length != candidate_byte_length)
        {
            std::ostringstream oss;

            oss << "Source byte length != candidate byte length";
            errors.put<std::string>("buffer.error", oss.str());
            errors.put<boost::uint32_t>("buffer.candidate" , candidate_byte_length);
            errors.put<boost::uint32_t>("buffer.source" , source_byte_length);
        }
        boost::uint8_t* s = source_data.getData(0);
        boost::uint8_t* c = candidate_data.getData(0);

        for (boost::uint32_t p = 0; p < std::min(source_byte_length, candidate_byte_length); ++p)
        {
            if (s[p] != c[p])
            {
                std::ostringstream oss;

                oss << "Byte number " << p << " is not equal for source and candidate";
                errors.put<std::string>("data.error", oss.str());
                badbytes++;
            }

        }

        if (badbytes > MAX_BADBYTES )
            break;

    }

}
Ejemplo n.º 28
0
DimensionMapPtr IteratorBase::fetchDimensionMap(Statement statement, sdo_pc* pc, PointBuffer const& oracle_buffer, PointBuffer const& user_buffer)
{
    
    boost::int32_t id = statement->GetInteger(&pc->pc_id);
    DimensionMaps::const_iterator i = m_dimensions.find(id);

    if (i != m_dimensions.end())
    {
        getReader().log()->get(logDEBUG2) << "IteratorBase::fetchDimensionMap: found existing DimensionMap with id " << id << std::endl;
        return i->second;
    }
    else
    {
        DimensionMapPtr output  = DimensionMapPtr(m_oracle_buffer->getSchema().mapDimensions(  user_buffer.getSchema(), 
                                                                                            false /*ignore namespaces*/));
        getReader().log()->get(logDEBUG2) << "DimensionMapPtr->size():  " << output->size() << std::endl;
        if (!output->size()) throw pdal_error("fetchDimensionMap map was unable to map any dimensions!");
        
        for (schema::DimensionMap::const_iterator i = output->begin(); i != output->end(); ++i)
        {
            getReader().log()->get(logDEBUG2) << "mapping " << i->first->getFQName() << " to " << i->second->getFQName() << std::endl;
        }
        std::pair<int, DimensionMapPtr> p(id, output);
        m_dimensions.insert(p);
        getReader().log()->get(logDEBUG2) << "IteratorBase::fetchDimensionMap: creating new DimensionMap with id " << id << std::endl;

        return p.second;
    }
}
Ejemplo n.º 29
0
boost::uint32_t InPlaceReprojection::readBufferImpl(PointBuffer& buffer)
{

    
    const boost::uint32_t numPoints = getPrevIterator().read(buffer);

    const Schema& schema = buffer.getSchema();
    
    Dimension const& old_x = schema.getDimension(m_reprojectionFilter.getOldXId());
    Dimension const& old_y = schema.getDimension(m_reprojectionFilter.getOldYId());
    Dimension const& old_z = schema.getDimension(m_reprojectionFilter.getOldZId());

    Dimension const& new_x = schema.getDimension(m_reprojectionFilter.getNewXId());
    Dimension const& new_y = schema.getDimension(m_reprojectionFilter.getNewYId());
    Dimension const& new_z = schema.getDimension(m_reprojectionFilter.getNewZId());
    
    bool logOutput = m_reprojectionFilter.log()->getLevel() > logDEBUG3;
    

    if (logOutput)
    {
        m_reprojectionFilter.log()->floatPrecision(8);
        m_reprojectionFilter.log()->get(logDEBUG3) << "old_x: " << old_x;
        m_reprojectionFilter.log()->get(logDEBUG3) << "old_y: " << old_y;
        m_reprojectionFilter.log()->get(logDEBUG3) << "old_z: " << old_z;

        m_reprojectionFilter.log()->get(logDEBUG3) << "new_x: " << new_x;
        m_reprojectionFilter.log()->get(logDEBUG3) << "new_y: " << new_y;
        m_reprojectionFilter.log()->get(logDEBUG3) << "new_z: " << new_z;
        
    }

    logOutput = m_reprojectionFilter.log()->getLevel() > logDEBUG3;

    for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
    {
        double x = m_reprojectionFilter.getScaledValue(buffer, old_x, pointIndex);
        double y = m_reprojectionFilter.getScaledValue(buffer, old_y, pointIndex);
        double z = m_reprojectionFilter.getScaledValue(buffer, old_z, pointIndex);
        
        if (logOutput)
            m_reprojectionFilter.log()->get(logDEBUG5) << "input: " << x << " y: " << y << " z: " << z << std::endl;
        m_reprojectionFilter.transform(x,y,z);
        if (logOutput)
            m_reprojectionFilter.log()->get(logDEBUG5) << "output: " << x << " y: " << y << " z: " << z << std::endl;
    
        m_reprojectionFilter.setScaledValue(buffer, x, new_x, pointIndex);
        m_reprojectionFilter.setScaledValue(buffer, y, new_y, pointIndex);
        m_reprojectionFilter.setScaledValue(buffer, z, new_z, pointIndex);
        
        if (logOutput)
        {
            m_reprojectionFilter.log()->get(logDEBUG5) << "scaled: " << m_reprojectionFilter.getScaledValue(buffer, new_x, pointIndex)
                  << " y: " << m_reprojectionFilter.getScaledValue(buffer, new_y, pointIndex)
                  << " z: " << m_reprojectionFilter.getScaledValue(buffer, new_z, pointIndex) << std::endl;
        }
    
        buffer.setNumPoints(pointIndex+1);
    }
    if (logOutput)
        m_reprojectionFilter.log()->clearFloat();

    updateBounds(buffer);

    return numPoints;
}
Ejemplo n.º 30
0
boost::uint32_t Reader::processBuffer(PointBuffer& data, boost::uint64_t index) const
{
    const Schema& schema = data.getSchema();

    // make up some data and put it into the buffer

    // how many are they asking for?
    boost::uint64_t numPointsWanted = data.getCapacity();

    // we can only give them as many as we have left
    boost::uint64_t numPointsAvailable = getNumPoints() - index;
    if (numPointsAvailable < numPointsWanted)
        numPointsWanted = numPointsAvailable;

    const Bounds<double>& bounds = getBounds();
    const std::vector< Range<double> >& dims = bounds.dimensions();
    const double minX = dims[0].getMinimum();
    const double maxX = dims[0].getMaximum();
    const double minY = dims[1].getMinimum();
    const double maxY = dims[1].getMaximum();
    const double minZ = dims[2].getMinimum();
    const double maxZ = dims[2].getMaximum();

    const double numDeltas = (double)getNumPoints() - 1.0;
    const double delX = (maxX - minX) / numDeltas;
    const double delY = (maxY - minY) / numDeltas;
    const double delZ = (maxZ - minZ) / numDeltas;

    const Dimension& dimX = schema.getDimension("X", getName());
    const Dimension& dimY = schema.getDimension("Y", getName());
    const Dimension& dimZ = schema.getDimension("Z", getName());
    const Dimension& dimTime = schema.getDimension("Time", getName());

    boost::uint64_t time = index;

    const Reader::Mode mode = getMode();

    boost::uint32_t cnt = 0;
    data.setNumPoints(0);

    for (boost::uint32_t pointIndex=0; pointIndex<numPointsWanted; pointIndex++)
    {
        double x;
        double y;
        double z;
        switch (mode)
        {
            case Reader::Random:
                x = Utils::random(minX, maxX);
                y = Utils::random(minY, maxY);
                z = Utils::random(minZ, maxZ);
                break;
            case Reader::Constant:
                x = minX;
                y = minY;
                z = minZ;
                break;
            case Reader::Ramp:
                x = minX + delX * pointIndex;
                y = minY + delY * pointIndex;
                z = minZ + delZ * pointIndex;
                break;
            default:
                throw pdal_error("invalid mode in FauxReader");
                break;
        }

        data.setField<double>(dimX, pointIndex, x);
        data.setField<double>(dimY, pointIndex, y);
        data.setField<double>(dimZ, pointIndex, z);
        data.setField<boost::uint64_t>(dimTime, pointIndex, time);

        ++time;

        ++cnt;
        data.setNumPoints(cnt);
        assert(cnt <= data.getCapacity());
    }

    return cnt;
}