- Timestamp:
- Aug 7, 2017, 2:56:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r822 r839 131 131 */ 132 132 void setReferenceUrl(maps* m,maps* tmpI){ 133 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);134 fflush(stderr);135 dumpMaps(tmpI);136 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);137 fflush(stderr);138 133 outputMapfile(m,tmpI); 139 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);140 fflush(stderr);141 dumpMaps(tmpI);142 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);143 fflush(stderr);144 134 map *msUrl=getMapFromMaps(m,"main","mapserverAddress"); 145 135 if(msUrl==NULL){ … … 169 159 if(strncasecmp(rformat->value,"text/xml",8)==0) 170 160 proto=1; 171 if(strncasecmp(rformat->value,"image/tiff",10)==0) 161 if(strncasecmp(rformat->value,"image/tiff",10)==0 || 162 strncasecmp(rformat->value,"image/geotiff",10)==0) 172 163 proto=2; 173 164 if(protoMap!=NULL){ … … 478 469 fprintf(stderr,"Unable to access the DataSource as ZIP File\n"); 479 470 setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); 480 OGR_DS_Destroy(poDS1);471 //OGR_DS_Destroy(poDS1); 481 472 }else{ 482 473 #ifdef DEBUGMS … … 549 540 #endif 550 541 setMapInMaps(conf,"lenv","message","Unable to open datasource in read only mode"); 551 OGR_DS_Destroy(poDS);552 OGRCleanupAll();542 //OGR_DS_Destroy(poDS); 543 //OGRCleanupAll(); 553 544 #ifdef DEBUGMS 554 545 fprintf(stderr,"Unable to access the DataSource, exit! \n"); … … 652 643 if (OGR_L_GetExtent(poLayer,&oExt, TRUE) == OGRERR_NONE){ 653 644 setMsExtent(output,m,myLayer,oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY); 645 char extent[1024]; 646 memset(&extent,0,1024); 647 sprintf(extent,"%d,%d,%d,%d",oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY); 648 addToMap(output->content,"boundingbox",extent); 654 649 } 655 650 … … 724 719 } 725 720 726 OGR_DS_Destroy(poDS);727 OGRCleanupAll();721 //OGR_DS_Destroy(poDS); 722 //OGRCleanupAll(); 728 723 729 724 return 1; … … 819 814 } 820 815 821 822 816 /** 823 817 * Set extent … … 836 830 + adfGeoTransform[4] * GDALGetRasterXSize(hDataset); 837 831 838 setMsExtent(output,m,myLayer,minX,minY,maxX,maxY); 839 832 setMsExtent(output,m,myLayer,minX,minY,maxX,maxY); 833 char extent[1024]; 834 memset(&extent,0,1024); 835 sprintf(extent,"%d,%d,%d,%d",minX,minY,maxX,maxY); 836 addToMap(output->content,"boundingbox",extent); 840 837 } 841 838 } … … 846 843 */ 847 844 char nBands[3]; 845 memset(&nBands,0,3); 848 846 int nBandsI=GDALGetRasterCount( hDataset ); 849 sprintf(nBands,"%d",GDALGetRasterCount( hDataset )); 850 msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands); 847 if(nBandsI<100){ 848 sprintf(nBands,"%d",GDALGetRasterCount( hDataset )); 849 msInsertHashTable(&(myLayer->metadata), "ows_bandcount", nBands); 850 } 851 851 if(nBandsI>=3) 852 852 msLayerAddProcessing(myLayer,"BANDS=1,2,3"); … … 860 860 */ 861 861 char lBands[7]; 862 memset(&nBands,0,7); 862 863 char *nameBands=NULL; 863 864 for( iBand = 0; iBand < nBandsI; iBand++ ){ 864 sprintf(lBands,"Band%d",iBand+1); 865 sprintf(lBands,"Band%d",iBand+1); 865 866 if(nameBands==NULL){ 866 867 nameBands=(char*)malloc((strlen(lBands)+1)*sizeof(char)); … … 869 870 if(iBand<4){ 870 871 char *tmpS=zStrdup(nameBands); 871 nameBands=(char*)realloc(nameBands,(strlen( nameBands)+strlen(lBands)+1)*sizeof(char));872 nameBands=(char*)realloc(nameBands,(strlen(tmpS)+strlen(lBands)+2)*sizeof(char)); 872 873 sprintf(nameBands,"%s %s",tmpS,lBands); 873 874 free(tmpS); … … 875 876 } 876 877 } 877 msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands); 878 878 if(nameBands!=NULL){ 879 msInsertHashTable(&(myLayer->metadata), "ows_bandnames", nameBands); 880 free(nameBands); 881 } 882 879 883 /** 880 884 * Loops over metadata information to setup specific information … … 894 898 char tmpMm[100]; 895 899 sprintf(tmpMm,"%.3f %.3f",adfCMinMax[0],adfCMinMax[1]); 896 char tmpI[ 21];900 char tmpI[31]; 897 901 sprintf(tmpI,"%s_interval",tmpN); 898 902 msInsertHashTable(&(myLayer->metadata), tmpI, tmpMm); … … 977 981 } 978 982 if( strlen(GDALGetRasterUnitType(hBand)) > 0 ){ 979 char tmpU[ 21];983 char tmpU[31]; 980 984 sprintf(tmpU,"%s_band_uom",tmpN); 981 985 msInsertHashTable(&(myLayer->metadata), tmpU, GDALGetRasterUnitType(hBand)); … … 988 992 GDALClose( hDataset ); 989 993 GDALDestroyDriverManager(); 994 990 995 CPLCleanupTLS(); 991 996 return 1; … … 999 1004 */ 1000 1005 void outputMapfile(maps* conf,maps* outputs){ 1001 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1002 fflush(stderr);1003 dumpMaps(outputs);1004 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1005 fflush(stderr);1006 1006 /** 1007 1007 * First store the value on disk … … 1013 1013 ext="json"; 1014 1014 1015 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1016 fflush(stderr);1017 1015 map* tmpMap=getMapFromMaps(conf,"main","dataPath"); 1018 1016 map* sidMap=getMapFromMaps(conf,"lenv","usid"); 1019 1017 char *pszDataSource=(char*)malloc((strlen(tmpMap->value)+strlen(sidMap->value)+strlen(outputs->name)+17)*sizeof(char)); 1020 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 1018 sprintf(pszDataSource,"%s/ZOO_DATA_%s_%s.%s",tmpMap->value,outputs->name,sidMap->value,ext); 1021 1019 int f=zOpen(pszDataSource,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); 1022 1020 map *gfile=getMap(outputs->content,"generated_file"); … … 1026 1024 map* sizeMap=getMap(outputs->content,"size"); 1027 1025 map* vData=getMap(outputs->content,"value"); 1028 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1029 fflush(stderr);1030 1026 if(sizeMap!=NULL){ 1031 1027 zWrite(f,vData->value,atoi(sizeMap->value)*sizeof(char)); … … 1034 1030 zWrite(f,vData->value,(strlen(vData->value)+1)*sizeof(char)); 1035 1031 } 1036 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1037 fflush(stderr);1038 1032 close(f); 1039 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1040 fflush(stderr);1041 1033 addToMap(outputs->content,"storage",pszDataSource); 1042 1034 free(pszDataSource); 1043 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1044 fflush(stderr);1045 1035 1046 1036 /* … … 1049 1039 mapObj *myMap=msNewMapObj(); 1050 1040 free(myMap->name); 1051 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1052 fflush(stderr);1053 1041 myMap->name=zStrdup("ZOO-Project_WXS_Server"); 1054 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1055 fflush(stderr);1056 1042 msMapSetSize(myMap,2048,2048); 1057 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1058 fflush(stderr);1059 1043 msMapSetExtent(myMap,-1,-1,1,1); 1060 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1061 fflush(stderr);1062 1044 1063 1045 /* … … 1068 1050 tmp1=getMapFromMaps(conf,"main","tmpUrl"); 1069 1051 myMap->web.imageurl=zStrdup(tmp1->value); 1070 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1071 fflush(stderr);1072 1052 1073 1053 /* … … 1080 1060 msAppendOutputFormat(myMap,msCloneOutputFormat(o1)); 1081 1061 msFreeOutputFormat(o1); 1082 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1083 fflush(stderr);1084 1062 1085 1063 #ifdef USE_KML … … 1094 1072 } 1095 1073 #endif 1096 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1097 fflush(stderr);1098 1074 1099 1075 outputFormatObj *o3=msCreateDefaultOutputFormat(NULL,"GDAL/GTiff","tiff"); … … 1106 1082 msFreeOutputFormat(o3); 1107 1083 } 1108 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1109 fflush(stderr);1110 1084 1111 1085 outputFormatObj *o4=msCreateDefaultOutputFormat(NULL,"GDAL/AAIGRID","grd"); … … 1118 1092 msFreeOutputFormat(o4); 1119 1093 } 1120 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1121 fflush(stderr);1122 1094 1123 1095 #ifdef USE_CAIRO … … 1133 1105 } 1134 1106 #endif 1135 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1136 fflush(stderr);1137 1107 1138 1108 /* … … 1141 1111 msLoadProjectionStringEPSG(&myMap->projection,"EPSG:4326"); 1142 1112 myMap->transparent=1; 1143 fprintf(stderr,"%s %D \n",__FILE__,__LINE__);1144 fflush(stderr);1145 1113 1146 1114 /**
Note: See TracChangeset
for help on using the changeset viewer.