function exif_tools_explode_gps_img_direction($direction, $ref = null)
{
    $direction = exif_tools_rational2float($direction);
    if ($ref == 'M') {
        # uh...
    }
    return $direction;
}
function flickr_photos_search_index_photo(&$photo, $meta = array())
{
    if (!$GLOBALS['cfg']['enable_feature_solr']) {
        return not_okay('search indexing is disabled');
    }
    if (!$meta) {
        $meta = flickr_photos_metadata_load($photo);
    }
    # really exit or just ignore all the $meta stuff below?
    if (!$meta['ok']) {
        return not_okay('failed to load photo metadata');
    }
    $meta = $meta['data']['photo'];
    $doc = array('id' => $photo['id'], 'user_id' => $photo['user_id'], 'title' => $photo['title'], 'perms' => $photo['perms'], 'datetaken' => solr_dates_prep_mysql_datetime($photo['datetaken']), 'dateupload' => solr_dates_prep_mysql_datetime($photo['dateupload']));
    $tags = array();
    $machinetags = array();
    if (isset($meta['tags']['tag'])) {
        foreach ($meta['tags']['tag'] as $tag) {
            $tags[] = $tag['raw'];
            if ($tag['machinetag']) {
                $machinetags = array_merge($machinetags, solr_machinetags_explode($tag['raw']));
            }
        }
    }
    if (count($tags)) {
        $doc['tags'] = $tags;
    }
    if (count($machinetags)) {
        $doc['machinetags'] = $machinetags;
    }
    if ($photo['hasgeo']) {
        $doc['location'] = "{$photo['latitude']},{$photo['longitude']}";
        $doc['accuracy'] = $photo['accuracy'];
        $doc['geoperms'] = $photo['geoperms'];
        $doc['geocontext'] = $photo['geocontext'];
        foreach (array('neighbourhood', 'locality', 'county', 'region', 'country', 'continent') as $place) {
            if (isset($meta['location'][$place])) {
                $doc[$place] = $meta['location'][$place]['woeid'];
            }
        }
        if ($place = flickr_places_get_by_woeid($photo['woeid'])) {
            $doc['timezone'] = $place['timezone'];
            $doc['place'] = $place['place_url'];
        }
    }
    # pull in some EXIF data (if present)
    $rsp = flickr_photos_exif_read($photo);
    if ($rsp['ok']) {
        $exif = $rsp['rows'];
        if (isset($exif['Make'])) {
            if ($make = exif_tools_scrub_string($exif['Make'])) {
                $doc['camera_make'] = ucwords($make);
            }
        }
        if (isset($exif['Model'])) {
            if ($model = exif_tools_scrub_string($exif['Model'])) {
                $doc['camera_model'] = $model;
            }
        }
        # EXIF: what else?
        if (isset($exif['FocalLength'])) {
            $doc['focal_length'] = exif_tools_rational2float($exif['FocalLength']);
        }
        if (isset($exif['ApetureValue'])) {
            $doc['apeture'] = exif_tools_rational2float($exif['ApetureValue']);
        }
        if (isset($exif['ShutterSpeedValue'])) {
            $doc['shutter_speed'] = exif_tools_rational2float($exif['ShutterSpeedValue']);
        }
        if (isset($exif['ISOSpeedRatings'])) {
            $doc['iso_speed'] = intval($exif['ISOSpeedRatings']);
        }
        # http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/GPS.html
        if (isset($exif['GPSAltitude'])) {
            $altitude = exif_tools_explode_gps_altitude($exif['GPSAltitude'], $exif['GPSAltitudeRef']);
            $doc['altitude'] = $altitude;
        }
        if (isset($exif['GPSImgDirection'])) {
            $direction = exif_tools_explode_gps_img_direction($exif['GPSImgDirection'], $exif['GPSImgDirectionRef']);
            $doc['direction'] = $direction;
        }
    }
    # go!
    $docs = array($doc);
    $rsp = solr_add($docs);
    return $rsp;
}