- Timestamp:
- Feb 1, 2011, 2:50:33 PM (14 years ago)
- Location:
- trunk/zoo-services/gdal/profile
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-services/gdal/profile/cgi-env/GdalExtractProfile.zcfg
r80 r102 7 7 serviceType = C 8 8 serviceProvider = gdal_profile_service.zo 9 <MetaData >9 <MetaData lang="en"> 10 10 title = My Demo 11 11 </MetaData> … … 21 21 value = topofr.tif 22 22 </Default> 23 <Supported>24 </Supported>25 23 </LiteralData> 26 24 [Geometry] -
trunk/zoo-services/gdal/profile/service.c
r50 r102 7 7 * 8 8 * **************************************************************************** 9 * Copyright (c) 2010 , GeoLabs SARL9 * Copyright (c) 2010-2011, GeoLabs SARL 10 10 * 11 11 * Permission is hereby granted, free of charge, to any person obtaining a … … 30 30 #ifdef ZOO_SERVICE 31 31 #include "service.h" 32 #include "service_internal.h" 32 33 #endif 33 34 #include "gdal.h" … … 61 62 62 63 hDataset = GDALOpen( pszFilename, GA_ReadOnly ); 64 free(pszFilename); 63 65 if( hDataset != NULL ) 64 66 { … … 99 101 length+=strlen(buffer); 100 102 for(k=0;k<nbGeom;k++){ 101 OGRGeometryH point;103 //OGRGeometryH point; 102 104 double prx,pry,prz; 103 105 OGR_G_GetPoint(geometry,k,&prx,&pry,&prz); 104 106 float *pafScanline; 105 106 107 pafScanline = (float *) CPLMalloc(sizeof(float)); 107 108 int px=(int)floor((prx-adfGeoTransform[0])/adfGeoTransform[1]); … … 115 116 sprintf(tmp,"GDALRasterIO failed for point (%d,%d)",px,py); 116 117 setMapInMaps(conf,"lenv","message",_ss(tmp)); 118 CPLFree(pafScanline); 119 free(tmp); 117 120 return SERVICE_FAILED; 118 121 } 119 if(buffer) 120 buffer=(char*)realloc(buffer,(strlen(buffer)+50+1)*sizeof(char)); 122 if(buffer!=NULL){ 123 int len=strlen(buffer); 124 buffer=(char*)realloc(buffer,(len+50+1)*sizeof(char)); 125 } 121 126 else 122 127 buffer=(char*)malloc((51)*sizeof(char)); 123 128 char *tmpValue=(char *)malloc(50*sizeof(char)); 124 129 sprintf(tmpValue,"[%.6f,%.6f,%.6f]%c",prx,pry,pafScanline[0],(k+1==nbGeom?' ':',')); 125 memcpy(buffer+length,tmpValue,strlen(tmpValue));130 strncpy(buffer+length,tmpValue,strlen(tmpValue)); 126 131 length+=strlen(tmpValue); 132 buffer[length]=0; 127 133 value=pafScanline[0]; 134 free(tmpValue); 128 135 //Usefull if we can export 3D JSON string at the end 129 136 //OGR_G_SetPoint(geometry,k,prx,pry,pafScanline[0]); 130 137 } 131 138 else{ 132 if(buffer )139 if(buffer!=NULL) 133 140 buffer=(char*)realloc(buffer,(strlen(buffer)+50+1)*sizeof(char)); 134 141 else … … 136 143 char *tmpValue=(char *)malloc(50*sizeof(char)); 137 144 sprintf(tmpValue,"[%.6f,%.6f,%.6f]%c",prx,pry,value,(k+1==nbGeom?' ':',')); 138 memcpy(buffer+length,tmpValue,strlen(tmpValue));145 strncpy(buffer+length,tmpValue,strlen(tmpValue)); 139 146 length+=strlen(tmpValue); 147 buffer[length]=0; 148 free(tmpValue); 140 149 value=value; 141 150 } 151 CPLFree(pafScanline); 142 152 ppx=px; 143 153 ppy=py; … … 146 156 char *tmpValue=(char *)malloc(3*sizeof(char)); 147 157 sprintf(tmpValue,"]}"); 148 memcpy(buffer+length,tmpValue,strlen(tmpValue)); 158 tmpValue[2]=0; 159 strncpy(buffer+length,tmpValue,strlen(tmpValue)); 160 length+=strlen(tmpValue); 161 buffer[length]=0; 149 162 #ifdef ZOO_SERVICE 150 163 setMapInMaps(outputs,"Profile","value",buffer); … … 153 166 fprintf(stderr,"%s\n",buffer); 154 167 #endif 168 free(buffer); 169 free(tmpValue); 170 OGR_G_DestroyGeometry(geometry); 155 171 } 156 172 } … … 163 179 #endif 164 180 } 165 181 OGRCleanupAll(); 166 182 GDALClose(hDataset); 183 GDALDestroyDriverManager(); 167 184 #ifdef ZOO_SERVICE 168 185 return SERVICE_SUCCEEDED;
Note: See TracChangeset
for help on using the changeset viewer.