[mapserver-commits] r9075 - sandbox/davidK

svn at osgeo.org svn at osgeo.org
Wed Jun 3 18:03:32 EDT 2009


Author: davidK
Date: 2009-06-03 18:03:32 -0400 (Wed, 03 Jun 2009)
New Revision: 9075

Added:
   sandbox/davidK/mapkml.cpp
   sandbox/davidK/mapkml.h
   sandbox/davidK/mapkmlrenderer.cpp
   sandbox/davidK/mapkmlrenderer.h
Log:


Added: sandbox/davidK/mapkml.cpp
===================================================================
--- sandbox/davidK/mapkml.cpp	                        (rev 0)
+++ sandbox/davidK/mapkml.cpp	2009-06-03 22:03:32 UTC (rev 9075)
@@ -0,0 +1,155 @@
+#include "mapserver.h"
+#include "mapkmlrenderer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+KmlRenderer* getKmlRenderer(imageObj* img)
+{
+	return (KmlRenderer*) img->img.plugin;
+}
+
+imageObj* msCreateImageKml(int width, int height, outputFormatObj *format, colorObj* bg)
+{
+	imageObj *image = NULL;
+
+	image = (imageObj*)malloc(sizeof(imageObj));
+	memset(image, 0, sizeof(imageObj));
+
+	KmlRenderer *ren = new KmlRenderer(width, height, bg);
+	image->img.plugin = (void *) ren;
+
+	return image;
+}
+
+int msSaveImageKml(imageObj *img, FILE *fp, outputFormatObj *format)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+	return renderer->saveImage(img, fp, format);
+}
+
+void msRenderLineKml(imageObj *img, shapeObj *p, strokeStyleObj *style)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+	renderer->renderLine(img, p, style);
+}
+
+void msRenderPolygonKml(imageObj *img, shapeObj *p, colorObj *color)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+	renderer->renderPolygon(img, p, color);
+}
+
+void msRenderPolygonTiledKml(imageObj *img, shapeObj *p, void *tile)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+}
+
+void msRenderLineTiledKml(imageObj *img, shapeObj *p, void *tile)
+{
+}
+
+void msRenderGlyphsKml(imageObj *img, double x, double y,
+      labelStyleObj *style, char *text)
+{
+}
+
+void msRenderGlyphsLineKml(imageObj *img,labelPathObj *labelpath,
+      labelStyleObj *style, char *text)
+{
+}
+
+void msRenderVectorSymbolKml(imageObj *img, double x, double y,
+		symbolObj *symbol, symbolStyleObj *style)
+{
+}
+
+void* msCreateVectorSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style)
+{
+	return NULL;
+}
+
+void msRenderPixmapSymbolKml(imageObj *img, double x, double y,
+    	symbolObj *symbol, symbolStyleObj *style)
+{
+}
+
+void* msCreatePixmapSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style)
+{
+	return NULL;
+}
+
+void msRenderEllipseSymbolKml(imageObj *image, double x, double y, 
+		symbolObj *symbol, symbolStyleObj *style)
+{
+}
+
+void* msCreateEllipseSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style)
+{
+	return NULL;
+}
+
+void msRenderTruetypeSymbolKml(imageObj *img, double x, double y,
+        symbolObj *symbol, symbolStyleObj *style)
+{
+}
+
+void* msCreateTruetypeSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style)
+{
+	return NULL;
+}
+
+void msRenderTileKml(imageObj *img, void *tile, double x, double y, double angle)
+{
+}
+
+void msGetRasterBufferKml(imageObj *img,rasterBufferObj *rb)
+{
+}
+
+void msMergeRasterBufferKml(imageObj *dest, rasterBufferObj *overlay, double opacity, int dstX, int dstY)
+{
+}
+
+int msGetTruetypeTextBBoxKml(imageObj *img,char *font, double size, char *string,
+		rectObj *rect, double **advances)
+{
+	return MS_FALSE;
+}
+
+void msStartNewLayerKml(imageObj *img, double opacity)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+	renderer->startNewLayer(img, opacity);
+}
+
+void msCloseNewLayerKml(imageObj *img, double opacity)
+{
+	KmlRenderer* renderer = getKmlRenderer(img);
+	renderer->closeNewLayer(img, opacity);
+}
+
+void msTransformShapeKml(shapeObj *shape, rectObj extend, double cellsize)
+{
+}
+
+void msFreeImageKml(imageObj *image)
+{
+}
+
+void msFreeTileKml(void *tile)
+{
+}
+
+void msFreeSymbolKml(symbolObj *symbol)
+{
+}
+
+#ifdef __cplusplus
+}
+#endif
\ No newline at end of file

