From 8d944cdaf59ff0db75745c1169f688f3781ab07a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 27 Jun 2013 13:53:55 +0000 Subject: [PATCH] Add new way for entering lat lon For the admin member edit page I add ability to input the DMS (Degrees Minutes Seconds) for Lat and Lon inputs. This is also updated in geocoder.js to read in and reset these when they move the marker. --- Toolkit/Common.php | 144 +++++++++++ Toolkit/Maps/geoCoder.js | 190 ++++++++++++--- Toolkit/Members/EditMemberInfo.php | 282 ++++++++++++++++------ Toolkit/Members/SearchList.php | 40 +++ Toolkit/Members/templates/editMember.tpl | 20 +- Toolkit/Members/templates/membersList.tpl | 2 + 6 files changed, 567 insertions(+), 111 deletions(-) diff --git a/Toolkit/Common.php b/Toolkit/Common.php index d3cec0c..0ee7610 100644 --- a/Toolkit/Common.php +++ b/Toolkit/Common.php @@ -54,6 +54,150 @@ class Toolkit_Common // }}} + /** + * Convert fload degrees to N/S or E/W Lat/Lon as D, D M, or D M S + * + * @param int $d The decimal lat lon + * @param string $LatLon (Lat or Lon) + * @param string $type (D, DM, or DMS) + * @param int $precision Decimal Precision + * + * @return array (text, dir, deg, min, sec) + */ + static public function f2LatLon($d, $LatLon, $type, $precision) + { + $sign = +1; + if ($d < 0) { + $sign = -1; + } + + switch ($LatLon) { + case 'Lat': + // Is it N or S? + $dir = 'N'; + if ($d < 0) { + $dir = 'S'; + } + + $deg_size = 2; + $dir_opts = array('1' => 'N', '-1' => 'S'); + break; + case 'Lon': + // Is it E or W? + $dir = 'E'; + if ($d < 0) { + $dir = 'W'; + } + + $deg_size = 3; + $dir_opts = array('1' => 'E', '-1' => 'W'); + break; + } + $d = abs($d); + $deg = 0; + $min = 0; + $sec = 0; + $format = "%s %0" . $deg_size . "." . $precision . "f°"; + + if ($type == 'D') { + $deg = $d; + } elseif ($type == 'DM' || $type == 'DMS') { + $deg = (int) $d; + $d = ($d - $deg) * 60; + $min = $d; + $format = "%s %02d° %02.".$precision."f'"; + if ($type == 'DMS') { + $min = (int) $d; + $sec = ($d - $min) * 60; + $format = "%s %0".$deg_size."d° %02d' %02.".$precision."f\""; + } + } + + // Setup possible direction selection + $dir_select = array( + array( + 'value' => 1, + 'name' => $dir_opts[1], + 'default' => ($sign == 1) + ), + array( + 'value' => - 1, + 'name' => $dir_opts[-1], + 'default' => ($sign == - 1) + ) + ); + + return array( + 'text' => $dms = sprintf($format, $dir, $deg, $min, $sec), + 'd_only' => ($sign * ($deg + ($min + $sec / 60) / 60)), + 'dir' => $sign, + 'dir_list' => $dir_select, + 'deg' => $deg, + 'min' => $min, + 'sec' => $sec, + ); + } + + /** + * Converts DMS ( Degrees / minutes / seconds ) + * to decimal format longitude / latitude + * + * @param type $deg + * @param type $min + * @param type $sec + * + * @return array + */ + public static function DMStoDEC($deg, $min, $sec) + { + return $deg + ((($min * 60) + ($sec)) / 3600); + } + + public static function convertLatToDMSString($lat) + { + $coord = Toolkit_Common::DECtoDMS($lat); + if ($coord == 0) { + return false; + } + return sprintf("%d°%d'%d\"%s", $coord[0], $coord[1], $coord[2], $coord[3] ? 'N' : 'S'); + } + + public static function convertLonToDMSString($lon) + { + $coord = Toolkit_Common::DECtoDMS($lon); + if ($coord == 0) { + return false; + } + return sprintf("%d°%d'%d\"%s", $coord[0], $coord[1], $coord[2], $coord[3] ? 'W' : 'E'); + } + + /** + * Converts decimal longitude / latitude to DMS + * (Degrees / minutes / seconds) + * + * This is the piece of code which may appear to + * be inefficient, but to avoid issues with floating + * point math we extract the integer part and the float + * part by using a string function. + * + * @param float $coord lat lon to convert + * + * @return array + */ + public static function DECtoDMS($coord) + { + if ($coord == 0) { + return false; + } + $isnorth = $coord >= 0; + $coord = abs($coord); + $deg = floor($coord); + $coord = ($coord - $deg) * 60; + $min = floor($coord); + $sec = floor(($coord-$min) * 60); + return array($deg, $min, $sec, $isnorth); + } + // {{{ arrayFlatten() /** diff --git a/Toolkit/Maps/geoCoder.js b/Toolkit/Maps/geoCoder.js index 302b839..0187bc5 100644 --- a/Toolkit/Maps/geoCoder.js +++ b/Toolkit/Maps/geoCoder.js @@ -7,15 +7,57 @@ var GLM_GeoMap = { geocoder: null, map: null, setDefaultLat: function(lat) { - GLM_GeoMap.defaultLat = lat; + GLM_GeoMap.defaultLat = lat; }, setDefaultLon: function(lon) { GLM_GeoMap.defaultLon = lon; }, initialize: function() { + console.log('GLM_GeoMap started'); GLM_GeoMap.createMap(); var lat = $("#lat").val(); var lon = $("#lon").val(); +// console.log('Lat: ' + lat); +// console.log('Lon: ' + lon); +// console.log('Loc:' + $("#loc").length); + var latDeg = $("#latDeg"); + var lonDeg = $("#lonDeg"); + var latDir = $("#latDir"); + var lonDir = $("#lonDir"); + var latMin = $("#latMin"); + var lonMin = $("#lonMin"); + var latSec = $("#latSec"); + var lonSec = $("#lonSec"); +// console.log('Lat[deg]: ' + latDeg.val()); +// console.log('Lon[deg]: ' + lonDeg.val()); +// console.log('Lat[dir]: ' + latDir.val()); +// console.log('Lon[dir]: ' + lonDir.val()); +// console.log('Lat[min]: ' + latMin.val()); +// console.log('Lon[min]: ' + lonMin.val()); +// console.log('Lat[sec]: ' + latSec.val()); +// console.log('Lon[sec]: ' + lonSec.val()); + var hemiLat = (latDir.val() == '1') + ? LocationFormatter.NORTH + : LocationFormatter.SOUTH; + console.log(hemiLat); + var lat = LocationFormatter.DMSToDecimal( + parseInt(latDeg.val()), + parseInt(latMin.val()), + parseInt(latSec.val()), + hemiLat + ); + var hemiLon = (lonDir.val() == '1') + ? LocationFormatter.EAST + : LocationFormatter.WEST; + var lon = LocationFormatter.DMSToDecimal( + parseInt(lonDeg.val()), + parseInt(lonMin.val()), + parseInt(lonSec.val()), + hemiLon + ); + console.log('Lat: ' + lat); + console.log('Lon: ' + lon); + if ($("#loc").length > 0) { var location = $("#loc").val(); } else { @@ -35,12 +77,15 @@ var GLM_GeoMap = { } if (lat && lon) { - GLM_GeoMap.createWithLatLon(); + GLM_GeoMap.createWithLatLon(lat, lon); } else if (location) { + console.log('Creating with location' + location); GLM_GeoMap.createWithLocation(location); } else if (street || city || state || zip) { + console.log('Creating with street,city,state,zip'); GLM_GeoMap.createWithAddress(street, city, state, zip); } else { + console.log('Creating with client location'); GLM_GeoMap.createWithClientLocation(); } }, @@ -54,9 +99,9 @@ var GLM_GeoMap = { mapTypeId: google.maps.MapTypeId.ROADMAP }; GLM_GeoMap.map = new google.maps.Map( - document.getElementById("map_canvas"), - myOptions - ); + document.getElementById("map_canvas"), + myOptions + ); }, addMarkerToMap: function(LatLng) { var marker = new google.maps.Marker({ @@ -66,7 +111,7 @@ var GLM_GeoMap = { }); var location = marker.getPosition(); GLM_GeoMap.updateLatLonDiv(location); - google.maps.event.addListener(marker, 'dragend', function(){ + google.maps.event.addListener(marker, 'dragend', function() { var location = marker.getPosition(); GLM_GeoMap.updateLatLonDiv(location); }); @@ -74,48 +119,77 @@ var GLM_GeoMap = { GLM_GeoMap.map.setZoom(15); }, updateLatLonDiv: function(point) { - $("#lat").val(point.lat()); - $("#lon").val(point.lng()); + var latDegrees = point.lat(); + var latDMS = LocationFormatter.decimalLatToDMS(latDegrees); + var lonDegrees = point.lng(); + var lonDMS = LocationFormatter.decimalLongToDMS(lonDegrees); + var latDeg = $("#latDeg"); + var lonDeg = $("#lonDeg"); + var latDir = $("#latDir"); + var lonDir = $("#lonDir"); + var latMin = $("#latMin"); + var lonMin = $("#lonMin"); + var latSec = $("#latSec"); + var lonSec = $("#lonSec"); + var hemiLat = (latDMS.hemi == LocationFormatter.NORTH) + ? 1 + : -1; + var hemiLon = (lonDMS.hemi == LocationFormatter.EAST) + ? 1 + : -1; + // update lat fields + latDeg.val(latDMS.deg); + latMin.val(latDMS.min); + latSec.val(latDMS.sec); + latDir.val(hemiLat); + // update lon fields + lonDeg.val(lonDMS.deg); + lonMin.val(lonDMS.min); + lonSec.val(lonDMS.sec); + lonDir.val(hemiLon); }, createWithClientLocation: function() { // Try HTML5 geolocation if (navigator.geolocation) { + console.log('Found location with HTML5'); navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng( - position.coords.latitude, - position.coords.longitude - ); + position.coords.latitude, + position.coords.longitude + ); GLM_GeoMap.addMarkerToMap(pos); }, function() { GLM_GeoMap.handleNoGeolocation(true); }); + } else { + console.log('Failed finding location with HTML5'); } }, - createWithLatLon: function() { + createWithLatLon: function(lat, lon) { GLM_GeoMap.addMarkerToMap(new google.maps.LatLng( - $("#lat").val(), - $("#lon").val() + lat, + lon )); }, createWithDefaultLatLon: function() { GLM_GeoMap.addMarkerToMap(new google.maps.LatLng( - GLM_GeoMap.defaultLat, - GLM_GeoMap.defaultLon - )); + GLM_GeoMap.defaultLat, + GLM_GeoMap.defaultLon + )); }, createWithLocation: function(address) { GLM_GeoMap.geocoder = new google.maps.Geocoder(); GLM_GeoMap.geocoder.geocode( - {'address': address}, - function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - GLM_GeoMap.map.setCenter(results[0].geometry.location); - GLM_GeoMap.addMarkerToMap(results[0].geometry.location); - } else { - GLM_GeoMap.createWithClientLocation(); - } + {'address': address}, + function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + GLM_GeoMap.map.setCenter(results[0].geometry.location); + GLM_GeoMap.addMarkerToMap(results[0].geometry.location); + } else { + GLM_GeoMap.createWithClientLocation(); } + } ); }, createWithAddress: function(street, city, state, zip) { @@ -134,15 +208,15 @@ var GLM_GeoMap = { } GLM_GeoMap.geocoder = new google.maps.Geocoder(); GLM_GeoMap.geocoder.geocode( - {'address': location}, - function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - GLM_GeoMap.map.setCenter(results[0].geometry.location); - GLM_GeoMap.addMarkerToMap(results[0].geometry.location); - } else { - GLM_GeoMap.createWithClientLocation(); - } + {'address': location}, + function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + GLM_GeoMap.map.setCenter(results[0].geometry.location); + GLM_GeoMap.addMarkerToMap(results[0].geometry.location); + } else { + GLM_GeoMap.createWithClientLocation(); } + } ); }, handleNoGeolocation: function(errorFlag) { @@ -161,4 +235,52 @@ var GLM_GeoMap = { var infowindow = new google.maps.InfoWindow(options); GLM_GeoMap.map.setCenter(options.position); } -} \ No newline at end of file +} + +function LocationFormatter() { +} +; + +LocationFormatter.NORTH = 'N'; +LocationFormatter.SOUTH = 'S'; +LocationFormatter.EAST = 'E'; +LocationFormatter.WEST = 'W'; + +LocationFormatter.roundToDecimal = function(inputNum, numPoints) { + var multiplier = Math.pow(10, numPoints); + return Math.round(inputNum * multiplier) / multiplier; +}; + +LocationFormatter.decimalToDMS = function(location, hemisphere) { + if (location < 0) { + location *= -1; // strip dash '-' + } + var degrees = Math.floor(location); // strip decimal remainer for degrees + var minutesFromRemainder = (location - degrees) * 60; // multiply the remainer by 60 + var minutes = Math.floor(minutesFromRemainder); // get minutes from integer + var secondsFromRemainder = (minutesFromRemainder - minutes) * 60; // multiply the remainer by 60 + var seconds = LocationFormatter.roundToDecimal(secondsFromRemainder, 2); // get minutes by rounding to integer + DMS = {"deg":degrees,"min":minutes,"sec":seconds,"hemi":hemisphere}; + return DMS; +}; + +LocationFormatter.decimalLatToDMS = function(location) { + var hemisphere = (location < 0) ? LocationFormatter.SOUTH : LocationFormatter.NORTH; // south if negative + return LocationFormatter.decimalToDMS(location, hemisphere); +}; + +LocationFormatter.decimalLongToDMS = function(location) { + var hemisphere = (location < 0) ? LocationFormatter.WEST : LocationFormatter.EAST; // west if negative + return LocationFormatter.decimalToDMS(location, hemisphere); +}; + +LocationFormatter.DMSToDecimal = function(degrees, minutes, seconds, hemisphere) { + console.log('DMSToDecimal: ' + + degrees + ' ' + + minutes + ' ' + + seconds + ' ' + + hemisphere); + var ddVal = degrees + minutes / 60 + seconds / 3600; + ddVal = (hemisphere == LocationFormatter.SOUTH || hemisphere == LocationFormatter.WEST) ? ddVal * -1 : ddVal; + return LocationFormatter.roundToDecimal(ddVal, 5); +}; \ No newline at end of file diff --git a/Toolkit/Members/EditMemberInfo.php b/Toolkit/Members/EditMemberInfo.php index e001c4c..dcb83e9 100644 --- a/Toolkit/Members/EditMemberInfo.php +++ b/Toolkit/Members/EditMemberInfo.php @@ -685,13 +685,47 @@ class Toolkit_Members_EditMemberInfo $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { foreach ($row as $k => $v) { - if ($k == 'logo') { - $defaults['old_logo_rmv'] = $v; + switch ($k) { + case 'logo': + $defaults['old_logo_rmv'] = $v; $k = 'image_rmv'; $v = ''.$v.''; - } - $defaults[$k] = $v; + break; + case 'lat': + $latDMS = Toolkit_Common::f2LatLon( + $v, + 'Lat', + 'DMS', + 2 + ); + $sec = (float)sprintf("%01.2f", $latDMS['sec']); + $defaults['lat'] = array( + 'dir' => $latDMS['dir'], + 'deg' => $latDMS['deg'], + 'min' => $latDMS['min'], + 'sec' => (float)$sec + ); + break; + case 'lon': + $latDMS = Toolkit_Common::f2LatLon( + $v, + 'Lon', + 'DMS', + 2 + ); + $sec = (float)sprintf("%01.2f", $latDMS['sec']); + $defaults['lon'] = array( + 'dir' => $latDMS['dir'], + 'deg' => $latDMS['deg'], + 'min' => $latDMS['min'], + 'sec' => (float)$sec + ); + break; + default: + $defaults[$k] = $v; + break; + } } } @@ -931,9 +965,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'description', 'display' => null, 'opts' => array( - 'id' => 'description', - 'rows' => 8, - 'cols' => 43 + 'id' => 'description', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -953,9 +987,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'guide', 'display' => null, 'opts' => array( - 'id' => 'guide', - 'rows' => 8, - 'cols' => 43 + 'id' => 'guide', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -972,9 +1006,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'facilities', 'display' => null, 'opts' => array( - 'id' => 'facilities', - 'rows' => 8, - 'cols' => 43 + 'id' => 'facilities', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -991,9 +1025,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'hours', 'display' => null, 'opts' => array( - 'id' => 'hours', - 'rows' => 8, - 'cols' => 43 + 'id' => 'hours', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -1010,9 +1044,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'directions', 'display' => null, 'opts' => array( - 'id' => 'directions', - 'rows' => 8, - 'cols' => 43 + 'id' => 'directions', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -1029,9 +1063,9 @@ class Toolkit_Members_EditMemberInfo 'name' => 'information', 'display' => null, 'opts' => array( - 'id' => 'information', - 'rows' => 8, - 'cols' => 43 + 'id' => 'information', + 'rows' => 8, + 'cols' => 43 ), 'noCharLimit' => true ); @@ -1109,19 +1143,105 @@ class Toolkit_Members_EditMemberInfo Map It' ); + // create groups for Lat and Lon + $lat[] = array( + 'type' => 'select', + 'name' => 'dir', + 'req' => false, + 'display' => '', + 'opts' => array('1' => 'N', '-1' => 'S'), + 'att' => array('id' => 'latDir'), + 'noCharLimit' => true + ); + $lat[] = array( + 'type' => 'text', + 'name' => 'deg', + 'req' => false, + 'display' => 'Deg', + 'opts' => array( + 'id' => 'latDeg', 'size' => 3, 'maxlength' => 3 + ), + 'noCharLimit' => true + ); + $lat[] = array( + 'type' => 'text', + 'name' => 'min', + 'req' => false, + 'display' => 'Min', + 'opts' => array( + 'id' => 'latMin', 'size' => 2, 'maxlength' => 2 + ), + 'noCharLimit' => true + ); + $lat[] = array( + 'type' => 'text', + 'name' => 'sec', + 'req' => false, + 'display' => 'Sec', + 'opts' => array( + 'id' => 'latSec', 'size' => 2, 'maxlength' => 4 + ), + 'noCharLimit' => true + ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'lat', - 'display' => 'Latitude', - 'opts' => array('id' => 'lat', 'class' => 'text') + 'type' => 'group', + 'req' => false, + 'name' => 'lat', + 'group' => $lat, + 'label' => 'Latitude', + 'seperator' => ' ', + 'appendName' => true, + 'noCharLimit' => true + ); + + $lon[] = array( + 'type' => 'select', + 'name' => 'dir', + 'req' => false, + 'display' => '', + 'opts' => array('1' => 'E', '-1' => 'W'), + 'att' => array('id' => 'lonDir'), + 'noCharLimit' => true + ); + $lon[] = array( + 'type' => 'text', + 'name' => 'deg', + 'req' => false, + 'display' => '', + 'opts' => array( + 'id' => 'lonDeg', 'size' => 3, 'maxlength' => 3 + ), + 'noCharLimit' => true + ); + $lon[] = array( + 'type' => 'text', + 'name' => 'min', + 'req' => false, + 'display' => '', + 'opts' => array( + 'id' => 'lonMin', 'size' => 2, 'maxlength' => 2 + ), + 'noCharLimit' => true + ); + $lon[] = array( + 'type' => 'text', + 'name' => 'sec', + 'req' => false, + 'display' => '', + 'opts' => array( + 'id' => 'lonSec', 'size' => 2, 'maxlength' => 4 + ), + 'noCharLimit' => true ); $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'lon', - 'display' => 'Longitude', - 'opts' => array('id' => 'lon', 'class' => 'text') + 'type' => 'group', + 'req' => false, + 'name' => 'lon', + 'group' => $lon, + 'label' => 'Longitude', + 'seperator' => ' ', + 'appendName' => true, + 'noCharLimit' => true ); // {{{ Main Image @@ -1181,15 +1301,15 @@ class Toolkit_Members_EditMemberInfo $f = array(); $f[] = array( 'element' => '__ALL__', - 'filter' => 'trim' + 'filter' => 'trim' ); $f[] = array( 'element' => 'paypal', - 'filter' => array('Toolkit_Common', 'filterURI') + 'filter' => array('Toolkit_Common', 'filterURI') ); $f[] = array( 'element' => 'url', - 'filter' => array('Toolkit_Common', 'filterURI') + 'filter' => array('Toolkit_Common', 'filterURI') ); $this->setupFilters($f); } @@ -1322,42 +1442,42 @@ class Toolkit_Members_EditMemberInfo 'reset' => false, 'force' => false ); - $r[] = array( - 'element' => 'lat', - 'message' => 'ERROR: Must be a numeric!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'lat', - 'message' => 'ERROR: Latitude out of range!', - 'type' => 'callback', - 'format' => array(&$this, 'checkLatitude'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'lon', - 'message' => 'ERROR: Must be a numeric!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $r[] = array( - 'element' => 'lon', - 'message' => 'ERROR: Longitude out of range!', - 'type' => 'callback', - 'format' => array(&$this, 'checkLongitude'), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); +// $r[] = array( +// 'element' => 'lat', +// 'message' => 'ERROR: Must be a numeric!', +// 'type' => 'numeric', +// 'format' => null, +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); +// $r[] = array( +// 'element' => 'lat', +// 'message' => 'ERROR: Latitude out of range!', +// 'type' => 'callback', +// 'format' => array(&$this, 'checkLatitude'), +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); +// $r[] = array( +// 'element' => 'lon', +// 'message' => 'ERROR: Must be a numeric!', +// 'type' => 'numeric', +// 'format' => null, +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); +// $r[] = array( +// 'element' => 'lon', +// 'message' => 'ERROR: Longitude out of range!', +// 'type' => 'callback', +// 'format' => array(&$this, 'checkLongitude'), +// 'validation' => $this->validationType, +// 'reset' => false, +// 'force' => false +// ); $allowDuplicateMemberNames = $this->config ->getItem('section', 'conf') @@ -2048,15 +2168,21 @@ class Toolkit_Members_EditMemberInfo $this->dbh, $this->tableName ); - $values['city_id'] + $values['city_id'] = ($values['city_id']) ? $values['city_id'] : null; - $values['state_id'] + $values['state_id'] = ($values['state_id']) ? $values['state_id'] : null; - + // need to process the lat lon first + $latInput = $values['lat']; + $values['lat'] = $latInput['dir'] * ($latInput['deg'] + ($latInput['min'] + ($latInput['sec'] / 60)) / 60); + $lonInput = $values['lon']; + $values['lon'] = $lonInput['dir'] * ($lonInput['deg'] + ($lonInput['min'] + ($lonInput['sec'] / 60)) / 60); +// var_dump($values); +// exit; foreach ($values as $k => $v) { switch ($k) { case 'MAX_FILE_SIZE' : @@ -2281,7 +2407,7 @@ class Toolkit_Members_EditMemberInfo // {{{ setLatLngCoords() /** - * Description for setLatLngCoords() + * Turning off the lookup of lat lon for this site * * @param array &$values Values array * @@ -2290,6 +2416,7 @@ class Toolkit_Members_EditMemberInfo */ protected function setLatLngCoords(&$values) { + return $values; $geocoder = new GeocodeYahoo(); $sql = " @@ -2513,7 +2640,10 @@ class Toolkit_Members_EditMemberInfo // before we render the form. That way the // template knows about any errors on the form. $this->validated = $this->validate(); +// var_dump($this); +// exit; if ($this->validated) { +// die('here'); $processed = $this->process(array(&$this, 'processData'), $this->mergeFiles); } @@ -2521,7 +2651,7 @@ class Toolkit_Members_EditMemberInfo // into the form. these values ar calculated and then inserted into the forms // element values. So we need to process the data first and then render the form. $this->setupRenderers(); - +// return $this->template->bufferedOutputObject($this->view); } diff --git a/Toolkit/Members/SearchList.php b/Toolkit/Members/SearchList.php index 5c38e45..4d4c2a8 100644 --- a/Toolkit/Members/SearchList.php +++ b/Toolkit/Members/SearchList.php @@ -346,6 +346,24 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder array(&$this, 'mapIcon') )); + $this->addColumn(new Structures_DataGrid_Column( + 'Latitude', + 'lat', + 'lat', + null, + null, + array(&$this, 'lat') + )); + + $this->addColumn(new Structures_DataGrid_Column( + 'Longitude', + 'lon', + 'lon', + null, + null, + array(&$this, 'lon') + )); + } // }}} @@ -537,6 +555,28 @@ class Toolkit_Members_SearchList extends Toolkit_FlexyDataGridBuilder // }}} + public function lat($data) + { + extract($data['record']); + if ($lat) { + $latitude = Toolkit_Common::f2LatLon($lat, 'Lat', 'DMS', 2); + return $latitude['text']; + } else { + return ''; + } + } + + public function lon($data) + { + extract($data['record']); + if ($lon) { + $longitude = Toolkit_Common::f2LatLon($lon, 'Lat', 'DMS', 2); + return $longitude['text']; + } else { + return ''; + } + } + // {{{ phone() /** diff --git a/Toolkit/Members/templates/editMember.tpl b/Toolkit/Members/templates/editMember.tpl index e03ab42..aa31c07 100644 --- a/Toolkit/Members/templates/editMember.tpl +++ b/Toolkit/Members/templates/editMember.tpl @@ -61,7 +61,7 @@ {elem.label:h} {if:elem.error}{end:} - +
{elem.error:h}
@@ -70,6 +70,24 @@ {gitem.label:h}
{end:} {gitem.html:h} + {if:gitem.isName(#lat[deg]#)} + ° + {end:} + {if:gitem.isName(#lat[min]#)} + ' + {end:} + {if:gitem.isName(#lat[sec]#)} + " + {end:} + {if:gitem.isName(#lon[deg]#)} + ° + {end:} + {if:gitem.isName(#lon[min]#)} + ' + {end:} + {if:gitem.isName(#lon[sec]#)} + " + {end:} {if:elem.separator}{elem.separator:h}{end:} {end:} diff --git a/Toolkit/Members/templates/membersList.tpl b/Toolkit/Members/templates/membersList.tpl index a1f40a7..ea2af06 100644 --- a/Toolkit/Members/templates/membersList.tpl +++ b/Toolkit/Members/templates/membersList.tpl @@ -54,6 +54,8 @@
Terrain: {row[terrain]}
Difficulty: {row[difficulty]}
Dogs Allowed: {row[dogs]}
+
Lat: {row[lat]:h}
+
Lon: {row[lon]:h}