$query = "SELECT uuid, array_to_string(categories, ',') as categories, thumbnail, st_x(location::geometry) as lon, st_y(location::geometry) as lat, st_astext(geometry) as geometry, timestamp, " . "source_name, source_website, source_id, source_license " . "FROM {$fw_core_tbl} WHERE ST_DWithin(location, ST_GeogFromText('POINT({$lon} {$lat})'), {$radius}) AND categories && '{" . $common_params['categories'] . "}' LIMIT " . $common_params['max_results']; } else { $query = "SELECT uuid, array_to_string(categories, ',') as categories, " . "thumbnail, st_x(location::geometry) as lon, st_y(location::geometry) " . "as lat, st_astext(geometry) as geometry, timestamp, userid, " . "source_name, source_website, source_id, source_license " . "FROM {$fw_core_tbl} WHERE ST_DWithin(location, ST_GeogFromText(" . "'POINT({$lon} {$lat})'), {$radius}) LIMIT " . $common_params['max_results']; } // echo "<br>" . $query; $core_result = pg_query($query); if (!$core_result) { header("HTTP/1.0 500 Internal Server Error"); $error = pg_last_error(); die($error); } $incl_fw_core = FALSE; if (in_array("fw_core", $common_params['components'])) { $incl_fw_core = TRUE; } $json_struct = fw_core_pgsql2array($core_result, $incl_fw_core); if ($incl_fw_core) { $fw_core_intl_tbl = $db_opts['fw_core_intl_table_name']; foreach ($json_struct['pois'] as $core_poi_uuid => $fw_core_content) { $poi_data = get_fw_core_intl_properties_for_poi($pgcon, $fw_core_intl_tbl, $core_poi_uuid, $fw_core_content); $json_struct['pois'][$core_poi_uuid] = $poi_data; } } $mongodb = connectMongoDB($db_opts['mongo_db_name']); //Time constraints based filtering if (isset($common_params['begin_time']) and isset($common_params['end_time']) and isset($common_params['min_minutes'])) { $begin_time = $common_params['begin_time']; $end_time = $common_params['end_time']; foreach (array_keys($json_struct["pois"]) as $uuid) { $fw_time = getComponentMongoDB($mongodb, "fw_time", $uuid, false); //Remove POI from $json_struct as it does not contain fw_time...
$poi_uuid = str_replace("'", "", $poi_uuid); $data[$poi_uuid] = array(); } $db_opts = get_db_options(); //Include fw_core in result data... if (in_array("fw_core", $components)) { $pgcon = connectPostgreSQL($db_opts["sql_db_name"]); $fw_core_tbl = $db_opts['fw_core_table_name']; $query = "SELECT uuid, array_to_string(categories, ',') as categories, thumbnail, st_x(location::geometry) as lon, st_y(location::geometry) as lat, st_astext(geometry) as geometry, timestamp, " . "source_name, source_website, source_id, source_license FROM {$fw_core_tbl} WHERE uuid IN ({$esc_ids})"; $core_result = pg_query($query); if (!$core_result) { header("HTTP/1.0 500 Internal Server Error"); $error = pg_last_error(); die($error); } $core_json_struct = fw_core_pgsql2array($core_result, TRUE); $core_pois = $core_json_struct['pois']; $fw_core_intl_tbl = $db_opts['fw_core_intl_table_name']; foreach ($core_pois as $core_poi_uuid => $fw_core_content) { $poi_data = get_fw_core_intl_properties_for_poi($pgcon, $fw_core_intl_tbl, $core_poi_uuid, $fw_core_content); $data[$core_poi_uuid] = $poi_data; } } //Handle other components from MongoDB... $mongodb = connectMongoDB($db_opts['mongo_db_name']); foreach ($components as $component) { //skip fw_core, as it hase been already handled... if ($component == "fw_core") { continue; } foreach (array_keys($data) as $uuid) {