[mapserver-commits] r10903 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Jan 24 15:21:24 EST 2011


Author: assefa
Date: 2011-01-24 12:21:24 -0800 (Mon, 24 Jan 2011)
New Revision: 10903

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapsymbol.c
Log:
Add possiblity to use symbols stored externally (#3662)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-01-24 16:41:49 UTC (rev 10902)
+++ trunk/mapserver/HISTORY.TXT	2011-01-24 20:21:24 UTC (rev 10903)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Add possiblity to use symbols stored externally, accessed through http (#3662)
+
 - Better handling of temporary files (#3354)
 
 - Support curved features in PostGIS (#3621)

Modified: trunk/mapserver/mapsymbol.c
===================================================================
--- trunk/mapserver/mapsymbol.c	2011-01-24 16:41:49 UTC (rev 10902)
+++ trunk/mapserver/mapsymbol.c	2011-01-24 20:21:24 UTC (rev 10903)
@@ -421,16 +421,50 @@
   /* Allocate/init memory for new symbol if needed */
   if (msGrowSymbolSet(symbolset) == NULL)
       return -1;
-  symbol = symbolset->symbol[symbolset->numsymbols];  
-  if(symbolset->map) {
-    symbol->full_pixmap_path = msStrdup(msBuildPath(szPath, symbolset->map->mappath, filename));  
-  } else {
-    symbol->full_pixmap_path = msStrdup(msBuildPath(szPath, NULL, filename));  
+  symbol = symbolset->symbol[symbolset->numsymbols];
+
+#ifdef USE_CURL
+  if (strncasecmp(filename, "http", 4) == 0)
+  {
+      char *tmpfullfilename = NULL;
+      char *tmpfilename = NULL;
+      char *tmppath = NULL;
+      int status = 0;
+      char szPath[MS_MAXPATHLEN];
+     int bCheckLocalCache = MS_TRUE;
+ 
+     tmppath = msTmpPath(NULL, NULL, NULL);
+     if (tmppath)
+     {
+          tmpfilename = msEncodeUrl(filename);
+          tmpfullfilename = msBuildPath(szPath, tmppath, tmpfilename);
+          if (tmpfullfilename)
+          {
+              /*use the url for now as a caching mechanism*/
+              if (msHTTPGetFile(filename, tmpfullfilename, &status, -1, bCheckLocalCache, 0) == MS_SUCCESS)
+              {
+                  symbol->imagepath = msStrdup(tmpfullfilename);
+                  symbol->full_pixmap_path = msStrdup(tmpfullfilename);
+              }
+              msFree(tmpfilename);
+          }
+          msFree(tmpfilename);
+          msFree(tmppath);
+     }
   }
+#endif
+  /*if the http did not work, allow it to be treated as a file*/
+  if (!symbol->full_pixmap_path)
+  {
+      if(symbolset->map) {
+          symbol->full_pixmap_path = msStrdup(msBuildPath(szPath, symbolset->map->mappath, filename));  
+      } else {
+          symbol->full_pixmap_path = msStrdup(msBuildPath(szPath, NULL, filename));  
+      }
+      symbol->imagepath = msStrdup(filename);
+  }
   symbol->name = msStrdup(filename);
-  symbol->imagepath = msStrdup(filename);
   symbol->type = MS_SYMBOL_PIXMAP;
-
   return(symbolset->numsymbols++);
 }
 



More information about the mapserver-commits mailing list