| 2132 | |
| 2133 | #ifdef USE_WCS_SVR |
| 2134 | int msWCSGetCoverageMetadata( layerObj *layer, coverageMetadataObj *cm ) |
| 2135 | { |
| 2136 | char *srs_urn = NULL; |
| 2137 | int i = 0; |
| 2138 | if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE ) |
| 2139 | return MS_FAILURE; |
| 2140 | |
| 2141 | /* -------------------------------------------------------------------- */ |
| 2142 | /* Get the SRS in WCS 1.0 format (eg. EPSG:n) */ |
| 2143 | /* -------------------------------------------------------------------- */ |
| 2144 | if((cm->srs = msOWSGetEPSGProj(&(layer->projection), &(layer->metadata), "CO", MS_TRUE)) == NULL) { |
| 2145 | if((cm->srs = msOWSGetEPSGProj(&(layer->map->projection), &(layer->map->web.metadata), "CO", MS_TRUE)) == NULL) { |
| 2146 | msSetError(MS_WCSERR, "Unable to determine the SRS for this layer, no projection defined and no metadata available.", "msWCSGetCoverageMetadata()"); |
| 2147 | return MS_FAILURE; |
| 2148 | } |
| 2149 | } |
| 2150 | |
| 2151 | /* -------------------------------------------------------------------- */ |
| 2152 | /* Get the SRS in urn format. */ |
| 2153 | /* -------------------------------------------------------------------- */ |
| 2154 | if((srs_urn = msOWSGetProjURN(&(layer->projection), &(layer->metadata), |
| 2155 | "CO", MS_TRUE)) == NULL) { |
| 2156 | srs_urn = msOWSGetProjURN(&(layer->map->projection), |
| 2157 | &(layer->map->web.metadata), |
| 2158 | "CO", MS_TRUE); |
| 2159 | } |
| 2160 | |
| 2161 | if( srs_urn != NULL ) |
| 2162 | { |
| 2163 | if( strlen(srs_urn) > sizeof(cm->srs_urn) - 1 ) |
| 2164 | { |
| 2165 | msSetError(MS_WCSERR, "SRS URN too long!", |
| 2166 | "msWCSGetCoverageMetadata()"); |
| 2167 | return MS_FAILURE; |
| 2168 | } |
| 2169 | |
| 2170 | strcpy( cm->srs_urn, srs_urn ); |
| 2171 | msFree( srs_urn ); |
| 2172 | } |
| 2173 | else |
| 2174 | cm->srs_urn[0] = '\0'; |
| 2175 | |
| 2176 | /* -------------------------------------------------------------------- */ |
| 2177 | /* If we have "virtual dataset" metadata on the layer, then use */ |
| 2178 | /* that in preference to inspecting the file(s). */ |
| 2179 | /* We require extent and either size or resolution. */ |
| 2180 | /* -------------------------------------------------------------------- */ |
| 2181 | if( msOWSLookupMetadata(&(layer->metadata), "CO", "extent") != NULL |
| 2182 | && (msOWSLookupMetadata(&(layer->metadata), "CO", "resolution") != NULL |
| 2183 | || msOWSLookupMetadata(&(layer->metadata), "CO", "size") != NULL) ){ |
| 2184 | const char *value; |
| 2185 | |
| 2186 | /* get extent */ |
| 2187 | cm->extent.minx = 0.0; |
| 2188 | cm->extent.maxx = 0.0; |
| 2189 | cm->extent.miny = 0.0; |
| 2190 | cm->extent.maxy = 0.0; |
| 2191 | if( msOWSGetLayerExtent( layer->map, layer, "CO", &cm->extent ) == MS_FAILURE ) |
no test coverage detected