2

我正在使用 libspatialindex ( http://libspatialindex.github.io/ ) 库来构建 r-tree:我正在使用以下代码批量加载 r-tree 中的 (latitude,longitude)。我需要批量加载给定地点的(id、纬度、经度)。以下代码执行批量加载。但我不知道为什么它不接受输入文件——没有关于 libspatial 索引的文档,因此我很困惑。

int main(int argc, char** argv)
{
    try
    {
        if (argc != 5)
        {
            std::cerr << "Usage: " << argv[0] << " input_file tree_file capacity utilization." << std::endl;
            return -1;
        }

        std::string baseName = argv[2];
        double utilization = atof(argv[4]);

        IStorageManager* diskfile = StorageManager::createNewDiskStorageManager(baseName, 4096);
            // Create a new storage manager with the provided base name and a 4K page size.

        StorageManager::IBuffer* file = StorageManager::createNewRandomEvictionsBuffer(*diskfile, 10, false);
            // applies a main memory random buffer on top of the persistent storage manager
            // (LRU buffer, etc can be created the same way).

        MyDataStream stream(argv[1]);

        // Create and bulk load a new RTree with dimensionality 2, using "file" as
        // the StorageManager and the RSTAR splitting policy.
        id_type indexIdentifier;
        ISpatialIndex* tree = RTree::createAndBulkLoadNewRTree(
            RTree::BLM_STR, stream, *file, utilization, atoi(argv[3]), atoi(argv[3]), 2, SpatialIndex::RTree::RV_RSTAR, indexIdentifier);

        std::cerr << *tree;
        std::cerr << "Buffer hits: " << file->getHits() << std::endl;
        std::cerr << "Index ID: " << indexIdentifier << std::endl;

        bool ret = tree->isIndexValid();
        if (ret == false) std::cerr << "ERROR: Structure is invalid!" << std::endl;
        else std::cerr << "The stucture seems O.K." << std::endl;

        delete tree;
        delete file;
        delete diskfile;
            // delete the buffer first, then the storage manager
            // (otherwise the the buffer will fail trying to write the dirty entries).
    }
    catch (Tools::Exception& e)
    {
        std::cerr << "******ERROR******" << std::endl;
        std::string s = e.what();
        std::cerr << s << std::endl;
        return -1;
    }

    return 0;
}

对于输入,我使用以下文件:

1 12.2 12.2 14.4 14.4
2 10.1 10.1 15.2 15.2
3 12.2 12.2 14.5 14.5
4 10.0 10.0 15.1 15.6

但我收到以下错误:

IllegalArgumentException: The data input should contain insertions only.

有人可以帮我看看我哪里出错了!!

4

0 回答 0