ZOO-Project
|
#include "service_internal_ms.h"
#include "server_internal.h"
#include "response_print.h"
#include "caching.h"
Macros | |
#define | CLASS class |
Cross platform definition of layerObj->class. More... | |
Functions | |
map * | getCorrespondance () |
Get a list of configuration keys having a corresponding mandatory ows_*. More... | |
int | getPublishedId (maps *elem) |
Return the current publish_id value. More... | |
void | setMapSize (maps *output, double minx, double miny, double maxx, double maxy) |
Add width and height keys to an output maps containing the maximum width and height for displaying the full data extent. More... | |
void | setReferenceUrl (maps *m, maps *tmpI) |
Add a Reference key to an output containing the WMFS/WFS/WCS request for accessing service result. More... | |
void | setSrsInformations (maps *output, mapObj *m, layerObj *myLayer, char *pszProjection) |
Set projection for a layer in a MAPFILE using Authority Code and Name if available or fallback to proj4 definition if available or fallback to default EPSG:4326. More... | |
void | setMsExtent (maps *output, mapObj *m, layerObj *myLayer, double minX, double minY, double maxX, double maxY) |
Set the MAPFILE extent, the the ows_extent for the layer, add wms_extent and wfs_extent to the output maps and call setMapSize. More... | |
int | tryOgr (maps *conf, maps *output, mapObj *m) |
Try to open a vector output and define the corresponding layer in the MAPFILE. More... | |
int | tryGdal (maps *conf, maps *output, mapObj *m) |
Try to open a raster output and define the corresponding layer in the MAPFILE. More... | |
void | outputMapfile (maps *conf, maps *outputs) |
Create a MapFile for WMS, WFS or WCS Service output. More... | |
void | saveMapNames (maps *conf, maps *output, char *mapfile) |
Save the map fullpath in a text file (.maps) More... | |
#define CLASS class |
Cross platform definition of layerObj->class.
map* getCorrespondance | ( | ) |
Get a list of configuration keys having a corresponding mandatory ows_*.
Map composed by a main.cfg maps name as key and the corresponding MapServer Mafile Metadata name to use see doc from here :
int getPublishedId | ( | maps * | elem | ) |
Return the current publish_id value.
elem | and maps pointer on which the search occur |
Create a MapFile for WMS, WFS or WCS Service output.
conf | the conf maps containing the main.cfg settings |
outputs | a specific output maps |
First store the value on disk
Set a ows_rootlayer_title,
Enable all the WXS requests using ows_enable_request see http://mapserver.org/trunk/development/rfc/ms-rfc-67.html
Set metadata extracted from main.cfg file maps
Save the map fullpath in a text file (.maps)
conf | the main configuration map pointer |
output | the current output for which a mapfile has been generated |
mapfile | the mapfile saved to store in the text file |
void setMapSize | ( | maps * | output, |
double | minx, | ||
double | miny, | ||
double | maxx, | ||
double | maxy | ||
) |
Add width and height keys to an output maps containing the maximum width and height for displaying the full data extent.
Restriction to an image having a size of 640x480 (width * height)
output | |
minx | the lower left x coordinate |
miny | the lower left y coordinate |
maxx | the upper right x coordinate |
maxy | the upper right y coordinate |
void setMsExtent | ( | maps * | output, |
mapObj * | m, | ||
layerObj * | myLayer, | ||
double | minX, | ||
double | minY, | ||
double | maxX, | ||
double | maxY | ||
) |
Set the MAPFILE extent, the the ows_extent for the layer, add wms_extent and wfs_extent to the output maps and call setMapSize.
output | the specific output |
m | the mapObj |
myLayer | the layerObj |
minX | the lower left x coordinate |
minY | the lower left y coordinate |
maxX | the upper right x coordinate |
maxY | the upper right y coordinate |
Add a Reference key to an output containing the WMFS/WFS/WCS request for accessing service result.
m | the conf maps containing the main.cfg settings |
tmpI | the specific output maps to add the Reference key |
void setSrsInformations | ( | maps * | output, |
mapObj * | m, | ||
layerObj * | myLayer, | ||
char * | pszProjection | ||
) |
Set projection for a layer in a MAPFILE using Authority Code and Name if available or fallback to proj4 definition if available or fallback to default EPSG:4326.
output | the output maps |
m | the opened mapObj |
myLayer | the layerObj |
pszProjection | a char* containing the SRS definition in WKT format |
Try to open a raster output and define the corresponding layer in the MAPFILE.
conf | the conf maps containing the main.cfg settings |
output | the specific output maps |
m | the mapObj |
Try to open the DataSource using GDAL
Add a new layer set name, data
Set Map Size to the raster size
Set projection using Authority Code and Name if available or fallback to proj4 definition if available or fallback to default EPSG:4326
Set extent
Extract information about available bands to set the bandcount and the processing directive
Name available Bands
Loops over metadata information to setup specific information
Classify one band raster pixel value using regular interval
Create a new class
Set class name
Set expression
Set color
Try to open a vector output and define the corresponding layer in the MAPFILE.
conf | the conf maps containing the main.cfg settings |
output | the specific output maps |
m | the mapObj |
Try to open the DataSource using OGR
Try to load the file as ZIP
OGRDataSourceH poDS1 = NULL; OGRSFDriverH poDriver1 = NULL; char *dsName=(char)malloc((8+strlen(pszDataSource)+1)*sizeof(char)); char *odsName=zStrdup(pszDataSource); char *sdsName=zStrdup(pszDataSource); char *demo=".data"; sdsName[strlen(sdsName)-(strlen(demo)-1)]='d'; sdsName[strlen(sdsName)-(strlen(demo)-2)]='i'; sdsName[strlen(sdsName)-(strlen(demo)-3)]='r'; sdsName[strlen(sdsName)-(strlen(demo)-4)]=0;
odsName[strlen(odsName)-(strlen(demo)-1)]='z'; odsName[strlen(odsName)-(strlen(demo)-2)]='i'; odsName[strlen(odsName)-(strlen(demo)-3)]='p'; odsName[strlen(odsName)-(strlen(demo)-4)]=0; sprintf(dsName,"/vsizip/%s",odsName);
#ifdef DEBUGMS fprintf(stderr,"Try loading %s, %s, %s\n",dsName,odsName,dsName); #endif
FILE* file = fopen(pszDataSource, "rb"); FILE* fileZ = fopen(odsName, "wb"); free(odsName); fseek(file, 0, SEEK_END); unsigned long fileLen=ftell(file); fseek(file, 0, SEEK_SET); char *buffer=(char *)malloc(fileLen+1); fread(buffer, fileLen, 1, file); fwrite(buffer,fileLen, 1, fileZ); fclose(file); fclose(fileZ); free(buffer); #ifdef DEBUGMS fprintf(stderr,"Try loading %s",dsName); #endif poDS1 = OGROpen( dsName, FALSE, poDriver1 ); if( poDS1 == NULL ){ fprintf(stderr,"Unable to access the DataSource as ZIP File\n"); setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); fprintf(stderr,"Remove ZIP File!\n"); unlink(odsName); OGR_DS_Destroy(poDS1); }else{ #ifdef DEBUGMS fprintf(stderr,"The DataSource is a ZIP File\n"); #endif char** demo=VSIReadDir(dsName); int i=0; zMkdir(sdsName #ifndef WIN32 ,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH #endif ); while(demo[i]!=NULL){ #ifdef DEBUGMS fprintf(stderr,"ZIP File content : %s\n",demo[i]); #endif char tmpDs=(char)malloc((strlen(dsName)+strlen(demo[i])+2)*sizeof(char)); sprintf(tmpDs,"%s/%s",dsName,demo[i]); fprintf(stderr,"read : %s\n",tmpDs);
VSILFILE* vsif=VSIFOpenL(tmpDs,"rb"); #ifdef DEBUGMS fprintf(stderr,"open : %s\n",tmpDs); #endif VSIFSeekL(vsif,0,SEEK_END); vsi_l_offset size=VSIFTellL(vsif); #ifdef DEBUGMS fprintf(stderr,"size : %d\n",size); #endif VSIFSeekL(vsif,0,SEEK_SET); char vsifcontent=(char) malloc(((int)size+1)*sizeof(char)); VSIFReadL(vsifcontent,1,(size_t)size,vsif); char fpath=(char) malloc((strlen(sdsName)+strlen(demo[1])+2)*sizeof(char)); sprintf(fpath,"%s/%s",sdsName,demo[i]); int f=zOpen(fpath,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); zWrite(f,vsifcontent,(int)size); close(f); chmod(fpath,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH); char* tmpP=strstr(fpath,".shp"); if(tmpP==NULL) tmpP=strstr(fpath,".SHP"); if(tmpP!=NULL){ #ifdef DEBUGMS fprintf(stderr,"*** DEBUG %s\n",strstr(tmpP,".")); #endif if( strcmp(tmpP,".shp")==0 || strcmp(tmpP,".SHP")==0 ){ tmpMap=getMap(output->content,"storage"); free(tmpMap->value); tmpMap->value=(char*) malloc((strlen(fpath)+1)*sizeof(char)); sprintf(tmpMap->value,"%s",fpath); pszDataSource=tmpMap->value; #ifdef DEBUGMS fprintf(stderr,"*** DEBUG %s\n",pszDataSource); #endif } } VSIFCloseL(vsif); i++; } OGR_DS_Destroy(poDS1); } free(sdsName); free(dsName);
Add a new layer set name, data
Detect the Geometry Type or use Polygon
Detect spatial reference or use WGS84
Detect the FID column or use the first attribute field as FID
Apply msStyle else fallback to the default style
Set style
Set specific style depending on type