- Timestamp:
- Feb 1, 2018, 11:27:28 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r860 r862 144 144 */ 145 145 void setReferenceUrl(maps* m,maps* tmpI){ 146 int imyIndex=getPublishedId(tmpI); 147 if(getMapArray(tmpI->content,"ref_wms_link",imyIndex)!=NULL) 148 return; 149 outputMapfile(m,tmpI); 146 150 map *msUrl=getMapFromMaps(m,"main","mapserverAddress"); 147 151 if(msUrl==NULL){ … … 150 154 exit(-1); 151 155 } 152 int imyIndex=getPublishedId(tmpI);153 156 if(getMapArray(tmpI->content,"ref_wms_link",imyIndex)!=NULL) 154 157 return; 155 outputMapfile(m,tmpI);156 158 int finalProto=-1; 157 159 map *msOgcVersion=getMapFromMaps(m,"main","msOgcVersion"); … … 165 167 map* versionMap=getMapArray(tmpI->content,"msOgcVersion",imyIndex); 166 168 map* datatype=getMapArray(tmpI->content,"geodatatype",imyIndex); 169 map* layerName=getMapArray(tmpI->content,"msLayer",imyIndex); 167 170 char options[4][5][25]={ 168 171 {"WMS","1.3.0","GetMap","layers=%s","wms_extent"}, 169 {"WFS","1. 1.0","GetFeature","typename=%s","wcs_extent"},172 {"WFS","1.0.0","GetFeature","typename=%s","wcs_extent"}, 170 173 {"WCS","2.0.0","GetCoverage","coverageid=%s","wcs_extent"}, 171 {"WCS","1. 1.0","GetCoverage","coverage=%s","wcs_extent"}174 {"WCS","1.0.0","GetCoverage","coverage=%s","wcs_extent"} 172 175 }; 173 if(datatype==NULL || strncmp(datatype->value,"other",5)==0){ 176 map *nbElements=getMapArray(tmpI->content,"nb_features",imyIndex); 177 if(nbElements==NULL) 178 nbElements=getMapArray(tmpI->content,"nb_pixels",imyIndex); 179 if(datatype==NULL || strncmp(datatype->value,"other",5)==0 || (nbElements!=NULL && atoi(nbElements->value)==0)){ 174 180 map* minNb=getMap(tmpI->content,"minoccurs"); 175 if(minNb==NULL || atoi(minNb->value)>=1){ 181 map* useMs=getMap(tmpI->content,"useMapserver"); 182 if((minNb==NULL || atoi(minNb->value)>=1) && useMs!=NULL && strncasecmp(useMs->value,"true",4)==0){ 176 183 setMapInMaps(m,"lenv","mapError","true"); 177 184 setMapInMaps(m,"lenv","locator",tmpI->name); 178 setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data.")); 185 if(nbElements==NULL) 186 setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not read it as geographic data.")); 187 else 188 setMapInMaps(m,"lenv","message",_("The ZOO-Kernel was able to retrieve the data but could not access any feature or pixel in te resulting file.")); 179 189 if(getMapFromMaps(m,"lenv","state")==NULL) 180 190 errorException (m, _("Unable to find any geographic data"), "WrongInputData", tmpI->name); … … 229 239 } 230 240 char layers[128]; 231 sprintf(layers,options[proto][3],tmpI->name); 232 241 if(layerName==NULL) 242 sprintf(layers,options[proto][3],tmpI->name); 243 else 244 sprintf(layers,options[proto][3],layerName->value); 245 233 246 if(format==NULL || width==NULL || height==NULL || extent==NULL){ 234 247 char tmpStr[1024]; … … 525 538 int imyIndex=getPublishedId(output); 526 539 msMapSetExtent(m,minX,minY,maxX,maxY); 540 m->maxsize=4096; 527 541 #ifdef DEBUGMS 528 542 fprintf(stderr,"Extent %.15f %.15f %.15f %.15f\n",minX,minY,maxX,maxY); … … 743 757 * Add a new layer set name, data 744 758 */ 745 if(msGrowMapLayers(m)==NULL){ 746 return -1; 747 } 748 if(initLayer((m->layers[m->numlayers]), m) == -1){ 749 return -1; 750 } 751 752 layerObj* myLayer=m->layers[m->numlayers]; 759 layerObj* myLayer=NULL; 760 if(getMapArray(output->content,"msInclude",imyIndex)==NULL){ 761 if(msGrowMapLayers(m)==NULL){ 762 return -1; 763 } 764 if(initLayer((m->layers[m->numlayers]), m) == -1){ 765 return -1; 766 } 767 myLayer=m->layers[m->numlayers]; 768 }else{ 769 myLayer=m->layers[m->numlayers-1]; 770 } 771 753 772 #ifdef DEBUGMS 754 773 dumpMaps(output); … … 852 871 else 853 872 msInsertHashTable(&(myLayer->metadata), "ows_title", "Default Title"); 873 874 if(getMapArray(output->content,"msInclude",imyIndex)==NULL){ 875 if(msGrowLayerClasses(myLayer) == NULL) 876 return -1; 877 if(initClass((myLayer->CLASS[myLayer->numclasses])) == -1) 878 return -1; 879 if(msGrowClassStyles(myLayer->CLASS[myLayer->numclasses]) == NULL) 880 return -1; 881 if(initStyle(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]) == -1) 882 return -1; 883 /** 884 * Apply msStyle else fallback to the default style 885 */ 886 tmpMap=getMap(output->content,"msStyle"); 887 if(tmpMap!=NULL) 888 msUpdateStyleFromString(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles],tmpMap->value,0); 889 else{ 890 /** 891 * Set style 892 */ 893 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.red=125; 894 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.green=125; 895 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.blue=255; 896 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.red=80; 897 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.green=80; 898 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.blue=80; 899 900 /** 901 * Set specific style depending on type 902 */ 903 if(myLayer->type == MS_LAYER_POLYGON) 904 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->width=3; 905 if(myLayer->type == MS_LAYER_LINE){ 906 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->width=3; 907 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinewidth=1.5; 908 } 909 if(myLayer->type == MS_LAYER_POINT){ 910 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->symbol=1; 911 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->size=15; 912 } 913 914 } 915 myLayer->CLASS[myLayer->numclasses]->numstyles++; 916 myLayer->numclasses++; 854 917 855 if(msGrowLayerClasses(myLayer) == NULL) 856 return -1; 857 if(initClass((myLayer->CLASS[myLayer->numclasses])) == -1) 858 return -1; 859 if(msGrowClassStyles(myLayer->CLASS[myLayer->numclasses]) == NULL) 860 return -1; 861 if(initStyle(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]) == -1) 862 return -1; 863 /** 864 * Apply msStyle else fallback to the default style 865 */ 866 tmpMap=getMap(output->content,"msStyle"); 867 if(tmpMap!=NULL) 868 msUpdateStyleFromString(myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles],tmpMap->value,0); 869 else{ 870 /** 871 * Set style 872 */ 873 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.red=125; 874 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.green=125; 875 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->color.blue=255; 876 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.red=80; 877 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.green=80; 878 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinecolor.blue=80; 879 880 /** 881 * Set specific style depending on type 882 */ 883 if(myLayer->type == MS_LAYER_POLYGON) 884 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->width=3; 885 if(myLayer->type == MS_LAYER_LINE){ 886 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->width=3; 887 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->outlinewidth=1.5; 888 } 889 if(myLayer->type == MS_LAYER_POINT){ 890 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->symbol=1; 891 myLayer->CLASS[myLayer->numclasses]->styles[myLayer->CLASS[myLayer->numclasses]->numstyles]->size=15; 892 } 893 894 } 895 myLayer->CLASS[myLayer->numclasses]->numstyles++; 896 myLayer->numclasses++; 897 898 m->layerorder[m->numlayers] = m->numlayers; 899 m->numlayers++; 900 901 } 902 918 m->layerorder[m->numlayers] = m->numlayers; 919 m->numlayers++; 920 921 } 922 } 903 923 OGR_DS_Destroy(poDS); 904 924 //OGRCleanupAll(); … … 982 1002 m->width=GDALGetRasterXSize( hDataset ); 983 1003 m->height=GDALGetRasterYSize( hDataset ); 1004 if(m->width>4096 || m->height>4096){ 1005 if(m->width>m->height) 1006 m->maxsize=m->width; 1007 else 1008 m->maxsize=m->height; 1009 }else 1010 m->maxsize=4096; 984 1011 addIntToMapArray(output->content,"nb_pixels",imyIndex,GDALGetRasterXSize( hDataset )*GDALGetRasterYSize( hDataset )); 985 1012 int pixel_type=GDALGetRasterDataType( hDataset ); 1013 addIntToMapArray(output->content,"pixel_data_type",imyIndex,pixel_type); 1014 1015 int outputIndex=msGetOutputFormatIndex(m,"tiff"); 1016 if(outputIndex>=0){ 1017 m->outputformatlist[outputIndex]->imagemode=((pixel_type==GDT_Byte)?MS_IMAGEMODE_BYTE:((pixel_type==GDT_Int16 || pixel_type==GDT_UInt16)?MS_IMAGEMODE_INT16:((pixel_type!=GDT_Float32)?MS_IMAGEMODE_FLOAT32:MS_IMAGEMODE_BYTE))); 1018 outputIndex=msGetOutputFormatIndex(m,"geotiff"); 1019 m->outputformatlist[outputIndex]->imagemode=((pixel_type==GDT_Byte)?MS_IMAGEMODE_BYTE:((pixel_type==GDT_Int16 || pixel_type==GDT_UInt16)?MS_IMAGEMODE_INT16:((pixel_type!=GDT_Float32)?MS_IMAGEMODE_FLOAT32:MS_IMAGEMODE_BYTE))); 1020 } 1021 // 1022 986 1023 /** 987 1024 * Set projection using Authority Code and Name if available or fallback to … … 1241 1278 * Create an empty map, set name, default size and extent 1242 1279 */ 1243 mapObj *myMap=msNewMapObj(); 1280 map* mapfileTemplate=getMapArray(outputs->content,"msInclude",imyIndex); 1281 mapObj *myMap=NULL; 1282 if(mapfileTemplate==NULL){ 1283 myMap=msNewMapObj(); 1284 } 1285 else{ 1286 map* dataPath=getMapFromMaps(conf,"main","dataPath"); 1287 map* sid=getMapFromMaps(conf,"lenv","sid"); 1288 char *mapfileTemplatePath=(char*)malloc(((strlen(dataPath->value)+strlen(sid->value)+strlen(outputs->name)+10)*sizeof(char))); 1289 sprintf(mapfileTemplatePath,"%s/%s_%s.map",dataPath->value,outputs->name,sid->value); 1290 myMap=msLoadMap(mapfileTemplate->value,mapfileTemplatePath); 1291 if(myMap==NULL){ 1292 setMapInMaps(conf,"lenv","message",_("Unable to open your template mapfile!")); 1293 return ; 1294 } 1295 } 1244 1296 free(myMap->name); 1245 1297 myMap->name=zStrdup("ZOO-Project_WXS_Server"); … … 1281 1333 fprintf(stderr,"Unable to initialize GDAL driver !\n"); 1282 1334 else{ 1283 o3->imagemode=MS_IMAGEMODE_ BYTE;1335 o3->imagemode=MS_IMAGEMODE_INT16; 1284 1336 o3->inmapfile=MS_TRUE; 1285 1337 msAppendOutputFormat(myMap,msCloneOutputFormat(o3)); … … 1291 1343 fprintf(stderr,"Unable to initialize GDAL driver !\n"); 1292 1344 else{ 1293 o4->imagemode=MS_IMAGEMODE_ INT16;1345 o4->imagemode=MS_IMAGEMODE_BYTE; 1294 1346 o4->inmapfile=MS_TRUE; 1295 1347 msAppendOutputFormat(myMap,msCloneOutputFormat(o4)); … … 1310 1362 #endif 1311 1363 1364 1312 1365 outputFormatObj *o6=msCreateDefaultOutputFormat(NULL,"GDAL/GTiff","geotiff"); 1313 1366 if(!o6) … … 1321 1374 } 1322 1375 1376 1323 1377 /* 1324 1378 * Set default projection to EPSG:4326 … … 1408 1462 sprintf(mapPath,"%s/%s_%d_%s.map",tmp1->value,outputs->name,imyIndex,sid->value); 1409 1463 msSaveMap(myMap,mapPath); 1464 saveMapNames(conf,outputs,mapPath); 1410 1465 free(mapPath); 1466 //free(myMap->symbolset.filename); 1411 1467 //msFreeSymbolSet(&myMap->symbolset); 1412 1468 msFreeMap(myMap); … … 1415 1471 } 1416 1472 1473 /** 1474 * Save the map fullpath in a text file (.maps) 1475 * @param conf the main configuration map pointer 1476 * @param output the current output for which a mapfile has been generated 1477 * @param mapfile the mapfile saved to store in the text file 1478 */ 1479 void saveMapNames(maps* conf,maps* output,char* mapfile){ 1480 map* storage=getMap(output->content,"storage"); 1481 char *tmp=zStrdup(storage->value); 1482 tmp[strlen(tmp)-strlen(strrchr(tmp,'.'))]=0; 1483 char* mapName=(char*)malloc((strlen(tmp)+6)*sizeof(char*)); 1484 sprintf(mapName,"%s.maps",tmp); 1485 FILE* myMaps=fopen(mapName,"a"); 1486 if(myMaps!=NULL){ 1487 fprintf(myMaps,"%s\n",mapfile); 1488 fclose(myMaps); 1489 } 1490 }
Note: See TracChangeset
for help on using the changeset viewer.