Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mapmanager/map.php

Go to the documentation of this file.
00001 <?php
00002 
00011 // Load the PHP mapscript extension if not already done
00012 if (!extension_loaded('MapScript'))
00013 {
00014     if (!dl('php_mapscript.so')) {
00015         trigger_error("The MapScript extension could not be loaded", E_USER_ERROR);
00016     }
00017 }
00018 
00023 function unique_id() 
00024 {
00025     return md5(uniqid(mt_rand(), true));
00026 }
00027 
00032 function unique_fname($prefix = null, $suffix = null, $dir = null) 
00033 {
00034     $name = $prefix.unique_id().$suffix;
00035     if ($dir !== null)
00036         return $dir.'/'.$name;
00037     return '/tmp/'.$name;
00038 }
00039 
00044 function unique_mapfile($prefix = null, $dir = null) 
00045 {
00046     return unique_fname($prefix, '.map', $dir);
00047 }
00048 
00049 
00060 class Map
00061 {
00063     var $_m = null;
00064 
00073     var $_map_string = null;
00074 
00080     function Map($map_file, $new_map_path = null) 
00081         {
00082             if ($new_map_path !== null) {
00083                 $this->setCObj(ms_newMapObj($map_file, $new_map_path));
00084             } else {
00085                 $this->setCObj(ms_newMapObj($map_file));
00086             }
00087         }
00088 
00089     
00090     // NONSTANDARD METHODS
00091 
00097     function loadMapString($map_string)
00098         {
00099             $tmpfname = unique_mapfile('MAP_LOAD_');
00100             $fh = fopen($tmpfname, 'w');
00101             fwrite($fh, $map_string);
00102             fclose($fh);
00103             $this->setCObj(ms_newMapObj($tmpfname));
00104             unlink($tmpfname);
00105         }
00106 
00112     function getCObj()
00113         {
00114             return $this->_m;
00115         }
00116 
00122     function setCObj($map)
00123         {
00124             $this->_m = $map;
00125         }        
00126     
00132     function &get($property_name) 
00133         {
00134             return $this->_m->$property_name;
00135         }
00136 
00137     // WRAPPED mapObj METHODS
00138 
00145     function clone() 
00146         {
00147             return $this->_m->clone();
00148         }
00149 
00156     function set($property_name, $new_value) 
00157         {
00158             return $this->_m->set($property_name, $new_value);
00159         }
00160 
00166     function getsymbolbyname($symbol_name) 
00167         {
00168             return $this->_m->getsymbolbyname($symbol_name);
00169         }
00170 
00175     function preparequery()
00176         {
00177             return $this->_m->preparequery();
00178         }
00179 
00184     function prepareImage() 
00185         {
00186             return $this->_m->prepareImage();
00187         }
00188 
00189 
00194     function draw() 
00195         {
00196             return $this->_m->draw();
00197         }
00198 
00203     function drawQuery() 
00204         {
00205             return $this->_m->drawQuery();
00206         }
00207 
00212     function drawLegend() 
00213         {
00214             return $this->_m->drawLegend();
00215         }
00216 
00221     function drawReferenceMap() 
00222         {
00223             return $this->_m->drawReferenceMap();
00224         }
00225 
00230     function drawScaleBar()
00231         {
00232             return $this->_m->drawScaleBar();
00233         }
00234 
00240     function embedlegend($image) 
00241         {
00242             return $this->_m->embedlegend($image);
00243         }
00244 
00250     function embedScalebar($image)
00251         {
00252             return $this->_m->embedScalebar($image);
00253         }
00254 
00260     function drawLabelCache($image)
00261         {
00262             return $this->_m->drawLabelCache($image);
00263         }
00264 
00270     function getLayer($index)
00271         {
00272             return $this->_m->getLayer($index);
00273         }
00274 
00280     function getLayerByName($layer_name)
00281         {
00282             return $this->_m->getLayerByName($layer_name);
00283         }
00284 
00290     function getcolorbyindex($iCloIndex) 
00291         {
00292             return $this->_m->getcolorbyindex($iCloIndex);
00293         }
00294 
00303     function setextent($minx, $miny, $maxx, $maxy) 
00304         {
00305             return $this->_m->setextent($minx, $miny, $maxx, $maxy);
00306         }
00307 
00318     function zoompoint($nZoomFactor, $oPixelPox, $nImageWidth, $nImageHeight, $oGeorefExt, $oMaxGeorefExt = null) 
00319         {
00320             if ($oMaxGeorefExt !== null)
00321                 return $this->_m->zoompoint($nZoomFactor, $oPixelPox, $nImageWidth, $nImageHeight, $oGeorefExt, $oMaxGeorefExt);
00322 
00323             return $this->_m->zoompoint($nZoomFactor, $oPixelPox, $nImageWidth, $nImageHeight, $oGeorefExt);
00324         }
00325 
00334     function zoomrectangle($oPixelExt, $nImageWidth, $nImageHeight, $oGeorefExt) 
00335         {
00336             return $this->_m->zoomrectangle($oPixelExt, $nImageWidth, $nImageHeight, $oGeorefExt);
00337         }
00338 
00349     function zoomscale($nScale, $oPixelPos, $nImageWidth, $nImageHeight, $oGeorefExt, $oMaxGeorefExt = null)
00350         {
00351             if ($oMaxGeorefExt !== null)
00352                 return $this->_m->zoomscale($nScale, $oPixelPos, $nImageWidth, $nImageHeight, $oGEorefExt, $oMaxGeorefExt);
00353 
00354             return $this->_m->zoomscale($nScale, $oPixelPos, $nImageWidth, $nImageHeight, $oGEorefExt);
00355         }
00356 
00364     function queryByPoint($point, $mode, $buffer) 
00365         {
00366             return $this->_m->queryByPoint($point, $mode, $buffer);
00367         }
00368 
00374     function queryByRect($rect)
00375         {
00376             return $this->_m->queryByRect($rect);
00377         }
00378 
00384     function queryByShape($shape)
00385         {
00386             return $this->_m->queryByShape($shape);
00387         }
00388 
00394     function queryByFeatures($slayer)
00395         {
00396             return $this->_m->queryByFeatures($slayer);
00397         }
00398 
00407     function queryByIndex($layerindex, $tileindex, $shapeindex, $addtoquery = MS_FALSE)
00408         {
00409             return $this->_m->queryByIndex($layerindex, $tileindex, $shapeindex, $addtoquery);
00410         }
00411 
00417     function savequery($filename)
00418         {
00419             return $this->_m->savequery($filename);
00420         }
00421 
00427     function loadquery($filename) 
00428         {
00429             return $this->_m->loadquery($filename);
00430         }
00431 
00437     function freequery($layerindex)
00438         {
00439             return $this->_m->freequery($layerindex);
00440         }
00441 
00447     function save($filename) 
00448         {
00449             return $this->_m->save($filename);
00450         }
00451 
00456     function getProjection()
00457         {
00458             return $this->_m->getProjection();
00459         }
00460 
00467     function setProjection($proj_params, $bSetUnitsAndExtents = MS_FALSE)
00468         {
00469             return $this->_m->setProjection($proj_params, $bSetUnitsAndExtents);
00470         }
00471 
00478     function setWKTProjection($proj_params, $bSetUnitsAndExtents = MS_FALSE)
00479         {
00480             return $this->_m->setWKTProjection($proj_params, $bSetUnitsAndExtents);
00481         }
00482 
00488     function getMetaData($name)
00489         {
00490             return $this->getMetaData($name);
00491         }
00492 
00499     function setMetaData($name, $value)
00500         {
00501             return $this->_m->setMetaData($name, $value);
00502         }
00503 
00509     function removeMetaData($name)
00510         {
00511             return $this->_m->removeMetaData($name);
00512         }
00513 
00519     function getLayersIndexByGroup($groupname) 
00520         {
00521             return $this->_m->getLayersIndexByGroup($groupname);
00522         }
00523 
00528     function getAllGroupNames()
00529         {
00530             return $this->_m->getAllGroupNames();
00531         }
00532 
00537     function getAllLayerNames()
00538         {
00539             return $this->_m->getAllLayerNames();
00540         }
00541 
00547     function moveLayerUp($layerindex)
00548         {
00549             return $this->_m->moveLayerUp($layerindex);
00550         }
00551 
00557     function moveLayerDown($layerindex)
00558         {
00559             return $this->_m->moveLayerDown($layerindex);
00560         }
00561 
00566     function getlayersdrawingorder()
00567         {
00568             return $this->_m->getlayersdrawingorder();
00569         }
00570 
00576     function setlayersdrawingorder($layeryindex)
00577         {
00578             return $this->_m->setlayersdrawingorder($layeryindex);
00579         }
00586     function processtemplate($params, $generateimages = MS_TRUE)
00587         {
00588             return $this->_m->processtemplate($params, $generateimages);
00589         }
00590 
00597     function processquerytemplate($params, $generateimages = MS_TRUE)
00598         {
00599             return $this->_m->processquerytemplate($params, $generateimages);
00600         }
00601 
00607     function processlegendtemplate($params)
00608         {
00609             return $this->_m->processlegendtemplate($params);
00610         }
00611 
00617     function setSymbolSet($fileName) 
00618         {
00619             return $this->_m->setSymbolSet($fileName);
00620         }
00621 
00626     function getNumSymbols() 
00627         {
00628             return $this->_m->getNumSymbols();
00629         }
00630 
00636     function setFontSet($fileName) 
00637         {
00638             return $this->_m->setFontSet($fileName);
00639         }
00640 
00646     function selectOutputFormat($type)
00647         {
00648             return $this->_m->selectOutputFormat($type);
00649         }
00650 
00656     function saveMapContext($filename)
00657         {
00658             return $this->_m->saveMapContext($filename);
00659         }
00660 
00666     function loadMapContext($filename)
00667         {
00668             return $this->_m->loadMapContext($filename);
00669         }
00670 
00676     function applySLD($sldxml)
00677         {
00678             return $this->_m->applySLD($sldxml);
00679         }
00680 
00686     function applySLDURL($sldurl)
00687         {
00688             return $this->_m->applySLDURL($sldurl);
00689         }
00690 
00695     function generateSLD()
00696         {
00697             return $this->_m->generateSLD();
00698         }
00699 
00700 
00701     /***************************************************
00702      * Printable INTERFACE
00703      ***************************************************/
00704 
00709     function toString()
00710         {
00711             $tmpfname = unique_mapfile('MAP_SAVE_');
00712             $this->save($tmpfname);
00713             $map_string = file_get_contents($tmpfname);
00714             unlink($tmpfname);
00715             return $map_string;
00716         }
00717 
00718     
00719     /***************************************************
00720      * Serialisation INTERFACE
00721      ***************************************************/
00722 
00732     function __sleep()
00733         {
00734             $this->_map_string = $this->toString();
00735             return array('_map_string');
00736         }
00737 
00747     function __wakeup()
00748         {
00749             $this->loadMapString($this->_map_string);
00750             $this->_map_string = null;
00751         }
00752 } 
00753   
00754 ?>

Generated on Mon Feb 14 11:40:06 2005 for MapManager by doxygen 1.3.5