[mapserver-commits] r9090 - sandbox/davidK

svn at osgeo.org svn at osgeo.org
Sat Jun 6 19:17:10 EDT 2009


Author: davidK
Date: 2009-06-06 19:17:10 -0400 (Sat, 06 Jun 2009)
New Revision: 9090

Modified:
   sandbox/davidK/mapkmlrenderer.cpp
   sandbox/davidK/mapkmlrenderer.h
Log:


Modified: sandbox/davidK/mapkmlrenderer.cpp
===================================================================
--- sandbox/davidK/mapkmlrenderer.cpp	2009-06-06 14:15:26 UTC (rev 9089)
+++ sandbox/davidK/mapkmlrenderer.cpp	2009-06-06 23:17:10 UTC (rev 9090)
@@ -40,27 +40,37 @@
 	/*      Write out the document.                                         */
 	/* -------------------------------------------------------------------- */
 
-	int size = 0;
-	xmlChar *buffer = NULL;
+	int bufSize = 0;
+	xmlChar *buf = NULL;
 	msIOContext *context = NULL;
 
 	if( msIO_needBinaryStdout() == MS_FAILURE )
 		return MS_FAILURE;
 
-	xmlDocDumpFormatMemoryEnc(XmlDoc, &buffer, &size, "ISO-8859-1", 1);
+	xmlDocDumpFormatMemoryEnc(XmlDoc, &buf, &bufSize, "ISO-8859-1", 1);
 
 	context = msIO_getHandler(fp);
 	if (context)
 	{
 		msIO_printf("Content-type: %s%c%c",format->mimetype,10,10);
-		msIO_contextWrite(context, buffer, size);
+
+		int chunkSize = 4096;
+
+		for (int i=0; i<bufSize; i+=chunkSize)
+		{
+			int size = chunkSize;
+			if (i + size > bufSize)
+				size = bufSize - i;
+
+			msIO_contextWrite(context, buf+i, size);
+		}
 	}
 	else
 	{
-		msIO_fprintf(fp, "%s", buffer);
+		//msIO_fprintf(fp, "%s", buffer);
 	}
 
-	xmlFree(buffer);
+	xmlFree(buf);
 
 	return(MS_SUCCESS);
 }
@@ -75,13 +85,10 @@
 	xmlAddChild(RootNode, LayerNode);
 	
 	xmlNodePtr layerNameNode = xmlNewChild(LayerNode, NULL, BAD_CAST "name", NULL);
-	xmlNodeAddContent(layerNameNode, BAD_CAST "layerName...");
+	xmlNodeAddContent(layerNameNode, BAD_CAST layer->name);
 
 	xmlNodePtr layerVisibilityNode = xmlNewChild(LayerNode, NULL, BAD_CAST "visibility", NULL);
 	xmlNodeAddContent(layerVisibilityNode, BAD_CAST "1");
-
-	xmlNodePtr layerDescriptionNode = xmlNewChild(LayerNode, NULL, BAD_CAST "description", NULL);
-	xmlNodeAddContent(layerDescriptionNode, BAD_CAST "layer desc...");
 }
 
 void KmlRenderer::closeNewLayer(imageObj *img, layerObj *layer)
@@ -91,7 +98,23 @@
 
 void KmlRenderer::renderLine(imageObj *img, shapeObj *p, strokeStyleObj *style)
 {
-	printf("\n");
+	xmlNodePtr placemarkNode = xmlNewChild(LayerNode, NULL, BAD_CAST "Placemark", NULL);
+
+	xmlNodePtr styleUrlNode = xmlNewChild(placemarkNode, NULL, BAD_CAST "styleUrl", NULL);
+	xmlNodeAddContent(styleUrlNode, BAD_CAST "#");
+
+	int includeZ = 1;
+
+	if (p->numlines == 1)
+	{
+		xmlNodePtr lineStringNode = xmlNewChild(placemarkNode, NULL, BAD_CAST "LineString", NULL);
+		addCoordsNode(lineStringNode, &p->line[0], includeZ);
+	}
+	else
+	{
+
+
+	}
 }
 
 void KmlRenderer::renderPolygon(imageObj *img, shapeObj *p, colorObj *color)
@@ -99,4 +122,19 @@
 
 }
 
+void KmlRenderer::addCoordsNode(xmlNodePtr node, lineObj *line, int includeZ)
+{
+	char lineBuf[128];
+
+	xmlNodePtr coordsNode = xmlNewChild(node, NULL, BAD_CAST "coordinates", NULL);
+	xmlNodeAddContent(coordsNode, BAD_CAST "\n");
+
+	for (int i=0; i<line->numpoints; i++)
+	{
+		sprintf(lineBuf, "\t%.8f,%.8f,%.8f\n", line->point[i].x, line->point[i].y,line->point[i].z);
+		xmlNodeAddContent(coordsNode, BAD_CAST lineBuf);
+	}
+	xmlNodeAddContent(coordsNode, BAD_CAST "\t");
+}
+
 #endif
\ No newline at end of file

Modified: sandbox/davidK/mapkmlrenderer.h
===================================================================
--- sandbox/davidK/mapkmlrenderer.h	2009-06-06 14:15:26 UTC (rev 9089)
+++ sandbox/davidK/mapkmlrenderer.h	2009-06-06 23:17:10 UTC (rev 9090)
@@ -15,6 +15,10 @@
 	xmlNodePtr	RootNode;
 	xmlNodePtr	LayerNode;
 
+protected:
+
+	void addCoordsNode(xmlNodePtr node, lineObj *line, int includeZ);
+
 public:
 
 	KmlRenderer(int width, int height, colorObj* color = NULL);



More information about the mapserver-commits mailing list