Commits

rashad  committed e4ed139

first phase cleaning done

  • Participants
  • Parent commits d1c000a

Comments (0)

Files changed (26)

File CMakeLists.txt

 
 
 ADD_LIBRARY (ossimVector SHARED
-load.cpp
+ossimVector.cpp
 ossimGdVectorSource.cpp
 ossimOgrVectorHandler.cpp
 ossimVectorFeature.cpp
 ossimVectorHandler.cpp
-ossimVectorLabel.cpp
-ossimVectorSource.cpp
-ossimVectorStyle.cpp)
+ossimVectorSource.cpp)
 
 # Link the executable to the OssimVector library.
 TARGET_LINK_LIBRARIES (ossimVector ${GDAL_LIBRARY} ${GEOS_LIBRARY} ${OSSIM_LIBRARIES} ${GD_LIBRARIES}) 
 
+ADD_EXECUTABLE(ossimVector_cli main.cpp)
+TARGET_LINK_LIBRARIES(ossimVector_cli ossimVector)
+
 #############################################################################
 # Makefile for building: ossimVectorQt
-# Generated by qmake (2.01a) (Qt 4.7.4) on: Wed Mar 7 22:55:02 2012
+# Generated by qmake (2.01a) (Qt 4.7.4) on: Thu Mar 8 23:10:50 2012
 # Project:  ossimVect.pro
 # Template: app
 # Command: /usr/bin/qmake -o Makefile ossimVect.pro
 DEFINES       = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
 CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
 CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.
+INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.. -I.
 LINK          = g++
 LFLAGS        = -Wl,-O1
 LIBS          = $(SUBLIBS)  -L/usr/lib/i386-linux-gnu -lgd -L.. -l ossimVector -lQtGui -lQtCore -lpthread 
 
 dist: 
 	@$(CHK_DIR_EXISTS) .tmp/ossimVectorQt1.0.0 || $(MKDIR) .tmp/ossimVectorQt1.0.0 
-	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents mainwindow.h widget.h ../load.h .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp widget.cpp .tmp/ossimVectorQt1.0.0/ && (cd `dirname .tmp/ossimVectorQt1.0.0` && $(TAR) ossimVectorQt1.0.0.tar ossimVectorQt1.0.0 && $(COMPRESS) ossimVectorQt1.0.0.tar) && $(MOVE) `dirname .tmp/ossimVectorQt1.0.0`/ossimVectorQt1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ossimVectorQt1.0.0
+	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents mainwindow.h widget.h .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp widget.cpp .tmp/ossimVectorQt1.0.0/ && (cd `dirname .tmp/ossimVectorQt1.0.0` && $(TAR) ossimVectorQt1.0.0.tar ossimVectorQt1.0.0 && $(COMPRESS) ossimVectorQt1.0.0.tar) && $(MOVE) `dirname .tmp/ossimVectorQt1.0.0`/ossimVectorQt1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ossimVectorQt1.0.0
 
 
 clean:compiler_clean 
 		ui_mainwindow.h
 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
 
-widget.o: widget.cpp widget.h \
-		../load.h \
-		../ossimVectorPrimitive.h
+widget.o: widget.cpp widget.h
 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o widget.o widget.cpp
 
 moc_mainwindow.o: moc_mainwindow.cpp 

File UI/ossimVect.pro

 TARGET = ossimVectorQt
 TEMPLATE = app
 SOURCES += main.cpp  mainwindow.cpp  widget.cpp
-HEADERS += mainwindow.h  widget.h ../load.h
+HEADERS += mainwindow.h  widget.h
+INCLUDEPATH+= "../"
 LIBS += -lgd -L.. -l ossimVector
+
+CCFLAG+= "-w"

File UI/widget.cpp

 #include <gd.h>
 
 #include <QPushButton>
-#include "../load.h"
+#include "ossimVector.h"
 Widget::Widget(QWidget *parent) :
     QWidget(parent)
 {
 void Widget::loadVector(QString fname)
 {
 
-im = load(fname.toStdString().c_str(),1);
+im = renderVector(fname.toStdString().c_str(),1);
 loaded = true;
 update();
 

File load.cpp

-
-#include <stdlib.h>
-#include <gd.h>
-
-#include "ossimVectorPrimitive.h"
-#include "ossimVector.h"
-#include "ossimVectorDef.h"
-#include "ossimVectorEnum.h"
-
-#include "ossimOgrVectorHandler.h"
-#include "ossimGdVectorSource.h"
-
-#include "load.h"
-double msAdjustExtent(ossimVectorRect *rect, int width, int height)
-{
-  double cellsize, ox, oy;
-
-  cellsize = OV_MAX(OV_CELLSIZE(rect->minx, rect->maxx, width), OV_CELLSIZE(rect->miny, rect->maxy, height));
-
-  if(cellsize <= 0) /* avoid division by zero errors */
-    return(0);
-
-  ox = OV_NINT(OV_MAX((width - (rect->maxx - rect->minx)/cellsize)/2,0)); // these were width-1 and height-1
-  oy = OV_NINT(OV_MAX((height - (rect->maxy - rect->miny)/cellsize)/2,0));
-
-  rect->minx = rect->minx - ox*cellsize;
-  rect->miny = rect->miny - oy*cellsize;
-  rect->maxx = rect->maxx + ox*cellsize;
-  rect->maxy = rect->maxy + oy*cellsize;
-
-  return(cellsize);
-}
-
-
-gdImagePtr load(const char *shpname, int label_index)
-{
-   gdImagePtr img=NULL;
-   ossimVectorRect    rect;
-
-
-int status;
-
-enum OV_LAYER_TYPE ltype;
-enum OV_SHAPE_TYPE stype;
-ossimVectorRect extent;
-
-    OGRRegisterAll();
-
-    OGRDataSource       *poDS;
-
-    poDS = OGRSFDriverRegistrar::Open( shpname, FALSE );
-    if( poDS == NULL )
-    {
-        printf( "Open failed.\n" );
-        exit( 1 );
-    }
-
-    OGRLayer  *poLayer;
-
-    poLayer = poDS->GetLayer(0);
-
-
-
-OGREnvelope *envelope = new OGREnvelope();
-poLayer->GetExtent(envelope,true);
-
-    poLayer->ResetReading();
-OGRFeature *poFeature = poLayer->GetNextFeature();
-        OGRGeometry *poGeometry;
-
-        poGeometry = poFeature->GetGeometryRef();
-        if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
-			{ltype = OV_LAYER_POINT;
-stype = OV_SHAPE_POINT;
-
-
-		}
-       else if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbLineString )
-	{		ltype = OV_LAYER_LINE;
-stype = OV_SHAPE_LINE;
-}       else if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon )
-{			ltype = OV_LAYER_POLYGON;
-stype = OV_SHAPE_POLYGON;
-}
-       OGRFeature::DestroyFeature( poFeature );
-
-    OGRDataSource::DestroyDataSource( poDS );
-
-
-extent.minx = envelope->MinX;
-extent.miny = envelope->MinY;
-extent.maxx = envelope->MaxX;
-extent.maxy = envelope->MaxY;
-
-/********************************************************
-      ______  _______________  ___    ____  
-     / __   /  ____/ _____/  /    \  /    \
-    / /  / /\  \   \  \  /  /  /\  \/  /\  \ 
-   / /  / /  \  \   \  \/  /  /  \___ /  \  \
-  / /__/ /___/  /___/  /  /  /            \  \
- /_____ /_____ /_____ /__/__/              \__\
-
-*********************************************************/
-
-
-double cellsize = msAdjustExtent(&(extent), 640, 480);
-
-
-
-ossimOgrVectorHandler *handler = new ossimOgrVectorHandler();
-
-ossimVectorFeature shape;
-ossimVectorRect searchrect;
-char annotate=1, cache=0;
-//featureListNodeObjPtr shpcache=NULL, current=NULL;
-
-
-status = handler->open(shpname);
-handler->setLayerType(ltype);
-
-status = handler->getLayerSchema();
-
-
-
-
-searchrect.minx = extent.minx;
-searchrect.miny = extent.miny;
-searchrect.maxx = extent.maxx;
-searchrect.maxy = extent.maxy;
-
-/*
-searchrect.minx = envelope->MinX;
-searchrect.miny = envelope->MinY;
-searchrect.maxx = envelope->MaxX;
-searchrect.maxy = envelope->MaxY;
-*/
-
-//cout << searchrect.miny << std::endl;
-handler->setFilter(searchrect);
-
-
-shape.init();
-
-
-ossimGdVectorSource *gdVectorSource = new ossimGdVectorSource();
-gdVectorSource->setLayerType(ltype);
-
-while((status = handler->getNextFeature(&shape)) == 0) 
-{
-    cache = 1;
-
-   shape.text = handler->getLabelText(&shape,1);
-   shape.type = stype;
-
-    status = gdVectorSource->drawFeature(&shape, !cache,searchrect,cellsize); // if caching we DON'T want to do overlays at this time
-    if(status != 0) 
-	 {
-      handler->close();
-      return NULL;
-    }
-
-    if(shape.numlines == 0) 
-	 {
-      shape.destroy();
-      continue;
-    }
-
-    shape.destroy();
-}
-
-
-
-
-
-
-
-  handler->close();
-
-
- // if(gdVectorSource->drawLabelCache() == -1)
-   // return NULL;
-
-  return gdVectorSource->getPointer();
-}
-

File load.h

-#include <gd.h>
-#include "ossimVectorPrimitive.h"
-gdImagePtr load(const char *shpname,int label_index);
-double msAdjustExtent(ossimVectorRect *rect, int width, int height);
 
-#include <stdlib.h>
 #include <gd.h>
-
-#include "ossimVectorPrimitive.h"
+#include <stdio.h>
 #include "ossimVector.h"
