dmBridge PHP API
UNLVSpatialQuery.php
00001 <?php
00002 #
00003 # UNLVSpatial: a dmBridge module for spatial content
00004 #
00005 # Copyright © 2009, 2010, 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 UNLVSpatialQuery extends DMAbstractQuery implements DMQuery {
00014 
00016    private $terms = array();
00017 
00018 
00022    public function getFeedURI() {
00023       return $this->getURI("atom");
00024    }
00025 
00030    public function getSearchResults() {
00031       if (count($this->results)) {
00032          return $this->results;
00033       }
00034 
00035       $ds = DMDataStoreFactory::getDataStore();
00036       switch ($ds->getType()) {
00037          case DMDataStoreType::PDO_MySQL:
00038             $ds = UNLVSpatialMySQLDataStore::getInstance();
00039             break;
00040          case DMDataStoreType::PDO_SQLite:
00041             $ds = UNLVSpatialSQLiteDataStore::getInstance();
00042             break;
00043       }
00044 
00045       $this->num_results = $ds->getNumObjectsMatchingQuery($this);
00046       return $ds->getObjectsMatchingQuery($this);
00047    }
00048 
00052    public function addQueryTerm(UNLVSpatialQueryTerm $term) {
00053       $this->terms[] = $term;
00054    }
00055 
00059    public function getQueryTerms() {
00060       return $this->terms;
00061    }
00062 
00066    public function getURI($representation = "html") {
00067       $terms = $this->getQueryTerms();
00068       $collections = $this->getCollections();
00069       $qs = array();
00070 
00071       for ($i = 1; $i <= count($terms); $i++) {
00072          $qs['mode' . $i] = $terms[$i-1]->getMatchingMode();
00073          $sp_obj = $terms[$i-1]->getExampleObject();
00074          $qs['nlat' . $i] = $sp_obj->getSpatialNorthLat();
00075          $qs['slat' . $i] = $sp_obj->getSpatialSouthLat();
00076          $qs['elong' . $i] = $sp_obj->getSpatialEastLong();
00077          $qs['wlong' . $i] = $sp_obj->getSpatialWestLong();
00078       }
00079 
00080       $qs['aliases'] = array();
00081       for ($i = 1; $i <= count($collections); $i++) {
00082          $qs['aliases'][] = $collections[$i-1]->getAlias();
00083       }
00084 
00085       return DMInternalURI::getURIWithParams("api/1/spatial_search", $qs,
00086             $representation);
00087    }
00088 
00089 }
 All Data Structures Functions Variables