2

I am using libspatialindex (http://libspatialindex.github.io/) library for r-tree construction: I am using the following code bulk loading the (latitude,longitude) in the r-tree. I need to bulk load (id,latitude,longitude) of a given place. The following code performs the bulk loading. But I dont know why is it not accepting the input file-- there is no documentation for libspatial index therefore I am confused.

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;
}

For input I am using the following file:

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

But I am getting the following error:

IllegalArgumentException: The data input should contain insertions only.

Can someone please help me as to where am I going wrong!!

Richard
  • 56,349
  • 34
  • 180
  • 251
user3809749
  • 129
  • 1
  • 6
  • Are there functions for creating the index? Probably that code is designed to work with files it created, and your file is not in the right format. Using it to create a file would allow you to study the resulting file. – Ben Voigt Jul 07 '14 at 18:23
  • @BenVoigt Ok..I am new to using libraries..can u please guide me a little bit as to how should I go about understanding libraries which have no documentation. As I really need to do bulk loading and then run some nearest neighbor and intersection queries on the top of it – user3809749 Jul 07 '14 at 18:26
  • 1
    Since there's no doc, read the source. Search for the error message that you see, and back up until you hit the condition then triggers the error. That will help you focus on whatever the library doesn't like in your data file. – Peter Jul 07 '14 at 19:02

0 Answers0