function CreateMarkupLayerDefinitionContent($featureSourceId, $className) { $basic = (strcmp($this->args["REDLINESTYLIZATION"], "BASIC") == 0); // Create the Markup Layer Definition. Create or update, this code is the same. $hexFgTransparency = sprintf("%02x", 255 * (100 - $this->args['FILLTRANSPARENCY']) / 100); // Convert % to an alpha value $hexBgTransparency = $this->args['FILLBACKTRANS'] ? "FF" : "00"; // All or nothing $bold = array_key_exists('LABELBOLD', $this->args) ? "true" : "false"; $italic = array_key_exists('LABELITALIC', $this->args) ? "true" : "false"; $underline = array_key_exists('LABELUNDERLINE', $this->args) ? "true" : "false"; if ($basic) { $markupLayerDefinition = file_get_contents("templates/markuplayerdefinition.xml"); $markupLayerDefinition = sprintf($markupLayerDefinition, $featureSourceId, //<ResourceId> - Feature Source $className, //<FeatureName> - Class Name $this->args['LABELSIZEUNITS'], //<Unit> - Mark Label $this->args['LABELFONTSIZE'], //<SizeX> - Mark Label Size $this->args['LABELFONTSIZE'], //<SizeY> - Mark Label Size 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Mark Label 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Mark Label $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Mark Label $bold, //<Bold> - Mark Label $italic, //<Bold> - Mark Label $underline, //<Underlined> - Mark Label $this->args['MARKERSIZEUNITS'], //<Unit> - Mark $this->args['MARKERSIZE'], //<SizeX> - Mark $this->args['MARKERSIZE'], //<SizeY> - Mark $this->args['MARKERTYPE'], //<Shape> - Mark 'FF' . $this->args['MARKERCOLOR'], //<ForegroundColor> - Mark 'FF' . $this->args['MARKERCOLOR'], //<Color> - Mark $this->args['LABELSIZEUNITS'], //<Unit> - Line Label $this->args['LABELFONTSIZE'], //<SizeX> - Line Label Size $this->args['LABELFONTSIZE'], //<SizeY> - Line Label Size 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Line Label 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Line Label $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Line Label $bold, //<Bold> - Line Label $italic, //<Bold> - Line Label $underline, //<Underlined> - Line Label $this->args['LINEPATTERN'], //<LineStyle> - Line $this->args['LINETHICKNESS'], //<Thickness> - Line 'FF' . $this->args['LINECOLOR'], //<Color> - Line $this->args['LINESIZEUNITS'], //<Unit> - Line $this->args['LABELSIZEUNITS'], //<Unit> - Polygon Label $this->args['LABELFONTSIZE'], //<SizeX> - Polygon Label Size $this->args['LABELFONTSIZE'], //<SizeY> - Polygon Label Size 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Polygon Label 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Polygon Label $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Polygon Label $bold, //<Bold> - Polygon Label $italic, //<Bold> - Polygon Label $underline, //<Underlined> - Polygon Label $this->args['FILLPATTERN'], //<FillPattern> - Fill $hexFgTransparency . $this->args['FILLFORECOLOR'], //<ForegroundColor> - Fill $hexBgTransparency . $this->args['FILLBACKCOLOR'], //<BackgroundColor> - Fill $this->args['BORDERPATTERN'], //<LineStyle> - Fill $this->args['BORDERTHICKNESS'], //<Thickness> - Fill 'FF' . $this->args['BORDERCOLOR'], //<Color> - Fill $this->args['BORDERSIZEUNITS']); //<Unit> - Fill } else { //Unlike other sprintf() based templates, we're using named placeholders for Advanced Stylization templates because there is //just way too many parameters to specify using a sprintf() approach with a high chance of parameter count mismatches as well. $markupLayerDefinition = file_get_contents("templates/markuplayerdefinition_advanced.xml"); $fontHeight = MarkupManager::SizeInMM($this->args['LABELFONTSIZE'], $this->args['LABELSIZEUNITS']); $labelForeColor = 'FF' . $this->args['LABELFORECOLOR']; $labelBackColor = 'FF' . $this->args['LABELBACKCOLOR']; //Substitute inner templates first, so their placeholders tokens are also brought in $markupLayerDefinition = str_replace("#{FILL_PATTERN_TEMPLATE}", MarkupManager::GetFillPatternTemplate($this->args['FILLPATTERN']), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{BORDER_PATTERN_TEMPLATE}", MarkupManager::GetBorderPatternGeometry($this->args['BORDERPATTERN']), $markupLayerDefinition); //For non-opaque labels we need to empty the frame fill color if (strcmp($this->args["LABELBACKSTYLE"], "Opaque") == 0) { $markupLayerDefinition = str_replace("#{FRAME_FILL_COLOR}", "0xffffffff", $markupLayerDefinition); } else { $markupLayerDefinition = str_replace("#{FRAME_FILL_COLOR}", "", $markupLayerDefinition); if (strcmp($this->args["LABELBACKSTYLE"], "Transparent") == 0) { $labelBackColor = ""; } } //I don't think this is correct wrt to the UI, but this is to replicate the behaviour that we currently have under basic stylization //If fill is solid and background color is fully transparent, comment that portion out of the composite type style as it will interfere //with the area foreground symbol if (strcmp($hexBgTransparency, "FF") == 0 && strcmp($this->args['FILLPATTERN'], "Solid") == 0) { $markupLayerDefinition = str_replace("#{START_BACKGROUND_FILL}", "<!--", $markupLayerDefinition); $markupLayerDefinition = str_replace("#{END_BACKGROUND_FILL}", "-->", $markupLayerDefinition); } else { $markupLayerDefinition = str_replace("#{START_BACKGROUND_FILL}", "", $markupLayerDefinition); $markupLayerDefinition = str_replace("#{END_BACKGROUND_FILL}", "", $markupLayerDefinition); } //Then do a find/replace of all known tokens $markupLayerDefinition = str_replace("#{RESOURCE_ID}", $featureSourceId, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{FEATURE_CLASS}", $className, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{FONT_HEIGHT}", $fontHeight, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{LABEL_FORE_COLOR}", $labelForeColor, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{LABEL_BACK_COLOR}", $labelBackColor, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{BOLD}", $bold, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{ITALIC}", $italic, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{UNDERLINE}", $underline, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MARKER_GEOMETRY}", MarkupManager::GetMarkerGeometry($this->args['MARKERTYPE']), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MARKER_SIZE_X}", MarkupManager::GetMarkerSize($this->args["MARKERSIZE"], $this->args["MARKERSIZEUNITS"]), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MARKER_SIZE_Y}", MarkupManager::GetMarkerSize($this->args["MARKERSIZE"], $this->args["MARKERSIZEUNITS"]), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MARKER_COLOR}", 'FF' . $this->args['MARKERCOLOR'], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{LINE_PATTERN_GEOMETRY}", MarkupManager::GetLinePatternGeometry($this->args['LINEPATTERN']), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{LINE_THICKNESS}", MarkupManager::GetLineThickness($this->args['LINETHICKNESS'], $this->args['LINESIZEUNITS']), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{LINE_COLOR}", 'FF' . $this->args['LINECOLOR'], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{FILL_BACK_COLOR}", $hexBgTransparency . $this->args['FILLBACKCOLOR'], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{FILL_FORE_COLOR}", $hexFgTransparency . $this->args['FILLFORECOLOR'], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{BORDER_THICKNESS}", MarkupManager::SizeInMM($this->args['BORDERTHICKNESS'], $this->args['BORDERSIZEUNITS']), $markupLayerDefinition); $markupLayerDefinition = str_replace("#{BORDER_COLOR}", 'FF' . $this->args['BORDERCOLOR'], $markupLayerDefinition); //Fill in the UI values under ExtendedData, so we can read from this element if we need to go back to Edit Style UI $markupLayerDefinition = str_replace("#{MG_RESOURCE_ID}", $featureSourceId, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FEATURE_CLASS}", $className, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FILL_PATTERN}", $this->args["FILLPATTERN"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_BORDER_PATTERN}", $this->args["BORDERPATTERN"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LINE_PATTERN}", $this->args["LINEPATTERN"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LABEL_FONT_SIZE}", $this->args["LABELFONTSIZE"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LABEL_FONT_UNITS}", $this->args["LABELSIZEUNITS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LABEL_FORECOLOR}", $this->args["LABELFORECOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LABEL_BACKCOLOR}", $this->args["LABELBACKCOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_BOLD}", $bold, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_ITALIC}", $italic, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_UNDERLINE}", $underline, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_MARKER_TYPE}", $this->args["MARKERTYPE"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_MARKER_SIZE}", $this->args["MARKERSIZE"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_MARKER_UNITS}", $this->args["MARKERSIZEUNITS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_MARKER_COLOR}", $this->args["MARKERCOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LINE_THICKNESS}", $this->args["LINETHICKNESS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LINE_UNITS}", $this->args["LINESIZEUNITS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LINE_COLOR}", $this->args["LINECOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FILL_BACK_COLOR}", $this->args["FILLBACKCOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FILL_FORE_COLOR}", $this->args["FILLFORECOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FILL_FORE_TRANSPARENCY}", $hexFgTransparency, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_FILL_BACK_TRANSPARENCY}", $hexBgTransparency, $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_BORDER_THICKNESS}", $this->args["BORDERTHICKNESS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_BORDER_UNITS}", $this->args["BORDERSIZEUNITS"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_BORDER_COLOR}", $this->args["BORDERCOLOR"], $markupLayerDefinition); $markupLayerDefinition = str_replace("#{MG_LABEL_STYLE}", $this->args["LABELBACKSTYLE"], $markupLayerDefinition); //print_r($markupLayerDefinition); } return $markupLayerDefinition; }