Added: sandbox/davidK/mapkml.h
===================================================================
--- sandbox/davidK/mapkml.h	                        (rev 0)
+++ sandbox/davidK/mapkml.h	2009-06-03 22:03:32 UTC (rev 9075)
@@ -0,0 +1,64 @@
+#ifndef MAPKML_H
+#define MAPKML_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mapserver.h"
+
+imageObj* msCreateImageKml(int width, int height, outputFormatObj *format, colorObj* bg);
+int msSaveImageKml(imageObj *img, FILE *fp, outputFormatObj *format);
+void msRenderLineKml(imageObj *img, shapeObj *p, strokeStyleObj *style);
+void msRenderPolygonKml(imageObj *img, shapeObj *p, colorObj *color);
+void msRenderPolygonTiledKml(imageObj *img, shapeObj *p, void *tile);
+void msRenderLineTiledKml(imageObj *img, shapeObj *p, void *tile);
+void msRenderGlyphsKml(imageObj *img, double x, double y,
+      labelStyleObj *style, char *text);
+
+void msRenderGlyphsLineKml(imageObj *img,labelPathObj *labelpath,
+      labelStyleObj *style, char *text);
+
+void msRenderVectorSymbolKml(imageObj *img, double x, double y,
+		symbolObj *symbol, symbolStyleObj *style);
+
+void* msCreateVectorSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style);
+
+void msRenderPixmapSymbolKml(imageObj *img, double x, double y,
+    	symbolObj *symbol, symbolStyleObj *style);
+
+void* msCreatePixmapSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style);
+
+void msRenderEllipseSymbolKml(imageObj *image, double x, double y, 
+		symbolObj *symbol, symbolStyleObj *style);
+
+void* msCreateEllipseSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style);
+
+void msRenderTruetypeSymbolKml(imageObj *img, double x, double y,
+        symbolObj *symbol, symbolStyleObj *style);
+
+void* msCreateTruetypeSymbolTileKml(int width, int height,
+        symbolObj *symbol, symbolStyleObj *style);
+
+void msRenderTileKml(imageObj *img, void *tile, double x, double y, double angle);
+void msGetRasterBufferKml(imageObj *img,rasterBufferObj *rb);
+
+void msMergeRasterBufferKml(imageObj *dest, rasterBufferObj *overlay, double opacity, int dstX, int dstY);
+int msGetTruetypeTextBBoxKml(imageObj *img,char *font, double size, char *string,
+		rectObj *rect, double **advances);
+
+void msStartNewLayerKml(imageObj *img, double opacity);
+void msCloseNewLayerKml(imageObj *img, double opacity);
+void msTransformShapeKml(shapeObj *shape, rectObj extend, double cellsize);
+void msFreeImageKml(imageObj *image);
+void msFreeTileKml(void *tile);
+void msFreeSymbolKml(symbolObj *symbol);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MAPKML_H */
\ No newline at end of file

