[mapserver-commits] r7124 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Nov 29 23:11:14 EST 2007


Author: warmerdam
Date: 2007-11-29 23:11:14 -0500 (Thu, 29 Nov 2007)
New Revision: 7124

Modified:
   trunk/mapserver/mapwcs.c
   trunk/mapserver/mapwcs.h
   trunk/mapserver/mapwcs11.c
Log:
WCS 1.1 working in a *very* preliminary way

Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c	2007-11-29 22:43:23 UTC (rev 7123)
+++ trunk/mapserver/mapwcs.c	2007-11-30 04:11:14 UTC (rev 7124)
@@ -275,7 +275,8 @@
 
 static int msWCSParseRequest(cgiRequestObj *request, wcsParamsObj *params, mapObj *map)
 {
-  int i;
+  int i, n;
+  char **tokens;
 
   if(!request || !params) /* nothing to do */
 	return MS_SUCCESS;
@@ -298,9 +299,6 @@
 
        /* GetCoverage parameters. */
        else if(strcasecmp(request->ParamNames[i], "BBOX") == 0) {
-         char **tokens;
-         int n;
-          
          tokens = msStringSplit(request->ParamValues[i], ',', &n);
          if(tokens==NULL || n != 4) {
            msSetError(MS_WMSERR, "Wrong number of arguments for BBOX.", "msWCSParseRequest()");
@@ -335,6 +333,31 @@
        else if(strcasecmp(request->ParamNames[i], "IDENTIFIER") == 0
                || strcasecmp(request->ParamNames[i], "IDENTIFIERS") == 0 )
            params->coverages = CSLAddString(params->coverages, request->ParamValues[i]);
+       /* WCS 1.1 style BOUNDINGBOX */
+       else if(strcasecmp(request->ParamNames[i], "BOUNDINGBOX") == 0) {
+         tokens = msStringSplit(request->ParamValues[i], ',', &n);
+         if(tokens==NULL || n < 5) {
+           msSetError(MS_WMSERR, "Wrong number of arguments for BOUNDINGBOX.", "msWCSParseRequest()");
+           return msWCSException(map, params->version, "InvalidParameterValue", "boundingbox");
+         }
+         params->bbox.minx = atof(tokens[0]);
+         params->bbox.miny = atof(tokens[1]);
+         params->bbox.maxx = atof(tokens[2]);
+         params->bbox.maxy = atof(tokens[3]);
+           
+         params->crs = strdup(tokens[4]);
+         msFreeCharArray(tokens, n);
+       } else if(strcasecmp(request->ParamNames[i], "GridOffsets") == 0) {
+         tokens = msStringSplit(request->ParamValues[i], ',', &n);
+         if(tokens==NULL || n < 2) {
+           msSetError(MS_WMSERR, "Wrong number of arguments for GridOffsets", 
+                      "msWCSParseRequest()");
+           return msWCSException(map, params->version, "InvalidParameterValue", "GridOffsets");
+         }
+         params->resx = atof(tokens[0]);
+         params->resy = atof(tokens[1]);
+         msFreeCharArray(tokens, n);
+       }
 	   
        /* and so on... */
     }
@@ -1044,27 +1067,24 @@
 
   /* handle the response CRS, that is set the map object projection */
   if(params->response_crs || params->crs ) {
+    int iUnits;
     const char *crs_to_use = params->response_crs;
+
     if( crs_to_use == NULL )
       crs_to_use = params->crs;
 
-    if (strncasecmp(crs_to_use, "EPSG:", 5) == 0) {
-      /* RESPONSE_CRS=EPSG:xxxx */
-      char buffer[32];
-      int iUnits;
-
-      sprintf(buffer, "init=epsg:%.20s", crs_to_use+5);
-
-      if (msLoadProjectionString(&(map->projection), buffer) != 0)
+    if (strncasecmp(crs_to_use, "EPSG:", 5) == 0
+        || strncasecmp(crs_to_use,"urn:ogc:def:crs:",16) == 0 ) {
+      if (msLoadProjectionString(&(map->projection), (char *) crs_to_use) != 0)
         return msWCSException( map, params->version, NULL, NULL);
-        
-      iUnits = GetMapserverUnitUsingProj(&(map->projection));
-      if (iUnits != -1)
-        map->units = iUnits;
     } else {  /* should we support WMS style AUTO: projections? (not for now) */
       msSetError(MS_WMSERR, "Unsupported SRS namespace (only EPSG currently supported).", "msWCSGetCoverage()");
       return msWCSException(map, params->version, "InvalidParameterValue", "srs");
     }
+
+    iUnits = GetMapserverUnitUsingProj(&(map->projection));
+    if (iUnits != -1)
+        map->units = iUnits;
   }
 
   /* did we get a TIME value (support only a single value for now) */
@@ -1178,7 +1198,16 @@
   }
     
   /* if necessary, project the BBOX */
-    
+
+  /* in WCS 1.1 the default is full resolution */
+  if( strncasecmp(params->version,"1.1",3) == 0 
+      && params->resx == 0.0 && params->resy == 0.0
+      && params->width == 0 && params->height == 0 ) {
+
+    params->resx = cm.geotransform[1];
+    params->resy = fabs(cm.geotransform[5]);
+  }
+
   /* compute width/height from BBOX and cellsize.  */
   if( (params->resx == 0.0 || params->resy == 0.0) && params->width != 0 && params->height != 0 ) {
     params->resx = (params->bbox.maxx - params->bbox.minx) / params->width;
@@ -1295,19 +1324,29 @@
   if( status != MS_SUCCESS ) {
     return msWCSException(map, params->version, NULL, NULL);
   }
-    
-  /* Emit back to client. */
-  msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
-  status = msSaveImage(map, image, NULL);
 
-  if( status != MS_SUCCESS )
+
+  if( strncmp(params->version, "1.1",3) == 0 )
   {
-      /* unfortunately, the image content type will have already been sent
-         but that is hard for us to avoid.  The main error that could happen
-         here is a misconfigured tmp directory or running out of space. */
-      return msWCSException(map, params->version, NULL, NULL);
+      msWCSReturnCoverage11( params, map, image );
   }
+  else /* WCS 1.0.0 - just return the binary data with a content type */
+  {
+      /* Emit back to client. */
+      msIO_printf("Content-type: %s%c%c", 
+                  MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
 
+      status = msSaveImage(map, image, NULL);
+      
+      if( status != MS_SUCCESS )
+      {
+          /* unfortunately, the image content type will have already been sent
+             but that is hard for us to avoid.  The main error that could happen
+             here is a misconfigured tmp directory or running out of space. */
+          return msWCSException(map, params->version, NULL, NULL);
+      }
+  }
+      
   /* Cleanup */
   msFreeImage(image);
   msApplyOutputFormat(&(map->outputformat), NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE);

Modified: trunk/mapserver/mapwcs.h
===================================================================
--- trunk/mapserver/mapwcs.h	2007-11-29 22:43:23 UTC (rev 7123)
+++ trunk/mapserver/mapwcs.h	2007-11-30 04:11:14 UTC (rev 7124)
@@ -85,5 +85,6 @@
 int msWCSGetCapabilities11(mapObj *map, wcsParamsObj *params, 
                            cgiRequestObj *req);
 int msWCSDescribeCoverage11(mapObj *map, wcsParamsObj *params );
+int msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map, imageObj *image);
 
 #endif /* nef MAPWCS_H */

Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c	2007-11-29 22:43:23 UTC (rev 7123)
+++ trunk/mapserver/mapwcs11.c	2007-11-30 04:11:14 UTC (rev 7124)
@@ -827,7 +827,59 @@
 
 #endif /* defined(USE_WCS_SVR) && defined(USE_LIBXML2) */
 
+/************************************************************************/
+/*                       msWCSReturnCoverage11()                        */
+/*                                                                      */
+/*      Return a render image as a coverage to the caller with WCS      */
+/*      1.1 "mime" wrapping.                                            */
+/************************************************************************/
 
+#if defined(USE_WCS_SVR)
+int  msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map, 
+                            imageObj *image )
+{
+    int status;
+
+    msIO_fprintf( 
+        stdout, 
+        "\n"
+        "--wcs\n"
+        "Content-Type: text/xml\n"
+        "Content-ID: wcs.xml%c%c"
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+        "<Coverages\n"
+        "     xmlns=\"http://www.opengis.net/wcs/1.1\"\n"
+        "     xmlns:ows=\"http://www.opengis.net/ows\"\n"
+        "     xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+        "     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+        "     xsi:schemaLocation=\"http://www.opengis.net/ows/1.1 ../owsCoverages.xsd\">\n"
+        "  <Coverage>\n"
+        "    <Reference xlink:href=\"cid:coverage/wcs.%s\"/>\n"
+        "  </Coverage>\n"
+        "</Coverages>\n"
+        "--wcs\n"
+        "Content-Type: %s\n"
+        "Content-Description: coverage data\n"
+        "Content-Transfer-Encoding: binary\n"
+        "Content-ID: coverage/wcs.%s\n"
+        "Content-Disposition: INLINE%c%c",
+        10, 10,
+        MS_IMAGE_EXTENSION(map->outputformat),
+        MS_IMAGE_MIME_TYPE(map->outputformat),
+        MS_IMAGE_EXTENSION(map->outputformat),
+        10, 10 );
+
+      status = msSaveImage(map, image, NULL);
+      
+      if( status != MS_SUCCESS )
+      {
+          return msWCSException(map, params->version, NULL, NULL);
+      }
+
+      return MS_SUCCESS;
+}
+#endif
+
 /************************************************************************/
 /* ==================================================================== */
 /*	If we don't have libxml2 but WCS SVR was selected, then         */



More information about the mapserver-commits mailing list