Permalink
Browse files

Implement Inspire extensions for WFS 2.0

  • Loading branch information...
rouault committed Oct 30, 2013
1 parent 3841065 commit 9fd134b3defedfcadd39f4f713c1d11c73d9e27e
Showing with 380 additions and 93 deletions.
  1. +54 −2 mapio.c
  2. +3 −0 mapio.h
  3. +2 −2 mapogcsos.c
  4. +34 −8 mapows.c
  5. +13 −8 mapows.h
  6. +28 −23 mapowscommon.c
  7. +24 −2 mapowscommon.h
  8. +1 −0 mapserver.h
  9. +18 −0 maputil.c
  10. +2 −2 mapwcs11.c
  11. +2 −2 mapwcs20.c
  12. +14 −0 mapwfs.c
  13. +7 −7 mapwfs11.c
  14. +166 −20 mapwfs20.c
  15. +11 −16 mapwms.c
  16. +1 −1 msautotest
56 mapio.c
@@ -650,6 +650,57 @@ void msIO_installStdoutToBuffer()
&group->stderr_context );
}
/************************************************************************/
/* msIO_pushStdoutToBufferAndGetOldContext() */
/* */
/* This function installs a temporary buffer I/O context and returns */
/* previously installed stdout handler. This previous stdout handler */
/* should later be restored with msIO_restoreOldStdoutContext(). */
/* This function can be for example used when wanting to ingest into */
/* libxml objects XML generated by msIO_fprintf() */
/************************************************************************/
msIOContext* msIO_pushStdoutToBufferAndGetOldContext()
{
msIOContextGroup *group = msIO_GetContextGroup();
msIOContext *old_context;
/* Backup current context */
old_context = (msIOContext*) msSmallMalloc(sizeof(msIOContext));
memcpy(old_context, &group->stdout_context, sizeof(msIOContext));
msIO_installStdoutToBuffer();
return old_context;
}
/************************************************************************/
/* msIO_restoreOldStdoutContext() */
/************************************************************************/
void msIO_restoreOldStdoutContext(msIOContext *context_to_restore)
{
msIOContextGroup *group = msIO_GetContextGroup();
msIOContext *prev_context = &group->stdout_context;
msIOBuffer* buffer;
/* Free memory associated to our temporary context */
assert( strcmp(prev_context->label, "buffer") == 0 );
buffer = (msIOBuffer* )prev_context->cbData;
msFree(buffer->data);
msFree(buffer);
/* Restore old context */
msIO_installHandlers( &group->stdin_context,
context_to_restore,
&group->stderr_context );
msFree(context_to_restore);
}
/************************************************************************/
/* msIO_installStdinFromBuffer() */
/************************************************************************/
@@ -847,9 +898,9 @@ int msIO_bufferWrite( void *cbData, void *data, int byteCount )
msIOBuffer *buf = (msIOBuffer *) cbData;
/*
** Grow buffer if needed.
** Grow buffer if needed (reserve one extra byte to put nul character)
*/
if( buf->data_offset + byteCount > buf->data_len ) {
if( buf->data_offset + byteCount >= buf->data_len ) {
buf->data_len = buf->data_len * 2 + byteCount + 100;
if( buf->data == NULL )
buf->data = (unsigned char *) malloc(buf->data_len);
@@ -871,6 +922,7 @@ int msIO_bufferWrite( void *cbData, void *data, int byteCount )
memcpy( buf->data + buf->data_offset, data, byteCount );
buf->data_offset += byteCount;
buf->data[buf->data_offset] = '\0';
return byteCount;
}
@@ -104,6 +104,9 @@ extern "C" {
void MS_DLL_EXPORT msIO_Cleanup(void);
char MS_DLL_EXPORT *msIO_stripStdoutBufferContentType(void);
void MS_DLL_EXPORT msIO_stripStdoutBufferContentHeaders(void);
msIOContext *msIO_pushStdoutToBufferAndGetOldContext(void);
void msIO_restoreOldStdoutContext(msIOContext *context_to_restore);
/* this is just for setting normal stdout's to binary mode on windows */
@@ -1240,10 +1240,10 @@ int msSOSGetCapabilities(mapObj *map, sosParamsObj *sosparams, cgiRequestObj *re
xmlAddChild(psRootNode, xmlNewComment(BAD_CAST msGetVersion()));
/*service identification*/
xmlAddChild(psRootNode, msOWSCommonServiceIdentification(psNsOws, map, "SOS", pszSOSVersion, "SO"));
xmlAddChild(psRootNode, msOWSCommonServiceIdentification(psNsOws, map, "SOS", pszSOSVersion, "SO", NULL));
/*service provider*/
xmlAddChild(psRootNode, msOWSCommonServiceProvider(psNsOws, psNsXLink, map, "SO"));
xmlAddChild(psRootNode, msOWSCommonServiceProvider(psNsOws, psNsXLink, map, "SO", NULL));
/*operation metadata */
@@ -1157,6 +1157,26 @@ const char *msOWSGetSchemasLocation(mapObj *map)
return schemas_location;
}
/* msOWSGetInspireSchemasLocation()
**
** schemas location is the root of the web tree where all Inspire-related
** schemas can be found on this server. These URLs must exist in order
** to validate xml.
**
** Use value of "inspire_schemas_location" metadata
*/
const char *msOWSGetInspireSchemasLocation(mapObj *map)
{
const char *schemas_location;
schemas_location = msLookupHashTable(&(map->web.metadata),
"inspire_schemas_location");
if (schemas_location == NULL)
schemas_location = "http://inspire.ec.europa.eu/schemas";
return schemas_location;
}
/* msOWSGetLanguage()
**
** returns the language via MAP/WEB/METADATA/ows_language
@@ -1252,16 +1272,19 @@ char *msOWSGetLanguageFromList(mapObj *map, const char *namespaces, const char *
** Returns a status code; MS_NOERR if all ok, action_if_not_found otherwise
*/
int msOWSPrintInspireCommonExtendedCapabilities(FILE *stream, mapObj *map, const char *namespaces,
int action_if_not_found, const char *tag_name,
const char *validated_language, const int service)
int action_if_not_found, const char *tag_name, const char* tag_ns,
const char *validated_language, const OWSServiceType service)
{
int metadataStatus = 0;
int languageStatus = 0;
msIO_fprintf(stream, " <%s>\n", tag_name);
if( tag_ns )
msIO_fprintf(stream, " <%s %s>\n", tag_name, tag_ns);
else
msIO_fprintf(stream, " <%s>\n", tag_name);
metadataStatus = msOWSPrintInspireCommonMetadata(stream, map, namespaces, action_if_not_found);
metadataStatus = msOWSPrintInspireCommonMetadata(stream, map, namespaces, action_if_not_found, service);
languageStatus = msOWSPrintInspireCommonLanguages(stream, map, namespaces, action_if_not_found, validated_language);
msIO_fprintf(stream, " </%s>\n", tag_name);
@@ -1276,7 +1299,7 @@ int msOWSPrintInspireCommonExtendedCapabilities(FILE *stream, mapObj *map, const
** Returns a status code; MS_NOERR if all OK, action_if_not_found otherwise
*/
int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *namespaces,
int action_if_not_found)
int action_if_not_found, const OWSServiceType service)
{
int status = MS_NOERR;
@@ -1303,7 +1326,7 @@ int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *names
}
}
} else if (strcasecmp("embed",inspire_capabilities) == 0) {
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_resourcelocator", OWS_NOERR, " <inspire_common:ResourceLocator>\n <inspire_common:URL>%s</inspire_common:URL>\n </inspire_common:ResourceLocator>\n", NULL);
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_resourcelocator", OWS_WARN, " <inspire_common:ResourceLocator>\n <inspire_common:URL>%s</inspire_common:URL>\n </inspire_common:ResourceLocator>\n", NULL);
msIO_fprintf(stream," <inspire_common:ResourceType>service</inspire_common:ResourceType>\n");
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_temporal_reference", OWS_WARN, " <inspire_common:TemporalReference>\n <inspire_common:DateOfLastRevision>%s</inspire_common:DateOfLastRevision>\n </inspire_common:TemporalReference>\n", "");
msIO_fprintf(stream, " <inspire_common:Conformity>\n");
@@ -1318,7 +1341,10 @@ int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *names
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_mpoc_email", OWS_WARN, " <inspire_common:EmailAddress>%s</inspire_common:EmailAddress>\n", "");
msIO_fprintf(stream, " </inspire_common:MetadataPointOfContact>\n");
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_metadatadate", OWS_WARN, " <inspire_common:MetadataDate>%s</inspire_common:MetadataDate>\n", "");
msIO_fprintf(stream," <inspire_common:SpatialDataServiceType>view</inspire_common:SpatialDataServiceType>\n");
if( service == OWS_WFS )
msIO_fprintf(stream," <inspire_common:SpatialDataServiceType>download</inspire_common:SpatialDataServiceType>\n");
else
msIO_fprintf(stream," <inspire_common:SpatialDataServiceType>view</inspire_common:SpatialDataServiceType>\n");
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "inspire_keyword", OWS_WARN, " <inspire_common:MandatoryKeyword xsi:type='inspire_common:classificationOfSpatialDataService'>\n <inspire_common:KeywordValue>%s</inspire_common:KeywordValue>\n </inspire_common:MandatoryKeyword>\n", "");
} else {
status = action_if_not_found;
@@ -2023,7 +2049,7 @@ void msOWSPrintEX_GeographicBoundingBox(FILE *stream, const char *tabspace,
*/
void msOWSPrintLatLonBoundingBox(FILE *stream, const char *tabspace,
rectObj *extent, projectionObj *srcproj,
projectionObj *wfsproj, int nService)
projectionObj *wfsproj, OWSServiceType nService)
{
const char *pszTag = "LatLonBoundingBox"; /* The default for WMS */
rectObj ext;
@@ -55,7 +55,7 @@ typedef struct {
char *pszGeometryName;
int nMaxFeatures;
char *pszBbox; /* only used with a Get Request */
char *pszOutputFormat; /* only used with DescibeFeatureType */
char *pszOutputFormat;
char *pszFeatureId;
char *pszSrs;
char *pszResultType;
@@ -64,6 +64,7 @@ typedef struct {
char *pszAcceptVersions;
char *pszSections;
char *pszSortBy; /* Not implemented yet */
char *pszLanguage;
} wfsParamsObj;
/*
@@ -164,6 +165,7 @@ MS_DLL_EXPORT char *msOWSTerminateOnlineResource(const char *src_url);
MS_DLL_EXPORT char *msOWSGetOnlineResource(mapObj *map, const char *namespaces, const char *metadata_name, cgiRequestObj *req);
MS_DLL_EXPORT char *msOWSGetOnlineResource2(mapObj *map, const char *namespaces, const char *metadata_name, cgiRequestObj *req, const char *validated_language);
MS_DLL_EXPORT const char *msOWSGetSchemasLocation(mapObj *map);
MS_DLL_EXPORT const char *msOWSGetInspireSchemasLocation(mapObj *map);
MS_DLL_EXPORT const char *msOWSGetLanguage(mapObj *map, const char *context);
MS_DLL_EXPORT char **msOWSGetLanguageList(mapObj *map, const char *namespaces, int *numitems);
MS_DLL_EXPORT char *msOWSGetLanguageFromList(mapObj *map, const char *namespaces, const char *requested_language);
@@ -175,14 +177,17 @@ MS_DLL_EXPORT char *msOWSGetLanguageFromList(mapObj *map, const char *namespaces
/* OWS_WMS and OWS_WFS used for functions that differ in behavior between */
/* WMS and WFS services (e.g. msOWSPrintLatLonBoundingBox()) */
#define OWS_WMS 1
#define OWS_WFS 2
typedef enum
{
OWS_WMS = 1,
OWS_WFS = 2
} OWSServiceType;
MS_DLL_EXPORT int msOWSPrintInspireCommonExtendedCapabilities(FILE *stream, mapObj *map, const char *namespaces,
const int action_if_not_found, const char *tag_name,
const char *validated_language, const int service);
const int action_if_not_found, const char *tag_name, const char* tag_ns,
const char *validated_language, const OWSServiceType service);
int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *namespaces,
int action_if_not_found);
int action_if_not_found, const OWSServiceType service);
int msOWSPrintInspireCommonLanguages(FILE *stream, mapObj *map, const char *namespaces,
int action_if_not_found, const char *validated_language);
@@ -252,7 +257,7 @@ int msOWSPrintEncodeParamList(FILE *stream, const char *name,
void msOWSProjectToWGS84(projectionObj *srcproj, rectObj *ext);
void msOWSPrintLatLonBoundingBox(FILE *stream, const char *tabspace,
rectObj *extent, projectionObj *srcproj,
projectionObj *wfsproj, int nService);
projectionObj *wfsproj, OWSServiceType nService);
void msOWSPrintEX_GeographicBoundingBox(FILE *stream, const char *tabspace,
rectObj *extent, projectionObj *srcproj);
@@ -460,7 +465,7 @@ int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *wfsparams,
#ifdef USE_LIBXML2
#include<libxml/tree.h>
xmlNodePtr msWFSDumpLayer11(mapObj *map, layerObj *lp, xmlNsPtr psNsOws,
int nWFSVersion);
int nWFSVersion, const char* validate_language);
#endif
char *msWFSGetOutputFormatList(mapObj *map, layerObj *layer, int nWFSVersion);
Oops, something went wrong.

0 comments on commit 9fd134b

Please sign in to comment.