コード例 #1
0
 public function load($area, $subject, $longBR, $latBR, $longTL, $latTL)
 {
     $geodatabase = DatabaseFactory::getFactory()->getGeoConnection();
     $table_name = $area . "_" . $subject;
     /*
     if ($area == "city") 
         { 
            $table_name = $subject;
            
         }
     if ($area == "county") 
         { 
            $table_name = "oc_" . $subject;
            
         }
     */
     $collection = $geodatabase->{$table_name};
     /*
         if(!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)){
     
            //$query = GeoQuery::findbybox(-117.91733264923096,33.676568503347546,-117.90239810943604,33.68606772497501);
           $query = GeoQuery::findbybox($longBR,  $latBR,  $longTL, $latTL);
           $count_ = $collection->count($query);
         }
        else {
            // in case of not box coordinate provide, will find all record
            $query=null;
            $count_ = $collection->count();
        }
     */
     $query = GeoQuery::findbybox($longBR, $latBR, $longTL, $latTL);
     $count_ = $collection->count($query);
     // $count_ = $collection->getSize();
     $_max_row_count = Config::get('Max_Row_Count');
     if ($count_ > 0 and $count_ < $_max_row_count) {
         if (!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)) {
             $cursor = $collection->find($query);
         } else {
             $cursor = $collection->find();
         }
         // iterate through the results
         $result = "{ \"type\": \"FeatureCollection\",\"features\": [";
         foreach ($cursor as $document) {
             //echo $document["properties"] . "\n";
             //print_r($document);
             //echo json_encode($document);
             $result = $result . json_encode($document) . ",";
         }
         $result = substr($result, 0, -1);
         $result = $result . "]}";
         echo $result;
     } else {
         echo $count_;
     }
     //else
 }
コード例 #2
0
ファイル: mongo1.php プロジェクト: hoogw/civilgis_php_0
        if (!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)) {
            $latTL = floatval($latTL);
            $longTL = floatval($longTL);
            $latBR = floatval($latBR);
            $longBR = floatval($longBR);
            // TL top-left  BR bottom-right
            $lowerLeft = array($longBR, $latBR);
            $upperLeft = array($longBR, $latTL);
            $upperRight = array($longTL, $latTL);
            $lowerRight = array($longTL, $latBR);
            $rectangleCoordinates = array(array($lowerLeft, $upperLeft, $upperRight, $lowerRight, $lowerLeft));
            $polygonGeometry = array('$geometry' => array('type' => 'Polygon', 'coordinates' => $rectangleCoordinates));
            $cond = array('geometry' => array('$geoWithin' => $polygonGeometry));
        }
        //if
        return $cond;
    }
}
//class
$query = GeoQuery::findbybox(-117.91733264923096, 33.676568503347546, -117.90239810943604, 33.68606772497501);
$count_ = $collection->count($query);
$cursor = $collection->find($query)->limit(200);
// iterate through the results
$result = "{ \"type\": \"FeatureCollection\",\"features\": [";
foreach ($cursor as $document) {
    $result = $result . json_encode($document) . ",";
}
$result = substr($result, 0, -1);
$result = $result . "]}";
echo $result;
//echo $count_;
コード例 #3
0
 public function loadall_mobile($area, $subject, $longBR, $latBR, $longTL, $latTL)
 {
     $geodatabase = DatabaseFactory::getFactory()->getGeoConnection();
     $table_name = $area . "_" . $subject;
     $collection = $geodatabase->{$table_name};
     $query = GeoQuery::findbybox($longBR, $latBR, $longTL, $latTL);
     $count_ = $collection->count($query);
     // $count_ = $collection->getSize();
     $_max_row_count = Config::get('Max_Row_Count_mobile');
     // loadall generate large amount of data here.
     if ($count_ > 0 and $count_ < $_max_row_count) {
         if (!empty($latTL) && !empty($longTL) && !empty($latBR) && !empty($longBR)) {
             $cursor = $collection->find($query);
         } else {
             $cursor = $collection->find();
         }
         // iterate through the results
         $result = "{ \"type\": \"FeatureCollection\",\"features\": [";
         foreach ($cursor as $document) {
             $result = $result . json_encode($document) . ",";
         }
         $result = substr($result, 0, -1);
         $result = $result . "]}";
         echo $result;
     } else {
         echo $count_;
     }
     //else
 }