[mapguide-users] Re: sample 'property_report.php' as a custom command

GordonL gordon.luckett at arrowgeomatics.com
Mon Sep 26 09:36:05 EDT 2011


The Property Report is a custom report for that particular data set.  You
would have to write your own.

Try out this generic one:
All you need is to launch the InvokeURL (Basic and Fusion) to run it.
<body onload="focus()">
<?php

$configFilePath = "C:\Program
Files\OSGeo\MapGuide\Web\www\webconfig.ini\webconfig.ini";

$mgSessionId = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST['SESSION']:
$_GET['SESSION'];
$mapName = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST['MAPNAME']:
$_GET['MAPNAME'];



// Initialize the Web Extensions and connect to the Server using
// the Web Extensions session identifier stored in PHP
// session state.

MgInitializeWebTier($cofigFilePath);

$userInfo = new MgUserInformation($mgSessionId);

$siteConnection = new MgSiteConnection();

$siteConnection->Open($userInfo);

$resourceService = $siteConnection->CreateService(0);

$featureService = $siteConnection->CreateService(2);

$queryOptions = new MgFeatureQueryOptions();


$map = new MgMap($siteConnection);
$map->Open($mapName);
        $selection = new MgSelection($map); 
		$selection->Open($resourceService, $mapName); 
        $selectedLayers = $selection->GetLayers(); 
        
		$numberLayers = $selectedLayers->GetCount(); 
        $wktReaderWriter = new MgWktReaderWriter();  //for getPropertyValue 
        $agfReaderWriter = new MgAgfReaderWriter();  // for getPropertyValue 
	              

		//Create table
		echo '<table>';
        for ($i = 0; $i < $numberLayers; $i++) 
        { 
           $layer = $selectedLayers->GetItem($i); 
    	   $layerName = $layer->GetName(); 
           $layerClassName = $layer->GetFeatureClassName();
           
		   
           $featureReader =  $selection->GetSelectedFeatures($layer,
$layerClassName, false); 
			$firstOne = true;
			
			 echo '<tr><td colspan=3>*Layer: ' .$layerName .'*</td></tr>';
		
		 
		 while ($featureReader->ReadNext()) 
             { 
                 
				 $propCount = $featureReader->GetPropertyCount(); 
                 for($j=0; $j<$propCount; $j++) 
                 { 
                   if($j ==0)
						echo '<tr>';
 					$propertyName = $featureReader->GetPropertyName($j); 
                     $boolVal = $featureReader->IsNull($propertyName); 
                     if ($boolVal) 
                     { 
                          continue; 
                     }// end if 
                     $propertyType =
$featureReader->GetPropertyType($propertyName); 
                     $propertyValue =
getPropertyValue($featureReader,$propertyType,$propertyName); 
                     
                     //echo '<tr><th align=right>' . $propertyName .
'</th><td> ' . $propertyValue . '</td></tr>';
					
				
					if($firstOne)
					{
						echo  '<td valign=top>*' . $propertyName . '*<br>' . $propertyValue .
'</td>';
					}
					else
					{ 
						echo  '<td>' .  $propertyValue . '</td>';
					}
					
					
				}
				$firstOne=false;
                 
             } //end loop over features

        } //end loop over layer
		


//-------------------------getPropertyValue
BEGINS--------------------------- 
/** 
  * Gets data for a layer property 
  */ 
function getPropertyValue(&$featureReader, $propertyType, $propertyName) 
{ 
    global $agfReaderWriter; 
    global $wktReaderWriter; 
    switch ($propertyType) 
    { 
        case 0 : 
            break; 
          case 1 : 
                 $val = $featureReader->GetBoolean($propertyName); 
                 $valStr = printBoolean($val); 
                 break; 
          case 2 : 
                 $val = $featureReader->GetByte($propertyName); 
                 break; 
          case 3 : 
                 $val = $featureReader->GetDateTime($propertyName);
				 $val = $val->ToString();
                 break; 
          case 4 : 
                 $val = $featureReader->GetSingle($propertyName); 
                 break; 
          case 5: 
                 $val = $featureReader->GetDouble($propertyName); 
                 break; 
          case 6 : 
                 $val = $featureReader->GetInt16($propertyName); 
                 break; 
          case 7 : 
                 $val = $featureReader->GetInt32($propertyName); 
                 break; 
          case 8 : 
                 $val = $featureReader->GetInt64($propertyName); 
                 break; 
          case 9 : 
                 $val = $featureReader->GetString($propertyName); 
                 break; 
          case 10 : 
                 //fwrite($logFileHandle, "$propertyName is blob"); 
                 break; 
          case 11 : 
                 break; 
          case 12 : 
                 $val = $featureReader->GetFeatureObject($propertyName); 
                break; 
          case 13 : 
                 break; 
          case 14 : 
                 $val = $featureReader->GetRaster($propertyName); 
                 break; 
       }// end switch 
       return $val; 
}



--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/sample-property-report-php-as-a-custom-command-tp6830978p6831885.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list