[mapserver-commits] r9244 - sandbox/davidK

svn at osgeo.org svn at osgeo.org
Mon Aug 10 01:40:24 EDT 2009


Author: davidK
Date: 2009-08-10 01:40:22 -0400 (Mon, 10 Aug 2009)
New Revision: 9244

Modified:
   sandbox/davidK/mapkmlrenderer.cpp
   sandbox/davidK/mapkmlrenderer.h
Log:
code cleaned, bug fixes

Modified: sandbox/davidK/mapkmlrenderer.cpp
===================================================================
--- sandbox/davidK/mapkmlrenderer.cpp	2009-08-07 08:37:58 UTC (rev 9243)
+++ sandbox/davidK/mapkmlrenderer.cpp	2009-08-10 05:40:22 UTC (rev 9244)
@@ -41,7 +41,7 @@
 	:	XmlDoc(NULL), LayerNode(NULL), GroundOverlayNode(NULL), Width(width), Height(height),
 		FirstLayer(true), RasterizerOutputFormat(NULL), InternalImg(NULL),
 		VectorMode(true), RasterMode(false), MapCellsize(1.0),
-		PlacemarkNode(NULL), GeomNode(NULL)
+		PlacemarkNode(NULL), GeomNode(NULL), MaxFeatureCount(100)
 {
 	//	Create document.
     XmlDoc = xmlNewDoc(BAD_CAST "1.0");
@@ -72,9 +72,6 @@
 		msFreeHashTable(StyleHashTable);
 
 	xmlCleanupParser();
-
-	//if (RasterizerOutputFormat)
-	//	msFreeOutputFormat(RasterizerOutputFormat);
 }
 
 imageObj* KmlRenderer::createInternalImage()
@@ -169,8 +166,6 @@
 
 void KmlRenderer::startNewLayer(imageObj *img, layerObj *layer)
 {
-	//LayerNode = xmlNewChild(DocNode, NULL, BAD_CAST "Folder", NULL);
-
 	LayerNode = xmlNewNode(NULL, BAD_CAST "Folder");
 	
 	xmlNewChild(LayerNode, NULL, BAD_CAST "name", BAD_CAST layer->name);
@@ -208,7 +203,7 @@
 
 		for (int i=0; i<layer->map->numoutputformats; i++)
 		{
-			const char *formatOptionStr = msGetOutputFormatOption(layer->map->outputformatlist[i],"kml_rasteroutputformat", "");
+			const char *formatOptionStr = msGetOutputFormatOption(layer->map->outputformatlist[i], "kml_rasteroutputformat", "");
 			if (strlen(formatOptionStr))
 			{
 				sprintf(rasterizerFomatName, "%s", formatOptionStr);
@@ -221,13 +216,16 @@
 			outputFormatObj *iFormat = layer->map->outputformatlist[i];
 			if(!strcasecmp(iFormat->name,rasterizerFomatName))
 			{
-				//RasterizerOutputFormat = msCloneOutputFormat(iFormat);
 				RasterizerOutputFormat = iFormat;
-
-				//InternalImg = createInternalImage();
 				break;
 			}
 		}
+
+		const char *formatOptionStr = msGetOutputFormatOption(img->format, "kml_maxfeaturecount", "");
+		if (strlen(formatOptionStr))
+		{
+			MaxFeatureCount = atoi(formatOptionStr);
+		}
 	}
 
 	// reset feature counter
@@ -240,7 +238,7 @@
 {
 	flushPlacemark();
 
-	if (FeatureCount > MaxFeatureCount)
+	if (!VectorMode)
 	{
 		// layer was rasterized, merge temp layer image with main output image
 
@@ -257,7 +255,7 @@
 
 			r->mergeRasterBuffer(InternalImg, &data, layer->opacity * 0.01, 0, 0);
 
-			msFreeImage(TempImg);
+			r->freeImage(TempImg);
 		}
 
 		xmlFreeNode(LayerNode);
@@ -308,13 +306,6 @@
 		if (MaxFeatureCount == 0)
 			VectorMode = false;
 	}
-	else
-	{
-		// no kml_maxfeaturecount tag found, set default feature count to 128
-		// if FeatureCount is greater than MaxFeatureCount, layer is rasterized and
-		// rendered as ground overlay
-		MaxFeatureCount = 128;
-	}
 }
 
 int KmlRenderer::checkProjection(projectionObj *projection)
@@ -788,96 +779,6 @@
 	}
 }
 
