1 /****************************************************************************** 2 * $Id$ 3 * 4 * Project: MapServer 5 * Purpose: OpenGIS Web Coverage Server (WCS) Declarations. 6 * Author: Steve Lime, Frank Warmerdam and the MapServer Team 7 * 8 ****************************************************************************** 9 * Copyright (c) 1996-2005 Regents of the University of Minnesota. 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining a 12 * copy of this software and associated documentation files (the "Software"), 13 * to deal in the Software without restriction, including without limitation 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 * and/or sell copies of the Software, and to permit persons to whom the 16 * Software is furnished to do so, subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice shall be included in 19 * all copies of this Software or works derived from this Software. 20 * 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 * DEALINGS IN THE SOFTWARE. 28 ****************************************************************************/ 29 30 #ifndef MAPWCS_H 31 #define MAPWCS_H 32 33 #include "mapserver.h" 34 #include "mapowscommon.h" 35 #include <limits.h> 36 #include <time.h> 37 #include <float.h> 38 39 #ifndef _WIN32 40 #include <sys/time.h> 41 #endif 42 43 /* 44 * Definitions 45 */ 46 47 #define MS_WCS_GML_COVERAGETYPE_RECTIFIED_GRID_COVERAGE "RectifiedGridCoverage" 48 49 enum { 50 MS_WCS_GET_CAPABILITIES, 51 MS_WCS_DESCRIBE_COVERAGE, 52 MS_WCS_GET_COVERAGE 53 }; 54 55 /* 56 ** Structure to hold metadata taken from the image or image tile index 57 */ 58 typedef struct { 59 char *srs_epsg; 60 char srs_urn[500]; 61 rectObj extent, llextent; 62 double geotransform[6]; 63 int xsize, ysize; 64 double xresolution, yresolution; 65 int bandcount; 66 int imagemode; 67 const char *bandinterpretation[10]; 68 } coverageMetadataObj; 69 70 typedef struct { 71 char *version; /* 1.0.0 for now */ 72 char *updatesequence; /* string, int or timestampe */ 73 char *request; /* GetCapabilities|DescribeCoverage|GetCoverage */ 74 char *service; /* MUST be WCS */ 75 char *section; /* of capabilities document: /WCS_Capabilities/Service|/WCS_Capabilities/Capability|/WCS_Capabilities/ContentMetadata */ 76 char **coverages; /* NULL terminated list of coverages (in the case of a GetCoverage there will only be 1) */ 77 char *crs; /* request coordinate reference system */ 78 char *response_crs; /* response coordinate reference system */ 79 rectObj bbox; /* subset bounding box (3D), although we'll only use 2D */ 80 char *time; 81 long width, height, depth; /* image dimensions */ 82 double originx, originy; /* WCS 1.1 GridOrigin */ 83 double resx, resy, resz; /* resolution */ 84 char *interpolation; /* interpolationMethod */ 85 char *format; 86 char *exceptions; /* exception MIME type, (default application=vnd.ogc.se_xml) */ 87 } wcsParamsObj; 88 89 /* -------------------------------------------------------------------- */ 90 /* Prototypes from mapwcs.c used in mapwcs11.c. */ 91 /* */ 92 /* Note, all prototypes are deliberately not exported from DLL */ 93 /* since they are for internal use within the core. */ 94 /* -------------------------------------------------------------------- */ 95 void msWCSFreeParams(wcsParamsObj *params); 96 int msWCSException(mapObj *map, const char *code, const char *locator, 97 const char *version); 98 int msWCSIsLayerSupported(layerObj *layer); 99 int msWCSGetCoverageMetadata( layerObj *layer, coverageMetadataObj *cm ); 100 void msWCSFreeCoverageMetadata(coverageMetadataObj *cm); 101 void msWCSSetDefaultBandsRangeSetInfo( wcsParamsObj *params, 102 coverageMetadataObj *cm, 103 layerObj *lp ); 104 const char *msWCSGetRequestParameter(cgiRequestObj *request, char *name); 105 void msWCSApplyLayerCreationOptions(layerObj* lp, 106 outputFormatObj* format, 107 const char* bandlist); 108 void msWCSApplyDatasetMetadataAsCreationOptions(layerObj* lp, 109 outputFormatObj* format, 110 const char* bandlist, 111 void* hDSIn); 112 113 /* -------------------------------------------------------------------- */ 114 /* Some WCS 1.1 specific functions from mapwcs11.c */ 115 /* -------------------------------------------------------------------- */ 116 int msWCSGetCapabilities11(mapObj *map, wcsParamsObj *params, 117 cgiRequestObj *req, owsRequestObj *ows_request); 118 int msWCSDescribeCoverage11(mapObj *map, wcsParamsObj *params, owsRequestObj *ows_request); 119 int msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map, imageObj *image); 120 int msWCSGetCoverageBands11( mapObj *map, cgiRequestObj *request, 121 wcsParamsObj *params, layerObj *lp, 122 char **p_bandlist ); 123 int msWCSException11(mapObj *map, const char *locator, 124 const char *exceptionCode, const char *version); 125 126 127 /* -------------------------------------------------------------------- */ 128 /* Some WCS 2.0 specific functions and structs from mapwcs20.c */ 129 /* -------------------------------------------------------------------- */ 130 131 enum { 132 MS_WCS20_TRIM = 0, 133 MS_WCS20_SLICE = 1 134 }; 135 136 enum { 137 MS_WCS20_ERROR_VALUE = -1, 138 MS_WCS20_SCALAR_VALUE = 0, 139 MS_WCS20_TIME_VALUE = 1, 140 MS_WCS20_UNDEFINED_VALUE = 2 141 }; 142 143 #define MS_WCS20_UNBOUNDED DBL_MAX 144 #define MS_WCS20_UNBOUNDED_TIME 0xFFFFFFFF 145 146 typedef struct { 147 union { 148 double scalar; 149 time_t time; 150 }; 151 int unbounded; /* 0 if bounded, 1 if unbounded */ 152 } timeScalarUnion; 153 154 typedef struct { 155 char *axis; /* the name of the subsetted axis */ 156 int operation; /* Either TRIM or SLICE */ 157 char *crs; /* optional CRS to use */ 158 int timeOrScalar; /* 0 if scalar value, 1 if time value */ 159 timeScalarUnion min; /* Minimum and Maximum of the subsetted axis;*/ 160 timeScalarUnion max; 161 } wcs20SubsetObj; 162 typedef wcs20SubsetObj * wcs20SubsetObjPtr; 163 164 typedef struct { 165 char *name; /* name of the axis */ 166 int size; /* pixelsize of the axis */ 167 double resolution; /* resolution of the axis */ 168 double scale; /* scale of the axis */ 169 char *resolutionUOM; /* resolution units of measure */ 170 wcs20SubsetObjPtr subset; 171 } wcs20AxisObj; 172 typedef wcs20AxisObj * wcs20AxisObjPtr; 173 174 typedef struct { 175 char *version; /* 2.0.0 v 2.0.1 */ 176 char *request; /* GetCapabilities|DescribeCoverage|GetCoverage */ 177 char *service; /* MUST be WCS */ 178 char **accept_versions; /* NULL terminated list of Accepted versions */ 179 char **accept_languages; /* NULL terminated list of Accepted versions */ 180 char **sections; /* NULL terminated list of GetCapabilities sections */ 181 char *updatesequence; /* GetCapabilities updatesequence */ 182 char **ids; /* NULL terminated list of coverages (in the case of a GetCoverage there will only be 1) */ 183 long width, height; /* image dimensions */ 184 double resolutionX; /* image resolution in X axis */ 185 double resolutionY; /* image resolution in Y axis */ 186 double scale; /* Overall scale */ 187 double scaleX; /* X-Axis specific scale */ 188 double scaleY; /* Y-Axis specific scale */ 189 char *resolutionUnits; /* Units of Measure for resolution */ 190 char *format; /* requested output format */ 191 int multipart; /* flag for multipart GML+image */ 192 char *interpolation; /* requested interpolation method */ 193 char *outputcrs; /* requested CRS for output */ 194 char *subsetcrs; /* determined CRS of the subsets */ 195 rectObj bbox; /* determined Bounding Box */ 196 int numaxes; /* number of axes */ 197 wcs20AxisObjPtr *axes; /* list of axes, NULL if none*/ 198 char **range_subset; /* list of bands selected */ 199 char **format_options; /* list of format specific options, NULL terminated */ 200 } wcs20ParamsObj; 201 typedef wcs20ParamsObj * wcs20ParamsObjPtr; 202 203 typedef struct { 204 union { 205 struct { 206 char *name; 207 char *interpretation; 208 char *uom; 209 char *definition; 210 char *description; 211 }; 212 char *values[5]; 213 }; 214 double interval_min; 215 double interval_max; 216 int significant_figures; 217 } wcs20rasterbandMetadataObj; 218 typedef wcs20rasterbandMetadataObj * wcs20rasterbandMetadataObjPtr; 219 220 typedef struct { 221 char *native_format; /* mime type of the native format */ 222 char *srs_epsg; 223 char srs_uri[200]; 224 rectObj extent; 225 double geotransform[6]; 226 double xresolution; 227 double yresolution; 228 int xsize; 229 int ysize; 230 int imagemode; 231 size_t numnilvalues; 232 char **nilvalues; 233 char **nilvalues_reasons; 234 size_t numbands; 235 wcs20rasterbandMetadataObjPtr bands; 236 } wcs20coverageMetadataObj; 237 typedef wcs20coverageMetadataObj * wcs20coverageMetadataObjPtr; 238 239 #define MS_WCS_20_PROFILE_CORE "http://www.opengis.net/spec/WCS/2.0/conf/core" 240 #define MS_WCS_20_PROFILE_KVP "http://www.opengis.net/spec/WCS_protocol-binding_get-kvp/1.0/conf/get-kvp" 241 #define MS_WCS_20_PROFILE_POST "http://www.opengis.net/spec/WCS_protocol-binding_post-xml/1.0/conf/post-xml" 242 #define MS_WCS_20_PROFILE_GML "http://www.opengis.net/spec/GMLCOV/1.0/conf/gml-coverage" 243 #define MS_WCS_20_PROFILE_GML_MULTIPART "http://www.opengis.net/spec/GMLCOV/1.0/conf/multipart" 244 #define MS_WCS_20_PROFILE_GML_SPECIAL "http://www.opengis.net/spec/GMLCOV/1.0/conf/special-format" 245 #define MS_WCS_20_PROFILE_GML_GEOTIFF "http://www.opengis.net/spec/GMLCOV_geotiff-coverages/1.0/conf/geotiff-coverage" 246 #define MS_WCS_20_PROFILE_CRS "http://www.opengis.net/spec/WCS_service-extension_crs/1.0/conf/crs" 247 #define MS_WCS_20_PROFILE_SCALING "http://www.opengis.net/spec/WCS_service-extension_scaling/1.0/conf/scaling" 248 #define MS_WCS_20_PROFILE_RANGESUBSET "http://www.opengis.net/spec/WCS_service-extension_range-subsetting/1.0/conf/record-subsetting" 249 #define MS_WCS_20_PROFILE_INTERPOLATION "http://www.opengis.net/spec/WCS_service-extension_interpolation/1.0/conf/interpolation" 250 251 /* -------------------------------------------------------------------- */ 252 /* WCS 2.0 function prototypes. */ 253 /* -------------------------------------------------------------------- */ 254 255 wcs20ParamsObjPtr msWCSCreateParamsObj20(); 256 void msWCSFreeParamsObj20(wcs20ParamsObjPtr params); 257 int msWCSParseRequest20(mapObj *map, cgiRequestObj *request, owsRequestObj *ows_request, wcs20ParamsObjPtr params); 258 259 int msWCSException20(mapObj *map, const char *locator, const char *exceptionCode, const char *version); 260 261 int msWCSGetCapabilities20(mapObj *map, cgiRequestObj *req, wcs20ParamsObjPtr params, owsRequestObj *ows_request); 262 int msWCSDescribeCoverage20(mapObj *map, wcs20ParamsObjPtr params, owsRequestObj *ows_request); 263 int msWCSGetCoverage20(mapObj *map, cgiRequestObj *request, wcs20ParamsObjPtr params, owsRequestObj *ows_request); 264 265 /* -------------------------------------------------------------------- */ 266 /* XML parsing helper macros. */ 267 /* -------------------------------------------------------------------- */ 268 269 #define XML_FOREACH_CHILD(parent_node, child_node) \ 270 for(child_node = parent_node->children; child_node != NULL; child_node = child_node->next) 271 272 /* Makro to continue the iteration over an xml structure */ 273 /* when the current node has the type 'text' or 'comment' */ 274 #define XML_LOOP_IGNORE_COMMENT_OR_TEXT(node) \ 275 if(xmlNodeIsText(node) || node->type == XML_COMMENT_NODE) \ 276 { \ 277 continue; \ 278 } 279 280 /* Makro to set an XML error that an unknown node type */ 281 /* occurred. */ 282 #define XML_UNKNOWN_NODE_ERROR(node) \ 283 msSetError(MS_WCSERR, "Unknown XML element '%s'.", \ 284 __FUNCTION__, (char *)node->name); \ 285 return MS_FAILURE; 286 287 #define XML_ASSERT_NODE_NAME(node,nodename) \ 288 if(EQUAL((char *)node->name, nodename) == MS_FALSE) \ 289 { \ 290 XML_UNKNOWN_NODE_ERROR(node); \ 291 } 292 293 #define MS_WCS_20_CAPABILITIES_INCLUDE_SECTION(params,section) \ 294 (params->sections == NULL \ 295 || CSLFindString(params->sections, "All") != -1 \ 296 || CSLFindString(params->sections, section) != -1) 297 298 #endif /* nef MAPWCS_H */ 299