* @SWG\Parameter(name="session", in="path", required=true, type="string", description="Your MapGuide Session ID"), * @SWG\Parameter(name="resName", in="path", required=true, type="string", description="The name of the Layer Definition"), * @SWG\Parameter(name="scale", in="path", required=true, type="number", description="The scale at which the symbolization is requested"), * @SWG\Parameter(name="geomType", in="path", required=true, type="integer", description="The type of symbolization required: 1=Point, 2=Line, 3=Area, 4=Composite"), * @SWG\Parameter(name="themecat", in="path", required=true, type="integer", description="The value indicating which theme category swatch to return. Used when there is a theme defined at this scale"), * @SWG\Parameter(name="width", in="query", required=true, type="integer", description="The requested image width in pixels"), * @SWG\Parameter(name="height", in="query", required=true, type="integer", description="The requested image height in pixels"), * @SWG\Parameter(name="type", in="path", required=true, type="string", description="The icon image type", enum={"PNG", "PNG8", "JPG", "GIF"}), * @SWG\Response(response=400, description="You supplied a bad request due to one or more missing or invalid parameters"), * @SWG\Response(response=401, description="Session ID or MapGuide credentials not specified"), * @SWG\Response(response=500, description="An error occurred during the operation") * ) */ $app->get("/session/:sessionId/:resName.LayerDefinition/legend/:scale/:geomtype/:themecat/icon.:format", function ($sessionId, $resName, $scale, $geomtype, $themecat, $format) use($app) { $resId = new MgResourceIdentifier("Session:{$sessionId}//{$resName}.LayerDefinition"); $ctrl = new MgMappingServiceController($app); $ctrl->GenerateLegendImage($resId, $scale, $geomtype, $themecat, $format); }); //============================= Rendering Service APIs ==================================== /** * @SWG\Get( * path="/session/{session}/{resName}.MapDefinition/image.{type}", * operationId="RenderMapDefinition", * summary="Renders an image of the specified map definition", * tags={"session"}, * @SWG\Parameter(name="session", in="path", required=true, type="string", description="Your MapGuide Session ID"), * @SWG\Parameter(name="resName", in="path", required=true, type="string", description="The name of the Map Definition"), * @SWG\Parameter(name="x", in="query", required=true, type="integer", description="The X coordinate of the map center to render"), * @SWG\Parameter(name="y", in="query", required=true, type="integer", description="The Y coordinate of the map center to render"), * @SWG\Parameter(name="scale", in="query", required=true, type="number", description="The map scale to render"), * @SWG\Parameter(name="width", in="query", required=true, type="integer", description="The width of the image"),
* @SWG\Parameter(name="marginbottom", in="query", required=false, type="number", description="bottom margin in inches"), * @SWG\Parameter(name="printlayout", in="query", required=false, type="string", description="The PrintLayout resource to use for plotting. Only applies if plotting to DWF"), * @SWG\Parameter(name="title", in="query", required=false, type="string", description="The title to put in the plot"), * @SWG\Parameter(name="type", in="path", required=true, type="string", description="The plot type", enum={"dwf", "pdf"}), * @SWG\Response(response=400, description="You supplied a bad request due to one or more missing or invalid parameters"), * @SWG\Response(response=401, description="Session ID or MapGuide credentials not specified"), * @SWG\Response(response=500, description="An error occurred during the operation") * ) */ $app->get("/library/:resourcePath+.MapDefinition/plot.:format", function ($resourcePath, $format) use($app) { $count = count($resourcePath); if ($count > 0) { $resourcePath[$count - 1] = $resourcePath[$count - 1] . ".MapDefinition"; } $resId = MgUtils::ParseLibraryResourceID($resourcePath); $ctrl = new MgMappingServiceController($app); $ctrl->GeneratePlotFromMapDefinition($resId, $format); }); //================================= Rendering Service APIs ================================== /** * @SWG\Get( * path="/library/{resourcePath}.MapDefinition/image.{type}", * operationId="RenderMapDefinition", * summary="Renders an image of the specified map definition", * tags={"library"}, * @SWG\Parameter(name="session", in="query", required=false, type="string", description="Your MapGuide Session ID"), * @SWG\Parameter(name="resourcePath", in="path", required=true, type="string", description="The path of the Map Definition"), * @SWG\Parameter(name="x", in="query", required=true, type="integer", description="The X coordinate of the map center to render"), * @SWG\Parameter(name="y", in="query", required=true, type="integer", description="The Y coordinate of the map center to render"), * @SWG\Parameter(name="scale", in="query", required=true, type="number", description="The map scale to render"), * @SWG\Parameter(name="width", in="query", required=true, type="integer", description="The width of the image"),
* @SWG\Response(response=500, description="An error occurred during the operation") * ) */ $app->post("/services/transformcoords", function () use($app) { $ctrl = new MgCoordinateSystemController($app); $ctrl->TransformCoordinates(); }); /** * @SWG\Post( * path="/services/createmap.{type}", * operationId="CreateRuntimeMap", * summary="Creates a new Runtime Map (MgMap) instance from the specified map definition and returns detailed information about its layer/group structure if requested", * tags={"services"}, * @SWG\Parameter(name="session", in="formData", required=false, type="string", description="Your MapGuide Session ID. If none specified you must pass the basic http authentication challenge"), * @SWG\Parameter(name="mapdefinition", in="formData", required=true, type="string", description="The Map Definition ID to create a new runtime map from"), * @SWG\Parameter(name="targetmapname", in="formData", required=false, type="string", description="The target map name to associate the Runtime Map by. By default, the name is generated from the Map Definition ID"), * @SWG\Parameter(name="requestedfeatures", in="formData", required=false, type="integer", description="A bitmask of the information about the Runtime Map that you would like returned. 1=Layer/Group structure, 2=icons, 4=Feature Source Information"), * @SWG\Parameter(name="iconformat", in="formData", required=false, type="string", description="The desired icon image format if icons are requested", enum={"PNG","JPG","PNG8","GIF"}), * @SWG\Parameter(name="iconwidth", in="formData", required=false, type="integer", description="The desired width of generated icons if icons are requested"), * @SWG\Parameter(name="iconheight", in="formData", required=false, type="integer", description="The desired height of generated icons if icons are requested"), * @SWG\Parameter(name="iconsperscalerange", in="formData", required=false, type="integer", description="The number of icons to generate per scale range if icons are requested"), * @SWG\Parameter(name="type", in="path", required=true, type="string", description="xml or json", enum={"json", "xml"}), * @SWG\Response(response=400, description="You supplied a bad request due to one or more missing or invalid parameters"), * @SWG\Response(response=401, description="Session ID or MapGuide credentials not specified"), * @SWG\Response(response=500, description="An error occurred during the operation") * ) */ $app->post("/services/createmap.:format", function ($format) use($app) { $ctrl = new MgMappingServiceController($app); $ctrl->CreateRuntimeMap($format); });
public function EnumerateMapLayerGroups($sessionId, $mapName, $format) { $userInfo = new MgUserInformation($sessionId); $siteConn = new MgSiteConnection(); $siteConn->Open($userInfo); $map = new MgMap($siteConn); $map->Open($mapName); $groups = $map->GetLayerGroups(); $groupCount = $groups->GetCount(); $output = "<GroupCollection>"; for ($i = 0; $i < $groupCount; $i++) { $group = $groups->GetItem($i); $parent = $group->GetGroup(); $output .= MgMappingServiceController::CreateGroupItem($group, $parent); } $output .= "</GroupCollection>"; $bs = new MgByteSource($output, strlen($output)); $bs->SetMimeType(MgMimeType::Xml); $br = $bs->GetReader(); if ($format == "json") { $this->OutputXmlByteReaderAsJson($br); } else { $this->OutputByteReader($br); } }