void Stage::setCoreProperties(const Stage& stage) { this->setSchema(stage.getSchema()); this->setNumPoints(stage.getNumPoints()); this->setPointCountType(stage.getPointCountType()); this->setBounds(stage.getBounds()); this->setSpatialReference(stage.getSpatialReference()); return; }
void Stage::execute(StreamPointTable& table, std::list<Stage *>& stages) { std::vector<bool> skips(table.capacity()); std::list<Stage *> filters; SpatialReference srs; // Separate out the first stage. Stage *reader = stages.front(); // Build a list of all stages except the first. We may have a writer in // this list in addition to filters, but we treat them in the same way. auto begin = stages.begin(); begin++; std::copy(begin, stages.end(), std::back_inserter(filters)); for (Stage *s : stages) { s->ready(table); srs = s->getSpatialReference(); if (!srs.empty()) table.setSpatialReference(srs); } // Loop until we're finished. We handle the number of points up to // the capacity of the StreamPointTable that we've been provided. bool finished = false; while (!finished) { // Clear the spatial reference when processing starts. table.clearSpatialReferences(); PointId idx = 0; PointRef point(table, idx); point_count_t pointLimit = table.capacity(); // When we get false back from a reader, we're done, so set // the point limit to the number of points processed in this loop // of the table. for (PointId idx = 0; idx < pointLimit; idx++) { point.setPointId(idx); finished = !reader->processOne(point); if (finished) pointLimit = idx; } srs = reader->getSpatialReference(); if (!srs.empty()) table.setSpatialReference(srs); // When we get a false back from a filter, we're filtering out a // point, so add it to the list of skips so that it doesn't get // processed by subsequent filters. for (Stage *s : filters) { for (PointId idx = 0; idx < pointLimit; idx++) { if (skips[idx]) continue; point.setPointId(idx); if (!s->processOne(point)) skips[idx] = true; } srs = s->getSpatialReference(); if (!srs.empty()) table.setSpatialReference(srs); } // Yes, vector<bool> is terrible. Can do something better later. for (size_t i = 0; i < skips.size(); ++i) skips[i] = false; table.reset(); } for (Stage *s : stages) s->done(table); }