-#include "ossimVectorDef.h"
-#include "ossimVectorEnum.h"
-
-#include "ossimOgrVectorHandler.h"
-#include "ossimGdVectorSource.h"
-
-
-double msAdjustExtent(ossimVectorRect *rect, int width, int height)
-{
-  double cellsize, ox, oy;
-
-  cellsize = OV_MAX(OV_CELLSIZE(rect->minx, rect->maxx, width), OV_CELLSIZE(rect->miny, rect->maxy, height));
-
-  if(cellsize <= 0) /* avoid division by zero errors */
-    return(0);
-
-  ox = OV_NINT(OV_MAX((width - (rect->maxx - rect->minx)/cellsize)/2,0)); // these were width-1 and height-1
-  oy = OV_NINT(OV_MAX((height - (rect->maxy - rect->miny)/cellsize)/2,0));
-
-  rect->minx = rect->minx - ox*cellsize;
-  rect->miny = rect->miny - oy*cellsize;
-  rect->maxx = rect->maxx + ox*cellsize;
-  rect->maxy = rect->maxy + oy*cellsize;
-
-  return(cellsize);
-}
 
 
 int main(int argc, char *argv[])
 {
    gdImagePtr img=NULL;
-   ossimVectorRect    rect;
    char* shpname;
 
-   char *outfile;
-   string display = "/usr/bin/display ";
+   FILE *outfile;
+
    if(argc < 2) 
    {
-      //printf("INVALID MAP AND ATTRIBUTE SPECIFIED. EXITING....\n");
-      printf("Usage ./ossimVector [vector_file] [attribute_index] [image_file]\n");
-      printf("eg: ./ossimVector /home/rashad/maps/andhra.shp 6 /home/rashad/vector.png\n\n");
+      printf("Usage ./ossimVector_cl [vector_file] [attribute_index] [image_file]\n");
+      printf("eg: ./ossimVector_cl /home/rashad/maps/andhra.shp 6 vector.png\n\n");
       exit(1);
    }
-   else 
-   {
-     shpname = strdup(argv[1]);
-int label_index = strtod(argv[2],NULL);
-     outfile = strdup(argv[3]);
-char **fnames ;
-int n;
-int status;
 
-enum OV_LAYER_TYPE ltype;
-enum OV_SHAPE_TYPE stype;
-ossimVectorRect extent;
+   shpname = argv[1];
+   int label_index = strtod(argv[2],NULL);
+   outfile = fopen(argv[3],"wb");
 
-    OGRRegisterAll();
+   img = renderVector(shpname,label_index);
+   gdImagePng(img,outfile);
 
-    OGRDataSource       *poDS;
-
-    poDS = OGRSFDriverRegistrar::Open( shpname, FALSE );
-    if( poDS == NULL )
-    {
-        printf( "Open failed.\n" );
-        exit( 1 );
-    }
-
-    OGRLayer  *poLayer;
-
-    poLayer = poDS->GetLayer(0);
-
-
-
-OGREnvelope *envelope = new OGREnvelope();
-poLayer->GetExtent(envelope,true);
-
-    poLayer->ResetReading();
-OGRFeature *poFeature = poLayer->GetNextFeature();
-        OGRGeometry *poGeometry;
-
-        poGeometry = poFeature->GetGeometryRef();
-        if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
-			{ltype = OV_LAYER_POINT;
-stype = OV_SHAPE_POINT;
-
-
-		}
-       else if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbLineString )
-	{		ltype = OV_LAYER_LINE;
-stype = OV_SHAPE_LINE;
-}       else if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon )
-{			ltype = OV_LAYER_POLYGON;
-stype = OV_SHAPE_POLYGON;
-}
-       OGRFeature::DestroyFeature( poFeature );
-
-    OGRDataSource::DestroyDataSource( poDS );
-
-
-extent.minx = envelope->MinX;
-extent.miny = envelope->MinY;
-extent.maxx = envelope->MaxX;
-extent.maxy = envelope->MaxY;
-
-/********************************************************
-      ______  _______________  ___    ____  
-     / __   /  ____/ _____/  /    \  /    \
-    / /  / /\  \   \  \  /  /  /\  \/  /\  \ 
-   / /  / /  \  \   \  \/  /  /  \___ /  \  \
-  / /__/ /___/  /___/  /  /  /            \  \
- /_____ /_____ /_____ /__/__/              \__\
-
-*********************************************************/
-
-
-double cellsize = msAdjustExtent(&(extent), 640, 480);
-
-
-
-ossimOgrVectorHandler *handler = new ossimOgrVectorHandler();
-
-ossimVectorFeature shape;
-ossimVectorRect searchrect;
-char annotate=1, cache=0;
-//featureListNodeObjPtr shpcache=NULL, current=NULL;
-
-
-status = handler->open(shpname);
-handler->setLayerType(ltype);
-if(status != 0) return -1;
-status = handler->getLayerSchema();
-
-if(status != 0) return -1;
-
-
-searchrect.minx = extent.minx;
-searchrect.miny = extent.miny;
-searchrect.maxx = extent.maxx;
-searchrect.maxy = extent.maxy;
-
-/*
-searchrect.minx = envelope->MinX;
-searchrect.miny = envelope->MinY;
-searchrect.maxx = envelope->MaxX;
-searchrect.maxy = envelope->MaxY;
-*/
-
-//cout << searchrect.miny << std::endl;
-status = handler->setFilter(searchrect);
-
-
-
-if(status == 2)
-	handler->close();
-else if(status != 0)
-	return -1;
-
-
-shape.init();
-
-
-ossimGdVectorSource *gdVectorSource = new ossimGdVectorSource();
-gdVectorSource->setLayerType(ltype);
-
-while((status = handler->getNextFeature(&shape)) == 0) {
-    cache = 1;
-
-   shape.text = handler->getLabelText(&shape,label_index);
-   shape.type = stype;
-
-    status = gdVectorSource->drawFeature(&shape, !cache,searchrect,cellsize); // if caching we DON'T want to do overlays at this time
-    if(status != 0) 
-	{
-      handler->close();
-      return -1;
-    }
-
-    if(shape.numlines == 0) 
-	{
-      shape.destroy();
-      continue;
-    }
-
-    shape.destroy();
+   return 0L;
 }
 
-
-
-
-
-
-
-  handler->close();
-
-
-  if(gdVectorSource->drawLabelCache() == -1)
-    return -1;
-
-gdVectorSource->saveImage(outfile);
-
-
-display = display + outfile;
-
-//int d =  system(display.c_str());
-
-   }
-  return 0L;
-}
-

File ossimGdVectorSource.cpp

 #include "ossimGdVectorSource.h"
-#include "ossimVectorDef.h"
-#include "ossimVectorEnum.h"
-
-
 
 ossimGdVectorSource::ossimGdVectorSource()
 {
+   img = gdImageCreate(640,480);
+   int red,green,blue;
 
+   red = green = blue = 255;
+   gdImageColorAllocate(img, red, green, blue);
 
-theStyle = new ossimVectorStyle();
-theStyle->outlinecolor = 2;
+   red = green  = blue = 100;
+   gdImageColorAllocate(img, red, green, blue);
 
+   green = blue = 0; red = 255;
+   gdImageColorAllocate(img, red, green, blue);
 
-ossimVectorLabel *label = &(theStyle->label);
-label->sizescaled = label->size = 1;
+   red =  green = blue = 0;
+   gdImageColorAllocate(img, red, green, blue);
+}
 
-label->color = 3;
 
-
-
-  symbolscale = -1.0;
-  sizeunits = OV_PIXELS;
-//  msInitProjection(&projection);/*FIXME*/
-  units = OV_METERS;
-  type = OV_LAYER_POLYGON;/*FIXME*/
-  labelcache = 1;
-  labelsizeitemindex = labelangleitemindex = -1;
-  transform = 1;
-  index = 0;
-
-inchesPerUnit[0]=1;
-inchesPerUnit[1] = 12;
-inchesPerUnit[2] = 63360.0;
-inchesPerUnit[3] = 39.3701;
-inchesPerUnit[4] = 39370.1;
-inchesPerUnit[5] = 4374754;
-img = gdImageCreate(640,480);
-int red,green,blue;
-red = green = blue = 255;
-gdImageColorAllocate(img, red, green, blue);
-red = green  = blue = 100;
-gdImageColorAllocate(img, red, green, blue);
-green = blue = 0; red = 255;
-gdImageColorAllocate(img, red, green, blue);
-
-red =  green = blue = 0;
-gdImageColorAllocate(img, red, green, blue);
-
-
-
-  label_cache.labels = (ossimVectorLabelCacheMember *)malloc(sizeof(ossimVectorLabelCacheMember)*OV_LABELCACHEINITSIZE);
-  if(label_cache.labels == NULL) {
-    printf("Malloc() error. initMap()");
-
-  }
-  label_cache.cachesize = OV_LABELCACHEINITSIZE;
-  label_cache.numlabels = 0;
-
-  label_cache.markers = (ossimVectorMarkerCacheMember *)malloc(sizeof(ossimVectorMarkerCacheMember)*OV_LABELCACHEINITSIZE);
-  if(label_cache.markers == NULL) {
-    printf("Malloc() error. initMap()");
-
-  }
-  label_cache.markercachesize = OV_LABELCACHEINITSIZE;
-  label_cache.nummarkers = 0;
- 
-
+ossimGdVectorSource::~ossimGdVectorSource()
+{
 
 }
