Exemple #1
0
function getFeaturesForTimeLine($layer_tablename,$tlCol,$tlStartDate,$tlEndDate,$BBOX){
	$BBOXES = GenerateBBoxes($BBOX,10);
	$cnt = count($BBOXES);
	$fids = array();
	for ($i=0; $i<$cnt; $i++) {
    	$query = "SELECT ".AUTO_DBCOL_PREFIX."id FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s')) AND %s between '%s' and '%s'";
    	$query_args = array($layer_tablename, $BBOXES[$i], $layer_tablename, $tlCol, $tlStartDate, $tlEndDate);
    	$result_db = db_query($query, $query_args);
    	while ($data = db_fetch_object($result_db)) {
      		$fids[] = $data->{AUTO_DBCOL_PREFIX.'id'};
    	}
  	}
  	return implode(",", $fids);

}
Exemple #2
0
function getMapPoints($table,$BBOX,$search_ids,$tl_col,$tlStartDate,$tlEndDate){
	$BBOXES = GenerateBBoxes($BBOX,10);
	$cnt = count($BBOXES);
	$pointlist = array();
	for ($i=0; $i<$cnt; $i++) {
		if ($search_ids != '') {
			$query = "SELECT ".AUTO_DBCOL_PREFIX."id,astext(".AUTO_DBCOL_PREFIX."topology) as location FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s')) AND ".AUTO_DBCOL_PREFIX."id in(%s) ";
      $query_args = array($table, $BBOXES[$i], $table, $search_ids);
		} else {
      if($tl_col != '') {



        $query = "SELECT ".AUTO_DBCOL_PREFIX."id,astext(".AUTO_DBCOL_PREFIX."topology) as location FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s')) AND %s between '%s' and '%s'";
        $query_args = array($table, $BBOXES[$i], $table, $tlCol, $tlStartDate, $tlEndDate);
      } else {
        $query = "SELECT ".AUTO_DBCOL_PREFIX."id,astext(".AUTO_DBCOL_PREFIX."topology) as location FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s'))";
        $query_args = array($table, $BBOXES[$i], $table);
      }
		}

		$result_db = db_query($query, $query_args);
		$no =0;
		$point ='';
		$loc='';
		while ($user_data = db_fetch_object($result_db))
		{
				$id= 'REAL|'.$user_data->{AUTO_DBCOL_PREFIX.'id'}.'_';
				$str = $id;
				$loc='';
				$loc = $user_data->location;
				$loc = str_replace('MULTIPOINT(','',$loc);
				$loc = str_replace('POINT(','',$loc);
				$loc = str_replace(' ', ',', $loc);
				$loc = str_replace(')', ';', $loc);
				$str .= $loc;
				$point .= $str;
				$no++;
		}

		if ($no < 5)
		{

			print_r($point);
		}
		else
		{
			$point ='';
			$BBOX = $BBOXES[$i];
			//Do one more iteration
			$NewBBOXES = GenerateBBoxes($BBOX,2);

			$counter = count($NewBBOXES);
			$Newpointlist = array();
			for ($j=0; $j<$counter; $j++) {

				if($search_ids != '') {

          $query = "SELECT ".AUTO_DBCOL_PREFIX."id,astext(".AUTO_DBCOL_PREFIX."topology) as location FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s')) AND ".AUTO_DBCOL_PREFIX."id in(%s)";
          $query_args = array($table, $NewBBOXES[$j], $table, $search_ids);
				} else {

          $query = "SELECT ".AUTO_DBCOL_PREFIX."id,astext(".AUTO_DBCOL_PREFIX."topology) as location FROM \"%s\" where ".AUTO_DBCOL_PREFIX."topology && setSRID('BOX3D(%s)'::box3d, (select srid from geometry_columns where f_table_name = '%s'))";
          $query_args = array($table, $NewBBOXES[$j], $table);
				}

				$newresult_db = db_query($query, $query_args);
				$newno =0;
				$newpoint ='';
				$newloc='';
				while ($newuser_data = db_fetch_object($newresult_db))
				{

					    $newid= 'REAL|'.$newuser_data->{AUTO_DBCOL_PREFIX.'id'}.'_';
						$newstr = $newid;
						$newloc='';
						$newloc = $newuser_data->location;
						$newloc = str_replace('MULTIPOINT(','',$newloc);
						$newloc = str_replace('POINT(','',$newloc);
						$newloc = str_replace(' ', ',', $newloc);
						$newloc = str_replace(')', ';', $newloc);
						$newstr .= $newloc;
						$newpoint .= $newstr;
						$Newpointlist[$newno] = $newloc;
						$newno++;
				}
				if ($newno < 4)
				{
					print_r($newpoint);

				}
				else
				{

					$newpoint = '';
					$newpoint.= "VIRTUAL|".$newno. "!". $NewBBOXES[$j];
					$newpoint.= "_". GetMedianPoint($Newpointlist);
					print_r($newpoint);
				}

			}
		}
	}

}