dmBridge PHP API
UNLVSpatialIndexer.php
00001 <?php
00002 #
00003 # UNLVSpatial: a dmBridge module for spatial content
00004 #
00005 # Copyright © 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 class UNLVSpatialIndexer {
00014 
00016    private $indexed_objects = array();
00018    private $skipped_objects = array();
00019 
00023    public function getIndexedObjects() {
00024       return $this->indexed_objects;
00025    }
00026 
00030    public function getSkippedObjects() {
00031       return $this->skipped_objects;
00032    }
00033 
00038    public function reindex(DMCollection $collection, DMDCElement $field) {
00039       $this->reset();
00040 
00041       $ds = UNLVSpatial::getDataStore();
00042       $ds->deleteAllObjectsInCollection($collection);
00043 
00044       $num_objects = $collection->getNumObjects();
00045       $results_per_page = 1000;
00046 
00047       $query = new DMObjectQuery();
00048       $query->addCollection($collection);
00049       $query->setNumResultsPerPage($results_per_page);
00050       for ($i = 1; $i <= $num_objects; $i = $i + $results_per_page) {
00051          $query->setPage($i);
00052          $results = $query->getSearchResults();
00053          foreach ($results as $obj) {
00054             try {
00055                UNLVSpatialObjectFactory::spatializeObject($obj);
00056                $obj->getSpatialDataSource();
00057                $ds->updateObject($obj);
00058                $this->indexed_objects[] = $obj;
00059             } catch (Exception $e) {
00060                // boundary units are unsupported
00061                $this->skipped_objects[] = $obj;
00062             }
00063          }
00064       }
00065    }
00066 
00067    private function reset() {
00068       
00069       $this->indexed_objects = array();
00070       $this->skipped_objects = array();
00071    }
00072 
00073 }
00074 
 All Data Structures Functions Variables