dmBridge PHP API
UNLVSpatialJSONOutputV1.php
00001 <?php
00002 #
00003 # UNLVSpatial: a dmBridge module for spatial content
00004 # Copyright © 2010 Board of Regents of the Nevada System of Higher
00005 # Education, on behalf of the University of Nevada, Las Vegas
00006 #
00007 
00012 class UNLVSpatialJSONRepresentationV1 extends DMJSONRepresentationV1 implements DMHTTPRepresentationTransformer {
00013 
00018    public function transformObject(DMObject $obj) {
00019       // build the JSON structure, but don't return it
00020       parent::transformObject($obj);
00021 
00022       $this->json_array['dmBridgeResponse']['dmObject']['bounds'] = array(
00023          'lat_n' => $obj->getSpatialNorthLat(),
00024          'lat_s' => $obj->getSpatialSouthLat(),
00025          'long_w' => $obj->getSpatialWestLong(),
00026          'long_e' => $obj->getSpatialEastLong()
00027       );
00028 
00029       return $this->output();
00030    }
00031 
00036    public function transformSpatialResults(UNLVSpatialQuery $q) {
00037       // results
00038       $this->addKey('page', $q->getPage());
00039       $this->addKey('resultsPerPage', $q->getNumResultsPerPage());
00040       $this->addKey('numPages', $q->getNumPages());
00041       $this->addKey('total', $q->getNumResults());
00042 
00043       $data = array();
00044       foreach ($q->getSearchResults() as $obj) {
00045          $data[] = array(
00046             'alias' => $obj->getCollection()->getAlias(),
00047             'pointer' => $obj->getPtr(),
00048             'href' => $obj->getURI(),
00049             'bounds' => array(
00050                'lat_n' => $obj->getSpatialNorthLat(),
00051                'lat_s' => $obj->getSpatialSouthLat(),
00052                'long_w' => $obj->getSpatialWestLong(),
00053                'long_e' => $obj->getSpatialEastLong()
00054             ),
00055          );
00056       }
00057       $this->addKey('results', $data);
00058 
00059       return $this->output();
00060    }
00061 
00062 }
 All Data Structures Functions Variables