-int cc=0;
-
-ossimGdVectorSource::~ossimGdVectorSource(){}
-
-
-void ossimGdVectorSource::clipPolygonRect(ossimVectorFeature *shape, ossimVectorRect rect)
-{
-  int i, j;
-  double deltax, deltay, xin,xout,  yin,yout;
-  double tinx,tiny,  toutx,touty,  tin1, tin2,  tout;
-  double x1,y1, x2,y2;
-
-  ossimVectorFeature tmp;
-  ossimVectorLine line={0,NULL};
-
-  tmp.init();
-  
-  if(shape->numlines == 0) /* nothing to clip */
-    return;
-   
-  for(j=0; j<shape->numlines; j++) {
-
-    line.point = (ossimVectorPoint *)malloc(sizeof(ossimVectorPoint)*2*shape->line[j].numpoints+1); /* worst case scenario, +1 allows us to duplicate the 1st and last point */
-    line.numpoints = 0;
-
-    for (i = 0; i < shape->line[j].numpoints-1; i++) {
-      
-      x1 = shape->line[j].point[i].x;
-      y1 = shape->line[j].point[i].y;
-      x2 = shape->line[j].point[i+1].x;
-      y2 = shape->line[j].point[i+1].y;
-      
-      deltax = x2-x1;
-      if (deltax == 0) { /* bump off of the vertical */
-	deltax = (x1 > rect.minx) ? -NEARZERO : NEARZERO ;
-      }
-      deltay = y2-y1;
-      if (deltay == 0) { /* bump off of the horizontal */
-	deltay = (y1 > rect.miny) ? -NEARZERO : NEARZERO ;
-      }
-      
-      if (deltax > 0) {		/*  points to right */
-	xin = rect.minx;
-	xout = rect.maxx;
-      }
-      else {
-	xin = rect.maxx;
-	xout = rect.minx;
-      }
-      if (deltay > 0) {		/*  points up */
-	yin = rect.miny;
-	yout = rect.maxy;
-      }
-      else {
-	yin = rect.maxy;
-	yout = rect.miny;
-      }
-      
-      tinx = (xin - x1)/deltax;
-      tiny = (yin - y1)/deltay;
-      
-      if (tinx < tiny) {	/* hits x first */
-	tin1 = tinx;
-	tin2 = tiny;
-      } else {			/* hits y first */
-	tin1 = tiny;
-	tin2 = tinx;
-      }
-      
-      if (1 >= tin1) {
-	if (0 < tin1) {
-	  line.point[line.numpoints].x = xin;
-	  line.point[line.numpoints].y = yin;
-	  line.numpoints++;
-	}
-	if (1 >= tin2) {
-	  toutx = (xout - x1)/deltax;
-	  touty = (yout - y1)/deltay;
-	  
-	  tout = (toutx < touty) ? toutx : touty ;
-	  
-	  if (0 < tin2 || 0 < tout) {
-	    if (tin2 <= tout) {
-	      if (0 < tin2) {
-		if (tinx > tiny) {
-		  line.point[line.numpoints].x = xin;
-		  line.point[line.numpoints].y = y1 + tinx*deltay;
-		  line.numpoints++;
-		} else {
-		  line.point[line.numpoints].x = x1 + tiny*deltax;
-		  line.point[line.numpoints].y = yin;
-		  line.numpoints++;
-		}
-	      }
-	      if (1 > tout) {
-		if (toutx < touty) {
-		  line.point[line.numpoints].x = xout;
-		  line.point[line.numpoints].y = y1 + toutx*deltay;
-		  line.numpoints++;
-		} else {
-		  line.point[line.numpoints].x = x1 + touty*deltax;
-		  line.point[line.numpoints].y = yout;
-		  line.numpoints++;
-		}
-	      }	else {
-		line.point[line.numpoints].x = x2;
-		line.point[line.numpoints].y = y2;
-		line.numpoints++;
-	      }
-	    } else {
-	      if (tinx > tiny) {
-		line.point[line.numpoints].x = xin;
-		line.point[line.numpoints].y = yout;
-		line.numpoints++;
-	      } else {
-		line.point[line.numpoints].x = xout;
-		line.point[line.numpoints].y = yin;
-		line.numpoints++;
-	      }
-	    }
-	  }
-	}
-      }
-    }
-
-    if(line.numpoints > 0) {
-      line.point[line.numpoints].x = line.point[0].x; // force closure
-      line.point[line.numpoints].y = line.point[0].y;
-      line.numpoints++;
-      tmp.msAddLine(&line);
-    }
-
-    free(line.point);
-  } /* next line */
-  
-  for (i=0; i<shape->numlines; i++) free(shape->line[i].point);
-  free(shape->line);
-
-  shape->line = tmp.line;
-  shape->numlines = tmp.numlines;
-
-  return;
-}
-
-
-
-int ossimGdVectorSource::clipLine(double *x1, double *y1, double *x2, double *y2, ossimVectorRect rect)
-{
-  double x, y;
-  double slope;
-  OV_CLIP_STATE check1, check2;
-
-  if(*x1 < rect.minx && *x2 < rect.minx)
-    return 0;
-  if(*x1 > rect.maxx && *x2 > rect.maxx)
-    return 0;
-
-  check1 = CLIP_CHECK(rect.minx, *x1, rect.maxx);
-  check2 = CLIP_CHECK(rect.minx, *x2, rect.maxx);
-  if(check1 == OV_CLIP_LEFT || check2 == OV_CLIP_LEFT) {
-    slope = (*y2 - *y1)/(*x2 - *x1);
-    y = *y1 + (rect.minx - *x1)*slope;
-    if(check1 == OV_CLIP_LEFT) {
-      *x1 = rect.minx;
-      *y1 = y;
-    } else {
-      *x2 = rect.minx;
-      *y2 = y;
-    }
-  }
-  if(check1 == OV_CLIP_RIGHT || check2 == OV_CLIP_RIGHT) {
-    slope = (*y2 - *y1)/(*x2 - *x1);
-    y = *y1 + (rect.maxx - *x1)*slope;
-    if(check1 == OV_CLIP_RIGHT) {
-      *x1 = rect.maxx;
-      *y1 = y;
-    } else {
-      *x2 = rect.maxx;
-      *y2 = y;
-    }
-  }
-
-  if(*y1 < rect.miny && *y2 < rect.miny)
-    return 0;
-  if(*y1 > rect.maxy && *y2 > rect.maxy)
-    return 0;
-
-  check1 = CLIP_CHECK(rect.miny, *y1, rect.maxy);
-  check2 = CLIP_CHECK(rect.miny, *y2, rect.maxy);
-  if(check1 == OV_CLIP_LEFT || check2 == OV_CLIP_LEFT) {
-    slope = (*x2 - *x1)/(*y2 - *y1);
-    x = *x1 + (rect.miny - *y1)*slope;
-    if(check1 == OV_CLIP_LEFT) {
-      *x1 = x;
-      *y1 = rect.miny;
-    } else {
-      *x2 = x;
-      *y2 = rect.miny;
-    }
-  }
-  if(check1 == OV_CLIP_RIGHT || check2 == OV_CLIP_RIGHT) {
-    slope = (*x2 - *x1)/(*y2 - *y1);
-    x = *x1 + (rect.maxy - *y1)*slope;
-    if(check1 == OV_CLIP_RIGHT) {
-      *x1 = x;
-      *y1 = rect.maxy;
-    } else {
-      *x2 = x;
-      *y2 = rect.maxy;
-    }
-  }
-
-  return 1;
-}
-
-void ossimGdVectorSource::clipPolylineRect(ossimVectorFeature *shape, ossimVectorRect rect)
-{
-  int i,j;
-  ossimVectorLine line={0,NULL};
-  double x1, x2, y1, y2;
-  ossimVectorFeature tmp={0,NULL};
-
-  if(shape->numlines == 0) /* nothing to clip */
-    return;
-
-  for(i=0; i<shape->numlines; i++) {
-
-    line.point = (ossimVectorPoint *)malloc(sizeof(ossimVectorPoint)*shape->line[i].numpoints);
-    line.numpoints = 0;
-
-    x1 = shape->line[i].point[0].x;
-    y1 = shape->line[i].point[0].y;
-    for(j=1; j<shape->line[i].numpoints; j++) {
-      x2 = shape->line[i].point[j].x;
-      y2 = shape->line[i].point[j].y;
-
-      if(clipLine(&x1,&y1,&x2,&y2,rect) == 1) {
-	if(line.numpoints == 0) { /* first segment, add both points */
-	  line.point[0].x = x1;
-	  line.point[0].y = y1;
-	  line.point[1].x = x2;
-	  line.point[1].y = y2;
-	  line.numpoints = 2;
-	} else { /* add just the last point */
-	  line.point[line.numpoints].x = x2;
-	  line.point[line.numpoints].y = y2;
-	  line.numpoints++;	  
-	}
-
-	if((x2 != shape->line[i].point[j].x) || (y2 != shape->line[i].point[j].y)) {
-	  tmp.msAddLine(&line);
-	  line.numpoints = 0; /* new line */
-	}
-      }
-
-      x1 = shape->line[i].point[j].x;
-      y1 = shape->line[i].point[j].y;
-    }
-
-    if(line.numpoints > 0)
-	  tmp.msAddLine(&line);
-    free(line.point);
-    line.numpoints = 0; /* new line */
-  }
-  
-  for (i=0; i<shape->numlines; i++) free(shape->line[i].point);
-  free(shape->line);
-
-  shape->line = tmp.line;
-  shape->numlines = tmp.numlines;
-}
-
-
-
-
-int ossimGdVectorSource::drawLabel(ossimVectorPoint labelPnt, char *str, ossimVectorLabel *label)
-{
-  if(!str)
-    return(0); /* not an error, just don't want to do anything */
-
-  if(strlen(str) == 0)
-    return(0); /* not an error, just don't want to do anything */
-
-  if(label->position != OV_XY) {
-    ossimVectorPoint p;
-    ossimVectorRect r;
-
-    if(getLabelSize(str, label, &r) == -1) return(-1);
-    p = get_metrics(&labelPnt, label->position, r, label->offsetx, label->offsety, label->angle, 0, NULL);
-    this->draw_text(p, str, label); /* actually draw the label */
-  } else {
-    labelPnt.x += label->offsetx;
-    labelPnt.y += label->offsety;
-    this->draw_text(labelPnt, str, label); /* actually draw the label */
-  }
-
-  return(0);
-}
-
-
-
-void ossimGdVectorSource::style_cache(ossimVectorStyle *from, ossimVectorStyle *to) 
-{
-  to->initStyle();
-
-  to->color = from->color;
-  to->symbol = from->symbol;
-  to->sizescaled = to->size = from->sizescaled;
-  to->backgroundcolor = from->backgroundcolor;
-  to->outlinecolor = from->outlinecolor;
-
-  to->overlaybackgroundcolor = from->overlaybackgroundcolor;
-  to->overlaycolor = from->overlaycolor;
-  to->overlayoutlinecolor = from->overlayoutlinecolor;
-  to->overlaysizescaled = to->overlaysize = from->overlaysizescaled;
-  to->overlaysymbol = from->overlaysymbol;
-
-  to->label = from->label; // this copies all non-pointers
-//  if(from->label.font) to->label.font = strdup(from->label.font);
-}
-
 
 int ossimGdVectorSource::drawFeature(ossimVectorFeature *shape, int overlay,ossimVectorRect extent,double cellsize)
 {
-  enum OV_UNITS units;
-units = OV_METERS;
+   std::vector<ossimVectorPoint>*pointList = &shape->points;
+   std::vector<ossimVectorPoint>::iterator pIt;
 
+   for(pIt = pointList->begin();pIt!= pointList->end();++pIt)
+   {
+      ossimVectorPoint point = *(pIt);
+      point.x =OV_MAP2IMAGE_X(point.x, extent.minx, cellsize);
+      point.y =OV_MAP2IMAGE_Y(point.y, extent.maxy, cellsize);
+      gdImageSetPixel(img, point.x, point.y, 2);
+   }
 
+      unsigned char* str1 = (unsigned char*)shape->getLabel().c_str();
 
-  int i,j,c;
-  ossimVectorRect cliprect;
-  ossimVectorPoint annopnt, *point;
-  double angle, length, scalefactor=1.0;
- 
-  ossimVectorPoint center; // circle origin
-  double r; // circle radius
 
-  cliprect.minx = extent.minx - 2*cellsize; // set clipping rectangle just a bit larger than the map extent
-  cliprect.miny = extent.miny - 2*cellsize;
-  cliprect.maxx = extent.maxx + 2*cellsize;
-  cliprect.maxy = extent.maxy + 2*cellsize;
+      ossimVectorPoint point;
+      point.x =OV_MAP2IMAGE_X(shape->labelPoint.x, extent.minx, cellsize);
+      point.y =OV_MAP2IMAGE_Y(shape->labelPoint.y, extent.maxy, cellsize);
+      gdImageString(img, gdFontSmall, point.x, point.y, str1, 3);
 
-  c = shape->classindex;
 
-  //FIXME if(symbolscale > 0 && map->scale > 0) scalefactor = symbolscale/map->scale;
-
-  if(sizeunits != OV_PIXELS) {
-    theStyle->sizescaled = theStyle->size * (inchesPerUnit[sizeunits]/inchesPerUnit[/*FIXME*/units]) / cellsize;
-    theStyle->overlaysizescaled = theStyle->overlaysize * (inchesPerUnit[sizeunits]/inchesPerUnit[/*FIXME*/units]) / cellsize;
-  }
-
- else {
-
-    theStyle->sizescaled = OV_NINT(theStyle->size * scalefactor);
-    theStyle->sizescaled = OV_MAX(theStyle->sizescaled, theStyle->minsize);
-    theStyle->sizescaled = OV_MIN(theStyle->sizescaled, theStyle->maxsize);
-    theStyle->overlaysizescaled = theStyle->sizescaled - (theStyle->size - theStyle->overlaysize); 
-    theStyle->overlaysizescaled = OV_MAX(theStyle->overlaysizescaled, theStyle->overlayminsize);
-    theStyle->overlaysizescaled = OV_MIN(theStyle->overlaysizescaled, theStyle->overlaymaxsize);
-
-  }
-
-  if(theStyle->sizescaled == 0) {return 0;}
-
-#if defined (USE_GD_FT) || defined (USE_GD_TTF)
-  if(theStyle->label.type == OV_TRUETYPE) {
-    theStyle->label.sizescaled = OV_NINT(theStyle->label.size * scalefactor);
-    theStyle->label.sizescaled = OV_MAX(theStyle->label.sizescaled, theStyle->label.minsize);
-    theStyle->label.sizescaled = OV_MIN(theStyle->label.sizescaled, theStyle->label.maxsize);
-  }
-#endif
-
-
-
-  switch(type) {
-
-  case OV_LAYER_POINT:
-/*FIXME
-#ifdef USE_PROJ
-      if(msProjectionsDiffer(&(projection), &(projection)))
-          msProjectShape(&projection, &projection, shape);
-#endif
-*/
-    for(j=0; j<shape->numlines;j++) {
-      for(i=0; i<shape->line[j].numpoints;i++) {
-
-	point = &(shape->line[j].point[i]);
-
-	if(transform) {
-	  if(!shape->msPointInRect(point, &extent)) continue; // next point
-	  point->x = OV_MAP2IMAGE_X(point->x, extent.minx, cellsize);
-	  point->y = OV_MAP2IMAGE_Y(point->y, extent.maxy, cellsize);
-	}
-
-	drawMarker(point, theStyle->symbol, theStyle->color, theStyle->backgroundcolor, theStyle->outlinecolor, theStyle->sizescaled);
-	if(overlay && theStyle->overlaysymbol >= 0) drawMarker(point, theStyle->overlaysymbol, theStyle->overlaycolor, theStyle->overlaybackgroundcolor, theStyle->overlayoutlinecolor, theStyle->overlaysizescaled);
-
-	if(shape->text) {
-	  if(labelangleitemindex != -1)
-	    theStyle->label.angle = atof(shape->values[labelangleitemindex]);
-
-	  if((labelsizeitemindex != -1) && (theStyle->label.type == OV_TRUETYPE)) {
-	    theStyle->label.sizescaled = atoi(shape->values[labelsizeitemindex])*((symbolscale > 0) ? scalefactor:1);
-	    theStyle->label.sizescaled = OV_MAX(theStyle->label.sizescaled, theStyle->label.minsize);
-	    theStyle->label.sizescaled = OV_MIN(theStyle->label.sizescaled, theStyle->label.maxsize);
-	  }
-
-	  if(labelcache)
-	    addLabel(index, c, shape->tileindex, shape->index, *point, shape->text, -1);
-	  else
-	    drawLabel(*point, shape->text, &theStyle->label);
-	}
-      }
-    }
-    break;
-
-  case OV_LAYER_LINE:
-
-/*FIXME
-#ifdef USE_PROJ
-    if(msProjectionsDiffer(&(projection), &(projection)))
-        msProjectShape(&projection, &projection, shape);
-#endif
-*/
-    if(transform) {
-      clipPolylineRect(shape, cliprect);
-      if(shape->numlines == 0) {return 0;}
-      transformFeature(shape, extent, cellsize);
-    }
-
-    drawLine(shape, theStyle->symbol, theStyle->color, theStyle->backgroundcolor, theStyle->sizescaled);
-    if(overlay && theStyle->overlaysymbol >= 0) drawLine( shape, theStyle->overlaysymbol, theStyle->overlaycolor, theStyle->overlaybackgroundcolor, theStyle->overlaysizescaled);
-
-    if(shape->text) {
-      if(shape->msPolylineLabelPoint(&annopnt, theStyle->label.minfeaturesize, &angle, &length) == 0) {
-	if(labelangleitemindex != -1)
-	  theStyle->label.angle = atof(shape->values[labelangleitemindex]);
-
-	if((labelsizeitemindex != -1) && (theStyle->label.type == OV_TRUETYPE)) {
-	  theStyle->label.sizescaled = atoi(shape->values[labelsizeitemindex])*((symbolscale > 0) ? scalefactor:1);
-	  theStyle->label.sizescaled = OV_MAX(theStyle->label.sizescaled, theStyle->label.minsize);
-	  theStyle->label.sizescaled = OV_MIN(theStyle->label.sizescaled, theStyle->label.maxsize);
-	}
-
-	if(theStyle->label.autoangle)
-	  theStyle->label.angle = angle;
-
-	if(labelcache)
-	  addLabel(index, c, shape->tileindex, shape->index, annopnt, shape->text, length);
-	else
-	  drawLabel(annopnt, shape->text, &theStyle->label);
-      }
-    }
-    break;
-
-  case OV_LAYER_POLYGON:
-
-      this->clipPolygonRect(shape, cliprect);
-      if(shape->numlines == 0) {return(0);}
-      this->transformFeature(shape, extent, cellsize);
-
-
-      //drawShade(shape, 0, 1, -1,2, 1);
-
-
-    if(theStyle->color < 0)
-      drawLine( shape, theStyle->symbol, theStyle->outlinecolor, theStyle->backgroundcolor, theStyle->sizescaled);
-    else
-
-      drawShade(shape, theStyle->symbol, 1, theStyle->backgroundcolor, theStyle->outlinecolor, theStyle->sizescaled);
-
-
-
-    if(overlay && theStyle->overlaysymbol >= 0) {
-      if(theStyle->overlaycolor < 0)
-	drawLine(shape, theStyle->overlaysymbol, theStyle->overlayoutlinecolor, theStyle->overlaybackgroundcolor, theStyle->overlaysizescaled);
-
-    }
-
-    if(shape->text) {
-      if(shape->msPolygonLabelPoint(&annopnt, -1) ==  0) {
-
-	if(labelangleitemindex != -1)
-	  theStyle->label.angle = atof(shape->values[labelangleitemindex]);
-
-	if((labelsizeitemindex != -1) && (theStyle->label.type == OV_TRUETYPE)) {
-	  theStyle->label.sizescaled = atoi(shape->values[labelsizeitemindex])*((symbolscale > 0) ? scalefactor:1);
-	  theStyle->label.sizescaled = OV_MAX(theStyle->label.sizescaled, theStyle->label.minsize);
-	  theStyle->label.sizescaled = OV_MIN(theStyle->label.sizescaled, theStyle->label.maxsize);
-	}
-
-	if(labelcache)
-	  addLabel(0, 0, shape->tileindex, shape->index, annopnt, shape->text, -1);
-	else
-	  drawLabel(annopnt, shape->text, &theStyle->label);
-      }
-    }
-
-    break;
-  default:
-    printf( "Unknown layer type.");
-    return 1;
-  }
-
-
-
-  return 0;
+   return 0;
 }
 
 
 
