<?php

$extensionDir 
"C:/Program Files/MapGuideOpenSource/WebServerExtensions/www/";
$viewerDir $extensionDir "mapviewerphp/";

// Bring in some constants and other items that could not be included in the 
// PHP extension due to language constraints

include $viewerDir "common.php";
include 
$viewerDir "constants.php";

try 
{

  
MgInitializeWebTier($extensionDir"webconfig.ini");

  
$coordSysFactory = new MgCoordinateSystemFactory();
  
$coordSysUTM10 $coordSysFactory->Create('PROJCS["NAD83 / UTM zone 10N",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-123],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","26910"]]');
  
$coordSysLL $coordSysFactory->Create('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]');
  
$csTransformUTM10toLL = new MgCoordinateSystemTransform($coordSysUTM10$coordSysLL);
  
$csTransformLLtoUTM10 = new MgCoordinateSystemTransform($coordSysLL$coordSysUTM10);

  
$wktReaderWriter = new MgWktReaderWriter();

  if (
1)
  {

     
$bboxWkt "POLYGON ( ( 428000 5451000 , 428000 5452000 , 429000 5452000 , 429000 5451000 , 428000 5451000 ) )";
   
     
$bbox $wktReaderWriter->Read($bboxWkt,$csTransformUTM10toLL);

  }
  else
  {

     
$bboxWkt "POLYGON ( ( -124 49, -124 50, -123 50, -123 49, -124 49 ) )";
   
     
$bbox $wktReaderWriter->Read($bboxWkt,$csTransformLLtoUTM10);
   
  }

  print 
$wktReaderWriter->Write($bbox);



catch (
Exception $ex
{
   print 
"<h1>Exception</h1><p>";
   print 
"Error: " $ex->GetMessage() . "<br />";
   print 
"Details:" $ex->GetDetails() . "</p>";
   exit;
}

?>