function api_flickr_photos_geo_possibleCorrections() { $photo_id = get_int64("photo_id"); $photo = _api_flickr_photos_geo_get_photo($photo_id); $type = get_str("place_type"); if (!$type) { api_output_error(999, "Missing place type"); } if (!flickr_places_is_valid_placetype($type)) { api_output_error(999, "Invalid place type"); } # TO DO: calculate based on $type $radius = 1.5; $bbox = geo_utils_bbox_from_point($photo['latitude'], $photo['longitude'], $radius, 'km'); $bbox = implode(",", array($bbox[1], $bbox[0], $bbox[3], $bbox[2])); $method = 'flickr.places.placesForBoundingBox'; $args = array('bbox' => $bbox, 'place_type' => $type); $rsp = flickr_api_call($method, $args); if (!$rsp['ok']) { api_output_error(999, "Flickr API error"); } $possible = array(); if ($rsp['rsp']['places']['total']) { foreach ($rsp['rsp']['places']['place'] as $place) { $possible[] = array('woeid' => $place['woeid'], 'placetype' => $place['place_type'], 'name' => $place['_content']); } } $parent = flickr_places_parent_placetype($type); $out = array('place_type' => $type, 'parent_place_type' => $parent, 'places' => $possible); return api_output_ok($out); }
function flickr_photos_places_contexts_for_user_and_place(&$user, &$place, $more = array()) { $defaults = array('viewer_id' => 0); $more = array_merge($defaults, $more); $more['enforce_geoperms'] = 1; if (!flickr_places_is_valid_placetype($place['place_type'])) { return not_okay("not a valid placetype"); } $query = array("user_id" => $user['id'], $place['place_type'] => $place['woeid']); $map = flickr_photos_geo_context_map(); $contexts = array(); foreach ($map as $ctx => $ignore) { $contexts[$ctx] = 0; } $rsp = flickr_photos_search_facet($query, 'geocontext', $more); if (!$rsp['ok']) { return $rsp; } foreach ($rsp['facets'] as $ctx => $count) { $contexts[$ctx] = $count; } return okay(array('contexts' => $contexts)); }
include "include/init.php"; loadlib("flickr_places"); loadlib("flickr_photos_places"); loadlib("flickr_photos_geo"); if (!$GLOBALS['cfg']['enable_feature_solr'] || !$GLOBALS['cfg']['enable_feature_places']) { error_disabled(); } $flickr_user = flickr_users_get_by_url(); $owner = users_get_by_id($flickr_user['user_id']); $is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0; $GLOBALS['smarty']->assign_by_ref("owner", $owner); $GLOBALS['smarty']->assign("is_own", $is_own); $facet = get_str("facet"); $placetypes = flickr_places_valid_placetypes(); if (!$facet || !flickr_places_is_valid_placetype($facet)) { $rand = rand(1, count($placetypes)); $facet = $placetypes[$rand - 1]; } $GLOBALS['smarty']->assign_by_ref("placetypes", $placetypes); $GLOBALS['smarty']->assign("facet", $facet); # TO DO: easter egg to make 'airports' a valid place type/url # to query by; this will probably mean indexing the place name # in solr which is probably not a bad idea anyway (20111229/straup) $more = array('viewer_id' => $GLOBALS['cfg']['user']['id']); if ($context = get_str("context")) { $map = flickr_photos_geo_context_map("string keys"); if (isset($map[$context])) { $geo_context = $map[$context]; $more['geocontext'] = $geo_context; $GLOBALS['smarty']->assign("context", $context);