-
-
-/* ------------------------------------------------------------------------------- */
-/*       Draw a single marker symbol of the specified size and color               */
-/* ------------------------------------------------------------------------------- */
-void ossimGdVectorSource::drawMarker(ossimVectorPoint *p, int sy, int fc, int bc, int oc, double sz)
+gdImagePtr ossimGdVectorSource::getPointer()
 {
-//  symbolObj *symbol;
-  int offset_x, offset_y, x, y;
-  int j;
-  gdPoint oldpnt,newpnt;
-  gdPoint mPoints[OV_MAXVECTORPOINTS];
-
-  gdImagePtr tmp;
-  int tmp_fc=-1, tmp_bc, tmp_oc=-1;
-
-  double scale=1.0;
-
-  int bbox[8];
-  ossimVectorRect rect;
-  char *font=NULL;
-
- // if(sy > symbolset->numsymbols || sy < 0) /* no such symbol, 0 is OK */
-   // return;
-
-  if(fc >= gdImageColorsTotal(img)) /* invalid color, -1 is valid */
-    return;
-
-  if(sz < 1) /* size too small */
-    return;
-
-  if(sy == 0 && fc >= 0) { /* simply draw a single pixel of the specified color */
-    gdImageSetPixel(img, p->x, p->y, fc);
-    return;
-  }  
-/*
-
-  symbol = &(symbolset->symbol[sy]);
-  
-  switch(symbol->type) {  
-  case(OV_SYMBOL_TRUETYPE):
-
-#if defined (USE_GD_FT) || defined (USE_GD_TTF)
-    font = msLookupHashTable(symbolset->fontset->fonts, symbol->font);
-    if(!font) return;
-
-    if(getCharacterSize(symbol->character, sz, font, &rect) == -1) return;
-
-    x = p->x - (rect.maxx - rect.minx)/2 - rect.minx;
-    y = p->y - rect.maxy + (rect.maxy - rect.miny)/2;  
-
-#ifdef USE_GD_TTF
-    gdImageStringTTF(img, bbox, ((symbol->antialias)?(fc):-(fc)), font, sz, 0, x, y, symbol->character);
-#else
-    gdImageStringFT(img, bbox, ((symbol->antialias)?(fc):-(fc)), font, sz, 0, x, y, symbol->character);
-#endif
-
-#endif
-
-    break;
-  case(OV_SYMBOL_PIXMAP):
-    if(sz == 1) { // don't scale
-      offset_x = OV_NINT(p->x - .5*symbol->img->sx);
-      offset_y = OV_NINT(p->y - .5*symbol->img->sy);
-      gdImageCopy(img, symbol->img, offset_x, offset_y, 0, 0, symbol->img->sx, symbol->img->sy);
-    } else {
-      scale = sz/symbol->img->sy;
-      offset_x = OV_NINT(p->x - .5*symbol->img->sx*scale);
-      offset_y = OV_NINT(p->y - .5*symbol->img->sy*scale);
-      gdImageCopyResized(img, symbol->img, offset_x, offset_y, 0, 0, symbol->img->sx*scale, symbol->img->sy*scale, symbol->img->sx, symbol->img->sy);
-    }
-    break;
-  case(OV_SYMBOL_ELLIPSE):
- 
-    scale = sz/symbol->sizey;
-    x = OV_NINT(symbol->sizex*scale)+1;
-    y = OV_NINT(symbol->sizey*scale)+1;
-
-
-    tmp = gdImageCreate(x, y);
-    tmp_bc = gdImageColorAllocate(tmp, gdImageRed(img, 0), gdImageGreen(img, 0), gdImageBlue(img, 0));
-    gdImageColorTransparent(tmp, 0);
-    if(fc >= 0)
-      tmp_fc = gdImageColorAllocate(tmp, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
-    if(oc >= 0)
-      tmp_oc = gdImageColorAllocate(tmp, gdImageRed(img, oc), gdImageGreen(img, oc), gdImageBlue(img, oc));
-
-    x = OV_NINT(tmp->sx/2);
-    y = OV_NINT(tmp->sy/2);
-
-
-    if(tmp_oc >= 0) {
-      gdImageArc(tmp, x, y, OV_NINT(scale*symbol->points[0].x), OV_NINT(scale*symbol->points[0].y), 0, 360, tmp_oc);
-      if(symbol->filled && tmp_fc >= 0)
-	gdImageFillToBorder(tmp, x, y, tmp_oc, tmp_fc);
-    } else {
-      if(tmp_fc >= 0) {
-	gdImageArc(tmp, x, y, OV_NINT(scale*symbol->points[0].x), OV_NINT(scale*symbol->points[0].y), 0, 360, tmp_fc);
-	if(symbol->filled)
-	  gdImageFillToBorder(tmp, x, y, tmp_fc, tmp_fc);
-      }
-    }
-
-
-    offset_x = OV_NINT(p->x - .5*tmp->sx);
-    offset_y = OV_NINT(p->y - .5*tmp->sx);
-    gdImageCopy(img, tmp, offset_x, offset_y, 0, 0, tmp->sx, tmp->sy);
-
-    gdImageDestroy(tmp);
-
-    break;
-  case(OV_SYMBOL_VECTOR):
-
-    scale = sz/symbol->sizey;
-
-    offset_x = OV_NINT(p->x - scale*.5*symbol->sizex);
-    offset_y = OV_NINT(p->y - scale*.5*symbol->sizey);
-    
-    if(symbol->filled) { 
-      for(j=0;j < symbol->numpoints;j++) {
-	mPoints[j].x = OV_NINT(scale*symbol->points[j].x + offset_x);
-	mPoints[j].y = OV_NINT(scale*symbol->points[j].y + offset_y);
-      }
-      if(fc >= 0)
-	gdImageFilledPolygon(img, mPoints, symbol->numpoints, fc);
-      if(oc >= 0)
-	gdImagePolygon(img, mPoints, symbol->numpoints, oc);
-      
-    } else  {   
-
-      if(fc < 0) return;
-      
-      oldpnt.x = OV_NINT(scale*symbol->points[0].x + offset_x); 
-      oldpnt.y = OV_NINT(scale*symbol->points[0].y + offset_y);
-      
-      for(j=1;j < symbol->numpoints;j++) { 
-	if((symbol->points[j].x < 0) && (symbol->points[j].x < 0)) {
-	  oldpnt.x = OV_NINT(scale*symbol->points[j].x + offset_x);
-	  oldpnt.y = OV_NINT(scale*symbol->points[j].y + offset_y);
-	} else {
-	  if((symbol->points[j-1].x < 0) && (symbol->points[j-1].y < 0)) {
-	    oldpnt.x = OV_NINT(scale*symbol->points[j].x + offset_x);
-	    oldpnt.y = OV_NINT(scale*symbol->points[j].y + offset_y);
-	  } else {
-	    newpnt.x = OV_NINT(scale*symbol->points[j].x + offset_x);
-	    newpnt.y = OV_NINT(scale*symbol->points[j].y + offset_y);
-	    gdImageLine(img, oldpnt.x, oldpnt.y, newpnt.x, newpnt.y, fc);
-	    oldpnt = newpnt;
-	  }
-	}
-      }     
-    }
-    break;
-  default:
-    break;
-  } 
-*/
-  return;
+   return img;
 }
 
