+ function setRoute($aRoutePoints, $fRouteWidth)
+ {
+ $this->aViewBox = false;
+
+ $this->sViewboxCentreSQL = "ST_SetSRID('LINESTRING(";
+ $sSep = '';
+ foreach($this->aRoutePoints as $aPoint)
+ {
+ $fPoint = (float)$aPoint;
+ $this->sViewboxCentreSQL .= $sSep.$fPoint;
+ $sSep = ($sSep == ' ') ? ',' : ' ';
+ }
+ $this->sViewboxCentreSQL .= ")'::geometry,4326)";
+
+ $this->sViewboxSmallSQL = 'st_buffer('.$this->sViewboxCentreSQL;
+ $this->sViewboxSmallSQL .= ','.($fRouteWidth/69).')';
+
+ $this->sViewboxLargeSQL = 'st_buffer('.$this->sViewboxCentreSQL;
+ $this->sViewboxLargeSQL .= ','.($fRouteWidth/30).')';
+ }
+
+ function setViewbox($aViewbox)
+ {
+ $this->aViewBox = array_map('floatval', $aViewbox);
+
+ $fHeight = $this->aViewBox[0] - $this->aViewBox[2];
+ $fWidth = $this->aViewBox[1] - $this->aViewBox[3];
+ $aBigViewBox[0] = $this->aViewBox[0] + $fHeight;
+ $aBigViewBox[2] = $this->aViewBox[2] - $fHeight;
+ $aBigViewBox[1] = $this->aViewBox[1] + $fWidth;
+ $aBigViewBox[3] = $this->aViewBox[3] - $fWidth;
+
+ $this->sViewboxCentreSQL = false;
+ $this->sViewboxSmallSQL = "ST_SetSRID(ST_MakeBox2D(ST_Point(".$this->aViewBox[0].",".$this->aViewBox[1]."),ST_Point(".$this->aViewBox[2].",".$this->aViewBox[3].")),4326)";
+ $this->sViewboxLargeSQL = "ST_SetSRID(ST_MakeBox2D(ST_Point(".$aBigViewBox[0].",".$aBigViewBox[1]."),ST_Point(".$aBigViewBox[2].",".$aBigViewBox[3].")),4326)";
+ }
+