示例#1
0
    function _plotPlacenames(&$img, $scanleft, $scanbottom, $scanright, $scantop, $bottom, $left)
    {
        $db =& $this->_getDB();
        $black = imagecolorallocate($img, 0, 64, 0);
        require_once 'geograph/conversions.class.php';
        $conv = new Conversions();
        if (!$this->reference_index) {
            $this->getGridRef(-1, -1);
            if (!$this->reference_index) {
                $this->getGridRef(-1, -1);
                $this->reference_index = 1;
            }
        }
        $reference_index = $this->reference_index;
        $gridcol = imagecolorallocate($img, 109, 186, 178);
        list($natleft, $natbottom) = $conv->internal_to_national($scanleft, $scanbottom, $reference_index);
        list($natright, $nattop) = $conv->internal_to_national($scanright, $scantop, $reference_index);
        if ($this->pixels_per_km < 1) {
            $div = 500000;
            //1 per 500k square
            $crit = "s = '1' AND";
            $cityfont = 3;
        } elseif ($this->pixels_per_km == 1) {
            $div = 100000;
            $crit = "(s = '1' OR s = '2') AND";
            $cityfont = 3;
        } elseif ($this->pixels_per_km == 4) {
            $div = 30000;
            #	$crit = "(s = '1' OR s = '2') AND";
            $cityfont = 3;
        } else {
            $div = 10000;
            $cityfont = 3;
        }
        $intleft = $scanleft * 1000;
        $intright = $scanright * 1000;
        $intbottom = $scanbottom * 1000;
        $inttop = $scantop * 1000;
        $rectangle = "'POLYGON(({$natleft} {$natbottom},{$natright} {$natbottom},{$natright} {$nattop},{$natleft} {$nattop},{$natleft} {$natbottom}))'";
        $rectanglexy = "'POLYGON(({$intleft} {$intbottom},{$intright} {$intbottom},{$intright} {$inttop},{$intleft} {$inttop},{$intleft} {$intbottom}))'";
        if ($reference_index == 1 || $reference_index == 2 && $this->pixels_per_km == 1 || $reference_index >= 3) {
            //$countries = "'EN','WA','SC'";
            $sql = <<<END
SELECT name,e,n,s,quad,reference_index
FROM loc_towns
WHERE 
 {$crit}
CONTAINS( GeomFromText({$rectanglexy}),\tpoint_xy) 
ORDER BY s
END;
            #GROUP BY FLOOR(e/$div),FLOOR(n/$div)
        } else {
            $countries = "'NI','RI'";
            $div *= 1.5;
            //becuase the irish data is more dence
            $sql = <<<END
SELECT e,n,full_name as name,reference_index
FROM loc_placenames
INNER JOIN `loc_wikipedia` ON ( full_name = text ) 
WHERE dsg = 'PPL' AND
loc_wikipedia.country IN ({$countries}) AND 
CONTAINS( GeomFromText({$rectangle}),\tpoint_en) 
GROUP BY gns_ufi
ORDER BY RAND()
END;
        }
        $squares = array();
        $recordSet =& $db->Execute($sql);
        while (!$recordSet->EOF) {
            $e = $recordSet->fields['e'];
            $n = $recordSet->fields['n'];
            $str = floor($e / $div) . ' ' . floor($n / $div * 1.4);
            if (!$squares[$str]) {
                // || $recordSet->fields['s'] ==1) {
                $squares[$str]++;
                list($x, $y) = $conv->national_to_internal($e, $n, $recordSet->fields['reference_index']);
                $imgx1 = ($x - $left) * $this->pixels_per_km;
                $imgy1 = $this->image_h - ($y - $bottom + 1) * $this->pixels_per_km;
                if ($this->pixels_per_km <= 4) {
                    imagefilledrectangle($img, $imgx1 - 1, $imgy1 - 2, $imgx1 + 1, $imgy1 + 2, $black);
                    imagefilledrectangle($img, $imgx1 - 2, $imgy1 - 1, $imgx1 + 2, $imgy1 + 1, $black);
                }
                $font = $recordSet->fields['s'] == 1 ? $cityfont : 2;
                $img1 = $this->_posText($imgx1, $imgy1, $font, $recordSet->fields['name'], $recordSet->fields['quad']);
                if (count($img1)) {
                    imageGlowString($img, $font, $img1[0], $img1[1], $recordSet->fields['name'], $gridcol);
                }
            }
            $recordSet->MoveNext();
        }
        if ($_GET['d']) {
            exit;
        }
        $recordSet->Close();
    }
