libspatialindex API Reference  (git-trunk)
sidx_api.cc
Go to the documentation of this file.
1 /******************************************************************************
2  * Project: libsidx - A C API wrapper around libspatialindex
3  * Purpose: C API wrapper implementation
4  * Author: Howard Butler, hobu.inc@gmail.com
5  ******************************************************************************
6  * Copyright (c) 2009, Howard Butler
7  *
8  * All rights reserved.
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27 ******************************************************************************/
28 
29 #include <cmath>
30 #include <limits>
31 #include <cassert>
32 #include <cstring>
33 #include <memory>
36 
37 #ifdef __GNUC__
38 # define LAST_ERROR_BUFFER_SIZE 1024
39 /*
40  * __thread is gcc specific extension for thread-local storage, that does not allow complex
41  * constructor. We can't use any of std containers for storing multiple error messages, but we
42  * could at least get latest error message safely. The error count will be at most 1. The finer
43  * solution would be to use thread-local storage from C++11, but since this library is compiled
44  * with C++98 flag, this option is not available yet.
45  */
46 static __thread struct
47 {
48  int code;
49  char message[LAST_ERROR_BUFFER_SIZE];
50  char method[LAST_ERROR_BUFFER_SIZE];
51 } last_error = {0, "", ""};
52 #else
53 static std::stack<Error> errors;
54 #endif
55 
56 #ifdef _WIN32
57 # pragma warning(push)
58 # pragma warning(disable: 4127) // assignment operator could not be generated
59 #endif
60 
61 #define VALIDATE_POINTER0(ptr, func) \
62  do { if( NULL == ptr ) { \
63  RTError const ret = RT_Failure; \
64  std::ostringstream msg; \
65  msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \
66  std::string message(msg.str()); \
67  Error_PushError( ret, message.c_str(), (func)); \
68  return; \
69  }} while(0)
70 
71 #define VALIDATE_POINTER1(ptr, func, rc) \
72  do { if( NULL == ptr ) { \
73  RTError const ret = RT_Failure; \
74  std::ostringstream msg; \
75  msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \
76  std::string message(msg.str()); \
77  Error_PushError( ret, message.c_str(), (func)); \
78  return (rc); \
79  }} while(0)
80 
82 
83 SIDX_C_DLL void Error_Reset(void) {
84 #ifdef __GNUC__
85  last_error.code = 0;
86 #else
87  if (errors.empty()) return;
88  for (std::size_t i=0;i<errors.size();i++) errors.pop();
89 #endif
90 }
91 
92 SIDX_C_DLL void Error_Pop(void) {
93 #ifdef __GNUC__
94  last_error.code = 0;
95 #else
96  if (errors.empty()) return;
97  errors.pop();
98 #endif
99 }
100 
102 #ifdef __GNUC__
103  return last_error.code;
104 #else
105  if (errors.empty())
106  return 0;
107  else {
108  Error err = errors.top();
109  return err.GetCode();
110  }
111 #endif
112 }
113 
115 #ifdef __GNUC__
116  if (last_error.code) {
117  return STRDUP(last_error.message);
118  } else {
119  return NULL;
120  }
121 #else
122  if (errors.empty())
123  return NULL;
124  else {
125  Error err = errors.top();
126  return STRDUP(err.GetMessage());
127  }
128 #endif
129 }
130 
132 #ifdef __GNUC__
133  if (last_error.code) {
134  return STRDUP(last_error.method);
135  } else {
136  return NULL;
137  }
138 #else
139  if (errors.empty())
140  return NULL;
141  else {
142  Error err = errors.top();
143  return STRDUP(err.GetMethod());
144  }
145 #endif
146 }
147 
148 SIDX_C_DLL void Error_PushError(int code, const char *message, const char *method) {
149 #ifdef __GNUC__
150  assert(code != 0);
151  last_error.code = code;
152  strncpy(last_error.message, message, LAST_ERROR_BUFFER_SIZE - 1);
153  strncpy(last_error.method, method, LAST_ERROR_BUFFER_SIZE - 1);
154  last_error.message[LAST_ERROR_BUFFER_SIZE-1] = '\0';
155  last_error.method[LAST_ERROR_BUFFER_SIZE-1] = '\0';
156 #else
157  Error err = Error(code, std::string(message), std::string(method));
158  errors.push(err);
159 #endif
160 }
161 
163 #ifdef __GNUC__
164  return last_error.code ? 1 : 0;
165 #else
166  return static_cast<int>(errors.size());
167 #endif
168 }
169 
171 {
172  VALIDATE_POINTER1(hProp, "Index_Create", NULL);
173  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
174 
175  try {
176  return (IndexH) new Index(*prop);
177  } catch (Tools::Exception& e)
178  {
180  e.what().c_str(),
181  "Index_Create");
182  return NULL;
183  } catch (std::exception const& e)
184  {
186  e.what(),
187  "Index_Create");
188  return NULL;
189  } catch (...) {
191  "Unknown Error",
192  "Index_Create");
193  return NULL;
194  }
195 }
196 
198  int (*readNext)(SpatialIndex::id_type *id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, size_t *nDataLength)
199  )
200 {
201  VALIDATE_POINTER1(hProp, "Index_CreateWithStream", NULL);
202  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
203 
204 
205  try {
206  return (IndexH) new Index(*prop, readNext);
207  } catch (Tools::Exception& e)
208  {
210  e.what().c_str(),
211  "Index_CreateWithStream");
212  } catch (std::exception const& e)
213  {
215  e.what(),
216  "Index_CreateWithStream");
217  return NULL;
218  } catch (...) {
220  "Unknown Error",
221  "Index_CreateWithStream");
222  return NULL;
223  }
224  return NULL;
225 }
226 
227 SIDX_DLL IndexH Index_CreateWithArray(IndexPropertyH hProp, uint64_t n, uint32_t dimension, uint64_t i_stri, uint64_t d_i_stri, uint64_t d_j_stri, int64_t *ids, double *mins, double *maxs)
228 {
229  using namespace SpatialIndex;
230 
231  VALIDATE_POINTER1(hProp, "Index_CreateWithArray", NULL);
232  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
233 
234  struct ArrayStream : IDataStream
235  {
236  ArrayStream(uint64_t n_, uint32_t d_, uint64_t i_stri_, uint64_t d_i_stri_,
237  uint64_t d_j_stri_, int64_t* ids_, double* mins_, double* maxs_)
238  : d(d_), i(0), n(n_), i_stri(i_stri_), d_i_stri(d_i_stri_),
239  d_j_stri(d_j_stri_), ids(ids_), tmp(new double[2*d_]), mins(mins_),
240  maxs(maxs_)
241  {}
242 
243  ~ArrayStream() { delete[] tmp; }
244 
245  IData* getNext() override
246  {
247  if (i >= n)
248  return nullptr;
249 
250  for (uint32_t j = 0; j < d; ++j)
251  {
252  tmp[j] = mins[i*d_i_stri + j*d_j_stri];
253  tmp[j + d] = maxs[i*d_i_stri + j*d_j_stri];
254  }
255  Region r(tmp, tmp + d, d);
256 
257  return new RTree::Data(0, nullptr, r, ids[i++*i_stri]);
258  }
259 
260  bool hasNext() override { return i < n; }
261  void rewind() override {}
262  uint32_t size() override { return 0; }
263 
264  uint32_t d;
265  uint64_t i, n, i_stri, d_i_stri, d_j_stri;
266  int64_t* ids;
267  double* tmp, *mins, *maxs;
268  };
269 
270  ArrayStream* bs = new ArrayStream(n, dimension, i_stri, d_i_stri, d_j_stri,
271  ids, mins, maxs);
272 
273  try {
274  return (IndexH) new Index(*prop, std::unique_ptr<IDataStream>(bs));
275  } catch (Tools::Exception& e)
276  {
278  e.what().c_str(),
279  "Index_CreateWithArray");
280  } catch (std::exception const& e)
281  {
283  e.what(),
284  "Index_CreateWithArray");
285  } catch (...) {
287  "Unknown Error",
288  "Index_CreateWithArray");
289  }
290  return NULL;
291 }
292 
294 {
295  VALIDATE_POINTER0(index, "Index_Destroy");
296  Index* idx = (Index*) index;
297  if (idx) delete idx;
298 }
299 
301 {
302  VALIDATE_POINTER0(index, "Index_Flush");
303  Index* idx = (Index*) index;
304  if (idx)
305  {
306  idx->flush();
307  }
308 }
309 
311  int64_t id,
312  double* pdMin,
313  double* pdMax,
314  double* pdVMin,
315  double* pdVMax,
316  double tStart,
317  double tEnd,
318  uint32_t nDimension
319  )
320 {
321  VALIDATE_POINTER1(index, "Index_DeleteTPData", RT_Failure);
322 
323  Index* idx = reinterpret_cast<Index*>(index);
324 
325  try {
326  idx->index().deleteData(SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension), id);
327  } catch (Tools::Exception& e)
328  {
330  e.what().c_str(),
331  "Index_DeleteTPData");
332  return RT_Failure;
333  } catch (std::exception const& e)
334  {
336  e.what(),
337  "Index_DeleteTPData");
338  return RT_Failure;
339  } catch (...) {
341  "Unknown Error",
342  "Index_DeleteTPData");
343  return RT_Failure;
344  }
345  return RT_None;
346 }
347 
349  int64_t id,
350  double* pdMin,
351  double* pdMax,
352  double tStart,
353  double tEnd,
354  uint32_t nDimension
355  )
356 {
357  VALIDATE_POINTER1(index, "Index_DeleteMVRData", RT_Failure);
358 
359  Index* idx = reinterpret_cast<Index*>(index);
360 
361  try {
362  idx->index().deleteData(SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension), id);
363  } catch (Tools::Exception& e)
364  {
366  e.what().c_str(),
367  "Index_DeleteMVRData");
368  return RT_Failure;
369  } catch (std::exception const& e)
370  {
372  e.what(),
373  "Index_DeleteMVRData");
374  return RT_Failure;
375  } catch (...) {
377  "Unknown Error",
378  "Index_DeleteMVRData");
379  return RT_Failure;
380  }
381  return RT_None;
382 }
383 
385  int64_t id,
386  double* pdMin,
387  double* pdMax,
388  uint32_t nDimension)
389 {
390  VALIDATE_POINTER1(index, "Index_DeleteData", RT_Failure);
391 
392  Index* idx = reinterpret_cast<Index*>(index);
393 
394  try {
395  idx->index().deleteData(SpatialIndex::Region(pdMin, pdMax, nDimension), id);
396  } catch (Tools::Exception& e)
397  {
399  e.what().c_str(),
400  "Index_DeleteData");
401  return RT_Failure;
402  } catch (std::exception const& e)
403  {
405  e.what(),
406  "Index_DeleteData");
407  return RT_Failure;
408  } catch (...) {
410  "Unknown Error",
411  "Index_DeleteData");
412  return RT_Failure;
413  }
414  return RT_None;
415 }
416 
418  int64_t id,
419  double* pdMin,
420  double* pdMax,
421  double* pdVMin,
422  double* pdVMax,
423  double tStart,
424  double tEnd,
425  uint32_t nDimension,
426  const uint8_t* pData,
427  size_t nDataLength
428  )
429 {
430  VALIDATE_POINTER1(index, "Index_InsertTPData", RT_Failure);
431 
432  Index* idx = reinterpret_cast<Index*>(index);
433 
434  // Test the data and check for the case when mins equal maxs (x,y,z,v)
435  // In that case, we will insert a SpatialIndex::MovingPoint
436  // instead of a SpatialIndex::MovingRegion
437 
438  bool isPoint = false;
439  SpatialIndex::IShape* shape = 0;
440  double const epsilon = std::numeric_limits<double>::epsilon();
441 
442  double length(0), vlength(0);
443  for (uint32_t i = 0; i < nDimension; ++i) {
444  double delta = pdMin[i] - pdMax[i];
445  length += std::fabs(delta);
446 
447  double vDelta = pdVMin[i] - pdVMax[i];
448  vlength += std::fabs(vDelta);
449  }
450 
451  if ((length <= epsilon) && (vlength <= epsilon)){
452  isPoint = true;
453  }
454 
455  if (isPoint == true) {
456  shape = new SpatialIndex::MovingPoint(pdMin, pdVMin, tStart, tEnd, nDimension);
457  } else {
458  shape = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
459  }
460  try {
461  // FIXME silently casting the nDataLength to uint32_t sucks, but
462  // no one should be putting huge byte counts into rtree data anyway.
463  idx->index().insertData((uint32_t)nDataLength,
464  pData,
465  *shape,
466  id);
467 
468  delete shape;
469  } catch (Tools::Exception& e)
470  {
472  e.what().c_str(),
473  "Index_InsertTPData");
474  delete shape;
475  return RT_Failure;
476  } catch (std::exception const& e)
477  {
479  e.what(),
480  "Index_InsertTPData");
481  delete shape;
482  return RT_Failure;
483  } catch (...) {
485  "Unknown Error",
486  "Index_InsertTPData");
487  delete shape;
488  return RT_Failure;
489  }
490  return RT_None;
491 
492 }
493 
495  int64_t id,
496  double* pdMin,
497  double* pdMax,
498  double tStart,
499  double tEnd,
500  uint32_t nDimension,
501  const uint8_t* pData,
502  size_t nDataLength
503  )
504 {
505  VALIDATE_POINTER1(index, "Index_InsertMVRData", RT_Failure);
506 
507  Index* idx = reinterpret_cast<Index*>(index);
508 
509  // Test the data and check for the case when mins equal maxs
510  // In that case, we will insert a SpatialIndex::TimePoint
511  // instead of a SpatialIndex::timeRegion
512 
513  bool isPoint = false;
514  SpatialIndex::IShape* shape = 0;
515  double const epsilon = std::numeric_limits<double>::epsilon();
516 
517  double length(0);
518  for (uint32_t i = 0; i < nDimension; ++i) {
519  double delta = pdMin[i] - pdMax[i];
520  length += std::fabs(delta);
521  }
522 
523  if (length <= epsilon){
524  isPoint = true;
525  }
526 
527  if (isPoint == true) {
528  shape = new SpatialIndex::TimePoint(pdMin, tStart, tEnd, nDimension);
529  } else {
530  shape = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
531  }
532  try {
533  // FIXME silently casting the nDataLength to uint32_t sucks, but
534  // no one should be putting huge byte counts into rtree data anyway.
535  idx->index().insertData((uint32_t)nDataLength,
536  pData,
537  *shape,
538  id);
539 
540  delete shape;
541  } catch (Tools::Exception& e)
542  {
544  e.what().c_str(),
545  "Index_InsertMVRData");
546  delete shape;
547  return RT_Failure;
548  } catch (std::exception const& e)
549  {
551  e.what(),
552  "Index_InsertMVRData");
553  delete shape;
554  return RT_Failure;
555  } catch (...) {
557  "Unknown Error",
558  "Index_InsertMVRData");
559  delete shape;
560  return RT_Failure;
561  }
562  return RT_None;
563 }
564 
565 
567  int64_t id,
568  double* pdMin,
569  double* pdMax,
570  uint32_t nDimension,
571  const uint8_t* pData,
572  size_t nDataLength)
573 {
574  VALIDATE_POINTER1(index, "Index_InsertData", RT_Failure);
575 
576  Index* idx = reinterpret_cast<Index*>(index);
577 
578  // Test the data and check for the case when minx == maxx, miny == maxy
579  // and minz == maxz. In that case, we will insert a SpatialIndex::Point
580  // instead of a SpatialIndex::Region
581 
582  bool isPoint = false;
583  SpatialIndex::IShape* shape = 0;
584  double const epsilon = std::numeric_limits<double>::epsilon();
585 
586  double length(0);
587  for (uint32_t i = 0; i < nDimension; ++i) {
588  double delta = pdMin[i] - pdMax[i];
589  length += std::fabs(delta);
590  }
591 
592  if (length <= epsilon) {
593  isPoint = true;
594  }
595 
596  if (isPoint == true) {
597  shape = new SpatialIndex::Point(pdMin, nDimension);
598  } else {
599  shape = new SpatialIndex::Region(pdMin, pdMax, nDimension);
600  }
601  try {
602  // FIXME silently casting the nDataLength to uint32_t sucks, but
603  // no one should be putting huge byte counts into rtree data anyway.
604  idx->index().insertData((uint32_t)nDataLength,
605  pData,
606  *shape,
607  id);
608 
609  delete shape;
610  } catch (Tools::Exception& e)
611  {
613  e.what().c_str(),
614  "Index_InsertData");
615  delete shape;
616  return RT_Failure;
617  } catch (std::exception const& e)
618  {
620  e.what(),
621  "Index_InsertData");
622  delete shape;
623  return RT_Failure;
624  } catch (...) {
626  "Unknown Error",
627  "Index_InsertData");
628  delete shape;
629  return RT_Failure;
630  }
631  return RT_None;
632 }
633 
635  double* pdMin,
636  double* pdMax,
637  double* pdVMin,
638  double* pdVMax,
639  double tStart,
640  double tEnd,
641  uint32_t nDimension,
642  IndexItemH** items,
643  uint64_t* nResults)
644 {
645  VALIDATE_POINTER1(index, "Index_TPIntersects_obj", RT_Failure);
646  Index* idx = reinterpret_cast<Index*>(index);
647  int64_t nResultLimit, nStart;
649 
650  nResultLimit = idx->GetResultSetLimit();
651  nStart = idx->GetResultSetOffset();
652 
653  ObjVisitor* visitor = new ObjVisitor;
654  try {
655  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
656  idx->index().intersectsWithQuery( *r,
657  *visitor);
658 
659  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
660 
661  delete r;
662  delete visitor;
663 
664  } catch (Tools::Exception& e)
665  {
667  e.what().c_str(),
668  "Index_TPIntersects_obj");
669  delete visitor;
670  delete r;
671  return RT_Failure;
672  } catch (std::exception const& e)
673  {
675  e.what(),
676  "Index_TPIntersects_obj");
677  delete visitor;
678  delete r;
679  return RT_Failure;
680  } catch (...) {
682  "Unknown Error",
683  "Index_TPIntersects_obj");
684  delete visitor;
685  delete r;
686  return RT_Failure;
687  }
688  return RT_None;
689 }
690 
692  double* pdMin,
693  double* pdMax,
694  double tStart,
695  double tEnd,
696  uint32_t nDimension,
697  IndexItemH** items,
698  uint64_t* nResults)
699 {
700  VALIDATE_POINTER1(index, "Index_MVRIntersects_obj", RT_Failure);
701  Index* idx = reinterpret_cast<Index*>(index);
702  int64_t nResultLimit, nStart;
704 
705  nResultLimit = idx->GetResultSetLimit();
706  nStart = idx->GetResultSetOffset();
707 
708  ObjVisitor* visitor = new ObjVisitor;
709  try {
710  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
711  idx->index().intersectsWithQuery( *r,
712  *visitor);
713 
714  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
715 
716  delete r;
717  delete visitor;
718 
719  } catch (Tools::Exception& e)
720  {
722  e.what().c_str(),
723  "Index_MVRIntersects_obj");
724  delete r;
725  delete visitor;
726  return RT_Failure;
727  } catch (std::exception const& e)
728  {
730  e.what(),
731  "Index_TPIntersects_obj");
732  delete r;
733  delete visitor;
734  return RT_Failure;
735  } catch (...) {
737  "Unknown Error",
738  "Index_TPIntersects_obj");
739  delete r;
740  delete visitor;
741  return RT_Failure;
742  }
743  return RT_None;
744 }
745 
747  double* pdMin,
748  double* pdMax,
749  uint32_t nDimension,
750  IndexItemH** items,
751  uint64_t* nResults)
752 {
753  VALIDATE_POINTER1(index, "Index_Intersects_obj", RT_Failure);
754  Index* idx = reinterpret_cast<Index*>(index);
755  int64_t nResultLimit, nStart;
756 
757  nResultLimit = idx->GetResultSetLimit();
758  nStart = idx->GetResultSetOffset();
759 
760  ObjVisitor* visitor = new ObjVisitor;
761  SpatialIndex::Region* r = 0;
762  try {
763  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
764  idx->index().intersectsWithQuery( *r,
765  *visitor);
766 
767  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
768 
769  delete r;
770  delete visitor;
771 
772  } catch (Tools::Exception& e)
773  {
774  delete r;
775  delete visitor;
777  e.what().c_str(),
778  "Index_Intersects_obj");
779  } catch (std::exception const& e)
780  {
781  delete r;
782  delete visitor;
784  e.what(),
785  "Index_Intersects_obj");
786  delete visitor;
787  } catch (...) {
788  delete r;
789  delete visitor;
791  "Unknown Error",
792  "Index_Intersects_obj");
793  }
794  return RT_None;
795 }
796 
798  double* pdMin,
799  double* pdMax,
800  uint32_t nDimension,
801  IndexItemH** items,
802  uint64_t* nResults)
803 {
804  VALIDATE_POINTER1(index, "Index_Contains_obj", RT_Failure);
805  Index* idx = reinterpret_cast<Index*>(index);
806  int64_t nResultLimit, nStart;
807 
808  nResultLimit = idx->GetResultSetLimit();
809  nStart = idx->GetResultSetOffset();
810 
811  ObjVisitor* visitor = new ObjVisitor;
812  SpatialIndex::Region* r = 0;
813  try {
814  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
815  idx->index().containsWhatQuery(*r, *visitor);
816 
817  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
818 
819  delete r;
820  delete visitor;
821 
822  } catch (Tools::Exception& e)
823  {
824  delete r;
825  delete visitor;
827  e.what().c_str(),
828  "Index_Contains_obj");
829  } catch (std::exception const& e)
830  {
831  delete r;
832  delete visitor;
834  e.what(),
835  "Index_Contains_obj");
836  delete visitor;
837  } catch (...) {
838  delete r;
839  delete visitor;
841  "Unknown Error",
842  "Index_Contains_obj");
843  }
844  return RT_None;
845 }
846 
848  double* pdMin,
849  double* pdMax,
850  double* pdVMin,
851  double* pdVMax,
852  double tStart,
853  double tEnd,
854  uint32_t nDimension,
855  int64_t** ids,
856  uint64_t* nResults)
857 {
858  VALIDATE_POINTER1(index, "Index_TPIntersects_id", RT_Failure);
859  Index* idx = reinterpret_cast<Index*>(index);
860 
861  int64_t nResultLimit, nStart;
863 
864  nResultLimit = idx->GetResultSetLimit();
865  nStart = idx->GetResultSetOffset();
866 
867  IdVisitor* visitor = new IdVisitor;
868  try {
869  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
870  idx->index().intersectsWithQuery( *r,
871  *visitor);
872 
873  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
874 
875  delete r;
876  delete visitor;
877  } catch (Tools::Exception& e)
878  {
880  e.what().c_str(),
881  "Index_TPIntersects_id");
882  delete r;
883  delete visitor;
884  return RT_Failure;
885  } catch (std::exception const& e)
886  {
888  e.what(),
889  "Index_TPIntersects_id");
890  delete r;
891  delete visitor;
892  return RT_Failure;
893  } catch (...) {
895  "Unknown Error",
896  "Index_TPIntersects_id");
897  delete r;
898  delete visitor;
899  return RT_Failure;
900  }
901  return RT_None;
902 }
903 
905  double* pdMin,
906  double* pdMax,
907  double tStart,
908  double tEnd,
909  uint32_t nDimension,
910  int64_t** ids,
911  uint64_t* nResults)
912 {
913  VALIDATE_POINTER1(index, "Index_MVRIntersects_id", RT_Failure);
914  Index* idx = reinterpret_cast<Index*>(index);
915 
916  int64_t nResultLimit, nStart;
918 
919  nResultLimit = idx->GetResultSetLimit();
920  nStart = idx->GetResultSetOffset();
921 
922  IdVisitor* visitor = new IdVisitor;
923  try {
924  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
925  idx->index().intersectsWithQuery( *r,
926  *visitor);
927 
928  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
929 
930  delete r;
931  delete visitor;
932  } catch (Tools::Exception& e)
933  {
935  e.what().c_str(),
936  "Index_MVRIntersects_id");
937  delete r;
938  delete visitor;
939  return RT_Failure;
940  } catch (std::exception const& e)
941  {
943  e.what(),
944  "Index_MVRIntersects_id");
945  delete r;
946  delete visitor;
947  return RT_Failure;
948  } catch (...) {
950  "Unknown Error",
951  "Index_MVRIntersects_id");
952  delete r;
953  delete visitor;
954  return RT_Failure;
955  }
956  return RT_None;
957 }
958 
959 
961  double *pdMin,
962  double *pdMax,
963  uint32_t nDimension,
964  int64_t **ids,
965  uint64_t *nResults)
966 {
967  VALIDATE_POINTER1(index, "Index_Contains_id", RT_Failure);
968  Index* idx = reinterpret_cast<Index*>(index);
969 
970  int64_t nResultLimit, nStart;
971  SpatialIndex::Region* r = 0;
972 
973  nResultLimit = idx->GetResultSetLimit();
974  nStart = idx->GetResultSetOffset();
975 
976  IdVisitor* visitor = new IdVisitor;
977  try {
978  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
979  idx->index().containsWhatQuery(*r, *visitor);
980 
981  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
982 
983  delete r;
984  delete visitor;
985 
986  } catch (Tools::Exception& e)
987  {
989  e.what().c_str(),
990  "Index_Contains_id");
991  delete r;
992  delete visitor;
993  return RT_Failure;
994  } catch (std::exception const& e)
995  {
997  e.what(),
998  "Index_Contains_id");
999  delete r;
1000  delete visitor;
1001  return RT_Failure;
1002  } catch (...) {
1004  "Unknown Error",
1005  "Index_Contains_id");
1006  delete r;
1007  delete visitor;
1008  return RT_Failure;
1009  }
1010  return RT_None;
1011 }
1012 
1013 
1015  double* pdMin,
1016  double* pdMax,
1017  uint32_t nDimension,
1018  int64_t** ids,
1019  uint64_t* nResults)
1020 {
1021  VALIDATE_POINTER1(index, "Index_Intersects_id", RT_Failure);
1022  Index* idx = reinterpret_cast<Index*>(index);
1023 
1024  int64_t nResultLimit, nStart;
1025 
1026  nResultLimit = idx->GetResultSetLimit();
1027  nStart = idx->GetResultSetOffset();
1028 
1029  IdVisitor visitor;
1030  try {
1031  SpatialIndex::Region r(pdMin, pdMax, nDimension);
1032  idx->index().intersectsWithQuery(r, visitor);
1033  Page_ResultSet_Ids(visitor, ids, nStart, nResultLimit, nResults);
1034  } catch (Tools::Exception& e)
1035  {
1037  e.what().c_str(),
1038  "Index_Intersects_id");
1039  return RT_Failure;
1040  } catch (std::exception const& e)
1041  {
1043  e.what(),
1044  "Index_Intersects_id");
1045  return RT_Failure;
1046  } catch (...) {
1048  "Unknown Error",
1049  "Index_Intersects_id");
1050  return RT_Failure;
1051  }
1052  return RT_None;
1053 }
1054 
1056  int64_t n,
1057  uint32_t d,
1058  uint64_t idsz,
1059  uint64_t d_i_stri,
1060  uint64_t d_j_stri,
1061  const double* mins,
1062  const double* maxs,
1063  int64_t* ids,
1064  uint64_t* cnts,
1065  int64_t* nr)
1066 {
1067  VALIDATE_POINTER1(index, "Index_Intersects_id_v", RT_Failure);
1068  auto& idx = reinterpret_cast<Index*>(index)->index();
1069  IdVisitor visitor;
1070  std::unique_ptr<double[]> tmp = std::unique_ptr<double[]>(new double[2*d]);
1071  uint64_t k = 0;
1072 
1073  // Clear the result count
1074  *nr = 0;
1075 
1076  try {
1077  for (uint64_t i = 0; i < n; ++i)
1078  {
1079  // Extract the bounding box
1080  for (uint64_t j = 0; j < d; ++j)
1081  {
1082  tmp[j] = mins[i*d_i_stri + j*d_j_stri];
1083  tmp[j + d] = maxs[i*d_i_stri + j*d_j_stri];
1084  }
1085 
1086  // Visit
1087  SpatialIndex::Region r(tmp.get(), tmp.get() + d, d);
1088  visitor.reset();
1089  idx.intersectsWithQuery(r, visitor);
1090 
1091  uint64_t nrc = visitor.GetResultCount();
1092  if (cnts)
1093  cnts[i] = nrc;
1094 
1095  // Ensure we have enough space for the results
1096  if (k + nrc > idsz)
1097  return RT_None;
1098 
1099  *nr = i + 1;
1100  for (uint64_t idx : visitor.GetResults())
1101  ids[k++] = idx;
1102  }
1103  } catch (Tools::Exception& e)
1104  {
1106  e.what().c_str(),
1107  "Index_Intersects_id_v");
1108  return RT_Failure;
1109  } catch (std::exception const& e)
1110  {
1112  e.what(),
1113  "Index_Intersects_id_v");
1114  return RT_Failure;
1115  } catch (...) {
1117  "Unknown Error",
1118  "Index_Intersects_id_v");
1119  return RT_Failure;
1120  }
1121  return RT_None;
1122 }
1123 
1125  double* pdMin,
1126  double* pdMax,
1127  double* pdVMin,
1128  double* pdVMax,
1129  double tStart,
1130  double tEnd,
1131  uint32_t nDimension,
1132  uint64_t* nResults)
1133 {
1134  VALIDATE_POINTER1(index, "Index_TPIntersects_count", RT_Failure);
1135  Index* idx = reinterpret_cast<Index*>(index);
1137 
1138  CountVisitor* visitor = new CountVisitor;
1139  try {
1140  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1141  idx->index().intersectsWithQuery( *r,
1142  *visitor);
1143 
1144  *nResults = visitor->GetResultCount();
1145 
1146  delete r;
1147  delete visitor;
1148  } catch (Tools::Exception& e)
1149  {
1151  e.what().c_str(),
1152  "Index_TPIntersects_count");
1153  delete r;
1154  delete visitor;
1155  return RT_Failure;
1156  } catch (std::exception const& e)
1157  {
1159  e.what(),
1160  "Index_TPIntersects_count");
1161  delete r;
1162  delete visitor;
1163  return RT_Failure;
1164  } catch (...) {
1166  "Unknown Error",
1167  "Index_TPIntersects_count");
1168  delete r;
1169  delete visitor;
1170  return RT_Failure;
1171  }
1172  return RT_None;
1173 }
1174 
1176  double* pdMin,
1177  double* pdMax,
1178  double tStart,
1179  double tEnd,
1180  uint32_t nDimension,
1181  uint64_t* nResults)
1182 {
1183  VALIDATE_POINTER1(index, "Index_MVRIntersects_count", RT_Failure);
1184  Index* idx = reinterpret_cast<Index*>(index);
1185  SpatialIndex::TimeRegion* r = 0;
1186 
1187  CountVisitor* visitor = new CountVisitor;
1188  try {
1189  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1190  idx->index().intersectsWithQuery( *r,
1191  *visitor);
1192 
1193  *nResults = visitor->GetResultCount();
1194 
1195  delete r;
1196  delete visitor;
1197 
1198  } catch (Tools::Exception& e)
1199  {
1201  e.what().c_str(),
1202  "Index_MVRIntersects_count");
1203  delete r;
1204  delete visitor;
1205  return RT_Failure;
1206  } catch (std::exception const& e)
1207  {
1209  e.what(),
1210  "Index_MVRIntersects_count");
1211  delete r;
1212  delete visitor;
1213  return RT_Failure;
1214  } catch (...) {
1216  "Unknown Error",
1217  "Index_MVRIntersects_count");
1218  delete r;
1219  delete visitor;
1220  return RT_Failure;
1221  }
1222  return RT_None;
1223 }
1224 
1226  double* pdMin,
1227  double* pdMax,
1228  uint32_t nDimension,
1229  uint64_t* nResults)
1230 {
1231  VALIDATE_POINTER1(index, "Index_Intersects_count", RT_Failure);
1232  Index* idx = reinterpret_cast<Index*>(index);
1233  SpatialIndex::Region* r = 0;
1234 
1235  CountVisitor* visitor = new CountVisitor;
1236  try {
1237  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1238  idx->index().intersectsWithQuery( *r,
1239  *visitor);
1240 
1241  *nResults = visitor->GetResultCount();
1242 
1243  delete r;
1244  delete visitor;
1245 
1246  } catch (Tools::Exception& e)
1247  {
1249  e.what().c_str(),
1250  "Index_Intersects_count");
1251  delete r;
1252  delete visitor;
1253  return RT_Failure;
1254  } catch (std::exception const& e)
1255  {
1257  e.what(),
1258  "Index_Intersects_count");
1259  delete r;
1260  delete visitor;
1261  return RT_Failure;
1262  } catch (...) {
1264  "Unknown Error",
1265  "Index_Intersects_count");
1266  delete r;
1267  delete visitor;
1268  return RT_Failure;
1269  }
1270  return RT_None;
1271 }
1272 
1274  double* pdMin,
1275  double* pdMax,
1276  uint32_t nDimension,
1277  uint64_t* nResults)
1278 {
1279  VALIDATE_POINTER1(index, "Index_Contains_count", RT_Failure);
1280  Index* idx = reinterpret_cast<Index*>(index);
1281  SpatialIndex::Region* r = 0;
1282 
1283  CountVisitor* visitor = new CountVisitor;
1284  try {
1285  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1286  idx->index().containsWhatQuery(*r, *visitor);
1287 
1288  *nResults = visitor->GetResultCount();
1289 
1290  delete r;
1291  delete visitor;
1292 
1293  } catch (Tools::Exception& e)
1294  {
1296  e.what().c_str(),
1297  "Index_Contains_count");
1298  delete r;
1299  delete visitor;
1300  return RT_Failure;
1301  } catch (std::exception const& e)
1302  {
1304  e.what(),
1305  "Index_Contains_count");
1306  delete r;
1307  delete visitor;
1308  return RT_Failure;
1309  } catch (...) {
1311  "Unknown Error",
1312  "Index_Contains_count");
1313  delete r;
1314  delete visitor;
1315  return RT_Failure;
1316  }
1317  return RT_None;
1318 }
1319 
1321  double* pdStartPoint,
1322  double* pdEndPoint,
1323  uint32_t nDimension,
1324  IndexItemH** items,
1325  uint64_t* nResults)
1326 {
1327  VALIDATE_POINTER1(index, "Index_Intersects_obj", RT_Failure);
1328  Index* idx = reinterpret_cast<Index*>(index);
1329 
1330  int64_t nResultLimit, nStart;
1332 
1333  nResultLimit = idx->GetResultSetLimit();
1334  nStart = idx->GetResultSetOffset();
1335 
1336  ObjVisitor* visitor = new ObjVisitor;
1337  try {
1338  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1339  idx->index().intersectsWithQuery( *l,
1340  *visitor);
1341 
1342  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1343 
1344  delete l;
1345  delete visitor;
1346 
1347  } catch (Tools::Exception& e)
1348  {
1350  e.what().c_str(),
1351  "Index_Intersects_obj");
1352  delete l;
1353  delete visitor;
1354  return RT_Failure;
1355  } catch (std::exception const& e)
1356  {
1358  e.what(),
1359  "Index_Intersects_obj");
1360  delete l;
1361  delete visitor;
1362  return RT_Failure;
1363  } catch (...) {
1365  "Unknown Error",
1366  "Index_Intersects_obj");
1367  delete l;
1368  delete visitor;
1369  return RT_Failure;
1370  }
1371  return RT_None;
1372 }
1373 
1375  double* pdStartPoint,
1376  double* pdEndPoint,
1377  uint32_t nDimension,
1378  int64_t** ids,
1379  uint64_t* nResults)
1380 {
1381  VALIDATE_POINTER1(index, "Index_Intersects_id", RT_Failure);
1382  Index* idx = reinterpret_cast<Index*>(index);
1383  int64_t nResultLimit, nStart;
1385 
1386  nResultLimit = idx->GetResultSetLimit();
1387  nStart = idx->GetResultSetOffset();
1388 
1389  IdVisitor* visitor = new IdVisitor;
1390  try {
1391  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1392  idx->index().intersectsWithQuery( *l,
1393  *visitor);
1394 
1395  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1396 
1397  delete l;
1398  delete visitor;
1399 
1400  } catch (Tools::Exception& e)
1401  {
1403  e.what().c_str(),
1404  "Index_Intersects_id");
1405  delete l;
1406  delete visitor;
1407  return RT_Failure;
1408  } catch (std::exception const& e)
1409  {
1411  e.what(),
1412  "Index_Intersects_id");
1413  delete l;
1414  delete visitor;
1415  return RT_Failure;
1416  } catch (...) {
1418  "Unknown Error",
1419  "Index_Intersects_id");
1420  delete l;
1421  delete visitor;
1422  return RT_Failure;
1423  }
1424  return RT_None;
1425 }
1426 
1428  double* pdStartPoint,
1429  double* pdEndPoint,
1430  uint32_t nDimension,
1431  uint64_t* nResults)
1432 {
1433  VALIDATE_POINTER1(index, "Index_Intersects_count", RT_Failure);
1434  Index* idx = reinterpret_cast<Index*>(index);
1436 
1437  CountVisitor* visitor = new CountVisitor;
1438  try {
1439  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1440  idx->index().intersectsWithQuery( *l,
1441  *visitor);
1442 
1443  *nResults = visitor->GetResultCount();
1444 
1445  delete l;
1446  delete visitor;
1447 
1448  } catch (Tools::Exception& e)
1449  {
1451  e.what().c_str(),
1452  "Index_Intersects_count");
1453  delete l;
1454  delete visitor;
1455  return RT_Failure;
1456  } catch (std::exception const& e)
1457  {
1459  e.what(),
1460  "Index_Intersects_count");
1461  delete l;
1462  delete visitor;
1463  return RT_Failure;
1464  } catch (...) {
1466  "Unknown Error",
1467  "Index_Intersects_count");
1468  delete l;
1469  delete visitor;
1470  return RT_Failure;
1471  }
1472  return RT_None;
1473 }
1474 
1476  double* pdMin,
1477  double* pdMax,
1478  double* pdVMin,
1479  double* pdVMax,
1480  double tStart,
1481  double tEnd,
1482  uint32_t nDimension,
1483  int64_t** ids,
1484  uint64_t* nResults)
1485 {
1486  VALIDATE_POINTER1(index, "Index_TPNearestNeighbors_id", RT_Failure);
1487  Index* idx = reinterpret_cast<Index*>(index);
1488  int64_t nResultLimit, nStart;
1490 
1491  nResultLimit = idx->GetResultSetLimit();
1492  nStart = idx->GetResultSetOffset();
1493 
1494  IdVisitor* visitor = new IdVisitor;
1495 
1496  try {
1497  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1498  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1499  *r,
1500  *visitor);
1501 
1502  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1503 
1504  delete r;
1505  delete visitor;
1506 
1507  } catch (Tools::Exception& e)
1508  {
1510  e.what().c_str(),
1511  "Index_TPNearestNeighbors_id");
1512  delete r;
1513  delete visitor;
1514  return RT_Failure;
1515  } catch (std::exception const& e)
1516  {
1518  e.what(),
1519  "Index_TPNearestNeighbors_id");
1520  delete r;
1521  delete visitor;
1522  return RT_Failure;
1523  } catch (...) {
1525  "Unknown Error",
1526  "Index_TPNearestNeighbors_id");
1527  delete r;
1528  delete visitor;
1529  return RT_Failure;
1530  }
1531  return RT_None;
1532 }
1533 
1535  double* pdMin,
1536  double* pdMax,
1537  double tStart,
1538  double tEnd,
1539  uint32_t nDimension,
1540  int64_t** ids,
1541  uint64_t* nResults)
1542 {
1543  VALIDATE_POINTER1(index, "Index_MVRNearestNeighbors_id", RT_Failure);
1544  Index* idx = reinterpret_cast<Index*>(index);
1545  int64_t nResultLimit, nStart;
1546  SpatialIndex::TimeRegion* r = 0;
1547 
1548  nResultLimit = idx->GetResultSetLimit();
1549  nStart = idx->GetResultSetOffset();
1550 
1551  IdVisitor* visitor = new IdVisitor;
1552 
1553  try {
1554  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1555  idx->index().nearestNeighborQuery((uint32_t) *nResults,
1556  *r,
1557  *visitor);
1558 
1559  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1560 
1561  delete r;
1562  delete visitor;
1563 
1564  } catch (Tools::Exception& e)
1565  {
1567  e.what().c_str(),
1568  "Index_MVRNearestNeighbors_id");
1569  delete r;
1570  delete visitor;
1571  return RT_Failure;
1572  } catch (std::exception const& e)
1573  {
1575  e.what(),
1576  "Index_MVRNearestNeighbors_id");
1577  delete r;
1578  delete visitor;
1579  return RT_Failure;
1580  } catch (...) {
1582  "Unknown Error",
1583  "Index_MVRNearestNeighbors_id");
1584  delete r;
1585  delete visitor;
1586  return RT_Failure;
1587  }
1588  return RT_None;
1589 }
1590 
1592  double* pdMin,
1593  double* pdMax,
1594  uint32_t nDimension,
1595  int64_t** ids,
1596  uint64_t* nResults)
1597 {
1598  VALIDATE_POINTER1(index, "Index_NearestNeighbors_id", RT_Failure);
1599  Index* idx = reinterpret_cast<Index*>(index);
1600  int64_t nResultLimit, nStart;
1601 
1602  nResultLimit = idx->GetResultSetLimit();
1603  nStart = idx->GetResultSetOffset();
1604 
1605  IdVisitor visitor;
1606 
1607  try {
1608  SpatialIndex::Region r(pdMin, pdMax, nDimension);
1609 
1610  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1611  r,
1612  visitor);
1613 
1614  Page_ResultSet_Ids(visitor, ids, nStart, nResultLimit, nResults);
1615  } catch (Tools::Exception& e)
1616  {
1618  e.what().c_str(),
1619  "Index_NearestNeighbors_id");
1620  return RT_Failure;
1621  } catch (std::exception const& e)
1622  {
1624  e.what(),
1625  "Index_NearestNeighbors_id");
1626  return RT_Failure;
1627  } catch (...) {
1629  "Unknown Error",
1630  "Index_NearestNeighbors_id");
1631  return RT_Failure;
1632  }
1633  return RT_None;
1634 }
1635 
1637  int64_t knn,
1638  int64_t n,
1639  uint32_t d,
1640  uint64_t idsz,
1641  uint64_t d_i_stri,
1642  uint64_t d_j_stri,
1643  const double* mins,
1644  const double* maxs,
1645  int64_t* ids,
1646  uint64_t* cnts,
1647  double* dists,
1648  int64_t* nr)
1649 {
1650  VALIDATE_POINTER1(index, "Index_NearestNeighbors_id_v", RT_Failure);
1651  auto& idx = reinterpret_cast<Index*>(index)->index();
1652  IdVisitor visitor;
1653  std::unique_ptr<double[]> tmp = std::unique_ptr<double[]>(new double[2*d]);
1654  uint64_t k = 0;
1655 
1656  // Clear the result count
1657  *nr = 0;
1658 
1659  try {
1660  for (uint64_t i = 0; i < n; ++i)
1661  {
1662  double max_dist = dists ? dists[i] : 0.0;
1663 
1664  // Extract the bounding box
1665  for (uint64_t j = 0; j < d; ++j)
1666  {
1667  tmp[j] = mins[i*d_i_stri + j*d_j_stri];
1668  tmp[j + d] = maxs[i*d_i_stri + j*d_j_stri];
1669  }
1670 
1671  // Visit
1672  SpatialIndex::Region r(tmp.get(), tmp.get() + d, d);
1673  visitor.reset();
1674  max_dist = idx.nearestNeighborQuery(static_cast<uint32_t>(abs(knn)), r, visitor, max_dist);
1675 
1676  uint64_t nrc = visitor.GetResultCount();
1677  if (knn < 0)
1678  nrc = std::min<uint64_t>(nrc, -knn);
1679 
1680  if (cnts)
1681  cnts[i] = nrc;
1682  if (dists)
1683  dists[i] = max_dist;
1684 
1685  // Ensure we have enough space for the results
1686  if (k + nrc > idsz)
1687  return RT_None;
1688 
1689  *nr = i + 1;
1690  auto& res = visitor.GetResults();
1691  for (uint64_t l = 0; l < nrc; ++l)
1692  ids[k++] = res[l];
1693 
1694  }
1695  } catch (Tools::Exception& e)
1696  {
1698  e.what().c_str(),
1699  "Index_NearestNeighbors_id_v");
1700  return RT_Failure;
1701  } catch (std::exception const& e)
1702  {
1704  e.what(),
1705  "Index_NearestNeighbors_id_v");
1706  return RT_Failure;
1707  } catch (...) {
1709  "Unknown Error",
1710  "Index_NearestNeighbors_id_v");
1711  return RT_Failure;
1712  }
1713  return RT_None;
1714 }
1715 
1717  double* pdMin,
1718  double* pdMax,
1719  double* pdVMin,
1720  double* pdVMax,
1721  double tStart,
1722  double tEnd,
1723  uint32_t nDimension,
1724  IndexItemH** items,
1725  uint64_t* nResults)
1726 {
1727  VALIDATE_POINTER1(index, "Index_TPNearestNeighbors_obj", RT_Failure);
1728  Index* idx = reinterpret_cast<Index*>(index);
1729 
1730  int64_t nResultLimit, nStart;
1732 
1733  nResultLimit = idx->GetResultSetLimit();
1734  nStart = idx->GetResultSetOffset();
1735 
1736  ObjVisitor* visitor = new ObjVisitor;
1737  try {
1738  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1739 
1740  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1741  *r,
1742  *visitor);
1743 
1744  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1745 
1746  delete r;
1747  delete visitor;
1748 
1749  } catch (Tools::Exception& e)
1750  {
1752  e.what().c_str(),
1753  "Index_TPNearestNeighbors_obj");
1754  delete r;
1755  delete visitor;
1756  return RT_Failure;
1757  } catch (std::exception const& e)
1758  {
1760  e.what(),
1761  "Index_TPNearestNeighbors_obj");
1762  delete r;
1763  delete visitor;
1764  return RT_Failure;
1765  } catch (...) {
1767  "Unknown Error",
1768  "Index_NearestNeighbors_obj");
1769  delete visitor;
1770  return RT_Failure;
1771  }
1772  return RT_None;
1773 }
1774 
1776  double* pdMin,
1777  double* pdMax,
1778  double tStart,
1779  double tEnd,
1780  uint32_t nDimension,
1781  IndexItemH** items,
1782  uint64_t* nResults)
1783 {
1784  VALIDATE_POINTER1(index, "Index_MVRNearestNeighbors_obj", RT_Failure);
1785  Index* idx = reinterpret_cast<Index*>(index);
1786 
1787  int64_t nResultLimit, nStart;
1788  SpatialIndex::TimeRegion* r = 0;
1789 
1790  nResultLimit = idx->GetResultSetLimit();
1791  nStart = idx->GetResultSetOffset();
1792 
1793  ObjVisitor* visitor = new ObjVisitor;
1794  try {
1795  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1796 
1797  idx->index().nearestNeighborQuery( (uint32_t)*nResults,
1798  *r,
1799  *visitor);
1800 
1801  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1802 
1803  delete r;
1804  delete visitor;
1805 
1806  } catch (Tools::Exception& e)
1807  {
1809  e.what().c_str(),
1810  "Index_MVRNearestNeighbors_obj");
1811  delete r;
1812  delete visitor;
1813  return RT_Failure;
1814  } catch (std::exception const& e)
1815  {
1817  e.what(),
1818  "Index_MVRNearestNeighbors_obj");
1819  delete r;
1820  delete visitor;
1821  return RT_Failure;
1822  } catch (...) {
1824  "Unknown Error",
1825  "Index_NearestNeighbors_obj");
1826  delete r;
1827  delete visitor;
1828  return RT_Failure;
1829  }
1830  return RT_None;
1831 }
1832 
1834  double* pdMin,
1835  double* pdMax,
1836  uint32_t nDimension,
1837  IndexItemH** items,
1838  uint64_t* nResults)
1839 {
1840  VALIDATE_POINTER1(index, "Index_NearestNeighbors_obj", RT_Failure);
1841  Index* idx = reinterpret_cast<Index*>(index);
1842 
1843  int64_t nResultLimit, nStart;
1844  SpatialIndex::Region* r = 0;
1845 
1846  nResultLimit = idx->GetResultSetLimit();
1847  nStart = idx->GetResultSetOffset();
1848 
1849  ObjVisitor* visitor = new ObjVisitor;
1850  try {
1851  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1852 
1853  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1854  *r,
1855  *visitor);
1856 
1857  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1858 
1859  delete r;
1860  delete visitor;
1861 
1862  } catch (Tools::Exception& e)
1863  {
1865  e.what().c_str(),
1866  "Index_NearestNeighbors_obj");
1867  delete r;
1868  delete visitor;
1869  return RT_Failure;
1870  } catch (std::exception const& e)
1871  {
1873  e.what(),
1874  "Index_NearestNeighbors_obj");
1875  delete r;
1876  delete visitor;
1877  return RT_Failure;
1878  } catch (...) {
1880  "Unknown Error",
1881  "Index_NearestNeighbors_obj");
1882  delete r;
1883  delete visitor;
1884  return RT_Failure;
1885  }
1886  return RT_None;
1887 }
1888 
1890  double* pdMin,
1891  double* pdMax,
1892  uint32_t nDimension,
1893  IndexItemH** ids,
1894  uint64_t* nResults)
1895 {
1896  VALIDATE_POINTER1(index, "Index_Intersects_internal", RT_Failure);
1897  Index* idx = reinterpret_cast<Index*>(index);
1898 
1899  int64_t nResultLimit, nStart;
1900 
1901  nResultLimit = idx->GetResultSetLimit();
1902  nStart = idx->GetResultSetOffset();
1903 
1904  ObjVisitor* visitor = new ObjVisitor;
1905  try {
1906  SpatialIndex::Region* r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1907  idx->index().internalNodesQuery( *r,
1908  *visitor);
1909 
1910  Page_ResultSet_Obj(*visitor, ids, nStart, nResultLimit, nResults);
1911 
1912  delete r;
1913  delete visitor;
1914 
1915  } catch (Tools::Exception& e)
1916  {
1918  e.what().c_str(),
1919  "Index_Intersects_internal");
1920  delete visitor;
1921  return RT_Failure;
1922  } catch (std::exception const& e)
1923  {
1925  e.what(),
1926  "Index_Intersects_internal");
1927  delete visitor;
1928  return RT_Failure;
1929  } catch (...) {
1931  "Unknown Error",
1932  "Index_Intersects_internal");
1933  delete visitor;
1934  return RT_Failure;
1935  }
1936  return RT_None;
1937 }
1938 
1940  double** ppdMin,
1941  double** ppdMax,
1942  uint32_t* nDimension)
1943 {
1944  VALIDATE_POINTER1(index, "Index_GetBounds", RT_Failure);
1945  Index* idx = reinterpret_cast<Index*>(index);
1946 
1947  BoundsQuery* query = new BoundsQuery;
1948 
1949  try {
1950  idx->index().queryStrategy( *query);
1951 
1952  const SpatialIndex::Region* bounds = query->GetBounds();
1953  if (bounds == 0) {
1954  *nDimension = 0;
1955  delete query;
1956  return RT_None;
1957  }
1958 
1959  *nDimension =bounds->getDimension();
1960 
1961  *ppdMin = (double*) malloc (*nDimension * sizeof(double));
1962  *ppdMax = (double*) malloc (*nDimension * sizeof(double));
1963 
1964  for (uint32_t i=0; i< *nDimension; ++i) {
1965  (*ppdMin)[i] = bounds->getLow(i);
1966  (*ppdMax)[i] = bounds->getHigh(i);
1967  }
1968 
1969  delete query;
1970 
1971  } catch (Tools::Exception& e)
1972  {
1974  e.what().c_str(),
1975  "Index_GetBounds");
1976  delete query;
1977  return RT_Failure;
1978  } catch (std::exception const& e)
1979  {
1981  e.what(),
1982  "Index_GetBounds");
1983  delete query;
1984  return RT_Failure;
1985  } catch (...) {
1987  "Unknown Error",
1988  "Index_GetBounds");
1989  delete query;
1990  return RT_Failure;
1991  }
1992  return RT_None;
1993 }
1994 
1996 {
1997  try
1998  {
1999  VALIDATE_POINTER1(index, "Index_SetResultSetOffset", RT_Failure);
2000  Index* idx = reinterpret_cast<Index*>(index);
2001  idx->SetResultSetOffset(value);
2002  }
2003  catch (...) {
2005  "Unknown Error",
2006  "Index_SetResultSetOffset");
2007  return RT_Failure;
2008  }
2009  return RT_None;
2010 }
2011 
2013 {
2014  VALIDATE_POINTER1(index, "Index_GetResultSetOffset", 0);
2015  Index* idx = reinterpret_cast<Index*>(index);
2016  return idx->GetResultSetOffset();
2017 }
2018 
2020 {
2021  try
2022  {
2023  VALIDATE_POINTER1(index, "Index_SetResultSetLimit", RT_Failure);
2024  Index* idx = reinterpret_cast<Index*>(index);
2025  idx->SetResultSetLimit(value);
2026  }
2027  catch (...) {
2029  "Unknown Error",
2030  "Index_SetResultSetLimit");
2031  return RT_Failure;
2032  }
2033  return RT_None;
2034 }
2035 
2037 {
2038  VALIDATE_POINTER1(index, "Index_GetResultSetLimit", 0);
2039  Index* idx = reinterpret_cast<Index*>(index);
2040  return idx->GetResultSetLimit();
2041 }
2042 
2044 {
2045  VALIDATE_POINTER1(index, "Index_IsValid", 0);
2046  Index* idx = reinterpret_cast<Index*>(index);
2047  return static_cast<uint32_t>(idx->index().isIndexValid());
2048 }
2049 
2051 {
2052  VALIDATE_POINTER1(index, "Index_GetProperties", 0);
2053  Index* idx = reinterpret_cast<Index*>(index);
2055  *ps = idx->GetProperties();
2056 
2057  Tools::PropertySet base_props;
2058  idx->index().getIndexProperties(base_props);
2059  ps->setProperty("IndexIdentifier", base_props.getProperty("IndexIdentifier"));
2060  return (IndexPropertyH)ps;
2061 }
2062 
2064 {
2065  VALIDATE_POINTER0(index, "Index_ClearBuffer");
2066  Index* idx = reinterpret_cast<Index*>(index);
2067  idx->buffer().clear();
2068 }
2069 
2070 SIDX_C_DLL void Index_DestroyObjResults(IndexItemH* results, uint32_t nResults)
2071 {
2072  VALIDATE_POINTER0(results, "Index_DestroyObjResults");
2073  SpatialIndex::IData* it;
2074  for (uint32_t i=0; i< nResults; ++i) {
2075  if (results[i] != NULL) {
2076  it = reinterpret_cast<SpatialIndex::IData*>(results[i]);
2077  if (it != 0)
2078  delete it;
2079  }
2080  }
2081 
2082  std::free(results);
2083 }
2084 
2085 
2086 SIDX_C_DLL void Index_Free(void* results)
2087 {
2088  VALIDATE_POINTER0(results, "Index_Free");
2089  if (results != 0)
2090  std::free(results);
2091 }
2092 
2094  uint32_t* nNumLeafNodes,
2095  uint32_t** nLeafSizes,
2096  int64_t** nLeafIDs,
2097  int64_t*** nLeafChildIDs,
2098  double*** pppdMin,
2099  double*** pppdMax,
2100  uint32_t* nDimension)
2101 {
2102  VALIDATE_POINTER1(index, "Index_GetLeaves", RT_Failure);
2103  Index* idx = reinterpret_cast<Index*>(index);
2104 
2105  std::vector<LeafQueryResult>::const_iterator i;
2106  LeafQuery* query = 0;
2107 
2108  // Fetch the dimensionality of the index
2109  Tools::PropertySet ps;
2110  idx->index().getIndexProperties(ps);
2111 
2112  Tools::Variant var;
2113  var = ps.getProperty("Dimension");
2114 
2115  if (var.m_varType != Tools::VT_EMPTY)
2116  {
2117  if (var.m_varType != Tools::VT_ULONG) {
2119  "Property Dimension must be Tools::VT_ULONG",
2120  "Index_GetLeaves");
2121  return RT_Failure;
2122  }
2123  }
2124 
2125  *nDimension = var.m_val.ulVal;
2126 
2127  try {
2128  query = new LeafQuery;
2129  idx->index().queryStrategy( *query);
2130 
2131  const std::vector<LeafQueryResult>& results = query->GetResults();
2132 
2133  *nNumLeafNodes = (uint32_t)results.size();
2134 
2135  *nLeafSizes = (uint32_t*) malloc (*nNumLeafNodes * sizeof(uint32_t));
2136  *nLeafIDs = (int64_t*) malloc (*nNumLeafNodes * sizeof(int64_t));
2137 
2138  *nLeafChildIDs = (int64_t**) malloc(*nNumLeafNodes * sizeof(int64_t*));
2139  *pppdMin = (double**) malloc (*nNumLeafNodes * sizeof(double*));
2140  *pppdMax = (double**) malloc (*nNumLeafNodes * sizeof(double*));
2141 
2142  uint32_t k=0;
2143  for (i = results.begin(); i != results.end(); ++i)
2144  {
2145  std::vector<SpatialIndex::id_type> const& ids = (*i).GetIDs();
2146  const SpatialIndex::Region* b = (*i).GetBounds();
2147 
2148  (*nLeafIDs)[k] = (*i).getIdentifier();
2149  (*nLeafSizes)[k] = (uint32_t)ids.size();
2150 
2151  (*nLeafChildIDs)[k] = (int64_t*) malloc( (*nLeafSizes)[k] * sizeof(int64_t));
2152  (*pppdMin)[k] = (double*) malloc (*nDimension * sizeof(double));
2153  (*pppdMax)[k] = (double*) malloc (*nDimension * sizeof(double));
2154  for (uint32_t c=0; c< *nDimension; ++c) {
2155  (*pppdMin)[k][c] = b->getLow(c);
2156  (*pppdMax)[k][c] = b->getHigh(c);
2157  }
2158  for (uint32_t cChild = 0; cChild < ids.size(); cChild++)
2159  {
2160  (*nLeafChildIDs)[k][cChild] = ids[cChild];
2161  }
2162  ++k;
2163  }
2164 
2165 
2166  delete query;
2167 
2168  } catch (Tools::Exception& e)
2169  {
2171  e.what().c_str(),
2172  "Index_GetLeaves");
2173  delete query;
2174  return RT_Failure;
2175  } catch (std::exception const& e)
2176  {
2178  e.what(),
2179  "Index_GetLeaves");
2180  delete query;
2181  return RT_Failure;
2182  } catch (...) {
2184  "Unknown Error",
2185  "Index_GetLeaves");
2186  delete query;
2187  return RT_Failure;
2188  }
2189  return RT_None;
2190 }
2191 
2192 
2194 {
2195  VALIDATE_POINTER0(item, "IndexItem_Destroy");
2196  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2197  if (it != 0) delete it;
2198 }
2199 
2201  uint8_t** data,
2202  uint64_t* length)
2203 {
2204  VALIDATE_POINTER1(item, "IndexItem_GetData", RT_Failure);
2205  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2206  uint8_t* p_data;
2207  uint32_t* l= new uint32_t;
2208 
2209  it->getData(*l,&p_data);
2210  *length = (uint64_t)*l;
2211  *data = (uint8_t*) malloc (*length * sizeof(uint8_t));
2212 
2213  memcpy(*data, p_data, *length);
2214  delete[] p_data;
2215  delete l;
2216  return RT_None;
2217 
2218 }
2219 
2221 {
2222  VALIDATE_POINTER1(item, "IndexItem_GetID",0);
2223  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2224  int64_t value = it->getIdentifier();
2225  return value;
2226 }
2227 
2229  double** ppdMin,
2230  double** ppdMax,
2231  uint32_t* nDimension)
2232 {
2233  VALIDATE_POINTER1(item, "IndexItem_GetBounds", RT_Failure);
2234  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2235 
2237  it->getShape(&s);
2238 
2240  s->getMBR(*bounds);
2241 
2242  if (bounds == 0) {
2243  *nDimension = 0;
2244  delete bounds;
2245  delete s;
2246  return RT_None;
2247  }
2248  *nDimension = bounds->getDimension();
2249 
2250  *ppdMin = (double*) malloc (*nDimension * sizeof(double));
2251  *ppdMax = (double*) malloc (*nDimension * sizeof(double));
2252 
2253  if (ppdMin == NULL || ppdMax == NULL) {
2255  "Unable to allocation bounds array(s)",
2256  "IndexItem_GetBounds");
2257  delete bounds;
2258  delete s;
2259  return RT_Failure;
2260  }
2261 
2262  for (uint32_t i=0; i< *nDimension; ++i) {
2263  (*ppdMin)[i] = bounds->getLow(i);
2264  (*ppdMax)[i] = bounds->getHigh(i);
2265  }
2266  delete bounds;
2267  delete s;
2268  return RT_None;
2269 }
2271 {
2273  Tools::Variant var;
2274  return (IndexPropertyH)ps;
2275 }
2276 
2278 {
2279  VALIDATE_POINTER0(hProp, "IndexProperty_Destroy");
2280  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2281  if (prop != 0) delete prop;
2282 }
2283 
2285  RTIndexType value)
2286 {
2287  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexType", RT_Failure);
2288  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2289 
2290  try
2291  {
2292  if (!(value == RT_RTree || value == RT_MVRTree || value == RT_TPRTree)) {
2293  throw std::runtime_error("Inputted value is not a valid index type");
2294  }
2295  Tools::Variant var;
2296  var.m_varType = Tools::VT_ULONG;
2297  var.m_val.ulVal = value;
2298  prop->setProperty("IndexType", var);
2299 
2300 
2301  } catch (Tools::Exception& e)
2302  {
2304  e.what().c_str(),
2305  "IndexProperty_SetIndexType");
2306  return RT_Failure;
2307  } catch (std::exception const& e)
2308  {
2310  e.what(),
2311  "IndexProperty_SetIndexType");
2312  return RT_Failure;
2313  } catch (...) {
2315  "Unknown Error",
2316  "IndexProperty_SetIndexType");
2317  return RT_Failure;
2318  }
2319  return RT_None;
2320 }
2321 
2323 {
2324  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexType", RT_InvalidIndexType);
2325  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2326 
2327  Tools::Variant var;
2328  var = prop->getProperty("IndexType");
2329 
2330  if (var.m_varType != Tools::VT_EMPTY)
2331  {
2332  if (var.m_varType != Tools::VT_ULONG) {
2334  "Property IndexType must be Tools::VT_ULONG",
2335  "IndexProperty_GetIndexType");
2336  return RT_InvalidIndexType;
2337  }
2338  return (RTIndexType) var.m_val.ulVal;
2339  }
2340 
2342  "Property IndexType was empty",
2343  "IndexProperty_GetIndexType");
2344  return RT_InvalidIndexType;
2345 
2346 }
2347 
2349 {
2350  VALIDATE_POINTER1(hProp, "IndexProperty_SetDimension", RT_Failure);
2351  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2352 
2353  try
2354  {
2355  Tools::Variant var;
2356  var.m_varType = Tools::VT_ULONG;
2357  var.m_val.ulVal = value;
2358  prop->setProperty("Dimension", var);
2359  } catch (Tools::Exception& e)
2360  {
2362  e.what().c_str(),
2363  "IndexProperty_SetDimension");
2364  return RT_Failure;
2365  } catch (std::exception const& e)
2366  {
2368  e.what(),
2369  "IndexProperty_SetDimension");
2370  return RT_Failure;
2371  } catch (...) {
2373  "Unknown Error",
2374  "IndexProperty_SetDimension");
2375  return RT_Failure;
2376  }
2377  return RT_None;
2378 }
2379 
2381 {
2382  VALIDATE_POINTER1(hProp, "IndexProperty_GetDimension", 0);
2383  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2384 
2385  Tools::Variant var;
2386  var = prop->getProperty("Dimension");
2387 
2388  if (var.m_varType != Tools::VT_EMPTY)
2389  {
2390  if (var.m_varType != Tools::VT_ULONG) {
2392  "Property IndexType must be Tools::VT_ULONG",
2393  "IndexProperty_GetDimension");
2394  return 0;
2395  }
2396 
2397  return var.m_val.ulVal;
2398  }
2399 
2400  // A zero dimension index is invalid.
2402  "Property Dimension was empty",
2403  "IndexProperty_GetDimension");
2404  return 0;
2405 }
2406 
2408  RTIndexVariant value)
2409 {
2410  using namespace SpatialIndex;
2411 
2412  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexVariant", RT_Failure);
2413  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2414 
2415  Tools::Variant var;
2416 
2417  try
2418  {
2419 
2420  if (!(value == RT_Linear || value == RT_Quadratic || value == RT_Star)) {
2421  throw std::runtime_error("Inputted value is not a valid index variant");
2422  }
2423 
2424  var.m_varType = Tools::VT_LONG;
2426  if (type == RT_InvalidIndexType ) {
2428  "Index type is not properly set",
2429  "IndexProperty_SetIndexVariant");
2430  return RT_Failure;
2431  }
2432  if (type == RT_RTree) {
2433  var.m_val.lVal = static_cast<RTree::RTreeVariant>(value);
2434  prop->setProperty("TreeVariant", var);
2435  } else if (type == RT_MVRTree) {
2436  var.m_val.lVal = static_cast<MVRTree::MVRTreeVariant>(value);
2437  prop->setProperty("TreeVariant", var);
2438  } else if (type == RT_TPRTree) {
2439  var.m_val.lVal = static_cast<TPRTree::TPRTreeVariant>(value);
2440  prop->setProperty("TreeVariant", var);
2441  }
2442 
2443  } catch (Tools::Exception& e)
2444  {
2446  e.what().c_str(),
2447  "IndexProperty_SetIndexVariant");
2448  return RT_Failure;
2449  } catch (std::exception const& e)
2450  {
2452  e.what(),
2453  "IndexProperty_SetIndexCapacity");
2454  return RT_Failure;
2455  } catch (...) {
2457  "Unknown Error",
2458  "IndexProperty_SetIndexCapacity");
2459  return RT_Failure;
2460  }
2461  return RT_None;
2462 }
2463 
2465 {
2466  VALIDATE_POINTER1( hProp,
2467  "IndexProperty_GetIndexVariant",
2469 
2470  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2471 
2472  Tools::Variant var;
2473  var = prop->getProperty("TreeVariant");
2474 
2475 
2476  if (var.m_varType != Tools::VT_EMPTY)
2477  {
2478  if (var.m_varType != Tools::VT_LONG) {
2480  "Property IndexVariant must be Tools::VT_LONG",
2481  "IndexProperty_GetIndexVariant");
2482  return RT_InvalidIndexVariant;
2483  }
2484 
2485  return static_cast<RTIndexVariant>(var.m_val.lVal);
2486  }
2487 
2488  // if we didn't get anything, we're returning an error condition
2490  "Property IndexVariant was empty",
2491  "IndexProperty_GetIndexVariant");
2492  return RT_InvalidIndexVariant;
2493 
2494 }
2495 
2497  RTStorageType value)
2498 {
2499  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexStorage", RT_Failure);
2500  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2501 
2502  try
2503  {
2504  if (!(value == RT_Disk || value == RT_Memory || value == RT_Custom)) {
2505  throw std::runtime_error("Inputted value is not a valid index storage type");
2506  }
2507  Tools::Variant var;
2508  var.m_varType = Tools::VT_ULONG;
2509  var.m_val.ulVal = value;
2510  prop->setProperty("IndexStorageType", var);
2511  } catch (Tools::Exception& e)
2512  {
2514  e.what().c_str(),
2515  "IndexProperty_SetIndexStorage");
2516  return RT_Failure;
2517  } catch (std::exception const& e)
2518  {
2520  e.what(),
2521  "IndexProperty_SetIndexStorage");
2522  return RT_Failure;
2523  } catch (...) {
2525  "Unknown Error",
2526  "IndexProperty_SetIndexStorage");
2527  return RT_Failure;
2528  }
2529  return RT_None;
2530 }
2531 
2533 {
2534  VALIDATE_POINTER1( hProp,
2535  "IndexProperty_GetIndexStorage",
2537 
2538  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2539 
2540  Tools::Variant var;
2541  var = prop->getProperty("IndexStorageType");
2542 
2543  if (var.m_varType != Tools::VT_EMPTY)
2544  {
2545  if (var.m_varType != Tools::VT_ULONG) {
2547  "Property IndexStorage must be Tools::VT_ULONG",
2548  "IndexProperty_GetIndexStorage");
2549  return RT_InvalidStorageType;
2550  }
2551 
2552  return static_cast<RTStorageType>(var.m_val.ulVal);
2553  }
2554 
2555  // if we didn't get anything, we're returning an error condition
2557  "Property IndexStorage was empty",
2558  "IndexProperty_GetIndexStorage");
2559  return RT_InvalidStorageType;
2560 
2561 }
2562 
2564  uint32_t value)
2565 {
2566  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexCapacity", RT_Failure);
2567  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2568 
2569  try
2570  {
2571  Tools::Variant var;
2572  var.m_varType = Tools::VT_ULONG;
2573  var.m_val.ulVal = value;
2574  prop->setProperty("IndexCapacity", var);
2575  } catch (Tools::Exception& e)
2576  {
2578  e.what().c_str(),
2579  "IndexProperty_SetIndexCapacity");
2580  return RT_Failure;
2581  } catch (std::exception const& e)
2582  {
2584  e.what(),
2585  "IndexProperty_SetIndexCapacity");
2586  return RT_Failure;
2587  } catch (...) {
2589  "Unknown Error",
2590  "IndexProperty_SetIndexCapacity");
2591  return RT_Failure;
2592  }
2593  return RT_None;
2594 }
2595 
2597 {
2598  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexCapacity", 0);
2599  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2600 
2601  Tools::Variant var;
2602  var = prop->getProperty("IndexCapacity");
2603 
2604  if (var.m_varType != Tools::VT_EMPTY)
2605  {
2606  if (var.m_varType != Tools::VT_ULONG) {
2608  "Property IndexCapacity must be Tools::VT_ULONG",
2609  "IndexProperty_GetIndexCapacity");
2610  return 0;
2611  }
2612 
2613  return var.m_val.ulVal;
2614  }
2615 
2616  // return nothing for an error
2618  "Property IndexCapacity was empty",
2619  "IndexProperty_GetIndexCapacity");
2620  return 0;
2621 }
2622 
2624  uint32_t value)
2625 {
2626  VALIDATE_POINTER1(hProp, "IndexProperty_SetLeafCapacity", RT_Failure);
2627  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2628 
2629  try
2630  {
2631  Tools::Variant var;
2632  var.m_varType = Tools::VT_ULONG;
2633  var.m_val.ulVal = value;
2634  prop->setProperty("LeafCapacity", var);
2635  } catch (Tools::Exception& e)
2636  {
2638  e.what().c_str(),
2639  "IndexProperty_SetLeafCapacity");
2640  return RT_Failure;
2641  } catch (std::exception const& e)
2642  {
2644  e.what(),
2645  "IndexProperty_SetLeafCapacity");
2646  return RT_Failure;
2647  } catch (...) {
2649  "Unknown Error",
2650  "IndexProperty_SetLeafCapacity");
2651  return RT_Failure;
2652  }
2653  return RT_None;
2654 }
2655 
2657 {
2658  VALIDATE_POINTER1(hProp, "IndexProperty_GetLeafCapacity", 0);
2659  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2660 
2661  Tools::Variant var;
2662  var = prop->getProperty("LeafCapacity");
2663 
2664  if (var.m_varType != Tools::VT_EMPTY)
2665  {
2666  if (var.m_varType != Tools::VT_ULONG) {
2668  "Property LeafCapacity must be Tools::VT_ULONG",
2669  "IndexProperty_GetLeafCapacity");
2670  return 0;
2671  }
2672 
2673  return var.m_val.ulVal;
2674  }
2675 
2676  // return nothing for an error
2678  "Property LeafCapacity was empty",
2679  "IndexProperty_GetLeafCapacity");
2680  return 0;
2681 }
2682 
2684  uint32_t value)
2685 {
2686  VALIDATE_POINTER1(hProp, "IndexProperty_SetPagesize", RT_Failure);
2687  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2688 
2689  try
2690  {
2691  Tools::Variant var;
2692  var.m_varType = Tools::VT_ULONG;
2693  var.m_val.ulVal = value;
2694  prop->setProperty("PageSize", var);
2695  } catch (Tools::Exception& e)
2696  {
2698  e.what().c_str(),
2699  "IndexProperty_SetPagesize");
2700  return RT_Failure;
2701  } catch (std::exception const& e)
2702  {
2704  e.what(),
2705  "IndexProperty_SetPagesize");
2706  return RT_Failure;
2707  } catch (...) {
2709  "Unknown Error",
2710  "IndexProperty_SetPagesize");
2711  return RT_Failure;
2712  }
2713  return RT_None;
2714 }
2715 
2717 {
2718  VALIDATE_POINTER1(hProp, "IndexProperty_GetPagesize", 0);
2719  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2720 
2721  Tools::Variant var;
2722  var = prop->getProperty("PageSize");
2723 
2724  if (var.m_varType != Tools::VT_EMPTY)
2725  {
2726  if (var.m_varType != Tools::VT_ULONG) {
2728  "Property PageSize must be Tools::VT_ULONG",
2729  "IndexProperty_GetPagesize");
2730  return 0;
2731  }
2732 
2733  return var.m_val.ulVal;
2734  }
2735 
2736  // return nothing for an error
2738  "Property PageSize was empty",
2739  "IndexProperty_GetPagesize");
2740  return 0;
2741 }
2742 
2744  uint32_t value)
2745 {
2746  VALIDATE_POINTER1(hProp, "IndexProperty_SetLeafPoolCapacity", RT_Failure);
2747  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2748 
2749  try
2750  {
2751  Tools::Variant var;
2752  var.m_varType = Tools::VT_ULONG;
2753  var.m_val.ulVal = value;
2754  prop->setProperty("LeafPoolCapacity", var);
2755  } catch (Tools::Exception& e)
2756  {
2758  e.what().c_str(),
2759  "IndexProperty_SetLeafPoolCapacity");
2760  return RT_Failure;
2761  } catch (std::exception const& e)
2762  {
2764  e.what(),
2765  "IndexProperty_SetLeafPoolCapacity");
2766  return RT_Failure;
2767  } catch (...) {
2769  "Unknown Error",
2770  "IndexProperty_SetLeafPoolCapacity");
2771  return RT_Failure;
2772  }
2773  return RT_None;
2774 }
2775 
2777 {
2778  VALIDATE_POINTER1(hProp, "IndexProperty_GetLeafPoolCapacity", 0);
2779  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2780 
2781  Tools::Variant var;
2782  var = prop->getProperty("LeafPoolCapacity");
2783 
2784  if (var.m_varType != Tools::VT_EMPTY)
2785  {
2786  if (var.m_varType != Tools::VT_ULONG) {
2788  "Property LeafPoolCapacity must be Tools::VT_ULONG",
2789  "IndexProperty_GetLeafPoolCapacity");
2790  return 0;
2791  }
2792 
2793  return var.m_val.ulVal;
2794  }
2795 
2796  // return nothing for an error
2798  "Property LeafPoolCapacity was empty",
2799  "IndexProperty_GetLeafPoolCapacity");
2800  return 0;
2801 }
2802 
2804  uint32_t value)
2805 {
2806  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexPoolCapacity", RT_Failure);
2807  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2808 
2809  try
2810  {
2811  Tools::Variant var;
2812  var.m_varType = Tools::VT_ULONG;
2813  var.m_val.ulVal = value;
2814  prop->setProperty("IndexPoolCapacity", var);
2815  } catch (Tools::Exception& e)
2816  {
2818  e.what().c_str(),
2819  "IndexProperty_SetIndexPoolCapacity");
2820  return RT_Failure;
2821  } catch (std::exception const& e)
2822  {
2824  e.what(),
2825  "IndexProperty_SetIndexPoolCapacity");
2826  return RT_Failure;
2827  } catch (...) {
2829  "Unknown Error",
2830  "IndexProperty_SetIndexPoolCapacity");
2831  return RT_Failure;
2832  }
2833  return RT_None;
2834 }
2835 
2837 {
2838  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexPoolCapacity", 0);
2839  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2840 
2841  Tools::Variant var;
2842  var = prop->getProperty("IndexPoolCapacity");
2843 
2844  if (var.m_varType != Tools::VT_EMPTY)
2845  {
2846  if (var.m_varType != Tools::VT_ULONG) {
2848  "Property IndexPoolCapacity must be Tools::VT_ULONG",
2849  "IndexProperty_GetIndexPoolCapacity");
2850  return 0;
2851  }
2852 
2853  return var.m_val.ulVal;
2854  }
2855 
2856  // return nothing for an error
2858  "Property IndexPoolCapacity was empty",
2859  "IndexProperty_GetIndexPoolCapacity");
2860  return 0;
2861 }
2862 
2864  uint32_t value)
2865 {
2866  VALIDATE_POINTER1(hProp, "IndexProperty_SetRegionPoolCapacity", RT_Failure);
2867  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2868 
2869  try
2870  {
2871  Tools::Variant var;
2872  var.m_varType = Tools::VT_ULONG;
2873  var.m_val.ulVal = value;
2874  prop->setProperty("RegionPoolCapacity", var);
2875  } catch (Tools::Exception& e)
2876  {
2878  e.what().c_str(),
2879  "IndexProperty_SetRegionPoolCapacity");
2880  return RT_Failure;
2881  } catch (std::exception const& e)
2882  {
2884  e.what(),
2885  "IndexProperty_SetRegionPoolCapacity");
2886  return RT_Failure;
2887  } catch (...) {
2889  "Unknown Error",
2890  "IndexProperty_SetRegionPoolCapacity");
2891  return RT_Failure;
2892  }
2893  return RT_None;
2894 }
2895 
2897 {
2898  VALIDATE_POINTER1(hProp, "IndexProperty_GetRegionPoolCapacity", 0);
2899  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2900 
2901  Tools::Variant var;
2902  var = prop->getProperty("RegionPoolCapacity");
2903 
2904  if (var.m_varType != Tools::VT_EMPTY)
2905  {
2906  if (var.m_varType != Tools::VT_ULONG) {
2908  "Property RegionPoolCapacity must be Tools::VT_ULONG",
2909  "IndexProperty_GetRegionPoolCapacity");
2910  return 0;
2911  }
2912 
2913  return var.m_val.ulVal;
2914  }
2915 
2916  // return nothing for an error
2918  "Property RegionPoolCapacity was empty",
2919  "IndexProperty_GetRegionPoolCapacity");
2920  return 0;
2921 }
2922 
2924  uint32_t value)
2925 {
2926  VALIDATE_POINTER1(hProp, "IndexProperty_SetPointPoolCapacity", RT_Failure);
2927  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2928 
2929  try
2930  {
2931  Tools::Variant var;
2932  var.m_varType = Tools::VT_ULONG;
2933  var.m_val.ulVal = value;
2934  prop->setProperty("PointPoolCapacity", var);
2935  } catch (Tools::Exception& e)
2936  {
2938  e.what().c_str(),
2939  "IndexProperty_SetPointPoolCapacity");
2940  return RT_Failure;
2941  } catch (std::exception const& e)
2942  {
2944  e.what(),
2945  "IndexProperty_SetPointPoolCapacity");
2946  return RT_Failure;
2947  } catch (...) {
2949  "Unknown Error",
2950  "IndexProperty_SetPointPoolCapacity");
2951  return RT_Failure;
2952  }
2953  return RT_None;
2954 }
2955 
2957 {
2958  VALIDATE_POINTER1(hProp, "IndexProperty_GetPointPoolCapacity", 0);
2959  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2960 
2961  Tools::Variant var;
2962  var = prop->getProperty("PointPoolCapacity");
2963 
2964  if (var.m_varType != Tools::VT_EMPTY)
2965  {
2966  if (var.m_varType != Tools::VT_ULONG) {
2968  "Property PointPoolCapacity must be Tools::VT_ULONG",
2969  "IndexProperty_GetPointPoolCapacity");
2970  return 0;
2971  }
2972 
2973  return var.m_val.ulVal;
2974  }
2975 
2976  // return nothing for an error
2978  "Property PointPoolCapacity was empty",
2979  "IndexProperty_GetPointPoolCapacity");
2980  return 0;
2981 }
2982 
2984  uint32_t value)
2985 {
2986  VALIDATE_POINTER1( hProp,
2987  "IndexProperty_SetNearMinimumOverlapFactor",
2988  RT_Failure);
2989  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2990 
2991  try
2992  {
2993  Tools::Variant var;
2994  var.m_varType = Tools::VT_ULONG;
2995  var.m_val.ulVal = value;
2996  prop->setProperty("NearMinimumOverlapFactor", var);
2997  } catch (Tools::Exception& e)
2998  {
3000  e.what().c_str(),
3001  "IndexProperty_SetNearMinimumOverlapFactor");
3002  return RT_Failure;
3003  } catch (std::exception const& e)
3004  {
3006  e.what(),
3007  "IndexProperty_SetNearMinimumOverlapFactor");
3008  return RT_Failure;
3009  } catch (...) {
3011  "Unknown Error",
3012  "IndexProperty_SetNearMinimumOverlapFactor");
3013  return RT_Failure;
3014  }
3015  return RT_None;
3016 }
3017 
3019 {
3020  VALIDATE_POINTER1(hProp, "IndexProperty_GetNearMinimumOverlapFactor", 0);
3021  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3022 
3023  Tools::Variant var;
3024  var = prop->getProperty("NearMinimumOverlapFactor");
3025 
3026  if (var.m_varType != Tools::VT_EMPTY)
3027  {
3028  if (var.m_varType != Tools::VT_ULONG) {
3030  "Property NearMinimumOverlapFactor must be Tools::VT_ULONG",
3031  "IndexProperty_GetNearMinimumOverlapFactor");
3032  return 0;
3033  }
3034 
3035  return var.m_val.ulVal;
3036  }
3037 
3038  // return nothing for an error
3040  "Property NearMinimumOverlapFactor was empty",
3041  "IndexProperty_GetNearMinimumOverlapFactor");
3042  return 0;
3043 }
3044 
3045 
3047  uint32_t value)
3048 {
3049  VALIDATE_POINTER1(hProp, "IndexProperty_SetBufferingCapacity", RT_Failure);
3050  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3051 
3052  try
3053  {
3054  Tools::Variant var;
3055  var.m_varType = Tools::VT_ULONG;
3056  var.m_val.ulVal = value;
3057  prop->setProperty("Capacity", var);
3058  } catch (Tools::Exception& e)
3059  {
3061  e.what().c_str(),
3062  "IndexProperty_SetBufferingCapacity");
3063  return RT_Failure;
3064  } catch (std::exception const& e)
3065  {
3067  e.what(),
3068  "IndexProperty_SetBufferingCapacity");
3069  return RT_Failure;
3070  } catch (...) {
3072  "Unknown Error",
3073  "IndexProperty_SetBufferingCapacity");
3074  return RT_Failure;
3075  }
3076  return RT_None;
3077 }
3078 
3080 {
3081  VALIDATE_POINTER1(hProp, "IndexProperty_GetBufferingCapacity", 0);
3082  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3083 
3084  Tools::Variant var;
3085  var = prop->getProperty("Capacity");
3086 
3087  if (var.m_varType != Tools::VT_EMPTY)
3088  {
3089  if (var.m_varType != Tools::VT_ULONG) {
3091  "Property Capacity must be Tools::VT_ULONG",
3092  "IndexProperty_GetBufferingCapacity");
3093  return 0;
3094  }
3095 
3096  return var.m_val.ulVal;
3097  }
3098 
3099  // return nothing for an error
3101  "Property Capacity was empty",
3102  "IndexProperty_GetBufferingCapacity");
3103  return 0;
3104 }
3105 
3107  uint32_t value)
3108 {
3109  VALIDATE_POINTER1(hProp, "IndexProperty_SetEnsureTightMBRs", RT_Failure);
3110  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3111 
3112  try
3113  {
3114  if (value > 1 ) {
3116  "EnsureTightMBRs is a boolean value and must be 1 or 0",
3117  "IndexProperty_SetEnsureTightMBRs");
3118  return RT_Failure;
3119  }
3120  Tools::Variant var;
3121  var.m_varType = Tools::VT_BOOL;
3122  var.m_val.blVal = value != 0;
3123  prop->setProperty("EnsureTightMBRs", var);
3124  } catch (Tools::Exception& e)
3125  {
3127  e.what().c_str(),
3128  "IndexProperty_SetEnsureTightMBRs");
3129  return RT_Failure;
3130  } catch (std::exception const& e)
3131  {
3133  e.what(),
3134  "IndexProperty_SetEnsureTightMBRs");
3135  return RT_Failure;
3136  } catch (...) {
3138  "Unknown Error",
3139  "IndexProperty_SetEnsureTightMBRs");
3140  return RT_Failure;
3141  }
3142  return RT_None;
3143 }
3144 
3146 {
3147  VALIDATE_POINTER1(hProp, "IndexProperty_GetEnsureTightMBRs", 0);
3148  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3149 
3150  Tools::Variant var;
3151  var = prop->getProperty("EnsureTightMBRs");
3152 
3153  if (var.m_varType != Tools::VT_EMPTY)
3154  {
3155  if (var.m_varType != Tools::VT_BOOL) {
3157  "Property EnsureTightMBRs must be Tools::VT_BOOL",
3158  "IndexProperty_GetEnsureTightMBRs");
3159  return 0;
3160  }
3161 
3162  return var.m_val.blVal;
3163  }
3164 
3165  // return nothing for an error
3167  "Property EnsureTightMBRs was empty",
3168  "IndexProperty_GetEnsureTightMBRs");
3169  return 0;
3170 }
3171 
3173  uint32_t value)
3174 {
3175  VALIDATE_POINTER1(hProp, "IndexProperty_SetWriteThrough", RT_Failure);
3176  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3177 
3178  try
3179  {
3180  if (value > 1 ) {
3182  "WriteThrough is a boolean value and must be 1 or 0",
3183  "IndexProperty_SetWriteThrough");
3184  return RT_Failure;
3185  }
3186  Tools::Variant var;
3187  var.m_varType = Tools::VT_BOOL;
3188  var.m_val.blVal = value != 0;
3189  prop->setProperty("WriteThrough", var);
3190  } catch (Tools::Exception& e)
3191  {
3193  e.what().c_str(),
3194  "IndexProperty_SetWriteThrough");
3195  return RT_Failure;
3196  } catch (std::exception const& e)
3197  {
3199  e.what(),
3200  "IndexProperty_SetWriteThrough");
3201  return RT_Failure;
3202  } catch (...) {
3204  "Unknown Error",
3205  "IndexProperty_SetWriteThrough");
3206  return RT_Failure;
3207  }
3208  return RT_None;
3209 }
3210 
3212 {
3213  VALIDATE_POINTER1(hProp, "IndexProperty_GetWriteThrough", 0);
3214  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3215 
3216  Tools::Variant var;
3217  var = prop->getProperty("WriteThrough");
3218 
3219  if (var.m_varType != Tools::VT_EMPTY)
3220  {
3221  if (var.m_varType != Tools::VT_BOOL) {
3223  "Property WriteThrough must be Tools::VT_BOOL",
3224  "IndexProperty_GetWriteThrough");
3225  return 0;
3226  }
3227 
3228  return var.m_val.blVal;
3229  }
3230 
3231  // return nothing for an error
3233  "Property WriteThrough was empty",
3234  "IndexProperty_GetWriteThrough");
3235  return 0;
3236 }
3237 
3239  uint32_t value)
3240 {
3241  VALIDATE_POINTER1(hProp, "IndexProperty_SetOverwrite", RT_Failure);
3242  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3243 
3244  try
3245  {
3246  if (value > 1 ) {
3248  "Overwrite is a boolean value and must be 1 or 0",
3249  "IndexProperty_SetOverwrite");
3250  return RT_Failure;
3251  }
3252  Tools::Variant var;
3253  var.m_varType = Tools::VT_BOOL;
3254  var.m_val.blVal = value != 0;
3255  prop->setProperty("Overwrite", var);
3256  } catch (Tools::Exception& e)
3257  {
3259  e.what().c_str(),
3260  "IndexProperty_SetOverwrite");
3261  return RT_Failure;
3262  } catch (std::exception const& e)
3263  {
3265  e.what(),
3266  "IndexProperty_SetOverwrite");
3267  return RT_Failure;
3268  } catch (...) {
3270  "Unknown Error",
3271  "IndexProperty_SetOverwrite");
3272  return RT_Failure;
3273  }
3274  return RT_None;
3275 }
3276 
3278 {
3279  VALIDATE_POINTER1(hProp, "IndexProperty_GetOverwrite", 0);
3280  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3281 
3282  Tools::Variant var;
3283  var = prop->getProperty("Overwrite");
3284 
3285  if (var.m_varType != Tools::VT_EMPTY)
3286  {
3287  if (var.m_varType != Tools::VT_BOOL) {
3289  "Property Overwrite must be Tools::VT_BOOL",
3290  "IndexProperty_GetOverwrite");
3291  return 0;
3292  }
3293 
3294  return var.m_val.blVal;
3295  }
3296 
3297  // return nothing for an error
3299  "Property Overwrite was empty",
3300  "IndexProperty_GetOverwrite");
3301  return 0;
3302 }
3303 
3304 
3306  double value)
3307 {
3308  VALIDATE_POINTER1(hProp, "IndexProperty_SetFillFactor", RT_Failure);
3309  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3310 
3311  try
3312  {
3313  Tools::Variant var;
3315  var.m_val.dblVal = value;
3316  prop->setProperty("FillFactor", var);
3317  } catch (Tools::Exception& e)
3318  {
3320  e.what().c_str(),
3321  "IndexProperty_SetFillFactor");
3322  return RT_Failure;
3323  } catch (std::exception const& e)
3324  {
3326  e.what(),
3327  "IndexProperty_SetFillFactor");
3328  return RT_Failure;
3329  } catch (...) {
3331  "Unknown Error",
3332  "IndexProperty_SetFillFactor");
3333  return RT_Failure;
3334  }
3335  return RT_None;
3336 }
3337 
3339 {
3340  VALIDATE_POINTER1(hProp, "IndexProperty_GetFillFactor", 0);
3341  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3342 
3343  Tools::Variant var;
3344  var = prop->getProperty("FillFactor");
3345 
3346  if (var.m_varType != Tools::VT_EMPTY)
3347  {
3348  if (var.m_varType != Tools::VT_DOUBLE) {
3350  "Property FillFactor must be Tools::VT_DOUBLE",
3351  "IndexProperty_GetFillFactor");
3352  return 0;
3353  }
3354 
3355  return var.m_val.dblVal;
3356  }
3357 
3358  // return nothing for an error
3360  "Property FillFactor was empty",
3361  "IndexProperty_GetFillFactor");
3362  return 0;
3363 }
3364 
3366  double value)
3367 {
3368  VALIDATE_POINTER1( hProp,
3369  "IndexProperty_SetSplitDistributionFactor",
3370  RT_Failure);
3371  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3372 
3373  try
3374  {
3375  Tools::Variant var;
3377  var.m_val.dblVal = value;
3378  prop->setProperty("SplitDistributionFactor", var);
3379  } catch (Tools::Exception& e)
3380  {
3382  e.what().c_str(),
3383  "IndexProperty_SetSplitDistributionFactor");
3384  return RT_Failure;
3385  } catch (std::exception const& e)
3386  {
3388  e.what(),
3389  "IndexProperty_SetSplitDistributionFactor");
3390  return RT_Failure;
3391  } catch (...) {
3393  "Unknown Error",
3394  "IndexProperty_SetSplitDistributionFactor");
3395  return RT_Failure;
3396  }
3397  return RT_None;
3398 }
3399 
3401 {
3402  VALIDATE_POINTER1(hProp, "IndexProperty_GetSplitDistributionFactor", 0);
3403  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3404 
3405  Tools::Variant var;
3406  var = prop->getProperty("SplitDistributionFactor");
3407 
3408  if (var.m_varType != Tools::VT_EMPTY)
3409  {
3410  if (var.m_varType != Tools::VT_DOUBLE) {
3412  "Property SplitDistributionFactor must be Tools::VT_DOUBLE",
3413  "IndexProperty_GetSplitDistributionFactor");
3414  return 0;
3415  }
3416 
3417  return var.m_val.dblVal;
3418  }
3419 
3420  // return nothing for an error
3422  "Property SplitDistributionFactor was empty",
3423  "IndexProperty_GetSplitDistributionFactor");
3424  return 0;
3425 }
3426 
3428  double value)
3429 {
3430  VALIDATE_POINTER1( hProp,
3431  "IndexProperty_SetTPRHorizon",
3432  RT_Failure);
3433  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3434 
3435  try
3436  {
3437  Tools::Variant var;
3439  var.m_val.dblVal = value;
3440  prop->setProperty("Horizon", var);
3441  } catch (Tools::Exception& e)
3442  {
3444  e.what().c_str(),
3445  "IndexProperty_SetTPRHorizon");
3446  return RT_Failure;
3447  } catch (std::exception const& e)
3448  {
3450  e.what(),
3451  "IndexProperty_SetTPRHorizon");
3452  return RT_Failure;
3453  } catch (...) {
3455  "Unknown Error",
3456  "IndexProperty_SetTPRHorizon");
3457  return RT_Failure;
3458  }
3459  return RT_None;
3460 }
3461 
3463 {
3464  VALIDATE_POINTER1(hProp, "IndexProperty_GetTPRHorizon", 0);
3465  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3466 
3467  Tools::Variant var;
3468  var = prop->getProperty("Horizon");
3469 
3470  if (var.m_varType != Tools::VT_EMPTY)
3471  {
3472  if (var.m_varType != Tools::VT_DOUBLE) {
3474  "Property Horizon must be Tools::VT_DOUBLE",
3475  "IndexProperty_GetTPRHorizon");
3476  return 0;
3477  }
3478 
3479  return var.m_val.dblVal;
3480  }
3481 
3482  // return nothing for an error
3484  "Property Horizon was empty",
3485  "IndexProperty_GetTPRHorizon");
3486  return 0;
3487 }
3488 
3490  double value)
3491 {
3492  VALIDATE_POINTER1( hProp,
3493  "IndexProperty_SetReinsertFactor",
3494  RT_Failure);
3495  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3496 
3497  try
3498  {
3499  Tools::Variant var;
3501  var.m_val.dblVal = value;
3502  prop->setProperty("ReinsertFactor", var);
3503  } catch (Tools::Exception& e)
3504  {
3506  e.what().c_str(),
3507  "IndexProperty_SetReinsertFactor");
3508  return RT_Failure;
3509  } catch (std::exception const& e)
3510  {
3512  e.what(),
3513  "IndexProperty_SetReinsertFactor");
3514  return RT_Failure;
3515  } catch (...) {
3517  "Unknown Error",
3518  "IndexProperty_SetReinsertFactor");
3519  return RT_Failure;
3520  }
3521  return RT_None;
3522 }
3523 
3525 {
3526  VALIDATE_POINTER1(hProp, "IndexProperty_GetReinsertFactor", 0);
3527  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3528 
3529  Tools::Variant var;
3530  var = prop->getProperty("ReinsertFactor");
3531 
3532  if (var.m_varType != Tools::VT_EMPTY)
3533  {
3534  if (var.m_varType != Tools::VT_DOUBLE) {
3536  "Property ReinsertFactor must be Tools::VT_DOUBLE",
3537  "IndexProperty_GetReinsertFactor");
3538  return 0;
3539  }
3540 
3541  return var.m_val.dblVal;
3542  }
3543 
3544  // return nothing for an error
3546  "Property ReinsertFactor was empty",
3547  "IndexProperty_GetReinsertFactor");
3548  return 0;
3549 }
3550 
3552  const char* value)
3553 {
3554  VALIDATE_POINTER1( hProp,
3555  "IndexProperty_SetFileName",
3556  RT_Failure);
3557  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3558 
3559  try
3560  {
3561  Tools::Variant var;
3562  var.m_varType = Tools::VT_PCHAR;
3563  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3564  prop->setProperty("FileName", var);
3565  } catch (Tools::Exception& e)
3566  {
3568  e.what().c_str(),
3569  "IndexProperty_SetFileName");
3570  return RT_Failure;
3571  } catch (std::exception const& e)
3572  {
3574  e.what(),
3575  "IndexProperty_SetFileName");
3576  return RT_Failure;
3577  } catch (...) {
3579  "Unknown Error",
3580  "IndexProperty_SetFileName");
3581  return RT_Failure;
3582  }
3583  return RT_None;
3584 }
3585 
3587 {
3588  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileName", 0);
3589  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3590 
3591  Tools::Variant var;
3592  var = prop->getProperty("FileName");
3593 
3594  if (var.m_varType != Tools::VT_EMPTY)
3595  {
3596  if (var.m_varType != Tools::VT_PCHAR) {
3598  "Property FileName must be Tools::VT_PCHAR",
3599  "IndexProperty_GetFileName");
3600  return NULL;
3601  }
3602 
3603  return STRDUP(var.m_val.pcVal);
3604  }
3605 
3606  // return nothing for an error
3608  "Property FileName was empty",
3609  "IndexProperty_GetFileName");
3610  return NULL;
3611 }
3612 
3613 
3615  const char* value)
3616 {
3617  VALIDATE_POINTER1( hProp,
3618  "IndexProperty_SetFileNameExtensionDat",
3619  RT_Failure);
3620  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3621 
3622  try
3623  {
3624  Tools::Variant var;
3625  var.m_varType = Tools::VT_PCHAR;
3626  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3627  prop->setProperty("FileNameDat", var);
3628 
3629  } catch (Tools::Exception& e)
3630  {
3632  e.what().c_str(),
3633  "IndexProperty_SetFileNameExtensionDat");
3634  return RT_Failure;
3635  } catch (std::exception const& e)
3636  {
3638  e.what(),
3639  "IndexProperty_SetFileNameExtensionDat");
3640  return RT_Failure;
3641  } catch (...) {
3643  "Unknown Error",
3644  "IndexProperty_SetFileNameExtensionDat");
3645  return RT_Failure;
3646  }
3647  return RT_None;
3648 }
3649 
3651 {
3652  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileNameExtensionDat", 0);
3653  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3654 
3655  Tools::Variant var;
3656  var = prop->getProperty("FileNameDat");
3657 
3658  if (var.m_varType != Tools::VT_EMPTY)
3659  {
3660  if (var.m_varType != Tools::VT_PCHAR) {
3662  "Property FileNameDat must be Tools::VT_PCHAR",
3663  "IndexProperty_GetFileNameExtensionDat");
3664  return NULL;
3665  }
3666 
3667  return STRDUP(var.m_val.pcVal);
3668  }
3669 
3670  // return nothing for an error
3672  "Property FileNameDat was empty",
3673  "IndexProperty_GetFileNameExtensionDat");
3674  return NULL;
3675 }
3676 
3678  const char* value)
3679 {
3680  VALIDATE_POINTER1( hProp,
3681  "IndexProperty_SetFileNameExtensionIdx",
3682  RT_Failure);
3683  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3684 
3685  try
3686  {
3687  Tools::Variant var;
3688  var.m_varType = Tools::VT_PCHAR;
3689  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3690  prop->setProperty("FileNameIdx", var);
3691 
3692  } catch (Tools::Exception& e)
3693  {
3695  e.what().c_str(),
3696  "IndexProperty_SetFileNameExtensionIdx");
3697  return RT_Failure;
3698  } catch (std::exception const& e)
3699  {
3701  e.what(),
3702  "IndexProperty_SetFileNameExtensionIdx");
3703  return RT_Failure;
3704  } catch (...) {
3706  "Unknown Error",
3707  "IndexProperty_SetFileNameExtensionIdx");
3708  return RT_Failure;
3709  }
3710  return RT_None;
3711 }
3712 
3714 {
3715  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileNameExtensionIdx", 0);
3716  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3717 
3718  Tools::Variant var;
3719  var = prop->getProperty("FileNameIdx");
3720 
3721  if (var.m_varType != Tools::VT_EMPTY)
3722  {
3723  if (var.m_varType != Tools::VT_PCHAR) {
3725  "Property FileNameIdx must be Tools::VT_PCHAR",
3726  "IndexProperty_GetFileNameExtensionIdx");
3727  return NULL;
3728  }
3729 
3730  return STRDUP(var.m_val.pcVal);
3731  }
3732 
3733  // return nothing for an error
3735  "Property FileNameIdx was empty",
3736  "IndexProperty_GetFileNameExtensionIdx");
3737  return NULL;
3738 }
3739 
3741  uint32_t value)
3742 {
3743  VALIDATE_POINTER1(hProp, "IndexProperty_SetCustomStorageCallbacksSize", RT_Failure);
3744  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3745 
3746  try
3747  {
3748  Tools::Variant var;
3749  var.m_varType = Tools::VT_ULONG;
3750  var.m_val.ulVal = value;
3751  prop->setProperty("CustomStorageCallbacksSize", var);
3752  } catch (Tools::Exception& e)
3753  {
3755  e.what().c_str(),
3756  "IndexProperty_SetCustomStorageCallbacksSize");
3757  return RT_Failure;
3758  } catch (std::exception const& e)
3759  {
3761  e.what(),
3762  "IndexProperty_SetCustomStorageCallbacksSize");
3763  return RT_Failure;
3764  } catch (...) {
3766  "Unknown Error",
3767  "IndexProperty_SetCustomStorageCallbacksSize");
3768  return RT_Failure;
3769  }
3770  return RT_None;
3771 }
3772 
3774 {
3775  VALIDATE_POINTER1(hProp, "IndexProperty_GetCustomStorageCallbacksSize", 0);
3776  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3777 
3778  Tools::Variant var;
3779  var = prop->getProperty("CustomStorageCallbacksSize");
3780 
3781  if (var.m_varType != Tools::VT_EMPTY)
3782  {
3783  if (var.m_varType != Tools::VT_ULONG) {
3785  "Property CustomStorageCallbacksSize must be Tools::VT_ULONG",
3786  "IndexProperty_GetCustomStorageCallbacksSize");
3787  return 0;
3788  }
3789 
3790  return var.m_val.ulVal;
3791  }
3792 
3793  // return nothing for an error
3795  "Property CustomStorageCallbacksSize was empty",
3796  "IndexProperty_GetCustomStorageCallbacksSize");
3797  return 0;
3798 }
3799 
3801  const void* value)
3802 {
3803  VALIDATE_POINTER1( hProp,
3804  "IndexProperty_SetCustomStorageCallbacks",
3805  RT_Failure);
3806  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3807 
3808  // check if the CustomStorageCallbacksSize is alright, so we can make a copy of the passed in structure
3809  Tools::Variant varSize;
3810  varSize = prop->getProperty("CustomStorageCallbacksSize");
3812  {
3813  std::ostringstream ss;
3814  ss << "The supplied storage callbacks size is wrong, expected "
3816  << ", got " << varSize.m_val.ulVal;
3818  ss.str().c_str(),
3819  "IndexProperty_SetCustomStorageCallbacks");
3820  return RT_Failure;
3821  }
3822 
3823  try
3824  {
3825  Tools::Variant var;
3826  var.m_varType = Tools::VT_PVOID;
3827  var.m_val.pvVal = value ?
3830  )
3831  : 0;
3832  prop->setProperty("CustomStorageCallbacks", var);
3833 
3834  } catch (Tools::Exception& e)
3835  {
3837  e.what().c_str(),
3838  "IndexProperty_SetCustomStorageCallbacks");
3839  return RT_Failure;
3840  } catch (std::exception const& e)
3841  {
3843  e.what(),
3844  "IndexProperty_SetCustomStorageCallbacks");
3845  return RT_Failure;
3846  } catch (...) {
3848  "Unknown Error",
3849  "IndexProperty_SetCustomStorageCallbacks");
3850  return RT_Failure;
3851  }
3852  return RT_None;
3853 }
3854 
3856 {
3857  VALIDATE_POINTER1(hProp, "IndexProperty_GetCustomStorageCallbacks", 0);
3858  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3859 
3860  Tools::Variant var;
3861  var = prop->getProperty("CustomStorageCallbacks");
3862 
3863  if (var.m_varType != Tools::VT_EMPTY)
3864  {
3865  if (var.m_varType != Tools::VT_PVOID) {
3867  "Property CustomStorageCallbacks must be Tools::VT_PVOID",
3868  "IndexProperty_GetCustomStorageCallbacks");
3869  return NULL;
3870  }
3871 
3872  return var.m_val.pvVal;
3873  }
3874 
3875  // return nothing for an error
3877  "Property CustomStorageCallbacks was empty",
3878  "IndexProperty_GetCustomStorageCallbacks");
3879  return NULL;
3880 }
3881 
3883  int64_t value)
3884 {
3885  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexID", RT_Failure);
3886  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3887 
3888  try
3889  {
3890  Tools::Variant var;
3892  var.m_val.llVal = value;
3893  prop->setProperty("IndexIdentifier", var);
3894  } catch (Tools::Exception& e)
3895  {
3897  e.what().c_str(),
3898  "IndexProperty_SetIndexID");
3899  return RT_Failure;
3900  } catch (std::exception const& e)
3901  {
3903  e.what(),
3904  "IndexProperty_SetIndexID");
3905  return RT_Failure;
3906  } catch (...) {
3908  "Unknown Error",
3909  "IndexProperty_SetIndexID");
3910  return RT_Failure;
3911  }
3912  return RT_None;
3913 }
3914 
3916 {
3917  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexID", 0);
3918  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3919 
3920  Tools::Variant var;
3921  var = prop->getProperty("IndexIdentifier");
3922 
3923  if (var.m_varType != Tools::VT_EMPTY)
3924  {
3925  if (var.m_varType != Tools::VT_LONGLONG) {
3927  "Property IndexIdentifier must be Tools::VT_LONGLONG",
3928  "IndexProperty_GetIndexID");
3929  return 0;
3930  }
3931 
3932  return var.m_val.llVal;
3933  }
3934 
3935  // return nothing for an error
3937  "Property IndexIdentifier was empty",
3938  "IndexProperty_GetIndexID");
3939  return 0;
3940 }
3941 
3942 SIDX_C_DLL void* SIDX_NewBuffer(size_t length)
3943 {
3944  return new char[length];
3945 }
3946 
3948 {
3949  VALIDATE_POINTER1(hProp, "IndexProperty_SetResultSetLimit", RT_Failure);
3950 
3951  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3952 
3953  try
3954  {
3955  Tools::Variant var;
3957  var.m_val.llVal = value;
3958  prop->setProperty("ResultSetLimit", var);
3959  } catch (Tools::Exception& e)
3960  {
3962  e.what().c_str(),
3963  "IndexProperty_SetResultSetLimit");
3964  return RT_Failure;
3965  } catch (std::exception const& e)
3966  {
3968  e.what(),
3969  "IndexProperty_SetResultSetLimit");
3970  return RT_Failure;
3971  } catch (...) {
3973  "Unknown Error",
3974  "IndexProperty_SetResultSetLimit");
3975  return RT_Failure;
3976  }
3977  return RT_None;
3978 }
3979 
3981 {
3982  VALIDATE_POINTER1(hProp, "IndexProperty_GetResultSetLimit", 0);
3983  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3984 
3985  Tools::Variant var;
3986  var = prop->getProperty("ResultSetLimit");
3987 
3988  if (var.m_varType != Tools::VT_EMPTY)
3989  {
3990  if (var.m_varType != Tools::VT_LONGLONG) {
3992  "Property ResultSetLimit must be Tools::VT_LONGLONG",
3993  "IndexProperty_GetResultSetLimit");
3994  return 0;
3995  }
3996 
3997  return var.m_val.llVal;
3998  }
3999 
4000  // return nothing for an error
4002  "Property ResultSetLimit was empty",
4003  "IndexProperty_GetResultSetLimit");
4004  return 0;
4005 }
4006 
4007 
4008 SIDX_C_DLL void SIDX_DeleteBuffer(void* buffer)
4009 {
4010  delete [] static_cast<char*>(buffer);
4011 }
4012 
4013 
4015 {
4016 
4017  std::ostringstream ot;
4018 
4019 #ifdef SIDX_RELEASE_NAME
4020  ot << SIDX_RELEASE_NAME;
4021 #else
4022  ot << "1.3.2";
4023 #endif
4024 
4025  std::string out(ot.str());
4026  return STRDUP(out.c_str());
4027 
4028 }
4029 IDX_C_END
4030 
4031 #ifdef _WIN32
4032 # pragma warning(pop)
4033 #endif
SIDX_DLL void Page_ResultSet_Ids(IdVisitor &visitor, int64_t **ids, int64_t nStart, int64_t nResultLimit, uint64_t *nResults)
Definition: Utility.cc:157
SIDX_DLL Tools::PropertySet * GetDefaults()
Definition: Utility.cc:31
SIDX_DLL void Page_ResultSet_Obj(ObjVisitor &visitor, IndexItemH **items, int64_t nStart, int64_t nResultLimit, uint64_t *nResults)
Definition: Utility.cc:195
#define SIDX_RELEASE_NAME
Definition: Version.h:46
SpatialIndex::Region * GetBounds() const
Definition: BoundsQuery.h:46
uint64_t GetResultCount() const
Definition: CountVisitor.h:43
Definition: Error.h:34
int GetCode() const
Definition: Error.h:45
const char * GetMessage() const
Definition: Error.h:46
const char * GetMethod() const
Definition: Error.h:47
std::vector< uint64_t > & GetResults()
Definition: IdVisitor.h:45
uint64_t GetResultCount() const
Definition: IdVisitor.h:44
void reset()
Definition: IdVisitor.h:46
SpatialIndex::ISpatialIndex & index()
const Tools::PropertySet GetProperties()
int64_t GetResultSetOffset()
Definition: capi/Index.cc:357
SpatialIndex::StorageManager::IBuffer & buffer()
void SetResultSetLimit(int64_t v)
Definition: capi/Index.cc:377
void SetResultSetOffset(int64_t v)
Definition: capi/Index.cc:362
int64_t GetResultSetLimit()
Definition: capi/Index.cc:372
void flush()
Definition: capi/Index.cc:386
std::vector< LeafQueryResult > const & GetResults() const
Definition: LeafQuery.h:73
virtual void getData(uint32_t &len, uint8_t **data) const =0
virtual void getShape(IShape **out) const =0
virtual id_type getIdentifier() const =0
virtual void getMBR(Region &out) const =0
virtual void intersectsWithQuery(const IShape &query, IVisitor &v)=0
virtual bool deleteData(const IShape &shape, id_type shapeIdentifier)=0
virtual void internalNodesQuery(const IShape &query, IVisitor &v)=0
virtual void insertData(uint32_t len, const uint8_t *pData, const IShape &shape, id_type shapeIdentifier)=0
virtual double nearestNeighborQuery(uint32_t k, const IShape &query, IVisitor &v, INearestNeighborComparator &nnc, double max_dist=0.0)=0
virtual bool isIndexValid()=0
virtual void getIndexProperties(Tools::PropertySet &out) const =0
virtual void queryStrategy(IQueryStrategy &qs)=0
virtual void containsWhatQuery(const IShape &query, IVisitor &v)=0
uint32_t getDimension() const override
Definition: Region.cc:208
virtual double getHigh(uint32_t index) const
Definition: Region.cc:522
virtual double getLow(uint32_t index) const
Definition: Region.cc:514
virtual std::string what()=0
void setProperty(std::string property, Variant const &v)
Definition: Tools.cc:354
Variant getProperty(std::string property) const
Definition: Tools.cc:346
int64_t llVal
Definition: Tools.h:283
void * pvVal
Definition: Tools.h:293
uint32_t ulVal
Definition: Tools.h:289
bool blVal
Definition: Tools.h:291
union Tools::Variant::@0 m_val
int32_t lVal
Definition: Tools.h:282
double dblVal
Definition: Tools.h:286
VariantType m_varType
Definition: Tools.h:277
char * pcVal
Definition: Tools.h:292
int64_t id_type
Definition: SpatialIndex.h:41
class SIDX_DLL PropertySet
Definition: Tools.h:298
@ VT_BOOL
Definition: Tools.h:100
@ VT_EMPTY
Definition: Tools.h:103
@ VT_LONGLONG
Definition: Tools.h:104
@ VT_PCHAR
Definition: Tools.h:101
@ VT_LONG
Definition: Tools.h:90
@ VT_DOUBLE
Definition: Tools.h:94
@ VT_PVOID
Definition: Tools.h:102
@ VT_ULONG
Definition: Tools.h:97
SIDX_C_DLL char * IndexProperty_GetFileName(IndexPropertyH hProp)
Definition: sidx_api.cc:3586
SIDX_C_DLL RTError IndexProperty_SetRegionPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2863
SIDX_C_DLL RTError Index_Intersects_obj(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:746
SIDX_C_DLL RTError Index_InsertTPData(IndexH index, int64_t id, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, const uint8_t *pData, size_t nDataLength)
Definition: sidx_api.cc:417
SIDX_C_DLL RTError Index_MVRNearestNeighbors_id(IndexH index, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:1534
SIDX_C_DLL RTError IndexProperty_SetFileNameExtensionIdx(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3677
SIDX_DLL RTError Index_SetResultSetLimit(IndexH index, int64_t value)
Definition: sidx_api.cc:2019
SIDX_C_DLL double IndexProperty_GetSplitDistributionFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3400
SIDX_C_DLL char * IndexProperty_GetFileNameExtensionDat(IndexPropertyH hProp)
Definition: sidx_api.cc:3650
SIDX_C_DLL RTError IndexProperty_SetTPRHorizon(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3427
SIDX_DLL RTError IndexProperty_SetResultSetLimit(IndexPropertyH hProp, uint64_t value)
Definition: sidx_api.cc:3947
SIDX_C_DLL void IndexItem_Destroy(IndexItemH item)
Definition: sidx_api.cc:2193
SIDX_C_DLL RTError IndexItem_GetBounds(IndexItemH item, double **ppdMin, double **ppdMax, uint32_t *nDimension)
Definition: sidx_api.cc:2228
SIDX_C_DLL void Index_Free(void *results)
Definition: sidx_api.cc:2086
SIDX_C_DLL RTError IndexProperty_SetCustomStorageCallbacksSize(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3740
SIDX_C_DLL RTError IndexProperty_SetOverwrite(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3238
SIDX_C_DLL void * IndexProperty_GetCustomStorageCallbacks(IndexPropertyH hProp)
Definition: sidx_api.cc:3855
SIDX_C_DLL IndexPropertyH IndexProperty_Create()
Definition: sidx_api.cc:2270
SIDX_C_DLL RTError Index_Contains_obj(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:797
SIDX_DLL IndexH Index_CreateWithArray(IndexPropertyH hProp, uint64_t n, uint32_t dimension, uint64_t i_stri, uint64_t d_i_stri, uint64_t d_j_stri, int64_t *ids, double *mins, double *maxs)
Definition: sidx_api.cc:227
SIDX_C_DLL RTError IndexProperty_SetEnsureTightMBRs(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3106
SIDX_C_DLL int64_t IndexProperty_GetIndexID(IndexPropertyH hProp)
Definition: sidx_api.cc:3915
IDX_C_START SIDX_C_DLL void Error_Reset(void)
Definition: sidx_api.cc:83
SIDX_C_DLL RTError Index_NearestNeighbors_id_v(IndexH index, int64_t knn, int64_t n, uint32_t d, uint64_t idsz, uint64_t d_i_stri, uint64_t d_j_stri, const double *mins, const double *maxs, int64_t *ids, uint64_t *cnts, double *dists, int64_t *nr)
Definition: sidx_api.cc:1636
SIDX_C_DLL RTError IndexProperty_SetIndexCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2563
SIDX_C_DLL RTError Index_TPNearestNeighbors_obj(IndexH index, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:1716
SIDX_C_DLL RTError Index_Intersects_id_v(IndexH index, int64_t n, uint32_t d, uint64_t idsz, uint64_t d_i_stri, uint64_t d_j_stri, const double *mins, const double *maxs, int64_t *ids, uint64_t *cnts, int64_t *nr)
Definition: sidx_api.cc:1055
SIDX_C_DLL RTError Index_MVRIntersects_obj(IndexH index, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:691
SIDX_C_DLL int Error_GetErrorCount(void)
Definition: sidx_api.cc:162
SIDX_C_DLL RTError Index_TPIntersects_count(IndexH index, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1124
SIDX_C_DLL double IndexProperty_GetFillFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3338
SIDX_C_DLL char * Error_GetLastErrorMsg(void)
Definition: sidx_api.cc:114
SIDX_C_DLL RTIndexVariant IndexProperty_GetIndexVariant(IndexPropertyH hProp)
Definition: sidx_api.cc:2464
SIDX_C_DLL uint32_t IndexProperty_GetCustomStorageCallbacksSize(IndexPropertyH hProp)
Definition: sidx_api.cc:3773
SIDX_C_DLL RTError IndexProperty_SetBufferingCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3046
SIDX_C_DLL RTError Index_SegmentIntersects_id(IndexH index, double *pdStartPoint, double *pdEndPoint, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:1374
SIDX_C_DLL RTError Index_InsertData(IndexH index, int64_t id, double *pdMin, double *pdMax, uint32_t nDimension, const uint8_t *pData, size_t nDataLength)
Definition: sidx_api.cc:566
SIDX_C_DLL uint32_t IndexProperty_GetBufferingCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:3079
SIDX_DLL uint64_t IndexProperty_GetResultSetLimit(IndexPropertyH hProp)
Definition: sidx_api.cc:3980
SIDX_C_DLL RTError Index_DeleteData(IndexH index, int64_t id, double *pdMin, double *pdMax, uint32_t nDimension)
Definition: sidx_api.cc:384
SIDX_C_DLL RTIndexType IndexProperty_GetIndexType(IndexPropertyH hProp)
Definition: sidx_api.cc:2322
SIDX_C_DLL uint32_t IndexProperty_GetOverwrite(IndexPropertyH hProp)
Definition: sidx_api.cc:3277
SIDX_C_DLL RTError Index_DeleteMVRData(IndexH index, int64_t id, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension)
Definition: sidx_api.cc:348
SIDX_C_DLL RTError IndexProperty_SetIndexID(IndexPropertyH hProp, int64_t value)
Definition: sidx_api.cc:3882
SIDX_C_DLL RTError IndexProperty_SetWriteThrough(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3172
SIDX_C_DLL void IndexProperty_Destroy(IndexPropertyH hProp)
Definition: sidx_api.cc:2277
SIDX_C_DLL uint32_t IndexProperty_GetRegionPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2896
SIDX_C_DLL RTError IndexProperty_SetIndexStorage(IndexPropertyH hProp, RTStorageType value)
Definition: sidx_api.cc:2496
SIDX_C_DLL RTError Index_MVRIntersects_count(IndexH index, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1175
SIDX_C_DLL RTError IndexProperty_SetSplitDistributionFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3365
SIDX_C_DLL RTError Index_InsertMVRData(IndexH index, int64_t id, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, const uint8_t *pData, size_t nDataLength)
Definition: sidx_api.cc:494
SIDX_C_DLL RTError Index_TPIntersects_id(IndexH index, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:847
static std::stack< Error > errors
Definition: sidx_api.cc:53
#define VALIDATE_POINTER0(ptr, func)
Definition: sidx_api.cc:61
SIDX_C_DLL RTError IndexProperty_SetCustomStorageCallbacks(IndexPropertyH hProp, const void *value)
Definition: sidx_api.cc:3800
SIDX_C_DLL RTError Index_TPIntersects_obj(IndexH index, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:634
SIDX_C_DLL double IndexProperty_GetReinsertFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3524
SIDX_C_DLL RTError IndexProperty_SetReinsertFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3489
SIDX_C_DLL uint32_t IndexProperty_GetNearMinimumOverlapFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3018
SIDX_C_DLL void Error_PushError(int code, const char *message, const char *method)
Definition: sidx_api.cc:148
SIDX_C_DLL RTError IndexProperty_SetLeafCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2623
SIDX_C_DLL RTError Index_NearestNeighbors_obj(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:1833
SIDX_C_DLL RTError Index_SegmentIntersects_obj(IndexH index, double *pdStartPoint, double *pdEndPoint, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:1320
SIDX_C_DLL uint32_t IndexProperty_GetIndexCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2596
SIDX_C_DLL RTError IndexProperty_SetDimension(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2348
SIDX_C_DLL void Index_Flush(IndexH index)
Definition: sidx_api.cc:300
SIDX_C_DLL uint32_t IndexProperty_GetDimension(IndexPropertyH hProp)
Definition: sidx_api.cc:2380
SIDX_C_DLL char * IndexProperty_GetFileNameExtensionIdx(IndexPropertyH hProp)
Definition: sidx_api.cc:3713
SIDX_C_DLL RTError IndexProperty_SetIndexType(IndexPropertyH hProp, RTIndexType value)
Definition: sidx_api.cc:2284
SIDX_C_DLL uint32_t IndexProperty_GetWriteThrough(IndexPropertyH hProp)
Definition: sidx_api.cc:3211
SIDX_C_DLL int64_t IndexItem_GetID(IndexItemH item)
Definition: sidx_api.cc:2220
SIDX_C_DLL RTError IndexProperty_SetIndexPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2803
SIDX_C_DLL RTError IndexProperty_SetPointPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2923
SIDX_C_DLL RTError Index_NearestNeighbors_id(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:1591
SIDX_C_DLL RTError IndexProperty_SetPagesize(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2683
SIDX_C_DLL RTError IndexItem_GetData(IndexItemH item, uint8_t **data, uint64_t *length)
Definition: sidx_api.cc:2200
SIDX_C_DLL RTError Index_Intersects_internal(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, IndexItemH **ids, uint64_t *nResults)
Definition: sidx_api.cc:1889
SIDX_C_DLL RTError IndexProperty_SetFillFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3305
SIDX_C_DLL RTError IndexProperty_SetNearMinimumOverlapFactor(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2983
SIDX_C_DLL RTError Index_MVRIntersects_id(IndexH index, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:904
SIDX_C_DLL uint32_t IndexProperty_GetEnsureTightMBRs(IndexPropertyH hProp)
Definition: sidx_api.cc:3145
SIDX_C_DLL RTError Index_Intersects_count(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1225
#define VALIDATE_POINTER1(ptr, func, rc)
Definition: sidx_api.cc:71
SIDX_C_DLL RTError IndexProperty_SetIndexVariant(IndexPropertyH hProp, RTIndexVariant value)
Definition: sidx_api.cc:2407
SIDX_C_DLL RTError Index_Intersects_id(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:1014
SIDX_DLL RTError Index_SetResultSetOffset(IndexH index, int64_t value)
Definition: sidx_api.cc:1995
SIDX_C_DLL uint32_t IndexProperty_GetLeafPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2776
SIDX_C_DLL void Index_Destroy(IndexH index)
Definition: sidx_api.cc:293
SIDX_C_DLL RTError Index_Contains_count(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1273
SIDX_C_DLL IndexPropertyH Index_GetProperties(IndexH index)
Definition: sidx_api.cc:2050
SIDX_C_DLL RTError Index_SegmentIntersects_count(IndexH index, double *pdStartPoint, double *pdEndPoint, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1427
SIDX_C_DLL RTError IndexProperty_SetLeafPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2743
SIDX_C_DLL RTError Index_GetLeaves(IndexH index, uint32_t *nNumLeafNodes, uint32_t **nLeafSizes, int64_t **nLeafIDs, int64_t ***nLeafChildIDs, double ***pppdMin, double ***pppdMax, uint32_t *nDimension)
Definition: sidx_api.cc:2093
SIDX_C_DLL RTError Index_TPNearestNeighbors_id(IndexH index, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:1475
SIDX_C_DLL RTError IndexProperty_SetFileNameExtensionDat(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3614
SIDX_C_DLL IndexH Index_Create(IndexPropertyH hProp)
Definition: sidx_api.cc:170
SIDX_C_DLL char * Error_GetLastErrorMethod(void)
Definition: sidx_api.cc:131
SIDX_C_DLL void * SIDX_NewBuffer(size_t length)
Definition: sidx_api.cc:3942
SIDX_C_DLL uint32_t IndexProperty_GetPointPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2956
SIDX_C_DLL char * SIDX_Version()
Definition: sidx_api.cc:4014
SIDX_C_DLL void Index_DestroyObjResults(IndexItemH *results, uint32_t nResults)
Definition: sidx_api.cc:2070
SIDX_C_DLL RTError Index_Contains_id(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, int64_t **ids, uint64_t *nResults)
Definition: sidx_api.cc:960
SIDX_DLL int64_t Index_GetResultSetOffset(IndexH index)
Definition: sidx_api.cc:2012
SIDX_C_DLL RTError Index_DeleteTPData(IndexH index, int64_t id, double *pdMin, double *pdMax, double *pdVMin, double *pdVMax, double tStart, double tEnd, uint32_t nDimension)
Definition: sidx_api.cc:310
SIDX_C_DLL void SIDX_DeleteBuffer(void *buffer)
Definition: sidx_api.cc:4008
SIDX_C_DLL RTError Index_MVRNearestNeighbors_obj(IndexH index, double *pdMin, double *pdMax, double tStart, double tEnd, uint32_t nDimension, IndexItemH **items, uint64_t *nResults)
Definition: sidx_api.cc:1775
SIDX_C_DLL double IndexProperty_GetTPRHorizon(IndexPropertyH hProp)
Definition: sidx_api.cc:3462
SIDX_C_DLL void Error_Pop(void)
Definition: sidx_api.cc:92
SIDX_C_DLL RTError Index_GetBounds(IndexH index, double **ppdMin, double **ppdMax, uint32_t *nDimension)
Definition: sidx_api.cc:1939
SIDX_C_DLL RTStorageType IndexProperty_GetIndexStorage(IndexPropertyH hProp)
Definition: sidx_api.cc:2532
SIDX_C_DLL void Index_ClearBuffer(IndexH index)
Definition: sidx_api.cc:2063
SIDX_C_DLL uint32_t Index_IsValid(IndexH index)
Definition: sidx_api.cc:2043
SIDX_C_DLL int Error_GetLastErrorNum(void)
Definition: sidx_api.cc:101
SIDX_C_DLL uint32_t IndexProperty_GetIndexPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2836
SIDX_DLL int64_t Index_GetResultSetLimit(IndexH index)
Definition: sidx_api.cc:2036
SIDX_C_DLL RTError IndexProperty_SetFileName(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3551
SIDX_C_DLL IndexH Index_CreateWithStream(IndexPropertyH hProp, int(*readNext)(SpatialIndex::id_type *id, double **pMin, double **pMax, uint32_t *nDimension, const uint8_t **pData, size_t *nDataLength))
Definition: sidx_api.cc:197
SIDX_C_DLL uint32_t IndexProperty_GetPagesize(IndexPropertyH hProp)
Definition: sidx_api.cc:2716
SIDX_C_DLL uint32_t IndexProperty_GetLeafCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2656
#define IDX_C_END
Definition: sidx_config.h:103
RTError
Definition: sidx_config.h:65
@ RT_None
Definition: sidx_config.h:66
@ RT_Failure
Definition: sidx_config.h:69
struct SpatialIndex_IData * IndexItemH
Definition: sidx_config.h:107
RTIndexVariant
Definition: sidx_config.h:90
@ RT_Quadratic
Definition: sidx_config.h:92
@ RT_Star
Definition: sidx_config.h:93
@ RT_InvalidIndexVariant
Definition: sidx_config.h:94
@ RT_Linear
Definition: sidx_config.h:91
struct Tools_PropertySet * IndexPropertyH
Definition: sidx_config.h:108
#define IDX_C_START
Definition: sidx_config.h:102
#define STRDUP
Definition: sidx_config.h:57
RTStorageType
Definition: sidx_config.h:82
@ RT_Memory
Definition: sidx_config.h:83
@ RT_Disk
Definition: sidx_config.h:84
@ RT_InvalidStorageType
Definition: sidx_config.h:86
@ RT_Custom
Definition: sidx_config.h:85
RTIndexType
Definition: sidx_config.h:74
@ RT_MVRTree
Definition: sidx_config.h:76
@ RT_InvalidIndexType
Definition: sidx_config.h:78
@ RT_TPRTree
Definition: sidx_config.h:77
@ RT_RTree
Definition: sidx_config.h:75
struct IndexS * IndexH
Definition: sidx_config.h:106
#define SIDX_C_DLL
Definition: sidx_export.h:40
#define SIDX_DLL
Definition: sidx_export.h:41