Added: sandbox/davidK/mapkmlrenderer.cpp
===================================================================
--- sandbox/davidK/mapkmlrenderer.cpp	                        (rev 0)
+++ sandbox/davidK/mapkmlrenderer.cpp	2009-06-03 22:03:32 UTC (rev 9075)
@@ -0,0 +1,102 @@
+#ifdef USE_KML
+
+#include "mapserver.h"
+#include "maperror.h"
+#include "mapkmlrenderer.h"
+#include "mapio.h"
+
+KmlRenderer::KmlRenderer(int width, int height, colorObj* color/*=NULL*/) 
+	:	XmlDoc(NULL), LayerNode(NULL)
+{
+	//	Create document.
+    XmlDoc = xmlNewDoc(BAD_CAST "1.0");
+
+    RootNode = xmlNewNode(NULL, BAD_CAST "kml");
+
+	//	Name spaces
+    xmlSetNs(RootNode, xmlNewNs(RootNode, BAD_CAST "http://www.opengis.net/kml/2.2", NULL));
+
+    xmlDocSetRootElement(XmlDoc, RootNode);
+
+	xmlNodePtr docNode = xmlNewChild(RootNode, NULL, BAD_CAST "Document", NULL);
+}
+
+KmlRenderer::~KmlRenderer()
+{
+	if (XmlDoc)
+		xmlFreeDoc(XmlDoc);
+
+	xmlCleanupParser();
+}
+
+imageObj* KmlRenderer::createImage(int width, int height, outputFormatObj *format, colorObj* bg)
+{
+	return NULL;
+}
+
+int KmlRenderer::saveImage(imageObj *img, FILE *fp, outputFormatObj *format)
+{
+	/* -------------------------------------------------------------------- */
+	/*      Write out the document.                                         */
+	/* -------------------------------------------------------------------- */
+
+	int size = 0;
+	xmlChar *buffer = NULL;
+	msIOContext *context = NULL;
+
+	if( msIO_needBinaryStdout() == MS_FAILURE )
+		return MS_FAILURE;
+
+	xmlDocDumpFormatMemoryEnc(XmlDoc, &buffer, &size, "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);
+	}
+	else
+	{
+		msIO_fprintf(fp, "%s", buffer);
+	}
+
+	xmlFree(buffer);
+
+	return(MS_SUCCESS);
+}
+
+void KmlRenderer::freeImage(imageObj *image)
+{
+}
+
+void KmlRenderer::startNewLayer(imageObj *img, double opacity)
+{
+	LayerNode = xmlNewChild(RootNode, NULL, BAD_CAST "Folder", NULL);
+	xmlAddChild(RootNode, LayerNode);
+	
+	xmlNodePtr layerNameNode = xmlNewChild(LayerNode, NULL, BAD_CAST "name", NULL);
+	xmlNodeAddContent(layerNameNode, BAD_CAST "layerName...");
+
+	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, double opacity)
+{
+	
+}
+
+void KmlRenderer::renderLine(imageObj *img, shapeObj *p, strokeStyleObj *style)
+{
+	printf("\n");
+}
+
+void KmlRenderer::renderPolygon(imageObj *img, shapeObj *p, colorObj *color)
+{
+
+}
+
+#endif
\ No newline at end of file

Added: sandbox/davidK/mapkmlrenderer.h
===================================================================
--- sandbox/davidK/mapkmlrenderer.h	                        (rev 0)
+++ sandbox/davidK/mapkmlrenderer.h	2009-06-03 22:03:32 UTC (rev 9075)
@@ -0,0 +1,35 @@
+#ifndef MAPKMLRENDERER_H
+#define MAPKMLRENDERER_H
+
+#if defined(USE_KML) && defined (USE_LIBXML2)
+
+#include "mapserver.h"
+#include "maplibxml2.h"
+
+
+class KmlRenderer
+{
+protected:
+
+    xmlDocPtr	XmlDoc;	/* document pointer */
+	xmlNodePtr	RootNode;
+	xmlNodePtr	LayerNode;
+
+public:
+
+	KmlRenderer(int width, int height, colorObj* color = NULL);
+	virtual ~KmlRenderer();
+
+    imageObj* createImage(int width, int height, outputFormatObj *format, colorObj* bg);
+    int saveImage(imageObj *img, FILE *fp, outputFormatObj *format);
+    void freeImage(imageObj *image);
+    
+	void startNewLayer(imageObj *img, double opacity);
+	void closeNewLayer(imageObj *img, double opacity);
+
+	void renderLine(imageObj *img, shapeObj *p, strokeStyleObj *style);
+	void renderPolygon(imageObj *img, shapeObj *p, colorObj *color);
+};
+
+#endif /* USE_KML && USE_LIBXML2*/
+#endif
\ No newline at end of file



More information about the mapserver-commits mailing list