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;
}
Beispiel #3
0
 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;
 }
 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;
 }
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']);
            list($usec, $sec) = explode(' ', microtime());
            $querytime_after = (double) $usec + (double) $sec;
            $smarty->assign('querytime', "200 conversions took " . number_format($querytime_after - $querytime_before, 4) . " Seconds");
        } else {
            //todo: make an educated guess - basically if could be irish then use that otherwise gb ?!? - probably not...
        }
    }
    if (count($latlong)) {
        $smarty->assign('lat', $latlong[0]);
        $smarty->assign('long', $latlong[1]);
        $smarty->assign('e', $_GET['e']);
        $smarty->assign('n', $_GET['n']);
    }