本文整理汇总了PHP中map::reverse_geocode方法的典型用法代码示例。如果您正苦于以下问题:PHP map::reverse_geocode方法的具体用法?PHP map::reverse_geocode怎么用?PHP map::reverse_geocode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map
的用法示例。
在下文中一共展示了map::reverse_geocode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __response_create_report
/**
* Create a report and assign it to one or more categories and set verification
*/
public function __response_create_report($vars)
{
$categories = array();
if (isset($vars['add_category'])) {
$categories = $vars['add_category'];
}
$verify = 0;
if (isset($vars['verify'])) {
$verify = (int) $vars['verify'];
}
$approve = 0;
if (isset($vars['approve'])) {
$approve = (int) $vars['approve'];
}
// Grab the location_id or create one if we can
$location_id = 0;
if (isset($this->data->location_id)) {
$location_id = $this->data->location_id;
} elseif (isset($this->data->latitude) and isset($this->data->longitude)) {
$location_name = map::reverse_geocode($this->data->latitude, $this->data->longitude);
// In case our location name is too long, chop off the end
$location_name = substr_replace($location_name, '', 250);
$location_data = (object) array('location_name' => $location_name, 'latitude' => $this->data->latitude, 'longitude' => $this->data->longitude);
$location = new Location_Model();
reports::save_location($location_data, $location);
$location_id = $location->id;
}
// We can only create reports if we have location.
if ($location_id == FALSE or $location_id == 0) {
return false;
}
// Build title
// Build title & description
// If this is a message
if (isset($this->data->message)) {
$incident_title = $this->data->message;
$incident_description = $this->data->message;
$incident_date = $this->data->message_date;
// If we're got more message detail, make that the description
if (!empty($message->message_detail)) {
$incident_description = $this->data->message_detail;
}
} elseif (isset($this->data->item_title)) {
$incident_title = html::strip_tags(html_entity_decode(html_entity_decode($this->data->item_title, ENT_QUOTES)));
$incident_description = html::clean(html_entity_decode($this->data->item_description, ENT_QUOTES));
$incident_date = $this->data->item_date;
}
// Override title from action options
if (!empty($vars['report_title'])) {
$incident_title = $vars['report_title'];
}
// Save Incident
$incident = new Incident_Model();
$incident->location_id = $location_id;
$incident->incident_title = $incident_title;
$incident->incident_description = $incident_description;
$incident->incident_date = $incident_date;
$incident->incident_active = $approve;
$incident->incident_verified = $verify;
$incident->incident_dateadd = date("Y-m-d H:i:s", time());
$incident->save();
// Conflicted.. do I run report add here? Potential to create a mess with action triggers?
//Event::run('ushahidi_action.report_add', $incident);
// Save media
if (isset($this->data->item_title)) {
$news = new Media_Model();
$news->location_id = $incident->location_id;
$news->incident_id = $incident->id;
$news->media_type = 4;
// News
$news->media_link = $this->data->item_link;
$news->media_date = $this->data->item_date;
$news->save();
}
$incident_id = $incident->id;
foreach ($categories as $category_id) {
// Assign Category
Incident_Category_Model::assign_category_to_incident($incident_id, $category_id);
}
// Link message with incident?
if (isset($this->data->message) and isset($this->data->id)) {
$message = new Message_Model($this->data->id);
$message->incident_id = $incident_id;
$message->save();
} elseif (isset($this->data->item_title) and isset($this->data->id)) {
$item = new Feed_Item_Model($this->data->id);
$item->incident_id = $incident_id;
$item->save();
}
return TRUE;
}
示例2: __response_create_report
/**
* Create a report and assign it to one or more categories and set verification
*/
public function __response_create_report($vars)
{
$categories = array();
if (isset($vars['add_category'])) {
$categories = $vars['add_category'];
}
$verify = 0;
if (isset($vars['verify'])) {
$verify = (int) $vars['verify'];
}
$approve = 0;
if (isset($vars['approve'])) {
$approve = (int) $vars['approve'];
}
// Grab the location_id or create one if we can
$location_id = 0;
if (isset($this->data->location_id)) {
$location_id = $this->data->location_id;
} elseif (isset($this->data->latitude) and isset($this->data->longitude)) {
$location_name = map::reverse_geocode($this->data->latitude, $this->data->longitude);
// In case our location name is too long, chop off the end
$location_name = substr_replace($location_name, '', 250);
$location_data = (object) array('location_name' => $location_name, 'latitude' => $this->data->latitude, 'longitude' => $this->data->longitude);
$location = new Location_Model();
reports::save_location($location_data, $location);
$location_id = $location->id;
}
// We can only create reports if we have location.
if ($location_id == FALSE or $location_id == 0) {
return false;
}
// Save Incident
$incident = new Incident_Model();
$incident->location_id = $location_id;
$incident->incident_title = $vars['report_title'];
$incident->incident_description = $this->data->message;
$incident->incident_date = $this->data->message_date;
$incident->incident_active = $approve;
$incident->incident_verified = $verify;
$incident->incident_dateadd = date("Y-m-d H:i:s", time());
$incident->save();
// Conflicted.. do I run report add here? Potential to create a mess with action triggers?
//Event::run('ushahidi_action.report_add', $incident);
$incident_id = $incident->id;
foreach ($categories as $category_id) {
// Assign Category
Incident_Category_Model::assign_category_to_incident($incident_id, $category_id);
}
// Link message with incident?
if (isset($this->data->message) and isset($this->data->id)) {
$message = new Message_Model($this->data->id);
$message->incident_id = $incident_id;
$message->save();
}
return TRUE;
}