Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp of the geocoder system #2320

Merged
merged 28 commits into from
Apr 23, 2017
Merged

Revamp of the geocoder system #2320

merged 28 commits into from
Apr 23, 2017

Conversation

DawoudIO
Copy link
Contributor

@DawoudIO DawoudIO commented Apr 17, 2017

  • Moving to willdurand/geocoder
  • Auto update Geo Location on Family Create / Update only
  • Update Maps
  • Update Update Geo Location for missing locations
  • Now we have an option for Google Maps or Bing Maps
  • Added Bing API Key
  • Moved Map zoom level to config
  • Updated Family/Person logic

closes #2314
closes #582
closes #1867
closes #2259
closes #2322

// Function takes latitude and longitude
// of two places as input and returns the
// distance in miles.
public static function LatLonDistance($lat1, $lon1, $lat2, $lon2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are copy/past form the other geocode.php file i'm not sure how useful the data is

@@ -507,18 +506,18 @@ class="fa fa-cart-plus"></i> <?= gettext("Add All Family Members to Cart") ?></a
<?= $item['text'] ?>
</div>

<?php if (($_SESSION['bNotes']) && ($item["editLink"] != "" || $item["deleteLink"] != "")) {
<?php if (($_SESSION['bNotes']) && (isset($item["editLink"]) || isset($item["deleteLink"]))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to fix errors in the logs

@@ -298,7 +298,7 @@

<script src="<?= SystemURLs::getRootPath() ?>/skin/locale/<?= $localeInfo->getLocale() ?>.js"></script>

<?php if ($sGlobalMessage) {
<?php if (isset($sGlobalMessage)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing log errors

if (SystemConfig::getValue('nChurchLatitude') == '' || SystemConfig::getValue('nChurchLongitude') == '') {
require 'Include/GeoCoder.php';
$myAddressLatLon = new AddressLatLon();
<div class="callout callout-info">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added exra info to link to the update all lat/lon

@@ -72,6 +63,8 @@
//Map all the families
$families = FamilyQuery::create()
->filterByDateDeactivated(null)
->filterByLatitude(0, Criteria::NOT_EQUAL)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we no longer update on the fly, filter out bad lat/lon

<?php

foreach ($families as $family) {
echo '<li><a href="'.$family->getViewURI().'">' . $family->getName() . '</a> ' . $family->getAddress() . '</li>';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added link to it is faster to fix the bad addresses

@@ -40,7 +40,8 @@
"setasign/fpdf": "1.8.1",
"phpmailer/phpmailer": "5.2.*",
"verot/class.upload.php": "dev-master",
"ifsnop/mysqldump-php": "2.*"
"ifsnop/mysqldump-php": "2.*",
"willdurand/geocoder": "3.3.*"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new lib

@DawoudIO DawoudIO modified the milestones: 2.7.1, 2.7.0 Apr 19, 2017

use ChurchCRM\Utils\GeoUtils;

class ChurchMetaData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

"bUseGoogleGeocode" => new ConfigItem(56, "bUseGoogleGeocode", "boolean", "1", gettext("Set true to use the Google geocoder. Set false to use rpc.geocoder.us.")),
"sISTusername" => new ConfigItem(54, "sISTusername", "text", "username", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Username for") . " - https://www.intelligentsearch.com/Hosted/User"),
"sISTpassword" => new ConfigItem(55, "sISTpassword", "text", "", gettext("Intelligent Search Technolgy, Ltd. CorrectAddress Password for") . " - https://www.intelligentsearch.com/Hosted/User"),
"sGeoCoderProvider" => new ConfigItem(56, "sGeoCoderProvider", "choice", "GoogleMaps", gettext("Select GeoCoder Provider") . " - https://github.com/geocoder-php/Geocoder/blob/3.x/README.md#address-based-providers", '{"Choices":["GoogleMaps", "BingMaps"]}'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

$this->setLatitude($output->results[0]->geometry->location->lat);
$this->setLongitude($output->results[0]->geometry->location->lng);
public function updateLanLng() {
if (!empty($this->getAddress()) && (!$this->hasLatitudeAndLongitude())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we want to update the lat/lng of an existing family?

$this->setLongitude($output->results[0]->geometry->location->lng);
public function updateLanLng() {
if (!empty($this->getAddress()) && (!$this->hasLatitudeAndLongitude())) {
$latLng = GeoUtils::getLatLong($this->getAddress());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes a traceback:

vagrant@scotchbox:~$ tail -f /tmp/ChurchCRM.log
[2017-04-18 21:06:22] defaultLogger.INFO: INSERT INTO note_nte (nte_ID, nte_per_ID, nte_Text, nte_DateEntered, nte_EnteredBy, nte_Type) VALUES (NULL, 2, 'Created via Family', '2017-04-18 21:06:22.000000', 1, 'create') [] []
[2017-04-18 21:06:22] defaultLogger.INFO: INSERT INTO note_nte (nte_ID, nte_per_ID, nte_Text, nte_DateEntered, nte_EnteredBy, nte_Type) VALUES (NULL, 3, 'Created via Family', '2017-04-18 21:06:22.000000', 1, 'create') [] []
[2017-04-18 21:06:22] defaultLogger.INFO: INSERT INTO note_nte (nte_ID, nte_fam_ID, nte_Text, nte_DateEntered, nte_EnteredBy, nte_Type) VALUES (NULL, 1, 'Created', '2017-04-18 21:06:22.000000', 1, 'create') [] []
[2017-04-18 21:06:22] defaultLogger.INFO: SELECT fam_ID, fam_Name, fam_Address1, fam_Address2, fam_City, fam_State, fam_Zip, fam_Country, fam_HomePhone, fam_WorkPhone, fam_CellPhone, fam_Email, fam_WeddingDate, fam_DateEntered, fam_DateLastEdited, fam_EnteredBy, fam_EditedBy, fam_scanCheck, fam_scanCredit, fam_SendNewsLetter, fam_DateDeactivated, fam_OkToCanvass, fam_Canvasser, fam_Latitude, fam_Longitude, fam_Envelope FROM family_fam WHERE fam_ID = '1' [] []
[18-Apr-2017 21:06:22 America/New_York] PHP Fatal error:  Uncaught Error: Class 'ChurchCRM\Utils\CurlHttpAdapter' not found in /var/www/public/ChurchCRM/utils/GeoUtils.php:15
Stack trace:
#0 /var/www/public/ChurchCRM/model/ChurchCRM/Family.php(298): ChurchCRM\Utils\GeoUtils::getLatLong('4222 Clinton Wa...')
#1 /var/www/public/FamilyEditor.php(442): ChurchCRM\Family->updateLanLng()
#2 {main}
  thrown in /var/www/public/ChurchCRM/utils/GeoUtils.php on line 15

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also what's causing the travis tests to fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya bad last min refactor ... i just fixed it

@DawoudIO
Copy link
Contributor Author

This should good tongo

@crossan007 crossan007 modified the milestones: 2.7.1, 2.7.2 Apr 23, 2017
@crossan007 crossan007 merged commit b14ed3f into master Apr 23, 2017
@ghost ghost removed the In Review label Apr 23, 2017
@crossan007 crossan007 deleted the feature/update-family-latlon branch April 23, 2017 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment