Changeset 173
- Timestamp:
- 03/04/10 09:33:28 (5 months ago)
- Location:
- spatialindex/trunk
- Files:
-
- 6 modified
- 2 copied
-
include/capi/CountVisitor.h (copied) (copied from spatialindex/trunk/include/capi/IdVisitor.h) (1 diff)
-
include/capi/Makefile.am (modified) (1 diff)
-
include/capi/sidx_api.h (modified) (1 diff)
-
include/capi/sidx_impl.h (modified) (1 diff)
-
makefile.vc (modified) (1 diff)
-
src/capi/CountVisitor.cc (copied) (copied from spatialindex/trunk/src/capi/IdVisitor.cc) (1 diff)
-
src/capi/Makefile.am (modified) (1 diff)
-
src/capi/sidx_api.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
spatialindex/trunk/include/capi/CountVisitor.h
r172 r173 1 1 /****************************************************************************** 2 * $Id: idvisitor.hpp 1361 2009-08-02 17:53:31Z hobu$3 *4 * Project: libsidx - A C API wrapper around libspatialindex5 * Purpose: C++ object declarations to implement the wrapper.6 * Author: Howard Butler, hobu.inc@gmail.com 7 *8 ******************************************************************************9 * Copyright (c) 2009, Howard Butler 10 *11 * All rights reserved.12 *13 * This library is free software; you can redistribute it and/or modify it under14 * the terms of the GNU Lesser General Public License as published by the Free15 * Software Foundation; either version 2.1 of the License, or (at your option)16 * any later version.2 * $Id$ 3 * 4 * Project: libsidx - A C API wrapper around libspatialindex 5 * Purpose: C++ objects to implement the count visitor. 6 * Author: Leonard Norrgård, leonard.norrgard@refactor.fi 7 * 8 ****************************************************************************** 9 * Copyright (c) 2010, Leonard Norrgård 10 * 11 * All rights reserved. 12 * 13 * This library is free software; you can redistribute it and/or modify it under 14 * the terms of the GNU Lesser General Public License as published by the Free 15 * Software Foundation; either version 2.1 of the License, or (at your option) 16 * any later version. 17 17 18 * This library is distributed in the hope that it will be useful, but WITHOUT19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS20 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more21 * details.22 *23 * You should have received a copy of the GNU Lesser General Public License24 * along with this library; if not, write to the Free Software Foundation, Inc.,25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA26 ****************************************************************************/18 * This library is distributed in the hope that it will be useful, but WITHOUT 19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 21 * details. 22 * 23 * You should have received a copy of the GNU Lesser General Public License 24 * along with this library; if not, write to the Free Software Foundation, Inc., 25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 ****************************************************************************/ 27 27 28 28 #pragma once 29 29 30 class IdVisitor : public SpatialIndex::IVisitor30 class CountVisitor : public SpatialIndex::IVisitor 31 31 { 32 32 private: 33 std::vector<uint64_t> m_vector; 34 uint64_t nResults; 33 uint64_t nResults; 35 34 36 35 public: 37 36 38 IdVisitor();39 ~IdVisitor();37 CountVisitor(); 38 ~CountVisitor(); 40 39 41 uint64_t GetResultCount() const { return nResults; } 42 std::vector<uint64_t>& GetResults() { return m_vector; } 43 44 void visitNode(const SpatialIndex::INode& n); 45 void visitData(const SpatialIndex::IData& d); 46 void visitData(std::vector<const SpatialIndex::IData*>& v); 40 uint64_t GetResultCount() const { return nResults; } 41 42 void visitNode(const SpatialIndex::INode& n); 43 void visitData(const SpatialIndex::IData& d); 44 void visitData(std::vector<const SpatialIndex::IData*>& v); 47 45 }; -
spatialindex/trunk/include/capi/Makefile.am
r144 r173 3 3 dist_spatialindex_HEADERS = \ 4 4 BoundsQuery.h \ 5 CountVisitor.h \ 5 6 DataStream.h \ 6 7 Error.h \ 7 LeafQuery.h \8 8 IdVisitor.h \ 9 9 Index.h \ 10 LeafQuery.h \ 10 11 ObjVisitor.h \ 11 12 sidx_api.h \ -
spatialindex/trunk/include/capi/sidx_api.h
r172 r173 75 75 uint64_t* nResults); 76 76 77 SIDX_DLL RTError Index_Intersects_count( IndexH index, 78 double* pdMin, 79 double* pdMax, 80 uint32_t nDimension, 81 uint64_t* nResults); 77 82 SIDX_DLL RTError Index_NearestNeighbors_obj(IndexH index, 78 83 double* pdMin, -
spatialindex/trunk/include/capi/sidx_impl.h
r144 r173 38 38 #include <capi/ObjVisitor.h> 39 39 #include <capi/IdVisitor.h> 40 #include <capi/CountVisitor.h> 40 41 #include <capi/BoundsQuery.h> 41 42 #include <capi/LeafQuery.h> -
spatialindex/trunk/makefile.vc
r153 r173 137 137 138 138 COBJS = src\capi\BoundsQuery.obj \ 139 src\capi\CountVisitor.obj \ 139 140 src\capi\DataStream.obj \ 140 141 src\capi\Error.obj \ -
spatialindex/trunk/src/capi/CountVisitor.cc
r138 r173 1 1 2 /****************************************************************************** 2 * $Id: idvisitor.cc 1361 2009-08-02 17:53:31Z hobu$3 *4 * Project: libsidx - A C API wrapper around libspatialindex5 * Purpose: C++ objects to implement the idvisitor.6 * Author: Howard Butler, hobu.inc@gmail.com 7 *8 ******************************************************************************9 * Copyright (c) 2009, Howard Butler 10 *11 * All rights reserved.12 *13 * This library is free software; you can redistribute it and/or modify it under14 * the terms of the GNU Lesser General Public License as published by the Free15 * Software Foundation; either version 2.1 of the License, or (at your option)16 * any later version.3 * $Id$ 4 * 5 * Project: libsidx - A C API wrapper around libspatialindex 6 * Purpose: C++ objects to implement the count visitor. 7 * Author: Leonard Norrgård, leonard.norrgard@refactor.fi 8 * 9 ****************************************************************************** 10 * Copyright (c) 2010, Leonard Norrgård 11 * 12 * All rights reserved. 13 * 14 * This library is free software; you can redistribute it and/or modify it under 15 * the terms of the GNU Lesser General Public License as published by the Free 16 * Software Foundation; either version 2.1 of the License, or (at your option) 17 * any later version. 17 18 18 * This library is distributed in the hope that it will be useful, but WITHOUT19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS20 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more21 * details.22 *23 * You should have received a copy of the GNU Lesser General Public License24 * along with this library; if not, write to the Free Software Foundation, Inc.,25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA26 ****************************************************************************/19 * This library is distributed in the hope that it will be useful, but WITHOUT 20 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 21 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 22 * details. 23 * 24 * You should have received a copy of the GNU Lesser General Public License 25 * along with this library; if not, write to the Free Software Foundation, Inc., 26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 ****************************************************************************/ 27 28 28 29 #include "sidx_impl.h" 29 30 30 IdVisitor::IdVisitor(): nResults(0)31 CountVisitor::CountVisitor(): nResults(0) 31 32 { 32 33 } 33 34 34 IdVisitor::~IdVisitor()35 CountVisitor::~CountVisitor() 35 36 { 36 37 37 38 } 38 39 39 void IdVisitor::visitNode(const SpatialIndex::INode& n)40 void CountVisitor::visitNode(const SpatialIndex::INode& n) 40 41 { 41 42 42 43 } 43 44 44 void IdVisitor::visitData(const SpatialIndex::IData& d)45 void CountVisitor::visitData(const SpatialIndex::IData& d) 45 46 { 46 nResults += 1; 47 48 m_vector.push_back(d.getIdentifier()); 47 nResults += 1; 49 48 } 50 49 51 void IdVisitor::visitData(std::vector<const SpatialIndex::IData*>& v)50 void CountVisitor::visitData(std::vector<const SpatialIndex::IData*>& v) 52 51 { 53 52 } -
spatialindex/trunk/src/capi/Makefile.am
r144 r173 2 2 noinst_LTLIBRARIES = libsidxc.la 3 3 INCLUDES = -I../../include -I../../include/capi 4 libsidxc_la_SOURCES = BoundsQuery.cc \ 4 libsidxc_la_SOURCES = BoundsQuery.cc \ 5 CountVisitor.cc \ 5 6 DataStream.cc \ 6 7 Error.cc \ 7 LeafQuery.cc \8 8 IdVisitor.cc \ 9 9 Index.cc \ 10 LeafQuery.cc \ 10 11 ObjVisitor.cc \ 11 12 sidx_api.cc \ -
spatialindex/trunk/src/capi/sidx_api.cc
r172 r173 378 378 } 379 379 380 SIDX_C_DLL RTError Index_Intersects_count( IndexH index, 381 double* pdMin, 382 double* pdMax, 383 uint32_t nDimension, 384 uint64_t* nResults) 385 { 386 VALIDATE_POINTER1(index, "Index_Intersects_count", RT_Failure); 387 Index* idx = static_cast<Index*>(index); 388 389 CountVisitor* visitor = new CountVisitor; 390 try { 391 SpatialIndex::Region* r = new SpatialIndex::Region(pdMin, pdMax, nDimension); 392 idx->index().intersectsWithQuery( *r, 393 *visitor); 394 395 *nResults = visitor->GetResultCount(); 396 397 delete r; 398 delete visitor; 399 400 } catch (Tools::Exception& e) 401 { 402 Error_PushError(RT_Failure, 403 e.what().c_str(), 404 "Index_Intersects_count"); 405 delete visitor; 406 return RT_Failure; 407 } catch (std::exception const& e) 408 { 409 Error_PushError(RT_Failure, 410 e.what(), 411 "Index_Intersects_count"); 412 delete visitor; 413 return RT_Failure; 414 } catch (...) { 415 Error_PushError(RT_Failure, 416 "Unknown Error", 417 "Index_Intersects_count"); 418 delete visitor; 419 return RT_Failure; 420 } 421 return RT_None; 422 } 423 380 424 SIDX_C_DLL RTError Index_NearestNeighbors_id(IndexH index, 381 425 double* pdMin,
