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  try {
1074  for (uint64_t i = 0; i < n; ++i)
1075  {
1076  // Extract the bounding box
1077  for (uint64_t j = 0; j < d; ++j)
1078  {
1079  tmp[j] = mins[i*d_i_stri + j*d_j_stri];
1080  tmp[j + d] = maxs[i*d_i_stri + j*d_j_stri];
1081  }
1082 
1083  // Visit
1084  SpatialIndex::Region r(tmp.get(), tmp.get() + d, d);
1085  visitor.reset();
1086  idx.intersectsWithQuery(r, visitor);
1087 
1088  uint64_t nrc = visitor.GetResultCount();
1089  if (cnts)
1090  cnts[i] = nrc;
1091 
1092  // Ensure we have enough space for the results
1093  if (k + nrc > idsz)
1094  return RT_None;
1095 
1096  *nr = i + 1;
1097  for (uint64_t idx : visitor.GetResults())
1098  ids[k++] = idx;
1099  }
1100  } catch (Tools::Exception& e)
1101  {
1103  e.what().c_str(),
1104  "Index_Intersects_id_v");
1105  return RT_Failure;
1106  } catch (std::exception const& e)
1107  {
1109  e.what(),
1110  "Index_Intersects_id_v");
1111  return RT_Failure;
1112  } catch (...) {
1114  "Unknown Error",
1115  "Index_Intersects_id_v");
1116  return RT_Failure;
1117  }
1118  return RT_None;
1119 }
1120 
1122  double* pdMin,
1123  double* pdMax,
1124  double* pdVMin,
1125  double* pdVMax,
1126  double tStart,
1127  double tEnd,
1128  uint32_t nDimension,
1129  uint64_t* nResults)
1130 {
1131  VALIDATE_POINTER1(index, "Index_TPIntersects_count", RT_Failure);
1132  Index* idx = reinterpret_cast<Index*>(index);
1134 
1135  CountVisitor* visitor = new CountVisitor;
1136  try {
1137  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1138  idx->index().intersectsWithQuery( *r,
1139  *visitor);
1140 
1141  *nResults = visitor->GetResultCount();
1142 
1143  delete r;
1144  delete visitor;
1145  } catch (Tools::Exception& e)
1146  {
1148  e.what().c_str(),
1149  "Index_TPIntersects_count");
1150  delete r;
1151  delete visitor;
1152  return RT_Failure;
1153  } catch (std::exception const& e)
1154  {
1156  e.what(),
1157  "Index_TPIntersects_count");
1158  delete r;
1159  delete visitor;
1160  return RT_Failure;
1161  } catch (...) {
1163  "Unknown Error",
1164  "Index_TPIntersects_count");
1165  delete r;
1166  delete visitor;
1167  return RT_Failure;
1168  }
1169  return RT_None;
1170 }
1171 
1173  double* pdMin,
1174  double* pdMax,
1175  double tStart,
1176  double tEnd,
1177  uint32_t nDimension,
1178  uint64_t* nResults)
1179 {
1180  VALIDATE_POINTER1(index, "Index_MVRIntersects_count", RT_Failure);
1181  Index* idx = reinterpret_cast<Index*>(index);
1182  SpatialIndex::TimeRegion* r = 0;
1183 
1184  CountVisitor* visitor = new CountVisitor;
1185  try {
1186  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1187  idx->index().intersectsWithQuery( *r,
1188  *visitor);
1189 
1190  *nResults = visitor->GetResultCount();
1191 
1192  delete r;
1193  delete visitor;
1194 
1195  } catch (Tools::Exception& e)
1196  {
1198  e.what().c_str(),
1199  "Index_MVRIntersects_count");
1200  delete r;
1201  delete visitor;
1202  return RT_Failure;
1203  } catch (std::exception const& e)
1204  {
1206  e.what(),
1207  "Index_MVRIntersects_count");
1208  delete r;
1209  delete visitor;
1210  return RT_Failure;
1211  } catch (...) {
1213  "Unknown Error",
1214  "Index_MVRIntersects_count");
1215  delete r;
1216  delete visitor;
1217  return RT_Failure;
1218  }
1219  return RT_None;
1220 }
1221 
1223  double* pdMin,
1224  double* pdMax,
1225  uint32_t nDimension,
1226  uint64_t* nResults)
1227 {
1228  VALIDATE_POINTER1(index, "Index_Intersects_count", RT_Failure);
1229  Index* idx = reinterpret_cast<Index*>(index);
1230  SpatialIndex::Region* r = 0;
1231 
1232  CountVisitor* visitor = new CountVisitor;
1233  try {
1234  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1235  idx->index().intersectsWithQuery( *r,
1236  *visitor);
1237 
1238  *nResults = visitor->GetResultCount();
1239 
1240  delete r;
1241  delete visitor;
1242 
1243  } catch (Tools::Exception& e)
1244  {
1246  e.what().c_str(),
1247  "Index_Intersects_count");
1248  delete r;
1249  delete visitor;
1250  return RT_Failure;
1251  } catch (std::exception const& e)
1252  {
1254  e.what(),
1255  "Index_Intersects_count");
1256  delete r;
1257  delete visitor;
1258  return RT_Failure;
1259  } catch (...) {
1261  "Unknown Error",
1262  "Index_Intersects_count");
1263  delete r;
1264  delete visitor;
1265  return RT_Failure;
1266  }
1267  return RT_None;
1268 }
1269 
1271  double* pdMin,
1272  double* pdMax,
1273  uint32_t nDimension,
1274  uint64_t* nResults)
1275 {
1276  VALIDATE_POINTER1(index, "Index_Contains_count", RT_Failure);
1277  Index* idx = reinterpret_cast<Index*>(index);
1278  SpatialIndex::Region* r = 0;
1279 
1280  CountVisitor* visitor = new CountVisitor;
1281  try {
1282  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1283  idx->index().containsWhatQuery(*r, *visitor);
1284 
1285  *nResults = visitor->GetResultCount();
1286 
1287  delete r;
1288  delete visitor;
1289 
1290  } catch (Tools::Exception& e)
1291  {
1293  e.what().c_str(),
1294  "Index_Contains_count");
1295  delete r;
1296  delete visitor;
1297  return RT_Failure;
1298  } catch (std::exception const& e)
1299  {
1301  e.what(),
1302  "Index_Contains_count");
1303  delete r;
1304  delete visitor;
1305  return RT_Failure;
1306  } catch (...) {
1308  "Unknown Error",
1309  "Index_Contains_count");
1310  delete r;
1311  delete visitor;
1312  return RT_Failure;
1313  }
1314  return RT_None;
1315 }
1316 
1318  double* pdStartPoint,
1319  double* pdEndPoint,
1320  uint32_t nDimension,
1321  IndexItemH** items,
1322  uint64_t* nResults)
1323 {
1324  VALIDATE_POINTER1(index, "Index_Intersects_obj", RT_Failure);
1325  Index* idx = reinterpret_cast<Index*>(index);
1326 
1327  int64_t nResultLimit, nStart;
1329 
1330  nResultLimit = idx->GetResultSetLimit();
1331  nStart = idx->GetResultSetOffset();
1332 
1333  ObjVisitor* visitor = new ObjVisitor;
1334  try {
1335  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1336  idx->index().intersectsWithQuery( *l,
1337  *visitor);
1338 
1339  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1340 
1341  delete l;
1342  delete visitor;
1343 
1344  } catch (Tools::Exception& e)
1345  {
1347  e.what().c_str(),
1348  "Index_Intersects_obj");
1349  delete l;
1350  delete visitor;
1351  return RT_Failure;
1352  } catch (std::exception const& e)
1353  {
1355  e.what(),
1356  "Index_Intersects_obj");
1357  delete l;
1358  delete visitor;
1359  return RT_Failure;
1360  } catch (...) {
1362  "Unknown Error",
1363  "Index_Intersects_obj");
1364  delete l;
1365  delete visitor;
1366  return RT_Failure;
1367  }
1368  return RT_None;
1369 }
1370 
1372  double* pdStartPoint,
1373  double* pdEndPoint,
1374  uint32_t nDimension,
1375  int64_t** ids,
1376  uint64_t* nResults)
1377 {
1378  VALIDATE_POINTER1(index, "Index_Intersects_id", RT_Failure);
1379  Index* idx = reinterpret_cast<Index*>(index);
1380  int64_t nResultLimit, nStart;
1382 
1383  nResultLimit = idx->GetResultSetLimit();
1384  nStart = idx->GetResultSetOffset();
1385 
1386  IdVisitor* visitor = new IdVisitor;
1387  try {
1388  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1389  idx->index().intersectsWithQuery( *l,
1390  *visitor);
1391 
1392  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1393 
1394  delete l;
1395  delete visitor;
1396 
1397  } catch (Tools::Exception& e)
1398  {
1400  e.what().c_str(),
1401  "Index_Intersects_id");
1402  delete l;
1403  delete visitor;
1404  return RT_Failure;
1405  } catch (std::exception const& e)
1406  {
1408  e.what(),
1409  "Index_Intersects_id");
1410  delete l;
1411  delete visitor;
1412  return RT_Failure;
1413  } catch (...) {
1415  "Unknown Error",
1416  "Index_Intersects_id");
1417  delete l;
1418  delete visitor;
1419  return RT_Failure;
1420  }
1421  return RT_None;
1422 }
1423 
1425  double* pdStartPoint,
1426  double* pdEndPoint,
1427  uint32_t nDimension,
1428  uint64_t* nResults)
1429 {
1430  VALIDATE_POINTER1(index, "Index_Intersects_count", RT_Failure);
1431  Index* idx = reinterpret_cast<Index*>(index);
1433 
1434  CountVisitor* visitor = new CountVisitor;
1435  try {
1436  l = new SpatialIndex::LineSegment(pdStartPoint, pdEndPoint, nDimension);
1437  idx->index().intersectsWithQuery( *l,
1438  *visitor);
1439 
1440  *nResults = visitor->GetResultCount();
1441 
1442  delete l;
1443  delete visitor;
1444 
1445  } catch (Tools::Exception& e)
1446  {
1448  e.what().c_str(),
1449  "Index_Intersects_count");
1450  delete l;
1451  delete visitor;
1452  return RT_Failure;
1453  } catch (std::exception const& e)
1454  {
1456  e.what(),
1457  "Index_Intersects_count");
1458  delete l;
1459  delete visitor;
1460  return RT_Failure;
1461  } catch (...) {
1463  "Unknown Error",
1464  "Index_Intersects_count");
1465  delete l;
1466  delete visitor;
1467  return RT_Failure;
1468  }
1469  return RT_None;
1470 }
1471 
1473  double* pdMin,
1474  double* pdMax,
1475  double* pdVMin,
1476  double* pdVMax,
1477  double tStart,
1478  double tEnd,
1479  uint32_t nDimension,
1480  int64_t** ids,
1481  uint64_t* nResults)
1482 {
1483  VALIDATE_POINTER1(index, "Index_TPNearestNeighbors_id", RT_Failure);
1484  Index* idx = reinterpret_cast<Index*>(index);
1485  int64_t nResultLimit, nStart;
1487 
1488  nResultLimit = idx->GetResultSetLimit();
1489  nStart = idx->GetResultSetOffset();
1490 
1491  IdVisitor* visitor = new IdVisitor;
1492 
1493  try {
1494  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1495  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1496  *r,
1497  *visitor);
1498 
1499  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1500 
1501  delete r;
1502  delete visitor;
1503 
1504  } catch (Tools::Exception& e)
1505  {
1507  e.what().c_str(),
1508  "Index_TPNearestNeighbors_id");
1509  delete r;
1510  delete visitor;
1511  return RT_Failure;
1512  } catch (std::exception const& e)
1513  {
1515  e.what(),
1516  "Index_TPNearestNeighbors_id");
1517  delete r;
1518  delete visitor;
1519  return RT_Failure;
1520  } catch (...) {
1522  "Unknown Error",
1523  "Index_TPNearestNeighbors_id");
1524  delete r;
1525  delete visitor;
1526  return RT_Failure;
1527  }
1528  return RT_None;
1529 }
1530 
1532  double* pdMin,
1533  double* pdMax,
1534  double tStart,
1535  double tEnd,
1536  uint32_t nDimension,
1537  int64_t** ids,
1538  uint64_t* nResults)
1539 {
1540  VALIDATE_POINTER1(index, "Index_MVRNearestNeighbors_id", RT_Failure);
1541  Index* idx = reinterpret_cast<Index*>(index);
1542  int64_t nResultLimit, nStart;
1543  SpatialIndex::TimeRegion* r = 0;
1544 
1545  nResultLimit = idx->GetResultSetLimit();
1546  nStart = idx->GetResultSetOffset();
1547 
1548  IdVisitor* visitor = new IdVisitor;
1549 
1550  try {
1551  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1552  idx->index().nearestNeighborQuery((uint32_t) *nResults,
1553  *r,
1554  *visitor);
1555 
1556  Page_ResultSet_Ids(*visitor, ids, nStart, nResultLimit, nResults);
1557 
1558  delete r;
1559  delete visitor;
1560 
1561  } catch (Tools::Exception& e)
1562  {
1564  e.what().c_str(),
1565  "Index_MVRNearestNeighbors_id");
1566  delete r;
1567  delete visitor;
1568  return RT_Failure;
1569  } catch (std::exception const& e)
1570  {
1572  e.what(),
1573  "Index_MVRNearestNeighbors_id");
1574  delete r;
1575  delete visitor;
1576  return RT_Failure;
1577  } catch (...) {
1579  "Unknown Error",
1580  "Index_MVRNearestNeighbors_id");
1581  delete r;
1582  delete visitor;
1583  return RT_Failure;
1584  }
1585  return RT_None;
1586 }
1587 
1589  double* pdMin,
1590  double* pdMax,
1591  uint32_t nDimension,
1592  int64_t** ids,
1593  uint64_t* nResults)
1594 {
1595  VALIDATE_POINTER1(index, "Index_NearestNeighbors_id", RT_Failure);
1596  Index* idx = reinterpret_cast<Index*>(index);
1597  int64_t nResultLimit, nStart;
1598 
1599  nResultLimit = idx->GetResultSetLimit();
1600  nStart = idx->GetResultSetOffset();
1601 
1602  IdVisitor visitor;
1603 
1604  try {
1605  SpatialIndex::Region r(pdMin, pdMax, nDimension);
1606 
1607  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1608  r,
1609  visitor);
1610 
1611  Page_ResultSet_Ids(visitor, ids, nStart, nResultLimit, nResults);
1612  } catch (Tools::Exception& e)
1613  {
1615  e.what().c_str(),
1616  "Index_NearestNeighbors_id");
1617  return RT_Failure;
1618  } catch (std::exception const& e)
1619  {
1621  e.what(),
1622  "Index_NearestNeighbors_id");
1623  return RT_Failure;
1624  } catch (...) {
1626  "Unknown Error",
1627  "Index_NearestNeighbors_id");
1628  return RT_Failure;
1629  }
1630  return RT_None;
1631 }
1632 
1634  int64_t knn,
1635  int64_t n,
1636  uint32_t d,
1637  uint64_t idsz,
1638  uint64_t d_i_stri,
1639  uint64_t d_j_stri,
1640  const double* mins,
1641  const double* maxs,
1642  int64_t* ids,
1643  uint64_t* cnts,
1644  double* dists,
1645  int64_t* nr)
1646 {
1647  VALIDATE_POINTER1(index, "Index_NearestNeighbors_id_v", RT_Failure);
1648  auto& idx = reinterpret_cast<Index*>(index)->index();
1649  IdVisitor visitor;
1650  std::unique_ptr<double[]> tmp = std::unique_ptr<double[]>(new double[2*d]);
1651  uint64_t k = 0;
1652 
1653  try {
1654  for (uint64_t i = 0; i < n; ++i)
1655  {
1656  double max_dist = dists ? dists[i] : 0.0;
1657 
1658  // Extract the bounding box
1659  for (uint64_t j = 0; j < d; ++j)
1660  {
1661  tmp[j] = mins[i*d_i_stri + j*d_j_stri];
1662  tmp[j + d] = maxs[i*d_i_stri + j*d_j_stri];
1663  }
1664 
1665  // Visit
1666  SpatialIndex::Region r(tmp.get(), tmp.get() + d, d);
1667  visitor.reset();
1668  max_dist = idx.nearestNeighborQuery(static_cast<uint32_t>(abs(knn)), r, visitor, max_dist);
1669 
1670  uint64_t nrc = visitor.GetResultCount();
1671  if (knn < 0)
1672  nrc = std::min<uint64_t>(nrc, -knn);
1673 
1674  if (cnts)
1675  cnts[i] = nrc;
1676  if (dists)
1677  dists[i] = max_dist;
1678 
1679  // Ensure we have enough space for the results
1680  if (k + nrc > idsz)
1681  return RT_None;
1682 
1683  *nr = i + 1;
1684  auto& res = visitor.GetResults();
1685  for (uint64_t l = 0; l < nrc; ++l)
1686  ids[k++] = res[l];
1687 
1688  }
1689  } catch (Tools::Exception& e)
1690  {
1692  e.what().c_str(),
1693  "Index_NearestNeighbors_id_v");
1694  return RT_Failure;
1695  } catch (std::exception const& e)
1696  {
1698  e.what(),
1699  "Index_NearestNeighbors_id_v");
1700  return RT_Failure;
1701  } catch (...) {
1703  "Unknown Error",
1704  "Index_NearestNeighbors_id_v");
1705  return RT_Failure;
1706  }
1707  return RT_None;
1708 }
1709 
1711  double* pdMin,
1712  double* pdMax,
1713  double* pdVMin,
1714  double* pdVMax,
1715  double tStart,
1716  double tEnd,
1717  uint32_t nDimension,
1718  IndexItemH** items,
1719  uint64_t* nResults)
1720 {
1721  VALIDATE_POINTER1(index, "Index_TPNearestNeighbors_obj", RT_Failure);
1722  Index* idx = reinterpret_cast<Index*>(index);
1723 
1724  int64_t nResultLimit, nStart;
1726 
1727  nResultLimit = idx->GetResultSetLimit();
1728  nStart = idx->GetResultSetOffset();
1729 
1730  ObjVisitor* visitor = new ObjVisitor;
1731  try {
1732  r = new SpatialIndex::MovingRegion(pdMin, pdMax, pdVMin, pdVMax, tStart, tEnd, nDimension);
1733 
1734  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1735  *r,
1736  *visitor);
1737 
1738  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1739 
1740  delete r;
1741  delete visitor;
1742 
1743  } catch (Tools::Exception& e)
1744  {
1746  e.what().c_str(),
1747  "Index_TPNearestNeighbors_obj");
1748  delete r;
1749  delete visitor;
1750  return RT_Failure;
1751  } catch (std::exception const& e)
1752  {
1754  e.what(),
1755  "Index_TPNearestNeighbors_obj");
1756  delete r;
1757  delete visitor;
1758  return RT_Failure;
1759  } catch (...) {
1761  "Unknown Error",
1762  "Index_NearestNeighbors_obj");
1763  delete visitor;
1764  return RT_Failure;
1765  }
1766  return RT_None;
1767 }
1768 
1770  double* pdMin,
1771  double* pdMax,
1772  double tStart,
1773  double tEnd,
1774  uint32_t nDimension,
1775  IndexItemH** items,
1776  uint64_t* nResults)
1777 {
1778  VALIDATE_POINTER1(index, "Index_MVRNearestNeighbors_obj", RT_Failure);
1779  Index* idx = reinterpret_cast<Index*>(index);
1780 
1781  int64_t nResultLimit, nStart;
1782  SpatialIndex::TimeRegion* r = 0;
1783 
1784  nResultLimit = idx->GetResultSetLimit();
1785  nStart = idx->GetResultSetOffset();
1786 
1787  ObjVisitor* visitor = new ObjVisitor;
1788  try {
1789  r = new SpatialIndex::TimeRegion(pdMin, pdMax, tStart, tEnd, nDimension);
1790 
1791  idx->index().nearestNeighborQuery( (uint32_t)*nResults,
1792  *r,
1793  *visitor);
1794 
1795  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1796 
1797  delete r;
1798  delete visitor;
1799 
1800  } catch (Tools::Exception& e)
1801  {
1803  e.what().c_str(),
1804  "Index_MVRNearestNeighbors_obj");
1805  delete r;
1806  delete visitor;
1807  return RT_Failure;
1808  } catch (std::exception const& e)
1809  {
1811  e.what(),
1812  "Index_MVRNearestNeighbors_obj");
1813  delete r;
1814  delete visitor;
1815  return RT_Failure;
1816  } catch (...) {
1818  "Unknown Error",
1819  "Index_NearestNeighbors_obj");
1820  delete r;
1821  delete visitor;
1822  return RT_Failure;
1823  }
1824  return RT_None;
1825 }
1826 
1828  double* pdMin,
1829  double* pdMax,
1830  uint32_t nDimension,
1831  IndexItemH** items,
1832  uint64_t* nResults)
1833 {
1834  VALIDATE_POINTER1(index, "Index_NearestNeighbors_obj", RT_Failure);
1835  Index* idx = reinterpret_cast<Index*>(index);
1836 
1837  int64_t nResultLimit, nStart;
1838  SpatialIndex::Region* r = 0;
1839 
1840  nResultLimit = idx->GetResultSetLimit();
1841  nStart = idx->GetResultSetOffset();
1842 
1843  ObjVisitor* visitor = new ObjVisitor;
1844  try {
1845  r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1846 
1847  idx->index().nearestNeighborQuery( static_cast<uint32_t>(*nResults),
1848  *r,
1849  *visitor);
1850 
1851  Page_ResultSet_Obj(*visitor, items, nStart, nResultLimit, nResults);
1852 
1853  delete r;
1854  delete visitor;
1855 
1856  } catch (Tools::Exception& e)
1857  {
1859  e.what().c_str(),
1860  "Index_NearestNeighbors_obj");
1861  delete r;
1862  delete visitor;
1863  return RT_Failure;
1864  } catch (std::exception const& e)
1865  {
1867  e.what(),
1868  "Index_NearestNeighbors_obj");
1869  delete r;
1870  delete visitor;
1871  return RT_Failure;
1872  } catch (...) {
1874  "Unknown Error",
1875  "Index_NearestNeighbors_obj");
1876  delete r;
1877  delete visitor;
1878  return RT_Failure;
1879  }
1880  return RT_None;
1881 }
1882 
1884  double* pdMin,
1885  double* pdMax,
1886  uint32_t nDimension,
1887  IndexItemH** ids,
1888  uint64_t* nResults)
1889 {
1890  VALIDATE_POINTER1(index, "Index_Intersects_internal", RT_Failure);
1891  Index* idx = reinterpret_cast<Index*>(index);
1892 
1893  int64_t nResultLimit, nStart;
1894 
1895  nResultLimit = idx->GetResultSetLimit();
1896  nStart = idx->GetResultSetOffset();
1897 
1898  ObjVisitor* visitor = new ObjVisitor;
1899  try {
1900  SpatialIndex::Region* r = new SpatialIndex::Region(pdMin, pdMax, nDimension);
1901  idx->index().internalNodesQuery( *r,
1902  *visitor);
1903 
1904  Page_ResultSet_Obj(*visitor, ids, nStart, nResultLimit, nResults);
1905 
1906  delete r;
1907  delete visitor;
1908 
1909  } catch (Tools::Exception& e)
1910  {
1912  e.what().c_str(),
1913  "Index_Intersects_internal");
1914  delete visitor;
1915  return RT_Failure;
1916  } catch (std::exception const& e)
1917  {
1919  e.what(),
1920  "Index_Intersects_internal");
1921  delete visitor;
1922  return RT_Failure;
1923  } catch (...) {
1925  "Unknown Error",
1926  "Index_Intersects_internal");
1927  delete visitor;
1928  return RT_Failure;
1929  }
1930  return RT_None;
1931 }
1932 
1934  double** ppdMin,
1935  double** ppdMax,
1936  uint32_t* nDimension)
1937 {
1938  VALIDATE_POINTER1(index, "Index_GetBounds", RT_Failure);
1939  Index* idx = reinterpret_cast<Index*>(index);
1940 
1941  BoundsQuery* query = new BoundsQuery;
1942 
1943  try {
1944  idx->index().queryStrategy( *query);
1945 
1946  const SpatialIndex::Region* bounds = query->GetBounds();
1947  if (bounds == 0) {
1948  *nDimension = 0;
1949  delete query;
1950  return RT_None;
1951  }
1952 
1953  *nDimension =bounds->getDimension();
1954 
1955  *ppdMin = (double*) malloc (*nDimension * sizeof(double));
1956  *ppdMax = (double*) malloc (*nDimension * sizeof(double));
1957 
1958  for (uint32_t i=0; i< *nDimension; ++i) {
1959  (*ppdMin)[i] = bounds->getLow(i);
1960  (*ppdMax)[i] = bounds->getHigh(i);
1961  }
1962 
1963  delete query;
1964 
1965  } catch (Tools::Exception& e)
1966  {
1968  e.what().c_str(),
1969  "Index_GetBounds");
1970  delete query;
1971  return RT_Failure;
1972  } catch (std::exception const& e)
1973  {
1975  e.what(),
1976  "Index_GetBounds");
1977  delete query;
1978  return RT_Failure;
1979  } catch (...) {
1981  "Unknown Error",
1982  "Index_GetBounds");
1983  delete query;
1984  return RT_Failure;
1985  }
1986  return RT_None;
1987 }
1988 
1990 {
1991  try
1992  {
1993  VALIDATE_POINTER1(index, "Index_SetResultSetOffset", RT_Failure);
1994  Index* idx = reinterpret_cast<Index*>(index);
1995  idx->SetResultSetOffset(value);
1996  }
1997  catch (...) {
1999  "Unknown Error",
2000  "Index_SetResultSetOffset");
2001  return RT_Failure;
2002  }
2003  return RT_None;
2004 }
2005 
2007 {
2008  VALIDATE_POINTER1(index, "Index_GetResultSetOffset", 0);
2009  Index* idx = reinterpret_cast<Index*>(index);
2010  return idx->GetResultSetOffset();
2011 }
2012 
2014 {
2015  try
2016  {
2017  VALIDATE_POINTER1(index, "Index_SetResultSetLimit", RT_Failure);
2018  Index* idx = reinterpret_cast<Index*>(index);
2019  idx->SetResultSetLimit(value);
2020  }
2021  catch (...) {
2023  "Unknown Error",
2024  "Index_SetResultSetLimit");
2025  return RT_Failure;
2026  }
2027  return RT_None;
2028 }
2029 
2031 {
2032  VALIDATE_POINTER1(index, "Index_GetResultSetLimit", 0);
2033  Index* idx = reinterpret_cast<Index*>(index);
2034  return idx->GetResultSetLimit();
2035 }
2036 
2038 {
2039  VALIDATE_POINTER1(index, "Index_IsValid", 0);
2040  Index* idx = reinterpret_cast<Index*>(index);
2041  return static_cast<uint32_t>(idx->index().isIndexValid());
2042 }
2043 
2045 {
2046  VALIDATE_POINTER1(index, "Index_GetProperties", 0);
2047  Index* idx = reinterpret_cast<Index*>(index);
2049  *ps = idx->GetProperties();
2050 
2051  Tools::PropertySet base_props;
2052  idx->index().getIndexProperties(base_props);
2053  ps->setProperty("IndexIdentifier", base_props.getProperty("IndexIdentifier"));
2054  return (IndexPropertyH)ps;
2055 }
2056 
2058 {
2059  VALIDATE_POINTER0(index, "Index_ClearBuffer");
2060  Index* idx = reinterpret_cast<Index*>(index);
2061  idx->buffer().clear();
2062 }
2063 
2064 SIDX_C_DLL void Index_DestroyObjResults(IndexItemH* results, uint32_t nResults)
2065 {
2066  VALIDATE_POINTER0(results, "Index_DestroyObjResults");
2067  SpatialIndex::IData* it;
2068  for (uint32_t i=0; i< nResults; ++i) {
2069  if (results[i] != NULL) {
2070  it = reinterpret_cast<SpatialIndex::IData*>(results[i]);
2071  if (it != 0)
2072  delete it;
2073  }
2074  }
2075 
2076  std::free(results);
2077 }
2078 
2079 
2080 SIDX_C_DLL void Index_Free(void* results)
2081 {
2082  VALIDATE_POINTER0(results, "Index_Free");
2083  if (results != 0)
2084  std::free(results);
2085 }
2086 
2088  uint32_t* nNumLeafNodes,
2089  uint32_t** nLeafSizes,
2090  int64_t** nLeafIDs,
2091  int64_t*** nLeafChildIDs,
2092  double*** pppdMin,
2093  double*** pppdMax,
2094  uint32_t* nDimension)
2095 {
2096  VALIDATE_POINTER1(index, "Index_GetLeaves", RT_Failure);
2097  Index* idx = reinterpret_cast<Index*>(index);
2098 
2099  std::vector<LeafQueryResult>::const_iterator i;
2100  LeafQuery* query = 0;
2101 
2102  // Fetch the dimensionality of the index
2103  Tools::PropertySet ps;
2104  idx->index().getIndexProperties(ps);
2105 
2106  Tools::Variant var;
2107  var = ps.getProperty("Dimension");
2108 
2109  if (var.m_varType != Tools::VT_EMPTY)
2110  {
2111  if (var.m_varType != Tools::VT_ULONG) {
2113  "Property Dimension must be Tools::VT_ULONG",
2114  "Index_GetLeaves");
2115  return RT_Failure;
2116  }
2117  }
2118 
2119  *nDimension = var.m_val.ulVal;
2120 
2121  try {
2122  query = new LeafQuery;
2123  idx->index().queryStrategy( *query);
2124 
2125  const std::vector<LeafQueryResult>& results = query->GetResults();
2126 
2127  *nNumLeafNodes = (uint32_t)results.size();
2128 
2129  *nLeafSizes = (uint32_t*) malloc (*nNumLeafNodes * sizeof(uint32_t));
2130  *nLeafIDs = (int64_t*) malloc (*nNumLeafNodes * sizeof(int64_t));
2131 
2132  *nLeafChildIDs = (int64_t**) malloc(*nNumLeafNodes * sizeof(int64_t*));
2133  *pppdMin = (double**) malloc (*nNumLeafNodes * sizeof(double*));
2134  *pppdMax = (double**) malloc (*nNumLeafNodes * sizeof(double*));
2135 
2136  uint32_t k=0;
2137  for (i = results.begin(); i != results.end(); ++i)
2138  {
2139  std::vector<SpatialIndex::id_type> const& ids = (*i).GetIDs();
2140  const SpatialIndex::Region* b = (*i).GetBounds();
2141 
2142  (*nLeafIDs)[k] = (*i).getIdentifier();
2143  (*nLeafSizes)[k] = (uint32_t)ids.size();
2144 
2145  (*nLeafChildIDs)[k] = (int64_t*) malloc( (*nLeafSizes)[k] * sizeof(int64_t));
2146  (*pppdMin)[k] = (double*) malloc (*nDimension * sizeof(double));
2147  (*pppdMax)[k] = (double*) malloc (*nDimension * sizeof(double));
2148  for (uint32_t c=0; c< *nDimension; ++c) {
2149  (*pppdMin)[k][c] = b->getLow(c);
2150  (*pppdMax)[k][c] = b->getHigh(c);
2151  }
2152  for (uint32_t cChild = 0; cChild < ids.size(); cChild++)
2153  {
2154  (*nLeafChildIDs)[k][cChild] = ids[cChild];
2155  }
2156  ++k;
2157  }
2158 
2159 
2160  delete query;
2161 
2162  } catch (Tools::Exception& e)
2163  {
2165  e.what().c_str(),
2166  "Index_GetLeaves");
2167  delete query;
2168  return RT_Failure;
2169  } catch (std::exception const& e)
2170  {
2172  e.what(),
2173  "Index_GetLeaves");
2174  delete query;
2175  return RT_Failure;
2176  } catch (...) {
2178  "Unknown Error",
2179  "Index_GetLeaves");
2180  delete query;
2181  return RT_Failure;
2182  }
2183  return RT_None;
2184 }
2185 
2186 
2188 {
2189  VALIDATE_POINTER0(item, "IndexItem_Destroy");
2190  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2191  if (it != 0) delete it;
2192 }
2193 
2195  uint8_t** data,
2196  uint64_t* length)
2197 {
2198  VALIDATE_POINTER1(item, "IndexItem_GetData", RT_Failure);
2199  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2200  uint8_t* p_data;
2201  uint32_t* l= new uint32_t;
2202 
2203  it->getData(*l,&p_data);
2204  *length = (uint64_t)*l;
2205  *data = (uint8_t*) malloc (*length * sizeof(uint8_t));
2206 
2207  memcpy(*data, p_data, *length);
2208  delete[] p_data;
2209  delete l;
2210  return RT_None;
2211 
2212 }
2213 
2215 {
2216  VALIDATE_POINTER1(item, "IndexItem_GetID",0);
2217  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2218  int64_t value = it->getIdentifier();
2219  return value;
2220 }
2221 
2223  double** ppdMin,
2224  double** ppdMax,
2225  uint32_t* nDimension)
2226 {
2227  VALIDATE_POINTER1(item, "IndexItem_GetBounds", RT_Failure);
2228  SpatialIndex::IData* it = reinterpret_cast<SpatialIndex::IData*>(item);
2229 
2231  it->getShape(&s);
2232 
2234  s->getMBR(*bounds);
2235 
2236  if (bounds == 0) {
2237  *nDimension = 0;
2238  delete bounds;
2239  delete s;
2240  return RT_None;
2241  }
2242  *nDimension = bounds->getDimension();
2243 
2244  *ppdMin = (double*) malloc (*nDimension * sizeof(double));
2245  *ppdMax = (double*) malloc (*nDimension * sizeof(double));
2246 
2247  if (ppdMin == NULL || ppdMax == NULL) {
2249  "Unable to allocation bounds array(s)",
2250  "IndexItem_GetBounds");
2251  delete bounds;
2252  delete s;
2253  return RT_Failure;
2254  }
2255 
2256  for (uint32_t i=0; i< *nDimension; ++i) {
2257  (*ppdMin)[i] = bounds->getLow(i);
2258  (*ppdMax)[i] = bounds->getHigh(i);
2259  }
2260  delete bounds;
2261  delete s;
2262  return RT_None;
2263 }
2265 {
2267  Tools::Variant var;
2268  return (IndexPropertyH)ps;
2269 }
2270 
2272 {
2273  VALIDATE_POINTER0(hProp, "IndexProperty_Destroy");
2274  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2275  if (prop != 0) delete prop;
2276 }
2277 
2279  RTIndexType value)
2280 {
2281  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexType", RT_Failure);
2282  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2283 
2284  try
2285  {
2286  if (!(value == RT_RTree || value == RT_MVRTree || value == RT_TPRTree)) {
2287  throw std::runtime_error("Inputted value is not a valid index type");
2288  }
2289  Tools::Variant var;
2290  var.m_varType = Tools::VT_ULONG;
2291  var.m_val.ulVal = value;
2292  prop->setProperty("IndexType", var);
2293 
2294 
2295  } catch (Tools::Exception& e)
2296  {
2298  e.what().c_str(),
2299  "IndexProperty_SetIndexType");
2300  return RT_Failure;
2301  } catch (std::exception const& e)
2302  {
2304  e.what(),
2305  "IndexProperty_SetIndexType");
2306  return RT_Failure;
2307  } catch (...) {
2309  "Unknown Error",
2310  "IndexProperty_SetIndexType");
2311  return RT_Failure;
2312  }
2313  return RT_None;
2314 }
2315 
2317 {
2318  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexType", RT_InvalidIndexType);
2319  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2320 
2321  Tools::Variant var;
2322  var = prop->getProperty("IndexType");
2323 
2324  if (var.m_varType != Tools::VT_EMPTY)
2325  {
2326  if (var.m_varType != Tools::VT_ULONG) {
2328  "Property IndexType must be Tools::VT_ULONG",
2329  "IndexProperty_GetIndexType");
2330  return RT_InvalidIndexType;
2331  }
2332  return (RTIndexType) var.m_val.ulVal;
2333  }
2334 
2336  "Property IndexType was empty",
2337  "IndexProperty_GetIndexType");
2338  return RT_InvalidIndexType;
2339 
2340 }
2341 
2343 {
2344  VALIDATE_POINTER1(hProp, "IndexProperty_SetDimension", RT_Failure);
2345  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2346 
2347  try
2348  {
2349  Tools::Variant var;
2350  var.m_varType = Tools::VT_ULONG;
2351  var.m_val.ulVal = value;
2352  prop->setProperty("Dimension", var);
2353  } catch (Tools::Exception& e)
2354  {
2356  e.what().c_str(),
2357  "IndexProperty_SetDimension");
2358  return RT_Failure;
2359  } catch (std::exception const& e)
2360  {
2362  e.what(),
2363  "IndexProperty_SetDimension");
2364  return RT_Failure;
2365  } catch (...) {
2367  "Unknown Error",
2368  "IndexProperty_SetDimension");
2369  return RT_Failure;
2370  }
2371  return RT_None;
2372 }
2373 
2375 {
2376  VALIDATE_POINTER1(hProp, "IndexProperty_GetDimension", 0);
2377  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2378 
2379  Tools::Variant var;
2380  var = prop->getProperty("Dimension");
2381 
2382  if (var.m_varType != Tools::VT_EMPTY)
2383  {
2384  if (var.m_varType != Tools::VT_ULONG) {
2386  "Property IndexType must be Tools::VT_ULONG",
2387  "IndexProperty_GetDimension");
2388  return 0;
2389  }
2390 
2391  return var.m_val.ulVal;
2392  }
2393 
2394  // A zero dimension index is invalid.
2396  "Property Dimension was empty",
2397  "IndexProperty_GetDimension");
2398  return 0;
2399 }
2400 
2402  RTIndexVariant value)
2403 {
2404  using namespace SpatialIndex;
2405 
2406  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexVariant", RT_Failure);
2407  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2408 
2409  Tools::Variant var;
2410 
2411  try
2412  {
2413 
2414  if (!(value == RT_Linear || value == RT_Quadratic || value == RT_Star)) {
2415  throw std::runtime_error("Inputted value is not a valid index variant");
2416  }
2417 
2418  var.m_varType = Tools::VT_LONG;
2420  if (type == RT_InvalidIndexType ) {
2422  "Index type is not properly set",
2423  "IndexProperty_SetIndexVariant");
2424  return RT_Failure;
2425  }
2426  if (type == RT_RTree) {
2427  var.m_val.lVal = static_cast<RTree::RTreeVariant>(value);
2428  prop->setProperty("TreeVariant", var);
2429  } else if (type == RT_MVRTree) {
2430  var.m_val.lVal = static_cast<MVRTree::MVRTreeVariant>(value);
2431  prop->setProperty("TreeVariant", var);
2432  } else if (type == RT_TPRTree) {
2433  var.m_val.lVal = static_cast<TPRTree::TPRTreeVariant>(value);
2434  prop->setProperty("TreeVariant", var);
2435  }
2436 
2437  } catch (Tools::Exception& e)
2438  {
2440  e.what().c_str(),
2441  "IndexProperty_SetIndexVariant");
2442  return RT_Failure;
2443  } catch (std::exception const& e)
2444  {
2446  e.what(),
2447  "IndexProperty_SetIndexCapacity");
2448  return RT_Failure;
2449  } catch (...) {
2451  "Unknown Error",
2452  "IndexProperty_SetIndexCapacity");
2453  return RT_Failure;
2454  }
2455  return RT_None;
2456 }
2457 
2459 {
2460  VALIDATE_POINTER1( hProp,
2461  "IndexProperty_GetIndexVariant",
2463 
2464  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2465 
2466  Tools::Variant var;
2467  var = prop->getProperty("TreeVariant");
2468 
2469 
2470  if (var.m_varType != Tools::VT_EMPTY)
2471  {
2472  if (var.m_varType != Tools::VT_LONG) {
2474  "Property IndexVariant must be Tools::VT_LONG",
2475  "IndexProperty_GetIndexVariant");
2476  return RT_InvalidIndexVariant;
2477  }
2478 
2479  return static_cast<RTIndexVariant>(var.m_val.lVal);
2480  }
2481 
2482  // if we didn't get anything, we're returning an error condition
2484  "Property IndexVariant was empty",
2485  "IndexProperty_GetIndexVariant");
2486  return RT_InvalidIndexVariant;
2487 
2488 }
2489 
2491  RTStorageType value)
2492 {
2493  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexStorage", RT_Failure);
2494  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2495 
2496  try
2497  {
2498  if (!(value == RT_Disk || value == RT_Memory || value == RT_Custom)) {
2499  throw std::runtime_error("Inputted value is not a valid index storage type");
2500  }
2501  Tools::Variant var;
2502  var.m_varType = Tools::VT_ULONG;
2503  var.m_val.ulVal = value;
2504  prop->setProperty("IndexStorageType", var);
2505  } catch (Tools::Exception& e)
2506  {
2508  e.what().c_str(),
2509  "IndexProperty_SetIndexStorage");
2510  return RT_Failure;
2511  } catch (std::exception const& e)
2512  {
2514  e.what(),
2515  "IndexProperty_SetIndexStorage");
2516  return RT_Failure;
2517  } catch (...) {
2519  "Unknown Error",
2520  "IndexProperty_SetIndexStorage");
2521  return RT_Failure;
2522  }
2523  return RT_None;
2524 }
2525 
2527 {
2528  VALIDATE_POINTER1( hProp,
2529  "IndexProperty_GetIndexStorage",
2531 
2532  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2533 
2534  Tools::Variant var;
2535  var = prop->getProperty("IndexStorageType");
2536 
2537  if (var.m_varType != Tools::VT_EMPTY)
2538  {
2539  if (var.m_varType != Tools::VT_ULONG) {
2541  "Property IndexStorage must be Tools::VT_ULONG",
2542  "IndexProperty_GetIndexStorage");
2543  return RT_InvalidStorageType;
2544  }
2545 
2546  return static_cast<RTStorageType>(var.m_val.ulVal);
2547  }
2548 
2549  // if we didn't get anything, we're returning an error condition
2551  "Property IndexStorage was empty",
2552  "IndexProperty_GetIndexStorage");
2553  return RT_InvalidStorageType;
2554 
2555 }
2556 
2558  uint32_t value)
2559 {
2560  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexCapacity", RT_Failure);
2561  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2562 
2563  try
2564  {
2565  Tools::Variant var;
2566  var.m_varType = Tools::VT_ULONG;
2567  var.m_val.ulVal = value;
2568  prop->setProperty("IndexCapacity", var);
2569  } catch (Tools::Exception& e)
2570  {
2572  e.what().c_str(),
2573  "IndexProperty_SetIndexCapacity");
2574  return RT_Failure;
2575  } catch (std::exception const& e)
2576  {
2578  e.what(),
2579  "IndexProperty_SetIndexCapacity");
2580  return RT_Failure;
2581  } catch (...) {
2583  "Unknown Error",
2584  "IndexProperty_SetIndexCapacity");
2585  return RT_Failure;
2586  }
2587  return RT_None;
2588 }
2589 
2591 {
2592  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexCapacity", 0);
2593  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2594 
2595  Tools::Variant var;
2596  var = prop->getProperty("IndexCapacity");
2597 
2598  if (var.m_varType != Tools::VT_EMPTY)
2599  {
2600  if (var.m_varType != Tools::VT_ULONG) {
2602  "Property IndexCapacity must be Tools::VT_ULONG",
2603  "IndexProperty_GetIndexCapacity");
2604  return 0;
2605  }
2606 
2607  return var.m_val.ulVal;
2608  }
2609 
2610  // return nothing for an error
2612  "Property IndexCapacity was empty",
2613  "IndexProperty_GetIndexCapacity");
2614  return 0;
2615 }
2616 
2618  uint32_t value)
2619 {
2620  VALIDATE_POINTER1(hProp, "IndexProperty_SetLeafCapacity", RT_Failure);
2621  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2622 
2623  try
2624  {
2625  Tools::Variant var;
2626  var.m_varType = Tools::VT_ULONG;
2627  var.m_val.ulVal = value;
2628  prop->setProperty("LeafCapacity", var);
2629  } catch (Tools::Exception& e)
2630  {
2632  e.what().c_str(),
2633  "IndexProperty_SetLeafCapacity");
2634  return RT_Failure;
2635  } catch (std::exception const& e)
2636  {
2638  e.what(),
2639  "IndexProperty_SetLeafCapacity");
2640  return RT_Failure;
2641  } catch (...) {
2643  "Unknown Error",
2644  "IndexProperty_SetLeafCapacity");
2645  return RT_Failure;
2646  }
2647  return RT_None;
2648 }
2649 
2651 {
2652  VALIDATE_POINTER1(hProp, "IndexProperty_GetLeafCapacity", 0);
2653  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2654 
2655  Tools::Variant var;
2656  var = prop->getProperty("LeafCapacity");
2657 
2658  if (var.m_varType != Tools::VT_EMPTY)
2659  {
2660  if (var.m_varType != Tools::VT_ULONG) {
2662  "Property LeafCapacity must be Tools::VT_ULONG",
2663  "IndexProperty_GetLeafCapacity");
2664  return 0;
2665  }
2666 
2667  return var.m_val.ulVal;
2668  }
2669 
2670  // return nothing for an error
2672  "Property LeafCapacity was empty",
2673  "IndexProperty_GetLeafCapacity");
2674  return 0;
2675 }
2676 
2678  uint32_t value)
2679 {
2680  VALIDATE_POINTER1(hProp, "IndexProperty_SetPagesize", RT_Failure);
2681  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2682 
2683  try
2684  {
2685  Tools::Variant var;
2686  var.m_varType = Tools::VT_ULONG;
2687  var.m_val.ulVal = value;
2688  prop->setProperty("PageSize", var);
2689  } catch (Tools::Exception& e)
2690  {
2692  e.what().c_str(),
2693  "IndexProperty_SetPagesize");
2694  return RT_Failure;
2695  } catch (std::exception const& e)
2696  {
2698  e.what(),
2699  "IndexProperty_SetPagesize");
2700  return RT_Failure;
2701  } catch (...) {
2703  "Unknown Error",
2704  "IndexProperty_SetPagesize");
2705  return RT_Failure;
2706  }
2707  return RT_None;
2708 }
2709 
2711 {
2712  VALIDATE_POINTER1(hProp, "IndexProperty_GetPagesize", 0);
2713  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2714 
2715  Tools::Variant var;
2716  var = prop->getProperty("PageSize");
2717 
2718  if (var.m_varType != Tools::VT_EMPTY)
2719  {
2720  if (var.m_varType != Tools::VT_ULONG) {
2722  "Property PageSize must be Tools::VT_ULONG",
2723  "IndexProperty_GetPagesize");
2724  return 0;
2725  }
2726 
2727  return var.m_val.ulVal;
2728  }
2729 
2730  // return nothing for an error
2732  "Property PageSize was empty",
2733  "IndexProperty_GetPagesize");
2734  return 0;
2735 }
2736 
2738  uint32_t value)
2739 {
2740  VALIDATE_POINTER1(hProp, "IndexProperty_SetLeafPoolCapacity", RT_Failure);
2741  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2742 
2743  try
2744  {
2745  Tools::Variant var;
2746  var.m_varType = Tools::VT_ULONG;
2747  var.m_val.ulVal = value;
2748  prop->setProperty("LeafPoolCapacity", var);
2749  } catch (Tools::Exception& e)
2750  {
2752  e.what().c_str(),
2753  "IndexProperty_SetLeafPoolCapacity");
2754  return RT_Failure;
2755  } catch (std::exception const& e)
2756  {
2758  e.what(),
2759  "IndexProperty_SetLeafPoolCapacity");
2760  return RT_Failure;
2761  } catch (...) {
2763  "Unknown Error",
2764  "IndexProperty_SetLeafPoolCapacity");
2765  return RT_Failure;
2766  }
2767  return RT_None;
2768 }
2769 
2771 {
2772  VALIDATE_POINTER1(hProp, "IndexProperty_GetLeafPoolCapacity", 0);
2773  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2774 
2775  Tools::Variant var;
2776  var = prop->getProperty("LeafPoolCapacity");
2777 
2778  if (var.m_varType != Tools::VT_EMPTY)
2779  {
2780  if (var.m_varType != Tools::VT_ULONG) {
2782  "Property LeafPoolCapacity must be Tools::VT_ULONG",
2783  "IndexProperty_GetLeafPoolCapacity");
2784  return 0;
2785  }
2786 
2787  return var.m_val.ulVal;
2788  }
2789 
2790  // return nothing for an error
2792  "Property LeafPoolCapacity was empty",
2793  "IndexProperty_GetLeafPoolCapacity");
2794  return 0;
2795 }
2796 
2798  uint32_t value)
2799 {
2800  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexPoolCapacity", RT_Failure);
2801  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2802 
2803  try
2804  {
2805  Tools::Variant var;
2806  var.m_varType = Tools::VT_ULONG;
2807  var.m_val.ulVal = value;
2808  prop->setProperty("IndexPoolCapacity", var);
2809  } catch (Tools::Exception& e)
2810  {
2812  e.what().c_str(),
2813  "IndexProperty_SetIndexPoolCapacity");
2814  return RT_Failure;
2815  } catch (std::exception const& e)
2816  {
2818  e.what(),
2819  "IndexProperty_SetIndexPoolCapacity");
2820  return RT_Failure;
2821  } catch (...) {
2823  "Unknown Error",
2824  "IndexProperty_SetIndexPoolCapacity");
2825  return RT_Failure;
2826  }
2827  return RT_None;
2828 }
2829 
2831 {
2832  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexPoolCapacity", 0);
2833  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2834 
2835  Tools::Variant var;
2836  var = prop->getProperty("IndexPoolCapacity");
2837 
2838  if (var.m_varType != Tools::VT_EMPTY)
2839  {
2840  if (var.m_varType != Tools::VT_ULONG) {
2842  "Property IndexPoolCapacity must be Tools::VT_ULONG",
2843  "IndexProperty_GetIndexPoolCapacity");
2844  return 0;
2845  }
2846 
2847  return var.m_val.ulVal;
2848  }
2849 
2850  // return nothing for an error
2852  "Property IndexPoolCapacity was empty",
2853  "IndexProperty_GetIndexPoolCapacity");
2854  return 0;
2855 }
2856 
2858  uint32_t value)
2859 {
2860  VALIDATE_POINTER1(hProp, "IndexProperty_SetRegionPoolCapacity", RT_Failure);
2861  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2862 
2863  try
2864  {
2865  Tools::Variant var;
2866  var.m_varType = Tools::VT_ULONG;
2867  var.m_val.ulVal = value;
2868  prop->setProperty("RegionPoolCapacity", var);
2869  } catch (Tools::Exception& e)
2870  {
2872  e.what().c_str(),
2873  "IndexProperty_SetRegionPoolCapacity");
2874  return RT_Failure;
2875  } catch (std::exception const& e)
2876  {
2878  e.what(),
2879  "IndexProperty_SetRegionPoolCapacity");
2880  return RT_Failure;
2881  } catch (...) {
2883  "Unknown Error",
2884  "IndexProperty_SetRegionPoolCapacity");
2885  return RT_Failure;
2886  }
2887  return RT_None;
2888 }
2889 
2891 {
2892  VALIDATE_POINTER1(hProp, "IndexProperty_GetRegionPoolCapacity", 0);
2893  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2894 
2895  Tools::Variant var;
2896  var = prop->getProperty("RegionPoolCapacity");
2897 
2898  if (var.m_varType != Tools::VT_EMPTY)
2899  {
2900  if (var.m_varType != Tools::VT_ULONG) {
2902  "Property RegionPoolCapacity must be Tools::VT_ULONG",
2903  "IndexProperty_GetRegionPoolCapacity");
2904  return 0;
2905  }
2906 
2907  return var.m_val.ulVal;
2908  }
2909 
2910  // return nothing for an error
2912  "Property RegionPoolCapacity was empty",
2913  "IndexProperty_GetRegionPoolCapacity");
2914  return 0;
2915 }
2916 
2918  uint32_t value)
2919 {
2920  VALIDATE_POINTER1(hProp, "IndexProperty_SetPointPoolCapacity", RT_Failure);
2921  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2922 
2923  try
2924  {
2925  Tools::Variant var;
2926  var.m_varType = Tools::VT_ULONG;
2927  var.m_val.ulVal = value;
2928  prop->setProperty("PointPoolCapacity", var);
2929  } catch (Tools::Exception& e)
2930  {
2932  e.what().c_str(),
2933  "IndexProperty_SetPointPoolCapacity");
2934  return RT_Failure;
2935  } catch (std::exception const& e)
2936  {
2938  e.what(),
2939  "IndexProperty_SetPointPoolCapacity");
2940  return RT_Failure;
2941  } catch (...) {
2943  "Unknown Error",
2944  "IndexProperty_SetPointPoolCapacity");
2945  return RT_Failure;
2946  }
2947  return RT_None;
2948 }
2949 
2951 {
2952  VALIDATE_POINTER1(hProp, "IndexProperty_GetPointPoolCapacity", 0);
2953  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2954 
2955  Tools::Variant var;
2956  var = prop->getProperty("PointPoolCapacity");
2957 
2958  if (var.m_varType != Tools::VT_EMPTY)
2959  {
2960  if (var.m_varType != Tools::VT_ULONG) {
2962  "Property PointPoolCapacity must be Tools::VT_ULONG",
2963  "IndexProperty_GetPointPoolCapacity");
2964  return 0;
2965  }
2966 
2967  return var.m_val.ulVal;
2968  }
2969 
2970  // return nothing for an error
2972  "Property PointPoolCapacity was empty",
2973  "IndexProperty_GetPointPoolCapacity");
2974  return 0;
2975 }
2976 
2978  uint32_t value)
2979 {
2980  VALIDATE_POINTER1( hProp,
2981  "IndexProperty_SetNearMinimumOverlapFactor",
2982  RT_Failure);
2983  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
2984 
2985  try
2986  {
2987  Tools::Variant var;
2988  var.m_varType = Tools::VT_ULONG;
2989  var.m_val.ulVal = value;
2990  prop->setProperty("NearMinimumOverlapFactor", var);
2991  } catch (Tools::Exception& e)
2992  {
2994  e.what().c_str(),
2995  "IndexProperty_SetNearMinimumOverlapFactor");
2996  return RT_Failure;
2997  } catch (std::exception const& e)
2998  {
3000  e.what(),
3001  "IndexProperty_SetNearMinimumOverlapFactor");
3002  return RT_Failure;
3003  } catch (...) {
3005  "Unknown Error",
3006  "IndexProperty_SetNearMinimumOverlapFactor");
3007  return RT_Failure;
3008  }
3009  return RT_None;
3010 }
3011 
3013 {
3014  VALIDATE_POINTER1(hProp, "IndexProperty_GetNearMinimumOverlapFactor", 0);
3015  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3016 
3017  Tools::Variant var;
3018  var = prop->getProperty("NearMinimumOverlapFactor");
3019 
3020  if (var.m_varType != Tools::VT_EMPTY)
3021  {
3022  if (var.m_varType != Tools::VT_ULONG) {
3024  "Property NearMinimumOverlapFactor must be Tools::VT_ULONG",
3025  "IndexProperty_GetNearMinimumOverlapFactor");
3026  return 0;
3027  }
3028 
3029  return var.m_val.ulVal;
3030  }
3031 
3032  // return nothing for an error
3034  "Property NearMinimumOverlapFactor was empty",
3035  "IndexProperty_GetNearMinimumOverlapFactor");
3036  return 0;
3037 }
3038 
3039 
3041  uint32_t value)
3042 {
3043  VALIDATE_POINTER1(hProp, "IndexProperty_SetBufferingCapacity", RT_Failure);
3044  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3045 
3046  try
3047  {
3048  Tools::Variant var;
3049  var.m_varType = Tools::VT_ULONG;
3050  var.m_val.ulVal = value;
3051  prop->setProperty("Capacity", var);
3052  } catch (Tools::Exception& e)
3053  {
3055  e.what().c_str(),
3056  "IndexProperty_SetBufferingCapacity");
3057  return RT_Failure;
3058  } catch (std::exception const& e)
3059  {
3061  e.what(),
3062  "IndexProperty_SetBufferingCapacity");
3063  return RT_Failure;
3064  } catch (...) {
3066  "Unknown Error",
3067  "IndexProperty_SetBufferingCapacity");
3068  return RT_Failure;
3069  }
3070  return RT_None;
3071 }
3072 
3074 {
3075  VALIDATE_POINTER1(hProp, "IndexProperty_GetBufferingCapacity", 0);
3076  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3077 
3078  Tools::Variant var;
3079  var = prop->getProperty("Capacity");
3080 
3081  if (var.m_varType != Tools::VT_EMPTY)
3082  {
3083  if (var.m_varType != Tools::VT_ULONG) {
3085  "Property Capacity must be Tools::VT_ULONG",
3086  "IndexProperty_GetBufferingCapacity");
3087  return 0;
3088  }
3089 
3090  return var.m_val.ulVal;
3091  }
3092 
3093  // return nothing for an error
3095  "Property Capacity was empty",
3096  "IndexProperty_GetBufferingCapacity");
3097  return 0;
3098 }
3099 
3101  uint32_t value)
3102 {
3103  VALIDATE_POINTER1(hProp, "IndexProperty_SetEnsureTightMBRs", RT_Failure);
3104  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3105 
3106  try
3107  {
3108  if (value > 1 ) {
3110  "EnsureTightMBRs is a boolean value and must be 1 or 0",
3111  "IndexProperty_SetEnsureTightMBRs");
3112  return RT_Failure;
3113  }
3114  Tools::Variant var;
3115  var.m_varType = Tools::VT_BOOL;
3116  var.m_val.blVal = value != 0;
3117  prop->setProperty("EnsureTightMBRs", var);
3118  } catch (Tools::Exception& e)
3119  {
3121  e.what().c_str(),
3122  "IndexProperty_SetEnsureTightMBRs");
3123  return RT_Failure;
3124  } catch (std::exception const& e)
3125  {
3127  e.what(),
3128  "IndexProperty_SetEnsureTightMBRs");
3129  return RT_Failure;
3130  } catch (...) {
3132  "Unknown Error",
3133  "IndexProperty_SetEnsureTightMBRs");
3134  return RT_Failure;
3135  }
3136  return RT_None;
3137 }
3138 
3140 {
3141  VALIDATE_POINTER1(hProp, "IndexProperty_GetEnsureTightMBRs", 0);
3142  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3143 
3144  Tools::Variant var;
3145  var = prop->getProperty("EnsureTightMBRs");
3146 
3147  if (var.m_varType != Tools::VT_EMPTY)
3148  {
3149  if (var.m_varType != Tools::VT_BOOL) {
3151  "Property EnsureTightMBRs must be Tools::VT_BOOL",
3152  "IndexProperty_GetEnsureTightMBRs");
3153  return 0;
3154  }
3155 
3156  return var.m_val.blVal;
3157  }
3158 
3159  // return nothing for an error
3161  "Property EnsureTightMBRs was empty",
3162  "IndexProperty_GetEnsureTightMBRs");
3163  return 0;
3164 }
3165 
3167  uint32_t value)
3168 {
3169  VALIDATE_POINTER1(hProp, "IndexProperty_SetWriteThrough", RT_Failure);
3170  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3171 
3172  try
3173  {
3174  if (value > 1 ) {
3176  "WriteThrough is a boolean value and must be 1 or 0",
3177  "IndexProperty_SetWriteThrough");
3178  return RT_Failure;
3179  }
3180  Tools::Variant var;
3181  var.m_varType = Tools::VT_BOOL;
3182  var.m_val.blVal = value != 0;
3183  prop->setProperty("WriteThrough", var);
3184  } catch (Tools::Exception& e)
3185  {
3187  e.what().c_str(),
3188  "IndexProperty_SetWriteThrough");
3189  return RT_Failure;
3190  } catch (std::exception const& e)
3191  {
3193  e.what(),
3194  "IndexProperty_SetWriteThrough");
3195  return RT_Failure;
3196  } catch (...) {
3198  "Unknown Error",
3199  "IndexProperty_SetWriteThrough");
3200  return RT_Failure;
3201  }
3202  return RT_None;
3203 }
3204 
3206 {
3207  VALIDATE_POINTER1(hProp, "IndexProperty_GetWriteThrough", 0);
3208  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3209 
3210  Tools::Variant var;
3211  var = prop->getProperty("WriteThrough");
3212 
3213  if (var.m_varType != Tools::VT_EMPTY)
3214  {
3215  if (var.m_varType != Tools::VT_BOOL) {
3217  "Property WriteThrough must be Tools::VT_BOOL",
3218  "IndexProperty_GetWriteThrough");
3219  return 0;
3220  }
3221 
3222  return var.m_val.blVal;
3223  }
3224 
3225  // return nothing for an error
3227  "Property WriteThrough was empty",
3228  "IndexProperty_GetWriteThrough");
3229  return 0;
3230 }
3231 
3233  uint32_t value)
3234 {
3235  VALIDATE_POINTER1(hProp, "IndexProperty_SetOverwrite", RT_Failure);
3236  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3237 
3238  try
3239  {
3240  if (value > 1 ) {
3242  "Overwrite is a boolean value and must be 1 or 0",
3243  "IndexProperty_SetOverwrite");
3244  return RT_Failure;
3245  }
3246  Tools::Variant var;
3247  var.m_varType = Tools::VT_BOOL;
3248  var.m_val.blVal = value != 0;
3249  prop->setProperty("Overwrite", var);
3250  } catch (Tools::Exception& e)
3251  {
3253  e.what().c_str(),
3254  "IndexProperty_SetOverwrite");
3255  return RT_Failure;
3256  } catch (std::exception const& e)
3257  {
3259  e.what(),
3260  "IndexProperty_SetOverwrite");
3261  return RT_Failure;
3262  } catch (...) {
3264  "Unknown Error",
3265  "IndexProperty_SetOverwrite");
3266  return RT_Failure;
3267  }
3268  return RT_None;
3269 }
3270 
3272 {
3273  VALIDATE_POINTER1(hProp, "IndexProperty_GetOverwrite", 0);
3274  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3275 
3276  Tools::Variant var;
3277  var = prop->getProperty("Overwrite");
3278 
3279  if (var.m_varType != Tools::VT_EMPTY)
3280  {
3281  if (var.m_varType != Tools::VT_BOOL) {
3283  "Property Overwrite must be Tools::VT_BOOL",
3284  "IndexProperty_GetOverwrite");
3285  return 0;
3286  }
3287 
3288  return var.m_val.blVal;
3289  }
3290 
3291  // return nothing for an error
3293  "Property Overwrite was empty",
3294  "IndexProperty_GetOverwrite");
3295  return 0;
3296 }
3297 
3298 
3300  double value)
3301 {
3302  VALIDATE_POINTER1(hProp, "IndexProperty_SetFillFactor", RT_Failure);
3303  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3304 
3305  try
3306  {
3307  Tools::Variant var;
3309  var.m_val.dblVal = value;
3310  prop->setProperty("FillFactor", var);
3311  } catch (Tools::Exception& e)
3312  {
3314  e.what().c_str(),
3315  "IndexProperty_SetFillFactor");
3316  return RT_Failure;
3317  } catch (std::exception const& e)
3318  {
3320  e.what(),
3321  "IndexProperty_SetFillFactor");
3322  return RT_Failure;
3323  } catch (...) {
3325  "Unknown Error",
3326  "IndexProperty_SetFillFactor");
3327  return RT_Failure;
3328  }
3329  return RT_None;
3330 }
3331 
3333 {
3334  VALIDATE_POINTER1(hProp, "IndexProperty_GetFillFactor", 0);
3335  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3336 
3337  Tools::Variant var;
3338  var = prop->getProperty("FillFactor");
3339 
3340  if (var.m_varType != Tools::VT_EMPTY)
3341  {
3342  if (var.m_varType != Tools::VT_DOUBLE) {
3344  "Property FillFactor must be Tools::VT_DOUBLE",
3345  "IndexProperty_GetFillFactor");
3346  return 0;
3347  }
3348 
3349  return var.m_val.dblVal;
3350  }
3351 
3352  // return nothing for an error
3354  "Property FillFactor was empty",
3355  "IndexProperty_GetFillFactor");
3356  return 0;
3357 }
3358 
3360  double value)
3361 {
3362  VALIDATE_POINTER1( hProp,
3363  "IndexProperty_SetSplitDistributionFactor",
3364  RT_Failure);
3365  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3366 
3367  try
3368  {
3369  Tools::Variant var;
3371  var.m_val.dblVal = value;
3372  prop->setProperty("SplitDistributionFactor", var);
3373  } catch (Tools::Exception& e)
3374  {
3376  e.what().c_str(),
3377  "IndexProperty_SetSplitDistributionFactor");
3378  return RT_Failure;
3379  } catch (std::exception const& e)
3380  {
3382  e.what(),
3383  "IndexProperty_SetSplitDistributionFactor");
3384  return RT_Failure;
3385  } catch (...) {
3387  "Unknown Error",
3388  "IndexProperty_SetSplitDistributionFactor");
3389  return RT_Failure;
3390  }
3391  return RT_None;
3392 }
3393 
3395 {
3396  VALIDATE_POINTER1(hProp, "IndexProperty_GetSplitDistributionFactor", 0);
3397  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3398 
3399  Tools::Variant var;
3400  var = prop->getProperty("SplitDistributionFactor");
3401 
3402  if (var.m_varType != Tools::VT_EMPTY)
3403  {
3404  if (var.m_varType != Tools::VT_DOUBLE) {
3406  "Property SplitDistributionFactor must be Tools::VT_DOUBLE",
3407  "IndexProperty_GetSplitDistributionFactor");
3408  return 0;
3409  }
3410 
3411  return var.m_val.dblVal;
3412  }
3413 
3414  // return nothing for an error
3416  "Property SplitDistributionFactor was empty",
3417  "IndexProperty_GetSplitDistributionFactor");
3418  return 0;
3419 }
3420 
3422  double value)
3423 {
3424  VALIDATE_POINTER1( hProp,
3425  "IndexProperty_SetTPRHorizon",
3426  RT_Failure);
3427  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3428 
3429  try
3430  {
3431  Tools::Variant var;
3433  var.m_val.dblVal = value;
3434  prop->setProperty("Horizon", var);
3435  } catch (Tools::Exception& e)
3436  {
3438  e.what().c_str(),
3439  "IndexProperty_SetTPRHorizon");
3440  return RT_Failure;
3441  } catch (std::exception const& e)
3442  {
3444  e.what(),
3445  "IndexProperty_SetTPRHorizon");
3446  return RT_Failure;
3447  } catch (...) {
3449  "Unknown Error",
3450  "IndexProperty_SetTPRHorizon");
3451  return RT_Failure;
3452  }
3453  return RT_None;
3454 }
3455 
3457 {
3458  VALIDATE_POINTER1(hProp, "IndexProperty_GetTPRHorizon", 0);
3459  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3460 
3461  Tools::Variant var;
3462  var = prop->getProperty("Horizon");
3463 
3464  if (var.m_varType != Tools::VT_EMPTY)
3465  {
3466  if (var.m_varType != Tools::VT_DOUBLE) {
3468  "Property Horizon must be Tools::VT_DOUBLE",
3469  "IndexProperty_GetTPRHorizon");
3470  return 0;
3471  }
3472 
3473  return var.m_val.dblVal;
3474  }
3475 
3476  // return nothing for an error
3478  "Property Horizon was empty",
3479  "IndexProperty_GetTPRHorizon");
3480  return 0;
3481 }
3482 
3484  double value)
3485 {
3486  VALIDATE_POINTER1( hProp,
3487  "IndexProperty_SetReinsertFactor",
3488  RT_Failure);
3489  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3490 
3491  try
3492  {
3493  Tools::Variant var;
3495  var.m_val.dblVal = value;
3496  prop->setProperty("ReinsertFactor", var);
3497  } catch (Tools::Exception& e)
3498  {
3500  e.what().c_str(),
3501  "IndexProperty_SetReinsertFactor");
3502  return RT_Failure;
3503  } catch (std::exception const& e)
3504  {
3506  e.what(),
3507  "IndexProperty_SetReinsertFactor");
3508  return RT_Failure;
3509  } catch (...) {
3511  "Unknown Error",
3512  "IndexProperty_SetReinsertFactor");
3513  return RT_Failure;
3514  }
3515  return RT_None;
3516 }
3517 
3519 {
3520  VALIDATE_POINTER1(hProp, "IndexProperty_GetReinsertFactor", 0);
3521  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3522 
3523  Tools::Variant var;
3524  var = prop->getProperty("ReinsertFactor");
3525 
3526  if (var.m_varType != Tools::VT_EMPTY)
3527  {
3528  if (var.m_varType != Tools::VT_DOUBLE) {
3530  "Property ReinsertFactor must be Tools::VT_DOUBLE",
3531  "IndexProperty_GetReinsertFactor");
3532  return 0;
3533  }
3534 
3535  return var.m_val.dblVal;
3536  }
3537 
3538  // return nothing for an error
3540  "Property ReinsertFactor was empty",
3541  "IndexProperty_GetReinsertFactor");
3542  return 0;
3543 }
3544 
3546  const char* value)
3547 {
3548  VALIDATE_POINTER1( hProp,
3549  "IndexProperty_SetFileName",
3550  RT_Failure);
3551  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3552 
3553  try
3554  {
3555  Tools::Variant var;
3556  var.m_varType = Tools::VT_PCHAR;
3557  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3558  prop->setProperty("FileName", var);
3559  } catch (Tools::Exception& e)
3560  {
3562  e.what().c_str(),
3563  "IndexProperty_SetFileName");
3564  return RT_Failure;
3565  } catch (std::exception const& e)
3566  {
3568  e.what(),
3569  "IndexProperty_SetFileName");
3570  return RT_Failure;
3571  } catch (...) {
3573  "Unknown Error",
3574  "IndexProperty_SetFileName");
3575  return RT_Failure;
3576  }
3577  return RT_None;
3578 }
3579 
3581 {
3582  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileName", 0);
3583  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3584 
3585  Tools::Variant var;
3586  var = prop->getProperty("FileName");
3587 
3588  if (var.m_varType != Tools::VT_EMPTY)
3589  {
3590  if (var.m_varType != Tools::VT_PCHAR) {
3592  "Property FileName must be Tools::VT_PCHAR",
3593  "IndexProperty_GetFileName");
3594  return NULL;
3595  }
3596 
3597  return STRDUP(var.m_val.pcVal);
3598  }
3599 
3600  // return nothing for an error
3602  "Property FileName was empty",
3603  "IndexProperty_GetFileName");
3604  return NULL;
3605 }
3606 
3607 
3609  const char* value)
3610 {
3611  VALIDATE_POINTER1( hProp,
3612  "IndexProperty_SetFileNameExtensionDat",
3613  RT_Failure);
3614  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3615 
3616  try
3617  {
3618  Tools::Variant var;
3619  var.m_varType = Tools::VT_PCHAR;
3620  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3621  prop->setProperty("FileNameDat", var);
3622 
3623  } catch (Tools::Exception& e)
3624  {
3626  e.what().c_str(),
3627  "IndexProperty_SetFileNameExtensionDat");
3628  return RT_Failure;
3629  } catch (std::exception const& e)
3630  {
3632  e.what(),
3633  "IndexProperty_SetFileNameExtensionDat");
3634  return RT_Failure;
3635  } catch (...) {
3637  "Unknown Error",
3638  "IndexProperty_SetFileNameExtensionDat");
3639  return RT_Failure;
3640  }
3641  return RT_None;
3642 }
3643 
3645 {
3646  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileNameExtensionDat", 0);
3647  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3648 
3649  Tools::Variant var;
3650  var = prop->getProperty("FileNameDat");
3651 
3652  if (var.m_varType != Tools::VT_EMPTY)
3653  {
3654  if (var.m_varType != Tools::VT_PCHAR) {
3656  "Property FileNameDat must be Tools::VT_PCHAR",
3657  "IndexProperty_GetFileNameExtensionDat");
3658  return NULL;
3659  }
3660 
3661  return STRDUP(var.m_val.pcVal);
3662  }
3663 
3664  // return nothing for an error
3666  "Property FileNameDat was empty",
3667  "IndexProperty_GetFileNameExtensionDat");
3668  return NULL;
3669 }
3670 
3672  const char* value)
3673 {
3674  VALIDATE_POINTER1( hProp,
3675  "IndexProperty_SetFileNameExtensionIdx",
3676  RT_Failure);
3677  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3678 
3679  try
3680  {
3681  Tools::Variant var;
3682  var.m_varType = Tools::VT_PCHAR;
3683  var.m_val.pcVal = STRDUP(value); // not sure if we should copy here
3684  prop->setProperty("FileNameIdx", var);
3685 
3686  } catch (Tools::Exception& e)
3687  {
3689  e.what().c_str(),
3690  "IndexProperty_SetFileNameExtensionIdx");
3691  return RT_Failure;
3692  } catch (std::exception const& e)
3693  {
3695  e.what(),
3696  "IndexProperty_SetFileNameExtensionIdx");
3697  return RT_Failure;
3698  } catch (...) {
3700  "Unknown Error",
3701  "IndexProperty_SetFileNameExtensionIdx");
3702  return RT_Failure;
3703  }
3704  return RT_None;
3705 }
3706 
3708 {
3709  VALIDATE_POINTER1(hProp, "IndexProperty_GetFileNameExtensionIdx", 0);
3710  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3711 
3712  Tools::Variant var;
3713  var = prop->getProperty("FileNameIdx");
3714 
3715  if (var.m_varType != Tools::VT_EMPTY)
3716  {
3717  if (var.m_varType != Tools::VT_PCHAR) {
3719  "Property FileNameIdx must be Tools::VT_PCHAR",
3720  "IndexProperty_GetFileNameExtensionIdx");
3721  return NULL;
3722  }
3723 
3724  return STRDUP(var.m_val.pcVal);
3725  }
3726 
3727  // return nothing for an error
3729  "Property FileNameIdx was empty",
3730  "IndexProperty_GetFileNameExtensionIdx");
3731  return NULL;
3732 }
3733 
3735  uint32_t value)
3736 {
3737  VALIDATE_POINTER1(hProp, "IndexProperty_SetCustomStorageCallbacksSize", RT_Failure);
3738  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3739 
3740  try
3741  {
3742  Tools::Variant var;
3743  var.m_varType = Tools::VT_ULONG;
3744  var.m_val.ulVal = value;
3745  prop->setProperty("CustomStorageCallbacksSize", var);
3746  } catch (Tools::Exception& e)
3747  {
3749  e.what().c_str(),
3750  "IndexProperty_SetCustomStorageCallbacksSize");
3751  return RT_Failure;
3752  } catch (std::exception const& e)
3753  {
3755  e.what(),
3756  "IndexProperty_SetCustomStorageCallbacksSize");
3757  return RT_Failure;
3758  } catch (...) {
3760  "Unknown Error",
3761  "IndexProperty_SetCustomStorageCallbacksSize");
3762  return RT_Failure;
3763  }
3764  return RT_None;
3765 }
3766 
3768 {
3769  VALIDATE_POINTER1(hProp, "IndexProperty_GetCustomStorageCallbacksSize", 0);
3770  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3771 
3772  Tools::Variant var;
3773  var = prop->getProperty("CustomStorageCallbacksSize");
3774 
3775  if (var.m_varType != Tools::VT_EMPTY)
3776  {
3777  if (var.m_varType != Tools::VT_ULONG) {
3779  "Property CustomStorageCallbacksSize must be Tools::VT_ULONG",
3780  "IndexProperty_GetCustomStorageCallbacksSize");
3781  return 0;
3782  }
3783 
3784  return var.m_val.ulVal;
3785  }
3786 
3787  // return nothing for an error
3789  "Property CustomStorageCallbacksSize was empty",
3790  "IndexProperty_GetCustomStorageCallbacksSize");
3791  return 0;
3792 }
3793 
3795  const void* value)
3796 {
3797  VALIDATE_POINTER1( hProp,
3798  "IndexProperty_SetCustomStorageCallbacks",
3799  RT_Failure);
3800  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3801 
3802  // check if the CustomStorageCallbacksSize is alright, so we can make a copy of the passed in structure
3803  Tools::Variant varSize;
3804  varSize = prop->getProperty("CustomStorageCallbacksSize");
3806  {
3807  std::ostringstream ss;
3808  ss << "The supplied storage callbacks size is wrong, expected "
3810  << ", got " << varSize.m_val.ulVal;
3812  ss.str().c_str(),
3813  "IndexProperty_SetCustomStorageCallbacks");
3814  return RT_Failure;
3815  }
3816 
3817  try
3818  {
3819  Tools::Variant var;
3820  var.m_varType = Tools::VT_PVOID;
3821  var.m_val.pvVal = value ?
3824  )
3825  : 0;
3826  prop->setProperty("CustomStorageCallbacks", var);
3827 
3828  } catch (Tools::Exception& e)
3829  {
3831  e.what().c_str(),
3832  "IndexProperty_SetCustomStorageCallbacks");
3833  return RT_Failure;
3834  } catch (std::exception const& e)
3835  {
3837  e.what(),
3838  "IndexProperty_SetCustomStorageCallbacks");
3839  return RT_Failure;
3840  } catch (...) {
3842  "Unknown Error",
3843  "IndexProperty_SetCustomStorageCallbacks");
3844  return RT_Failure;
3845  }
3846  return RT_None;
3847 }
3848 
3850 {
3851  VALIDATE_POINTER1(hProp, "IndexProperty_GetCustomStorageCallbacks", 0);
3852  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3853 
3854  Tools::Variant var;
3855  var = prop->getProperty("CustomStorageCallbacks");
3856 
3857  if (var.m_varType != Tools::VT_EMPTY)
3858  {
3859  if (var.m_varType != Tools::VT_PVOID) {
3861  "Property CustomStorageCallbacks must be Tools::VT_PVOID",
3862  "IndexProperty_GetCustomStorageCallbacks");
3863  return NULL;
3864  }
3865 
3866  return var.m_val.pvVal;
3867  }
3868 
3869  // return nothing for an error
3871  "Property CustomStorageCallbacks was empty",
3872  "IndexProperty_GetCustomStorageCallbacks");
3873  return NULL;
3874 }
3875 
3877  int64_t value)
3878 {
3879  VALIDATE_POINTER1(hProp, "IndexProperty_SetIndexID", RT_Failure);
3880  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3881 
3882  try
3883  {
3884  Tools::Variant var;
3886  var.m_val.llVal = value;
3887  prop->setProperty("IndexIdentifier", var);
3888  } catch (Tools::Exception& e)
3889  {
3891  e.what().c_str(),
3892  "IndexProperty_SetIndexID");
3893  return RT_Failure;
3894  } catch (std::exception const& e)
3895  {
3897  e.what(),
3898  "IndexProperty_SetIndexID");
3899  return RT_Failure;
3900  } catch (...) {
3902  "Unknown Error",
3903  "IndexProperty_SetIndexID");
3904  return RT_Failure;
3905  }
3906  return RT_None;
3907 }
3908 
3910 {
3911  VALIDATE_POINTER1(hProp, "IndexProperty_GetIndexID", 0);
3912  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3913 
3914  Tools::Variant var;
3915  var = prop->getProperty("IndexIdentifier");
3916 
3917  if (var.m_varType != Tools::VT_EMPTY)
3918  {
3919  if (var.m_varType != Tools::VT_LONGLONG) {
3921  "Property IndexIdentifier must be Tools::VT_LONGLONG",
3922  "IndexProperty_GetIndexID");
3923  return 0;
3924  }
3925 
3926  return var.m_val.llVal;
3927  }
3928 
3929  // return nothing for an error
3931  "Property IndexIdentifier was empty",
3932  "IndexProperty_GetIndexID");
3933  return 0;
3934 }
3935 
3936 SIDX_C_DLL void* SIDX_NewBuffer(size_t length)
3937 {
3938  return new char[length];
3939 }
3940 
3942 {
3943  VALIDATE_POINTER1(hProp, "IndexProperty_SetResultSetLimit", RT_Failure);
3944 
3945  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3946 
3947  try
3948  {
3949  Tools::Variant var;
3951  var.m_val.llVal = value;
3952  prop->setProperty("ResultSetLimit", var);
3953  } catch (Tools::Exception& e)
3954  {
3956  e.what().c_str(),
3957  "IndexProperty_SetResultSetLimit");
3958  return RT_Failure;
3959  } catch (std::exception const& e)
3960  {
3962  e.what(),
3963  "IndexProperty_SetResultSetLimit");
3964  return RT_Failure;
3965  } catch (...) {
3967  "Unknown Error",
3968  "IndexProperty_SetResultSetLimit");
3969  return RT_Failure;
3970  }
3971  return RT_None;
3972 }
3973 
3975 {
3976  VALIDATE_POINTER1(hProp, "IndexProperty_GetResultSetLimit", 0);
3977  Tools::PropertySet* prop = reinterpret_cast<Tools::PropertySet*>(hProp);
3978 
3979  Tools::Variant var;
3980  var = prop->getProperty("ResultSetLimit");
3981 
3982  if (var.m_varType != Tools::VT_EMPTY)
3983  {
3984  if (var.m_varType != Tools::VT_LONGLONG) {
3986  "Property ResultSetLimit must be Tools::VT_LONGLONG",
3987  "IndexProperty_GetResultSetLimit");
3988  return 0;
3989  }
3990 
3991  return var.m_val.llVal;
3992  }
3993 
3994  // return nothing for an error
3996  "Property ResultSetLimit was empty",
3997  "IndexProperty_GetResultSetLimit");
3998  return 0;
3999 }
4000 
4001 
4002 SIDX_C_DLL void SIDX_DeleteBuffer(void* buffer)
4003 {
4004  delete [] static_cast<char*>(buffer);
4005 }
4006 
4007 
4009 {
4010 
4011  std::ostringstream ot;
4012 
4013 #ifdef SIDX_RELEASE_NAME
4014  ot << SIDX_RELEASE_NAME;
4015 #else
4016  ot << "1.3.2";
4017 #endif
4018 
4019  std::string out(ot.str());
4020  return STRDUP(out.c_str());
4021 
4022 }
4023 IDX_C_END
4024 
4025 #ifdef _WIN32
4026 # pragma warning(pop)
4027 #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:47
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:3580
SIDX_C_DLL RTError IndexProperty_SetRegionPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2857
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:1531
SIDX_C_DLL RTError IndexProperty_SetFileNameExtensionIdx(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3671
SIDX_DLL RTError Index_SetResultSetLimit(IndexH index, int64_t value)
Definition: sidx_api.cc:2013
SIDX_C_DLL double IndexProperty_GetSplitDistributionFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3394
SIDX_C_DLL char * IndexProperty_GetFileNameExtensionDat(IndexPropertyH hProp)
Definition: sidx_api.cc:3644
SIDX_C_DLL RTError IndexProperty_SetTPRHorizon(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3421
SIDX_DLL RTError IndexProperty_SetResultSetLimit(IndexPropertyH hProp, uint64_t value)
Definition: sidx_api.cc:3941
SIDX_C_DLL void IndexItem_Destroy(IndexItemH item)
Definition: sidx_api.cc:2187
SIDX_C_DLL RTError IndexItem_GetBounds(IndexItemH item, double **ppdMin, double **ppdMax, uint32_t *nDimension)
Definition: sidx_api.cc:2222
SIDX_C_DLL void Index_Free(void *results)
Definition: sidx_api.cc:2080
SIDX_C_DLL RTError IndexProperty_SetCustomStorageCallbacksSize(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3734
SIDX_C_DLL RTError IndexProperty_SetOverwrite(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3232
SIDX_C_DLL void * IndexProperty_GetCustomStorageCallbacks(IndexPropertyH hProp)
Definition: sidx_api.cc:3849
SIDX_C_DLL IndexPropertyH IndexProperty_Create()
Definition: sidx_api.cc:2264
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:3100
SIDX_C_DLL int64_t IndexProperty_GetIndexID(IndexPropertyH hProp)
Definition: sidx_api.cc:3909
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:1633
SIDX_C_DLL RTError IndexProperty_SetIndexCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2557
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:1710
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:1121
SIDX_C_DLL double IndexProperty_GetFillFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3332
SIDX_C_DLL char * Error_GetLastErrorMsg(void)
Definition: sidx_api.cc:114
SIDX_C_DLL RTIndexVariant IndexProperty_GetIndexVariant(IndexPropertyH hProp)
Definition: sidx_api.cc:2458
SIDX_C_DLL uint32_t IndexProperty_GetCustomStorageCallbacksSize(IndexPropertyH hProp)
Definition: sidx_api.cc:3767
SIDX_C_DLL RTError IndexProperty_SetBufferingCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3040
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:1371
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:3073
SIDX_DLL uint64_t IndexProperty_GetResultSetLimit(IndexPropertyH hProp)
Definition: sidx_api.cc:3974
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:2316
SIDX_C_DLL uint32_t IndexProperty_GetOverwrite(IndexPropertyH hProp)
Definition: sidx_api.cc:3271
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:3876
SIDX_C_DLL RTError IndexProperty_SetWriteThrough(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:3166
SIDX_C_DLL void IndexProperty_Destroy(IndexPropertyH hProp)
Definition: sidx_api.cc:2271
SIDX_C_DLL uint32_t IndexProperty_GetRegionPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2890
SIDX_C_DLL RTError IndexProperty_SetIndexStorage(IndexPropertyH hProp, RTStorageType value)
Definition: sidx_api.cc:2490
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:1172
SIDX_C_DLL RTError IndexProperty_SetSplitDistributionFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3359
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:3794
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:3518
SIDX_C_DLL RTError IndexProperty_SetReinsertFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3483
SIDX_C_DLL uint32_t IndexProperty_GetNearMinimumOverlapFactor(IndexPropertyH hProp)
Definition: sidx_api.cc:3012
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:2617
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:1827
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:1317
SIDX_C_DLL uint32_t IndexProperty_GetIndexCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2590
SIDX_C_DLL RTError IndexProperty_SetDimension(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2342
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:2374
SIDX_C_DLL char * IndexProperty_GetFileNameExtensionIdx(IndexPropertyH hProp)
Definition: sidx_api.cc:3707
SIDX_C_DLL RTError IndexProperty_SetIndexType(IndexPropertyH hProp, RTIndexType value)
Definition: sidx_api.cc:2278
SIDX_C_DLL uint32_t IndexProperty_GetWriteThrough(IndexPropertyH hProp)
Definition: sidx_api.cc:3205
SIDX_C_DLL int64_t IndexItem_GetID(IndexItemH item)
Definition: sidx_api.cc:2214
SIDX_C_DLL RTError IndexProperty_SetIndexPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2797
SIDX_C_DLL RTError IndexProperty_SetPointPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2917
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:1588
SIDX_C_DLL RTError IndexProperty_SetPagesize(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2677
SIDX_C_DLL RTError IndexItem_GetData(IndexItemH item, uint8_t **data, uint64_t *length)
Definition: sidx_api.cc:2194
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:1883
SIDX_C_DLL RTError IndexProperty_SetFillFactor(IndexPropertyH hProp, double value)
Definition: sidx_api.cc:3299
SIDX_C_DLL RTError IndexProperty_SetNearMinimumOverlapFactor(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2977
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:3139
SIDX_C_DLL RTError Index_Intersects_count(IndexH index, double *pdMin, double *pdMax, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1222
#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:2401
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:1989
SIDX_C_DLL uint32_t IndexProperty_GetLeafPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2770
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:1270
SIDX_C_DLL IndexPropertyH Index_GetProperties(IndexH index)
Definition: sidx_api.cc:2044
SIDX_C_DLL RTError Index_SegmentIntersects_count(IndexH index, double *pdStartPoint, double *pdEndPoint, uint32_t nDimension, uint64_t *nResults)
Definition: sidx_api.cc:1424
SIDX_C_DLL RTError IndexProperty_SetLeafPoolCapacity(IndexPropertyH hProp, uint32_t value)
Definition: sidx_api.cc:2737
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:2087
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:1472
SIDX_C_DLL RTError IndexProperty_SetFileNameExtensionDat(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3608
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:3936
SIDX_C_DLL uint32_t IndexProperty_GetPointPoolCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2950
SIDX_C_DLL char * SIDX_Version()
Definition: sidx_api.cc:4008
SIDX_C_DLL void Index_DestroyObjResults(IndexItemH *results, uint32_t nResults)
Definition: sidx_api.cc:2064
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:2006
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:4002
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:1769
SIDX_C_DLL double IndexProperty_GetTPRHorizon(IndexPropertyH hProp)
Definition: sidx_api.cc:3456
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:1933
SIDX_C_DLL RTStorageType IndexProperty_GetIndexStorage(IndexPropertyH hProp)
Definition: sidx_api.cc:2526
SIDX_C_DLL void Index_ClearBuffer(IndexH index)
Definition: sidx_api.cc:2057
SIDX_C_DLL uint32_t Index_IsValid(IndexH index)
Definition: sidx_api.cc:2037
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:2830
SIDX_DLL int64_t Index_GetResultSetLimit(IndexH index)
Definition: sidx_api.cc:2030
SIDX_C_DLL RTError IndexProperty_SetFileName(IndexPropertyH hProp, const char *value)
Definition: sidx_api.cc:3545
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:2710
SIDX_C_DLL uint32_t IndexProperty_GetLeafCapacity(IndexPropertyH hProp)
Definition: sidx_api.cc:2650
#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