Phirehose::setLocations PHP Method

setLocations() public method

NOTE: The argument order is Longitude/Latitude (to match the Twitter API and GeoJSON specifications). Applies to: METHOD_FILTER See: http://apiwiki.twitter.com/Streaming-API-Documentation#locations Eg: setLocations(array( array(-122.75, 36.8, -121.75, 37.8), // San Francisco array(-74, 40, -73, 41), // New York ));
public setLocations ( array $boundingBoxes )
$boundingBoxes array
    public function setLocations($boundingBoxes)
    {
        $boundingBoxes = $boundingBoxes === NULL ? array() : $boundingBoxes;
        sort($boundingBoxes);
        // Non-optimal, but necessary
        // Flatten to single dimensional array
        $locationBoxes = array();
        foreach ($boundingBoxes as $boundingBox) {
            // Sanity check
            if (count($boundingBox) != 4) {
                // Invalid - Not much we can do here but log error
                $this->log('Invalid location bounding box: [' . implode(', ', $boundingBox) . ']', 'error');
                return FALSE;
            }
            // Append this lat/lon pairs to flattened array
            $locationBoxes = array_merge($locationBoxes, $boundingBox);
        }
        // If it's changed, make note
        if ($this->locationBoxes != $locationBoxes) {
            $this->filterChanged = TRUE;
        }
        // Set flattened value
        $this->locationBoxes = $locationBoxes;
    }