public function addProblem($problem, $category, $name, $email, $x, $y) { if ($this->isValid()) { $xy = reproject($x, $y, "4326", "3857"); $q = "INSERT INTO hampshire_problems(row_gid,problem,category,x,y," . "subdate) VALUES (" . $this->the_data["properties"]["gid"] . ",'{$problem}','{$category}'," . $xy[0] . "," . $xy[1] . ",NOW()) "; pg_query($q); $msg = "Parish: " . $this->the_data["properties"]["parish"] . "\n" . "ROW number: " . $this->the_data["properties"]["routeno"] . "\nROW type: " . $this->the_data["properties"]["row_type"] . "\n\nCategory: {$category}\n\nProblem: {$problem}\n\n"; $c = new ConversionsLatLong(); $osgb = $c->wgs84_to_osgb36($y, $x); //$gr = $c->osgb36_to_gridref($osgb[0],$osgb[1]); $msg .= "Grid ref: easting " . round($osgb[0]) . " northing " . round($osgb[1]) . "\n\n"; $msg .= "Reported By: {$name} (email {$email})"; if ($this->the_data["properties"]["county"] == "Hampshire") { mail(HANTS_EMAIL, "Right Of Way problem reported via FixMyPaths", $msg); } } }
function process_page($html) { $dom = new simple_html_dom(); $dom->load($html); $apps = array(); global $authority_code; global $nearby_api_key; foreach ($dom->find("table[class='AppDetailsTable'] tr") as $row) { # Man, this is hacky, but I'm not using dom here in case 'td' shows in plaintext of var if (stristr($row, 'FINALISED') || stristr($row, 'CONDITIONAL') || stristr($row, 'APPEALED') || stristr($row, 'WITHDRAWN') || stristr($row, 'NEW<') || stristr($row, 'APPROVED') || stristr($row, 'REFUSED')) { $appref = $authority_code . substr($row->children[0]->plaintext, 0, 2) . "/" . substr($row->children[0]->plaintext, 2); $rawappref = trim($row->children[0]->plaintext); $url = "http://planning.corkcity.ie/InternetEnquiry/rpt_ViewApplicDetails.asp?validFileNum=1&app_num_file=" . $rawappref; $rawdate = substr($row->children[4]->plaintext, 0, 10); $date = substr($rawdate, -4) . "-" . substr($rawdate, 3, 2) . "-" . substr($rawdate, 0, 2); $applicant = trim($row->children[5]->plaintext); $address = str_replace("<br>", ",", str_replace("<BR>", ",", $row->children[6]->innertext)); #print $row; #print "row"; #print $row; #print $row->children[15]->innertext; #$sizedetails = $row->children[15]->innertext; # Now fetch additional information. Part one, full description of plan $fullapphtml = scraperwiki::scrape($url); $fullappdom = new simple_html_dom(); $fullappdom->load($fullapphtml); $fullappdetails = $fullappdom->find("table[class='AppDetailsTable'] tr", 15)->children(1)->plaintext; #print $fullappdetails; unset($fullapphtml); $sizehtml = scraperwiki::scrape($url); $sizedom = new simple_html_dom(); $sizedom->load($sizehtml); $signifdetail = $sizedom->find("table[class='AppDetailsTable'] tr", 23)->children(1)->plaintext; $sizedetail = $sizedom->find("table[class='AppDetailsTable'] tr", 23)->children(4)->plaintext; unset($sizehtml); if (strpos($fullappdetails, "Protected Structure") !== false) { $protected = "Protected Structure"; } else { $protected = ""; } #print $protected; $spam_found = false; # mobile,council,gov etc $business = array("retail", "Hotel", "Ltd", "Limited", " shop", " shop"); foreach ($business as $businessword) { if (strrpos($row, $businessword)) { $spam_found = true; break; } } if ($spam_found) { $category = "Business"; } else { if (strpos($fullappdetails, "dwelling") !== false) { $category = "residential"; } else { $category = ""; } } #print $category; # Part two, location of application $lochtml = scraperwiki::scrape('http://planning.corkcity.ie/InternetEnquiry/rpt_ViewSiteLocDetails.asp?page_num=0&file_number=' . $rawappref); if (!stristr($lochtml, "No Site Location Details Found")) { $locdom = new simple_html_dom(); $locdom->load($lochtml); $locnorthing = round(floatval($locdom->find("table[class='AppDetailsTable'] tr", 1)->children(1)->plaintext)); $loceasting = round(floatval($locdom->find("table[class='AppDetailsTable'] tr", 1)->children(4)->plaintext)); # Part three, convert E&N to WGS84 using geograph class $c = new ConversionsLatLong(); $res = $c->irish_to_wgs84($loceasting, $locnorthing); $lat = $res[0]; $long = $res[1]; $locdom->clear(); unset($locdom); unset($lochtml); $apps["{$appref}"] = array('url' => $url, 'appref' => $appref, 'date' => $date, 'applicant' => $applicant, 'address' => $address, 'details' => $fullappdetails, 'signif' => $signifdetail, 'size' => $sizedetail, 'category' => $category, 'protected' => $protected, 'latitude' => $lat, 'longitude' => $long); } } } $dom->clear(); unset($dom); return $apps; }
function process_page($html) { $dom = new simple_html_dom(); $dom->load($html); $apps = array(); global $authority_code; global $nearby_api_key; foreach ($dom->find("table[class='AppDetailsTable'] tr") as $row) { # Man, this is hacky, but I'm not using dom here in case 'td' shows in plaintext of var if (stristr($row, 'FINALISED') || stristr($row, 'CONDITIONAL') || stristr($row, 'APPEALED') || stristr($row, 'WITHDRAWN') || stristr($row, 'NEW<') || stristr($row, 'APPROVED') || stristr($row, 'REFUSED')) { $appref = $authority_code . substr($row->children[0]->plaintext, 0, 2) . "/" . substr($row->children[0]->plaintext, 2); $rawappref = trim($row->children[0]->plaintext); $url = "http://planning.corkcity.ie/InternetEnquiry/rpt_ViewApplicDetails.asp?validFileNum=1&app_num_file=" . $rawappref; $rawdate = substr($row->children[4]->plaintext, 0, 10); $date = substr($rawdate, -4) . "-" . substr($rawdate, 3, 2) . "-" . substr($rawdate, 0, 2); $applicant = trim($row->children[5]->plaintext); $address = str_replace("<br>", ",", str_replace("<BR>", ",", $row->children[6]->innertext)); # Now fetch additional information. Part one, full description of plan $fullapphtml = scraperwiki::scrape($url); $fullappdom = new simple_html_dom(); $fullappdom->load($fullapphtml); $fullappdetails = $fullappdom->find("table[class='AppDetailsTable'] tr", 15)->children(1)->plaintext; unset($fullapphtml); # Part two, location of application $lochtml = scraperwiki::scrape('http://planning.corkcity.ie/InternetEnquiry/rpt_ViewSiteLocDetails.asp?page_num=0&file_number=' . $rawappref); if (!stristr($lochtml, "No Site Location Details Found")) { $locdom = new simple_html_dom(); $locdom->load($lochtml); $locnorthing = round(floatval($locdom->find("table[class='AppDetailsTable'] tr", 1)->children(1)->plaintext)); $loceasting = round(floatval($locdom->find("table[class='AppDetailsTable'] tr", 1)->children(4)->plaintext)); # Part three, convert E&N to WGS84 using geograph class $c = new ConversionsLatLong(); $res = $c->irish_to_wgs84($loceasting, $locnorthing); $lat = $res[0]; $long = $res[1]; $locdom->clear(); unset($locdom); unset($lochtml); $apps["{$appref}"] = array('url' => $url, 'appref' => $appref, 'date' => $date, 'applicant' => $applicant, 'address' => $address, 'details' => $fullappdetails, 'latitude' => $lat, 'longitude' => $long); } } } $dom->clear(); unset($dom); return $apps; }
function national_to_wgs84($e, $n, $reference_index, $usehermert = true) { require_once 'geograph/conversionslatlong.class.php'; $conv = new ConversionsLatLong(); $latlong = array(); if ($reference_index == 1) { $latlong = $conv->osgb36_to_wgs84($e, $n); } else { if ($reference_index == 2) { $latlong = $conv->irish_to_wgs84($e, $n, $usehermert); } } return $latlong; }
function national_to_wgs84($e, $n, $reference_index, $usehermert = true) { $conv = new ConversionsLatLong(); $latlong = array(); if ($reference_index == 1) { $latlong = $conv->osgb36_to_wgs84($e, $n); } elseif ($reference_index == 2) { $latlong = $conv->irish_to_wgs84($e, $n, $usehermert); } return $latlong; }
$smarty = new GeographPage(); dieUnderHighLoad(); # # # # # # # # # # # # # # # include 'geograph/export.inc.php'; # # # # # # # # # # # # # # # # let the browser know what's coming header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"geograph.csv\""); if (isset($_GET['headers']) && $_GET['headers'] == 'lower') { echo str_replace(array('photographer', 'easting', 'northing', 'figures', 'view_direction', 'image_'), array('photo', 'e', 'n', 'figs', 'dir', ''), preg_replace('/[^\\w,]+/', '_', strtolower($csvhead))) . "\n"; } else { echo "{$csvhead}\n"; } if (isset($_GET['coords'])) { require_once 'geograph/conversions.class.php'; $conv = new ConversionsLatLong(); } $counter = -1; while (!$recordSet->EOF) { $image = $recordSet->fields; $image['title'] = combineTexts($image['title'], $image['title2']); if (strpos($image['title'], ',') !== FALSE || strpos($image['title'], '"') !== FALSE) { $image['title'] = '"' . str_replace('"', '""', $image['title']) . '"'; } if (strpos($image['imageclass'], ',') !== FALSE || strpos($image['imageclass'], '"') !== FALSE) { $image['imageclass'] = '"' . str_replace('"', '""', $image['imageclass']) . '"'; } echo "{$image['gridimage_id']},{$image['title']},{$image['grid_reference']},{$image['realname']},{$image['imageclass']}"; if (!empty($_GET['thumb'])) { $gridimage->fastInit($image); echo ',' . $gridimage->getThumbnail(120, 120, true);
function reproject($x, $y, $inProj, $outProj) { // Project to wgs84 latlon $inProj = strtoupper($inProj); $outProj = strtoupper($outProj); switch ($inProj) { case 'GOOGLE': case 'EPSG:900913': case '900913': case '3785': case 'EPSG:3785': case '3857': case 'EPSG:3857': $ll = sphmerc_to_ll($x, $y); break; case 'OSGB': case '27700': case 'EPSG:27700': /* $ll = gr_to_wgs84_ll($x,$y); $ref = new OSRef($x,$y); $latlng = OSRefToLatLng($ref); $ll = array("lon"=>$latlng->lng,"lat"=>$latlng->lat); */ // 17/4/13 now use Barry Hunter's geograph code, seems to be // most accurate of these $c = new ConversionsLatLong(); $ll0 = $c->osgb36_to_wgs84($x, $y); $ll = array("lon" => $ll0[1], "lat" => $ll0[0]); break; default: $ll = array("lon" => $x, "lat" => $y); } // Project from wgs84 latlon to output format switch ($outProj) { case 'GOOGLE': case 'EPSG:900913': case '900913': case '3785': case 'EPSG:3785': case '3857': case 'EPSG:3857': $sm = ll_to_sphmerc($ll['lon'], $ll['lat']); $x = $sm['e']; $y = $sm['n']; break; case 'OSGB': case '27700': case 'EPSG:27700': /* $gr = wgs84_ll_to_gr($ll['lon'],$ll['lat']); $x = $gr['e']; $y = $gr['n']; $ll = new LatLng($ll['lat'],$ll['lon']); $gr = LatLngToOSRef($ll); $x = $gr->easting; $y = $gr->northing; */ // 17/4/13 now use Barry Hunter's geograph code, seems to be // most accurate of these $c = new ConversionsLatLong(); $gr = $c->wgs84_to_osgb36($ll['lat'], $ll['lon']); $x = $gr[0]; $y = $gr[1]; break; default: $x = $ll['lon']; $y = $ll['lat']; break; } return array($x, $y); }
* of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; require_once 'geograph/conversions.class.php'; require_once 'geograph/conversionslatlong.class.php'; init_session(); $conv = new ConversionsLatLong(); $smarty = new GeographPage(); $template = 'stuff_conversion.tpl'; $cacheid = ''; if ($_GET['To']) { //to lat/long if ($_GET['datum'] == 'osgb36') { $latlong = $conv->osgb36_to_wgs84($_GET['e'], $_GET['n']); } else { if ($_GET['datum'] == 'irish') { list($usec, $sec) = explode(' ', microtime()); $querytime_before = (double) $usec + (double) $sec; for ($q = 0; $q < 200; $q++) { $latlong = $conv->irish_to_wgs84($_GET['e'], $_GET['n'], $_GET['usehermert']); } $latlong = $conv->irish_to_wgs84($_GET['e'], $_GET['n'], $_GET['usehermert']);
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; require_once 'geograph/conversions.class.php'; require_once 'geograph/conversionslatlong.class.php'; require_once 'geograph/gridsquare.class.php'; require_once 'geograph/mapmosaic.class.php'; include_messages('latlong'); init_session(); $conv = new ConversionsLatLong(); $smarty = new GeographPage(); $template = 'latlong.tpl'; $cacheid = ''; if (!isset($_GET['usehermert'])) { $_GET['usehermert'] = 1; } if (!isset($_GET['datum'])) { $_GET['datum'] = '-'; } if (!empty($_GET['To'])) { //to lat/long if ($_GET['datum'] == 'osgb36') { $latlong = $conv->osgb36_to_wgs84($_GET['e'], $_GET['n']); } else { if ($_GET['datum'] == 'irish') {