-void ossimGdVectorSource::transformFeature(ossimVectorFeature *shape, ossimVectorRect extent, double cellsize)
-{
-  int i,j,k; /* loop counters */
-
-  if(shape->numlines == 0) return; // nothing to transform
-
-  if(shape->type == OV_SHAPE_LINE || shape->type == OV_SHAPE_POLYGON) { // remove co-linear vertices
-  
-    for(i=0; i<shape->numlines; i++) { // for each part
-      //cout << shape->line[i].point[0].x << "::" << shape->line[i].point[0].y << endl;
-
-      shape->line[i].point[0].x = OV_MAP2IMAGE_X(shape->line[i].point[0].x, extent.minx, cellsize);
-      shape->line[i].point[0].y = OV_MAP2IMAGE_Y(shape->line[i].point[0].y, extent.maxy, cellsize);
-
-      //cout << shape->line[i].point[0].x << "::" << shape->line[i].point[0].y << endl;
-      //cout << extent.maxy << endl;
-
-   
-      for(j=1, k=1; j < shape->line[i].numpoints; j++ ) {
-	
-	shape->line[i].point[k].x = OV_MAP2IMAGE_X(shape->line[i].point[j].x, extent.minx, cellsize);
-	shape->line[i].point[k].y = OV_MAP2IMAGE_Y(shape->line[i].point[j].y, extent.maxy, cellsize);
-
-	if(k == 1) {
-	  if((shape->line[i].point[0].x != shape->line[i].point[1].x) || (shape->line[i].point[0].y != shape->line[i].point[1].y))
-	    k++;
-	} else {
-	  if((shape->line[i].point[k-1].x != shape->line[i].point[k].x) || (shape->line[i].point[k-1].y != shape->line[i].point[k].y)) {
-	    if(((shape->line[i].point[k-2].y - shape->line[i].point[k-1].y)*(shape->line[i].point[k-1].x - shape->line[i].point[k].x)) == ((shape->line[i].point[k-2].x - shape->line[i].point[k-1].x)*(shape->line[i].point[k-1].y - shape->line[i].point[k].y))) {	    
-	      shape->line[i].point[k-1].x = shape->line[i].point[k].x;
-	      shape->line[i].point[k-1].y = shape->line[i].point[k].y;	
-	    } else {
-	      k++;
-	    }
-	  }
-	}
-      }
-      shape->line[i].numpoints = k; // save actual number kept
-    }
-  } else { // points or untyped shapes
-    for(i=0; i<shape->numlines; i++) { // for each part
-      for(j=1; j < shape->line[i].numpoints; j++ ) {
-	shape->line[i].point[j].x = OV_MAP2IMAGE_X(shape->line[i].point[j].x, extent.minx, cellsize);
-	shape->line[i].point[j].y = OV_MAP2IMAGE_Y(shape->line[i].point[j].y, extent.maxy, cellsize);
-      }
-    }
-  }
-
-  return;
-}
-
-
-
-#define NUM_SCANLINES 5
-
-
-
-
-int ossimGdVectorSource::saveImage(const char* filename)
-{
-  FILE *stream;
-  if(filename != NULL && strlen(filename) > 0) {
-    stream = fopen(filename, "wb");
-    if(!stream) {
-      return 1;
-    }
-  } else { /* use stdout */
-
-#ifdef _WIN32
-    /*
-    ** Change stdout mode to binary on win32 platforms
-    */
-    if(_setmode( _fileno(stdout), _O_BINARY) == -1) {
-      printf( "Unable to change stdout to binary mode. saveImage()");
-      return 1;
-    }
-#endif
-    stream = stdout;
-  }
-
-  //if(interlace)
-    //gdImageInterlace(img, 1);
-
-//  if(transparent)
-  //  gdImageColorTransparent(img, 0);
-
-
-    gdImagePng(img, stream);
-
-  
-
-  if(filename != NULL && strlen(filename) > 0) fclose(stream);
-
-  return 0;
-}
-
-double ossimGdVectorSource::dist(ossimVectorPoint a, ossimVectorPoint b)
-{
-  double d;
-
-  d = sqrt((pow((a.x-b.x),2) + pow((a.y-b.y),2)));
-  return(d);
-}
-
-
-int ossimGdVectorSource::drawLabelCache()
-{
-  ossimVectorPoint p;
-  int i, j, l;
-
-  ossimVectorRect r;
-  
-  ossimVectorLabelCacheMember *cachePtr=NULL;
-  ossimVectorStyle *classPtr=NULL;
-
-  ossimVectorLabel *labelPtr=NULL;
-
-  int draw_marker;
-  int marker_width, marker_height;
-  int marker_offset_x, marker_offset_y;
-  ossimVectorRect marker_rect;
-
-  for(l=label_cache.numlabels-1; l>=0; l--) {
-
-    cachePtr = &(label_cache.labels[l]); /* point to right spot in cache */
-
-
-    classPtr = &(cachePtr->style);
-    labelPtr = &(cachePtr->style.label);
-
-    if(!cachePtr->str)
-      continue;
-
-    if(strlen(cachePtr->str) == 0)
-      continue; 
-
-    if(getLabelSize(cachePtr->str, labelPtr, &r) == -1)
-      return(-1);
-
-    if(labelPtr->autominfeaturesize && ((r.maxx-r.minx) > cachePtr->featuresize))
-      continue; 
-
-    draw_marker = marker_offset_x = marker_offset_y = 0;
-    if((type == OV_LAYER_ANNOTATION || type == OV_LAYER_POINT) && (classPtr->color >= 0 || classPtr->outlinecolor > 0 || classPtr->symbol > 0)) { // there *is* a marker
-
-
-      marker_width = 1;marker_height = 1;
-      marker_offset_x = OV_NINT(marker_width/2.0);
-      marker_offset_y = OV_NINT(marker_height/2.0);      
-
-      marker_rect.minx = OV_NINT(cachePtr->point.x - .5 * marker_width);
-      marker_rect.miny = OV_NINT(cachePtr->point.y - .5 * marker_height);
-      marker_rect.maxx = marker_rect.minx + (marker_width-1);
-      marker_rect.maxy = marker_rect.miny + (marker_height-1);
-
-      if(type == OV_LAYER_ANNOTATION) draw_marker = 1;
-    }
-
-
-    if(labelPtr->position == OV_AUTO) {
-
-      if(type == OV_LAYER_LINE) {
-	int position = OV_UC;
-
-	for(j=0; j<2; j++) { 
-
-	  cachePtr->poly->destroy();
-	  cachePtr->status = 1;
-
-	  if(j == 1) {
-	    if(fabs(cos(labelPtr->angle)) < LINE_VERT_THRESHOLD)
-	      labelPtr->angle += 180.0;
-	    else
-	      position = OV_LC;
-	  }
-
-	  p = this->get_metrics(&(cachePtr->point), position, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, labelPtr->buffer, cachePtr->poly);
-
-	  if(draw_marker)
-	    this->rectToPolygon(marker_rect, cachePtr->poly); // save marker bounding polygon
-
-	  if(!labelPtr->partials) { // check against image first
-	    if(labelInImage(img->sx, img->sy, cachePtr->poly, labelPtr->buffer) == 0) {
-	      cachePtr->status = 0;
-	      continue; // next angle
-	    }
-	  }
-
-	  for(i=0; i<label_cache.nummarkers; i++) { // compare against points already drawn
-	    if(l != label_cache.markers[i].id) { // labels can overlap their own marker
-	      if(intersectLabelPolygons(label_cache.markers[i].poly, cachePtr->poly) == 1) { 
-		cachePtr->status = 0;
-		break;
-	      }
-	    }
-	  }
-
-	  if(!cachePtr->status)
-	    continue; // next angle
-
-	  for(i=l+1; i<label_cache.numlabels; i++) { // compare against rendered labels
-	    if(label_cache.labels[i].status == 1) { 
-
-	      if((labelPtr->mindistance != -1) && (cachePtr->classidx == label_cache.labels[i].classidx) && (strcmp(cachePtr->str,label_cache.labels[i].str) == 0) && (dist(cachePtr->point, label_cache.labels[i].point) <= labelPtr->mindistance)) { 
-		cachePtr->status = 0;
-		break;
-	      }
-
-	      if(this->intersectLabelPolygons(label_cache.labels[i].poly, cachePtr->poly) == 1) { 
-		cachePtr->status = 0;
-		break;
-	      }
-	    }
-	  }
-
-	  if(cachePtr->status) // found a suitable place for this label
-	    break;
-
-	} // next angle
-
-      } 
-
-else
-
- {
-	for(j=0; j<=7; j++) { 
-
-	  cachePtr->poly->destroy();
-	  cachePtr->status = 1;
-
-	  p = this->get_metrics(&(cachePtr->point), j, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, labelPtr->buffer, cachePtr->poly);
-
-	  if(draw_marker)
-	    this->rectToPolygon(marker_rect, cachePtr->poly); // save marker bounding polygon
-
-	  if(!labelPtr->partials) { // check against image first
-	    if(this->labelInImage(img->sx, img->sy, cachePtr->poly, labelPtr->buffer) == 0) {
-	      cachePtr->status = 0;
-	      continue; // next position
-	    }
-	  }
-
-	  for(i=0; i<label_cache.nummarkers; i++) { // compare against points already drawn
-	    if(l != label_cache.markers[i].id) { // labels can overlap their own marker
-	      if(this->intersectLabelPolygons(label_cache.markers[i].poly, cachePtr->poly) == 1) { 
-		cachePtr->status = 0;
-		break;
-	      }
-	    }
-	  }
-
-	  if(!cachePtr->status)
-	    continue; // next position
-
-	  for(i=l+1; i<label_cache.numlabels; i++) { // compare against rendered labels
-	    if(label_cache.labels[i].status == 1) {
-
-	      if((labelPtr->mindistance != -1) && (cachePtr->classidx == label_cache.labels[i].classidx) && (strcmp(cachePtr->str,label_cache.labels[i].str) == 0) && (dist(cachePtr->point, label_cache.labels[i].point) <= labelPtr->mindistance)) {
-		cachePtr->status = 0;
-		break;
-	      }
-
-	      if(this->intersectLabelPolygons(label_cache.labels[i].poly, cachePtr->poly) == 1) {
-		cachePtr->status = 0;
-		break;
-	      }
-	    }
-	  }
-
-	  if(cachePtr->status) // found a suitable place for this label
-	    break;
-	} // next position
-      }
-
-      if(labelPtr->force) cachePtr->status = 1; 
-
-    } else
-
- {
-
-
-
-      cachePtr->status = 1; 
-
-      if(labelPtr->position == OV_CC) // don't need the marker_offset
-        p = get_metrics(&(cachePtr->point), labelPtr->position, r, labelPtr->offsetx, labelPtr->offsety, labelPtr->angle, labelPtr->buffer, cachePtr->poly);
-      else
-        p = get_metrics(&(cachePtr->point), labelPtr->position, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, labelPtr->buffer, cachePtr->poly);
-
-      if(draw_marker)
-	this->rectToPolygon(marker_rect, cachePtr->poly); 
-
-      if(!labelPtr->force) { // no need to check anything else
-
-	if(!labelPtr->partials) {
-	  if(this->labelInImage(img->sx, img->sy, cachePtr->poly, labelPtr->buffer) == 0)
-	    cachePtr->status = 0;
-	}
-
-	if(!cachePtr->status)
-	  continue; // next label
-
-	for(i=0; i<label_cache.nummarkers; i++) { // compare against points already drawn
-	  if(l != label_cache.markers[i].id) { // labels can overlap their own marker
-	    if(this->intersectLabelPolygons(label_cache.markers[i].poly, cachePtr->poly) == 1) {
-	      cachePtr->status = 0;
-	      break;
-	    }
-	  }
-	}
-
-	if(!cachePtr->status)
-	  continue; // next label
-
-	for(i=l+1; i<label_cache.numlabels; i++) { // compare against rendered label
-	  if(label_cache.labels[i].status == 1) {
-	    if((labelPtr->mindistance != -1) && (cachePtr->classidx == label_cache.labels[i].classidx) && (strcmp(cachePtr->str, label_cache.labels[i].str) == 0) && (dist(cachePtr->point, label_cache.labels[i].point) <= labelPtr->mindistance)) {
-	      cachePtr->status = 0;
-	      break;
-	    }
-
-	    if(this->intersectLabelPolygons(label_cache.labels[i].poly, cachePtr->poly) == 1) { 
-	      cachePtr->status = 0;
-	      break;
-	    }
-	  }
-	}
-      }
-
-    } 
-
-
-
-    if(!cachePtr->status)
-      continue; 
-
-    if(draw_marker) { 
-      drawMarker(&(cachePtr->point), classPtr->symbol, classPtr->color, classPtr->backgroundcolor, classPtr->outlinecolor, classPtr->sizescaled);
-      if(classPtr->overlaysymbol >= 0) drawMarker(&(cachePtr->point), classPtr->overlaysymbol, classPtr->overlaycolor, classPtr->overlaybackgroundcolor, classPtr->overlayoutlinecolor, classPtr->overlaysizescaled);
-    }
-
-    if(labelPtr->backgroundcolor >= 0)
-      this->billboard(cachePtr->poly, labelPtr);
-
-    this->draw_text(p, cachePtr->str, labelPtr); 
-
-  } 
-
-  return(0);
-}
-
-
-void ossimGdVectorSource::billboard(ossimVectorFeature *shape, ossimVectorLabel *label)
-{
-  int i;
-  ossimVectorFeature temp;
-
-  temp.init();
-  temp.msAddLine(&shape->line[0]);
-
-  if(label->backgroundshadowcolor >= 0) {
-    for(i=0; i<temp.line[0].numpoints; i++) {
-      temp.line[0].point[i].x += label->backgroundshadowsizex;
-      temp.line[0].point[i].y += label->backgroundshadowsizey;
-    }
-    imageFilledPolygon(&temp, label->backgroundshadowcolor);
-    for(i=0; i<temp.line[0].numpoints; i++) {
-      temp.line[0].point[i].x -= label->backgroundshadowsizex;
-      temp.line[0].point[i].y -= label->backgroundshadowsizey;
-    }
-  }
-
-  imageFilledPolygon(&temp, label->backgroundcolor);
-
-  temp.destroy();
-}
-
-
-int ossimGdVectorSource::intersectLines(ossimVectorPoint a, ossimVectorPoint b, ossimVectorPoint c, ossimVectorPoint d) { /* from comp.graphics.alogorithms FAQ */
-
-  double r, s;
-  double denominator, numerator;
-
-  numerator = ((a.y-c.y)*(d.x-c.x) - (a.x-c.x)*(d.y-c.y));  
-  denominator = ((b.x-a.x)*(d.y-c.y) - (b.y-a.y)*(d.x-c.x));  
-
-  if((denominator == 0) && (numerator == 0)) { /* lines are coincident, intersection is a line segement if it exists */
-    if(a.y == c.y) { /* coincident horizontally, check x's */
-      if(((a.x >= OV_MIN(c.x,d.x)) && (a.x <= OV_MAX(c.x,d.x))) || ((b.x >= OV_MIN(c.x,d.x)) && (b.x <= OV_MAX(c.x,d.x))))
-	return 1;
-      else
-	return 0;
-    } else { /* test for y's will work fine for remaining cases */
-      if(((a.y >= OV_MIN(c.y,d.y)) && (a.y <= OV_MAX(c.y,d.y))) || ((b.y >= OV_MIN(c.y,d.y)) && (b.y <= OV_MAX(c.y,d.y))))
-	return 1;
-      else
-	return 0;
-    }
-  }
-
-  if(denominator == 0) /* lines are parallel, can't intersect */
-    return 0;
-
-  r = numerator/denominator;
-
-  if((r<0) || (r>1))
-    return 0; /* no intersection */
-
-  numerator = ((a.y-c.y)*(b.x-a.x) - (a.x-c.x)*(b.y-a.y));
-  s = numerator/denominator;
-
-  if((s<0) || (s>1))
-    return 0; /* no intersection */
-
-  return 1;
-}
-
-
-int ossimGdVectorSource::labelInImage(int width, int height, ossimVectorFeature *lpoly, int buffer)
-{
-  return 1;
-}
-
-int ossimGdVectorSource::intersectLabelPolygons(ossimVectorFeature *p1, ossimVectorFeature *p2) {
-  int c1,v1,c2,v2;
-  ossimVectorPoint *point;
-
-  /* STEP 1: look for intersecting line segments */
-  for(c1=0; c1<p1->numlines; c1++)
-    for(v1=1; v1<p1->line[c1].numpoints; v1++)
-      for(c2=0; c2<p2->numlines; c2++)
-	for(v2=1; v2<p2->line[c2].numpoints; v2++)
-	  if(intersectLines(p1->line[c1].point[v1-1], p1->line[c1].point[v1], p2->line[c2].point[v2-1], p2->line[c2].point[v2]) ==  1)
-	    return 1;
-
-  /* STEP 2: polygon one completely contains two (only need to check one point from each part) */
-  for(c2=0; c2<p2->numlines; c2++) {
-    point = &(p2->line[c2].point[0]);
-    for(c1=0; c1<p1->numlines; c1++) {
-      if(p1->msPointInPolygon(point, &p1->line[c1]) == 1) /* ok, the point is in a polygon */
-	return 1 ;
-    }
-  }
-
-  /* STEP 3: polygon two completely contains one (only need to check one point from each part) */
-  for(c1=0; c1<p1->numlines; c1++) {
-    point = &(p1->line[c1].point[0]);
-    for(c2=0; c2<p2->numlines; c2++) {
-      if(p1->msPointInPolygon(point, &p2->line[c2]) == 1) /* ok, the point is in a polygon */
-	return 1;
-    }
-  }
-
-  return 0;
-}
-
-void ossimGdVectorSource::rectToPolygon(ossimVectorRect rect, ossimVectorFeature *poly)
-{
-  ossimVectorLine line={0,NULL};
-
-  line.point = (ossimVectorPoint *)malloc(sizeof(ossimVectorPoint)*5);
-  
-  line.point[0].x = rect.minx;
-  line.point[0].y = rect.miny;
-  line.point[1].x = rect.minx;
-  line.point[1].y = rect.maxy;
-  line.point[2].x = rect.maxx;
-  line.point[2].y = rect.maxy;
-  line.point[3].x = rect.maxx;
-  line.point[3].y = rect.miny;
-  line.point[4].x = line.point[0].x;
-  line.point[4].y = line.point[0].y;
-  
-  line.numpoints = 5;
-  
-  poly->msAddLine(&line);
-  poly->type = OV_SHAPE_POLYGON;
-  poly->bounds = rect;
-  free(line.point);
-}
-
-
-#define MARKER_SLOP 2
-
-ossimVectorPoint ossimGdVectorSource::get_metrics(ossimVectorPoint *p, int position, ossimVectorRect rect, int ox, int oy, double angle, int buffer, ossimVectorFeature *poly)
-{
-  ossimVectorPoint q;
-  double x1=0, y1=0, x2=0, y2=0;
-  ossimVectorLine line={0,NULL};
-  double sin_a,cos_a;
-  double w, h, x, y;
-
-  w = rect.maxx - rect.minx;
-  h = rect.maxy - rect.miny;
-
-  switch(position) {
-  case OV_UL:
-    x1 = -w - ox;
-    y1 = -oy;
-    break;
-  case OV_UC:
-    x1 = -(w/2.0);
-    y1 = -oy - MARKER_SLOP;
-    break;
-  case OV_UR:
-    x1 = ox;
-    y1 = -oy;
-    break;
-  case OV_CL:
-    x1 = -w - ox - MARKER_SLOP;
-    y1 = (h/2.0);
-    break;
-  case OV_CC:
-    x1 = -(w/2.0) + ox;
-    y1 = (h/2.0) + oy;
-    break;
-  case OV_CR:
-    x1 = ox + MARKER_SLOP;
-    y1 = (h/2.0);
-    break;
-  case OV_LL:
-    x1 = -w - ox;
-    y1 = h + oy;
-    break;
-  case OV_LC:
-    x1 = -(w/2.0);
-    y1 = h + oy + MARKER_SLOP;
-    break;
-  case OV_LR:
-    x1 = ox;
-    y1 = h + oy;
-    break;
-  }
-
-  sin_a = sin(OV_DEG_TO_RAD*angle);
-  cos_a = cos(OV_DEG_TO_RAD*angle);
-
-  x = x1 - rect.minx;
-  y = rect.maxy - y1;
-  q.x = p->x + OV_NINT(x * cos_a - (y) * sin_a);
-  q.y = p->y - OV_NINT(x * sin_a + (y) * cos_a);
-
-  if(poly) {
-    line.point = (ossimVectorPoint *)malloc(sizeof(ossimVectorPoint)*5);
-    line.numpoints = 5;
-
-    x2 = x1 - buffer; /* ll */
-    y2 = y1 + buffer;
-    line.point[0].x = p->x + OV_NINT(x2 * cos_a - (-y2) * sin_a);
-    line.point[0].y = p->y - OV_NINT(x2 * sin_a + (-y2) * cos_a);
-
-    x2 = x1 - buffer; /* ul */
-    y2 = y1 - h - buffer;
-    line.point[1].x = p->x + OV_NINT(x2 * cos_a - (-y2) * sin_a);
-    line.point[1].y = p->y - OV_NINT(x2 * sin_a + (-y2) * cos_a);
-
-    x2 = x1 + w + buffer; /* ur */
-    y2 = y1 - h - buffer;
-    line.point[2].x = p->x + OV_NINT(x2 * cos_a - (-y2) * sin_a);
-    line.point[2].y = p->y - OV_NINT(x2 * sin_a + (-y2) * cos_a);
-
-    x2 = x1 + w + buffer; /* lr */
-    y2 = y1 + buffer;
-    line.point[3].x = p->x + OV_NINT(x2 * cos_a - (-y2) * sin_a);
-    line.point[3].y = p->y - OV_NINT(x2 * sin_a + (-y2) * cos_a);
-
-    line.point[4].x = line.point[0].x;
-    line.point[4].y = line.point[0].y;
-
-    poly->msAddLine(&line);
-    free(line.point);
-  }
-
-  return(q);
-}
-
-
-int ossimGdVectorSource::getLabelSize(char *str, ossimVectorLabel *label, ossimVectorRect *rect) 
-{
-/*
-  if(label->type == OV_TRUETYPE) {
-
-#if defined (USE_GD_FT) || defined (USE_GD_TTF)
-    int bbox[8];
-    char *error=NULL, *font=NULL;
-
-    font = msLookupHashTable(fontset->fonts, label->font);
-    if(!font) {
-      if(label->font) 
-          msSetError(OV_TTFERR, "Requested font (%s) not found.", 
-                     "getLabelSize()", label->font);
-      else
-          msSetError(OV_TTFERR, "Requested font (NULL) not found.", 
-                     "getLabelSize()" );
-      return(-1);
-    }
-
-#ifdef USE_GD_TTF
-    error = gdImageStringTTF(NULL, bbox, 0, font, label->sizescaled, 0, 0, 0, str);
-#else
-    error = gdImageStringFT(NULL, bbox, 0, font, label->sizescaled, 0, 0, 0, str);
-#endif
-    if(error) {
-      msSetError(OV_TTFERR, error, "getLabelSize()");
-      return(-1);
-    }
-
-    rect->minx = bbox[0];
-    rect->miny = bbox[5];
-    rect->maxx = bbox[2];
-    rect->maxy = bbox[1];
-#else
-    msSetError(OV_TTFERR, "TrueType font support is not available.", "getLabelSize()");
-    return(-1);
-#endif
-  } else 
-FIXME*/
-{
-    gdFontPtr fontPtr;
-    unsigned char **token=NULL;
-    int t, num_tokens, max_token_length=0;
-
-    if((fontPtr = getBitmapFont(label->size)) == NULL)
-      return(-1);
-
-    if(label->wrap != '\0') {
-      if((token = split(str, label->wrap, &(num_tokens))) == NULL)
-	return(0);
-
-      for(t=0; t<num_tokens; t++)
-	max_token_length = OV_MAX(max_token_length, strlen((const char *)token[t]));
-
-      rect->minx = 0;
-      rect->miny = -(fontPtr->h * num_tokens);
-      rect->maxx = fontPtr->w * max_token_length;
-      rect->maxy = 0;
-
-      //msFreeCharArray((char **)token, num_tokens);
-    } else {
-      rect->minx = 0;
-      rect->miny = -fontPtr->h;
-      rect->maxx = fontPtr->w * strlen(str);
-      rect->maxy = 0;
-    }
-  }
-  return(0);
-}
-
-gdFontPtr ossimGdVectorSource::getBitmapFont(int size)
-{
-
-return gdFontSmall;
-/*
-  switch(size) { 
-  case OV_TINY:
-    return(gdFontTiny);
-    break;
-  case OV_SMALL:
-    return(gdFontSmall);
-    break;
-  case OV_MEDIUM:
-    return(gdFontMediumBold);
-    break;
-  case OV_LARGE:
-    return(gdFontLarge);
-    break;
-  case OV_GIANT:
-    return(gdFontGiant);
-    break;
-  default:
-    msSetError(OV_GDERR,"Invalid bitmap font. Must be one of tiny, small, medium, large or giant." , "getBitmapFont()");
-    return(NULL);
-  }
-*/
-}
-
-
-int ossimGdVectorSource::addLabel(int layeridx, int classidx, int tileidx, int shapeidx, ossimVectorPoint point, char *str, double featuresize)
-{
-  int i;
-  char wrap[2];
-
-  if(!str) return(0); /* not an error */
-
-  if(label_cache.numlabels == label_cache.cachesize) { /* just add it to the end */
-    label_cache.labels = (ossimVectorLabelCacheMember *) realloc(label_cache.labels, sizeof(ossimVectorLabelCacheMember)*(label_cache.cachesize+OV_LABELCACHEINCREMENT));
-    if(!label_cache.labels) {
-      printf("Realloc() error. addLabel()");
-      return(-1);
-    }
-    label_cache.cachesize += OV_LABELCACHEINCREMENT;
-  }
-
-  i = label_cache.numlabels;
-
-
-  label_cache.labels[i].point = point;
-  label_cache.labels[i].point.x = OV_NINT(label_cache.labels[i].point.x);
-  label_cache.labels[i].point.y = OV_NINT(label_cache.labels[i].point.y);
-
-  label_cache.labels[i].str = str;
-
-  // GD/Freetype recognizes \r\n as a true line wrap so we must turn the wrap character into that pattern
-/*  if(map->layers[layeridx]._class[classidx].label.type != OV_BITMAP && map->layers[layeridx]._class[classidx].label.wrap != '\0') {
-    wrap[0] = map->layers[layeridx]._class[classidx].label.wrap;
-    wrap[1] = '\0';
-    label_cache.labels[i].str = gsub(label_cache.labels[i].str, wrap, "\r\n");
-  }
-*/
-//  class_cache(&(map->layers[layeridx]._class[classidx]), &(label_cache.labels[i]._class)); 
-  style_cache(theStyle, &(label_cache.labels[i].style)); 
-
-  // label_cache.labels[i].size = map->layers[layeridx]._class[classidx].label.sizescaled;
-  // label_cache.labels[i].angle = map->layers[layeridx]._class[classidx].label.angle;
-  label_cache.labels[i].featuresize = featuresize;
-
-  label_cache.labels[i].poly = (ossimVectorFeature *) malloc(sizeof(ossimVectorFeature));
-  label_cache.labels[i].poly->init();
-
-  label_cache.labels[i].status = 0;
-
-  if(type == OV_LAYER_POINT) { // cache the marker placement
-    ossimVectorRect rect;
-    int w, h;
-
-    if(label_cache.nummarkers == label_cache.markercachesize) { /* just add it to the end */
-      label_cache.markers = (ossimVectorMarkerCacheMember *) realloc(label_cache.markers, sizeof(ossimVectorMarkerCacheMember)*(label_cache.cachesize+OV_LABELCACHEINCREMENT));
-      if(!label_cache.markers) {
-	printf( "Realloc() error. addLabel()");
-	return(-1);
-      }
-      label_cache.markercachesize+=OV_LABELCACHEINCREMENT;
-    }
-
-    i = label_cache.nummarkers;
-
-    label_cache.markers[i].poly = (ossimVectorFeature *) malloc(sizeof(ossimVectorFeature));
-    label_cache.markers[i].poly->init();
-    w = 1; h = 1;
-
-    rect.minx = OV_NINT(point.x - .5 * w);
-    rect.miny = OV_NINT(point.y - .5 * h);
-    rect.maxx = rect.minx + (w-1);
-    rect.maxy = rect.miny + (h-1);
-    rectToPolygon(rect, label_cache.markers[i].poly);
-    label_cache.markers[i].id = label_cache.numlabels;
-
-    label_cache.nummarkers++;
-  }
-
-  label_cache.numlabels++;
-
-  return(0);
-}
-
-
-
-
-
-int ossimGdVectorSource::draw_text(ossimVectorPoint labelPnt, char *str, ossimVectorLabel *label)
-{
-  int x, y;
-
-  if(!str)
-    return(0); /* not an error, just don't want to do anything */
-
-  if(strlen(str) == 0)
-    return(0); /* not an error, just don't want to do anything */
-
-  x = OV_NINT(labelPnt.x);
-  y = OV_NINT(labelPnt.y);
-/*
-  if(label->type == OV_TRUETYPE) {
-    char *error=NULL, *font=NULL;
-    int bbox[8];
-    double angle_radians = OV_DEG_TO_RAD*label->angle;
-
-#if defined (USE_GD_FT) || defined (USE_GD_TTF)
-    if(!fontset) {
-      msSetError(OV_TTFERR, "No fontset defined.", "draw_text()");
-      return(-1);
-    }
-
-    if(!label->font) {
-      msSetError(OV_TTFERR, "No TrueType font defined.", "draw_text()");
-      return(-1);
-    }
-
-    font = msLookupHashTable(fontset->fonts, label->font);
-    if(!font) {
-       msSetError(OV_TTFERR, "Requested font (%s) not found.", "draw_text()",
-                  label->font);
-      return(-1);
-    }
-
-    if(label->outlinecolor >= 0) { 
-#ifdef USE_GD_TTF
-      error = gdImageStringTTF(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x-1, y-1, str);
-#else
-      error = gdImageStringFT(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x-1, y-1, str);
-#endif
-      if(error) {
-	msSetError(OV_TTFERR, error, "draw_text()");
-	return(-1);
-      }
-
-#ifdef USE_GD_TTF
-      gdImageStringTTF(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x-1, y+1, str);
-      gdImageStringTTF(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x+1, y+1, str);
-      gdImageStringTTF(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x+1, y-1, str);
-#else
-      gdImageStringFT(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x-1, y+1, str);
-      gdImageStringFT(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x+1, y+1, str);
-      gdImageStringFT(img, bbox, ((label->antialias)?(label->outlinecolor):-(label->outlinecolor)), font, label->sizescaled, angle_radians, x+1, y-1, str);
-#endif
-
-    }
-
-    if(label->shadowcolor >= 0) { 
-#ifdef USE_GD_TTF
-      error = gdImageStringTTF(img, bbox, ((label->antialias)?(label->shadowcolor):-(label->shadowcolor)), font, label->sizescaled, angle_radians, x+label->shadowsizex, y+label->shadowsizey, str);
-#else
-      error = gdImageStringFT(img, bbox, ((label->antialias)?(label->shadowcolor):-(label->shadowcolor)), font, label->sizescaled, angle_radians, x+label->shadowsizex, y+label->shadowsizey, str);
-#endif
-      if(error) {
-	msSetError(OV_TTFERR, error, "draw_text()");
-	return(-1);
-      }
-    }
-
-#ifdef USE_GD_TTF
-    gdImageStringTTF(img, bbox, ((label->antialias)?(label->color):-(label->color)), font, label->sizescaled, angle_radians, x, y, str);
-#else
-    gdImageStringFT(img, bbox, ((label->antialias)?(label->color):-(label->color)), font, label->sizescaled, angle_radians, x, y, str);
-#endif
-
-#else
-    msSetError(OV_TTFERR, "TrueType font support is not available.", "draw_text()");
-    return(-1);
-#endif
-
-  } else 
-*/
-{ /* OV_BITMAP */
-    unsigned char **token=NULL;
-    int t, num_tokens;
-    gdFontPtr fontPtr;
-
-    if((fontPtr = getBitmapFont(label->size)) == NULL)
-      return(-1);
-
-    if(label->wrap != '\0') {
-      if((token = split(str, label->wrap, &(num_tokens))) == NULL)
-	return(-1);
-
-      y -= fontPtr->h*num_tokens;
-      for(t=0; t<num_tokens; t++) {
-	if(label->outlinecolor >= 0) {