示例#2
0
     $smarty->assign("page_title", "Historic County (Pre 1974) Centre Points");
     $smarty->assign("start_info", "These are approximate centres for counties pre 1974 re-shuffle");
     $counties = $db->GetAll("select * from loc_counties_pre74 where n > 0 order by reference_index,n");
 } elseif ($type == 'modern') {
     $smarty->assign("page_title", "Modern Administrative County Centre Points");
     $smarty->assign("start_info", "These are approximate centres for modern administrative counties.");
     $smarty->assign("extra_info", "<div class=\"copyright\">Great Britain locations based upon Ordnance Survey&reg 1:50 000 Scale Gazetteer with the permission of Ordnance Survey on behalf of The Controller of Her Majesty's Stationery Office, &copy; Crown copyright. Educational licence 100045616.</div>");
     $counties = $db->GetAll("select * from os_gaz_county where n > 0 and name not like 'XX%' order by reference_index,n");
 } elseif ($type == 'capital') {
     $smarty->assign("page_title", "Ireland County Capital Towns");
     $smarty->assign("extra_info", "* at the moment we dont actully store which county each capital is in, this information is furthermore only available for Ireland so far.");
     $counties = $db->GetAll("SELECT * FROM `loc_towns` WHERE `s` = '2' AND `reference_index` = 2 ORDER BY n");
 }
 if ($counties) {
     foreach ($counties as $i => $row) {
         list($x, $y) = $conv->national_to_internal($row['e'], $row['n'], $row['reference_index']);
         $sql = "select * from gridimage_search where x={$x} and y={$y} order by moderation_status+0 desc,seq_no limit 1";
         $rec = $db->GetRow($sql);
         if (count($rec)) {
             $gridimage = new GridImage();
             $gridimage->fastInit($rec);
             $gridimage->county = $row['name'];
             $results[] = $gridimage;
         } else {
             $sql = "select grid_reference from gridsquare where x={$x} and y={$y} limit 1";
             $rec = $db->GetRow($sql);
             if (count($rec)) {
                 $rec['county'] = $row['name'];
                 $unfilled[] = $rec;
             } else {
                 $nonland[] = array('county' => $row['name']);
示例#3
0
         if ($data == 'blank') {
             header("HTTP/1.0 302 Found");
             header("Status: 302 Found");
             header("Location: http://{$CONF['CONTENT_HOST']}/maps/blank.png");
         } else {
             header("Content-Type: image/png");
             print $data;
         }
         exit;
     }
 }
 /////////////////////////
 // no hit from the cache....
 $lastmod = time();
 $w = $rastermap->tilewidth[$rastermap->service];
 list($x, $y) = $conv->national_to_internal($e, $n, $reference_index);
 $db = NewADOConnection($GLOBALS['DSN']);
 $scanleft = $x;
 $scanright = $x + $stepdist;
 $scanbottom = $y;
 $scantop = $y + $stepdist;
 $rectangle = "'POLYGON(({$scanleft} {$scanbottom},{$scanright} {$scanbottom},{$scanright} {$scantop},{$scanleft} {$scantop},{$scanleft} {$scanbottom}))'";
 if ($_GET['l'] == 'p') {
     $sql = "select (nateastings DIV 100 * 100) AS nateastings,\r\n\t\t\t\t\t(natnorthings DIV 100 * 100) AS natnorthings,\r\n\t\t\t\t\tcount(*) as imagecount \r\n\t\t\t\t\tfrom gridimage inner join gridsquare using (gridsquare_id) where \r\n\t\t\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\r\n\t\t\t\t\tand moderation_status = 'geograph' and natgrlen <= 3\r\n\t\t\t\t\tgroup by nateastings DIV 100, natnorthings DIV 100";
 } else {
     $sql = "select x,y,imagecount,percent_land,has_geographs from gridsquare where \r\n\t\t\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)";
 }
 /////////////////////////
 // fetch from database
 $arr = $db->getAll($sql);
 if (count($arr)) {
示例#4
0
    //limit 1 is added automaticallu
    preg_match('/\\((\\d+) (\\d+)\\)/', $str, $m);
    if ($str && $m[1]) {
        $mapw = $mosaic->image_w / $mosaic->pixels_per_km / 2;
        $mosaic->setOrigin($m[1] - $mapw, $m[2] - $mapw);
    }
    $token = $mosaic->getToken();
    $cacheid = 'mapper|' . $token;
} elseif (isset($_GET['t'])) {
    $mosaic->setToken($_GET['t']);
    $token = $mosaic->getToken();
    $cacheid = 'mapper|' . $token;
} elseif (isset($_GET['lat'])) {
    require_once 'geograph/conversions.class.php';
    $conv = new Conversions();
    list($x, $y) = $conv->national_to_internal($_GET['lon'], $_GET['lat'], 1);
    if (isset($_GET['zoom'])) {
        switch ($_GET['zoom']) {
            case 0:
                $mosaic->pixels_per_km = 4;
                break;
            case 1:
                $mosaic->pixels_per_km = 40;
                break;
                //there isnt a direct equiv
            //there isnt a direct equiv
            case 2:
                $mosaic->pixels_per_km = 40;
                break;
            case 3:
                $mosaic->pixels_per_km = 80;