-char* KmlRenderer::lookupPointStyle(colorObj *color)
-{
-	return NULL;
-}
-
-char* KmlRenderer::lookupLineStyle(strokeStyleObj *strokeStyle)
-{
-	/*
-	<LineStyle id="ID">
-	  <!-- inherited from ColorStyle -->
-	  <color>ffffffff</color>            <!-- kml:color -->
-	  <colorMode>normal</colorMode>      <!-- colorModeEnum: normal or random -->
-
-	  <!-- specific to LineStyle -->
-	  <width>1</width>                   <!-- float -->
-	</LineStyle>
-	*/
-
-	char hexColor[16];
-	sprintf(hexColor,"%02x%02x%02x%02x", strokeStyle->color.alpha, strokeStyle->color.blue,
-											strokeStyle->color.green, strokeStyle->color.red);
-
-	char styleName[32];
-	sprintf(styleName, "lineStyle%s_w%.1f", hexColor, strokeStyle->width);
-
-	char *styleUrl = msLookupHashTable(StyleHashTable, styleName);
-	if (!styleUrl)
-	{
-		char styleValue[32];
-		sprintf(styleValue, "#%s", styleName);
-
-		hashObj *hash = msInsertHashTable(StyleHashTable, styleName, styleValue);
-		styleUrl = hash->data;
-
-		// Insert new PolyStyle node into Document node
-		xmlNodePtr styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
-		xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST styleName);
-
-		xmlNodePtr lineStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "LineStyle", NULL);
-		xmlNewChild(lineStyleNode, NULL, BAD_CAST "color", BAD_CAST hexColor);
-
-		char width[16];
-		sprintf(width, "%.1f", strokeStyle->width);
-		xmlNewChild(lineStyleNode, NULL, BAD_CAST "width", BAD_CAST width);
-	}
-
-	return styleUrl;
-}
-
-char* KmlRenderer::lookupPolygonStyle(colorObj *color)
-{
-	/*
-	<PolyStyle id="ID">
-	  <!-- inherited from ColorStyle -->
-	  <color>ffffffff</color>            <!-- kml:color -->
-	  <colorMode>normal</colorMode>      <!-- kml:colorModeEnum: normal or random -->
-
-	  <!-- specific to PolyStyle -->
-	  <fill>1</fill>                     <!-- boolean -->
-	  <outline>1</outline>               <!-- boolean -->
-	</PolyStyle>
-	*/
-
-	char hexColor[16];
-	sprintf(hexColor,"%02x%02x%02x%02x", color->alpha, color->blue, color->green, color->red);
-
-	char styleName[32];
-	sprintf(styleName, "polyStyle%s", hexColor);
-
-	char *styleUrl = msLookupHashTable(StyleHashTable, styleName);
-	if (!styleUrl)
-	{
-		char styleValue[32];
-		sprintf(styleValue, "#%s", styleName);
-
-		hashObj *hash = msInsertHashTable(StyleHashTable, styleName, styleValue);
-		styleUrl = hash->data;
-
-		// Insert new PolyStyle node into Document node
-		xmlNodePtr styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
-		xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST styleName);
-
-		xmlNodePtr polyStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "PolyStyle", NULL);
-		xmlNewChild(polyStyleNode, NULL, BAD_CAST "color", BAD_CAST hexColor);
-	}
-
-	return styleUrl;
-}
-
-
 char* KmlRenderer::lookupSymbolUrl(symbolObj *symbol, symbolStyleObj *style)
 {
 	/*	

Modified: sandbox/davidK/mapkmlrenderer.h
===================================================================
--- sandbox/davidK/mapkmlrenderer.h	2009-08-07 08:37:58 UTC (rev 9243)
+++ sandbox/davidK/mapkmlrenderer.h	2009-08-10 05:40:22 UTC (rev 9244)
@@ -82,8 +82,21 @@
 	int				FirstLayer;
 
 	// max number of features rendered in "vector KML" mode
+	// default value 100
+	// value can be specified in format option
+	// OUTPUTFORMAT
+	//  ...
+	//	FORMATOPTION "kml_maxfeaturecount=512"
+	// END	
+	//
+	// value can be specified also in layer metadata
+	// METADATA
+	//	kml_maxfeaturecount	"512"
+	// END	
 	int				MaxFeatureCount;
 
+	// if FeatureCount is greater than MaxFeatureCount, layer is rasterized and
+	// rendered as ground overlay
 	// number of features in layer
 	int				FeatureCount;
 
@@ -105,10 +118,6 @@
 	xmlNodePtr createPlacemarkNode(xmlNodePtr parentNode, char *styleUrl);
 	xmlNodePtr createGroundOverlayNode(char *imageHref);
 
-	char* lookupPointStyle(colorObj *color);
-	char* lookupLineStyle(strokeStyleObj *strokeStyle);
-	char* lookupPolygonStyle(colorObj *color);
-
 	char* lookupSymbolUrl(symbolObj *symbol, symbolStyleObj *style);
 
 	void addCoordsNode(xmlNodePtr parentNode, pointObj *pts, int numPts);



More information about the mapserver-commits mailing list