getMessage() . "\n"; die; } echo "[php]: Initialized\n"; // We haven't and shouldn't need to require/include constants.php // they are now baked into the PHP extension along with the other // MapGuide API proxy classes echo "[php]: Testing some constants\n"; echo " - " . MgMimeType::Agf . "\n"; echo " - " . MgMimeType::Kml . "\n"; echo " - " . MgMimeType::Mvt . "\n"; echo " - " . MgImageFormats::Png . "\n"; echo " - " . MgImageFormats::Gif . "\n"; echo " - " . MgLogFileType::Authentication . "\n"; echo " - " . MgServerInformationProperties::ClientOperationsQueueCount . "\n"; $user = new MgUserInformation("Anonymous", ""); // Basic set/get $user->SetLocale("en"); echo "[php]: Locale is: " . $user->GetLocale() . "\n"; $conn = new MgSiteConnection(); $conn->Open($user); // Create a session repository $site = $conn->GetSite(); $sessionID = $site->CreateSession(); echo "[php]: Created session: $sessionID\n"; $user->SetMgSessionId($sessionID); // Get an instance of the required services. $resourceService = $conn->CreateService(MgServiceType::ResourceService); echo "[php]: Created Resource Service\n"; $mappingService = $conn->CreateService(MgServiceType::MappingService); echo "[php]: Created Mapping Service\n"; $resId = new MgResourceIdentifier("Library://"); echo "[php]: Enumeratin'\n"; $resources = $resourceService->EnumerateResources($resId, -1, ""); echo $resources->ToString() . "\n"; echo "[php]: Coordinate System\n"; $csFactory = new MgCoordinateSystemFactory(); echo "[php]: CS Catalog\n"; $catalog = $csFactory->GetCatalog(); echo "[php]: Category Dictionary\n"; $catDict = $catalog->GetCategoryDictionary(); echo "[php]: CS Dictionary\n"; $csDict = $catalog->GetCoordinateSystemDictionary(); echo "[php]: Datum Dictionary\n"; $datumDict = $catalog->GetDatumDictionary(); echo "[php]: Coordinate System - LL84\n"; $cs1 = $csFactory->CreateFromCode("LL84"); echo "[php]: Coordinate System - WGS84.PseudoMercator\n"; $cs2 = $csFactory->CreateFromCode("WGS84.PseudoMercator"); echo "[php]: Make xform\n"; $xform = $csFactory->GetTransform($cs1, $cs2); echo "[php]: WKT Reader\n"; $wktRw = new MgWktReaderWriter(); echo "[php]: WKT Point\n"; $pt = $wktRw->Read("POINT (1 2)"); $coord = $pt->GetCoordinate(); echo "[php]: X: ".$coord->GetX().", Y: ".$coord->GetY()."\n"; $site->DestroySession($sessionID); echo "[php]: Destroyed session $sessionID\n"; echo "[php]: Test byte reader (read_size=2)\n"; $bs = new MgByteSource("abcd1234", 8); $content = ""; $br = $bs->GetReader(); $buf = ""; while ($br->Read($buf, 2) > 0) { echo "Buffer: '$buf'\n"; $content .= $buf; } echo "[php]: Test byte reader2 (read_size=3)\n"; $bs2 = new MgByteSource("abcd1234", 8); $content = ""; $br2 = $bs2->GetReader(); $buf = ""; while ($br2->Read($buf, 3) > 0) { echo "Buffer: '$buf'\n"; $content .= $buf; } echo "[php]: Test byte reader3 (stringification)\n"; $bs3 = new MgByteSource("abcd1234", 8); $br3 = $bs3->GetReader(); echo "Stringified: " . $br3->ToString() . "\n"; $agfRw = new MgAgfReaderWriter(); echo "[php]: Trigger an exception\n"; try { $agfRw->Read(NULL); } catch (MgException $ex) { echo "[php]: MgException caught\n"; echo "[php]: MgException - Code: ".$ex->GetExceptionCode()."\n"; echo "[php]: MgException - Message: ".$ex->GetExceptionMessage()."\n"; echo "[php]: MgException - Details: ".$ex->GetDetails()."\n"; echo "[php]: MgException - Stack: ".$ex->GetStackTrace()."\n"; echo "Is standard PHP exception too? " . ($ex instanceof Exception) . "\n"; } catch (Exception $ex) { echo "[php]: Exception: " . $ex->getMessage() . "\n"; } echo "[php]: Trigger another exception\n"; try { $r2 = new MgResourceIdentifier(""); } catch (MgException $ex2) { echo "[php]: MgException caught\n"; echo "[php]: MgException - Code: ".$ex2->GetExceptionCode()."\n"; echo "[php]: MgException - Message: ".$ex2->GetExceptionMessage()."\n"; echo "[php]: MgException - Details: ".$ex2->GetDetails()."\n"; echo "[php]: MgException - Stack: ".$ex2->GetStackTrace()."\n"; echo "Is standard PHP exception too? " . ($ex2 instanceof Exception) . "\n"; } catch (Exception $ex) { echo "[php]: Exception: " . $ex->getMessage() . "\n"; } echo "Press any key to exit\n"; readline(); ?>