- Timestamp:
- May 31, 2011, 3:30:49 AM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/zoo-services/ogr/base-vect-ops/service.c
r55 r217 43 43 44 44 void printExceptionReportResponse(maps*,map*); 45 char *base64(const unsignedchar *input, int length);45 char *base64(const char *input, int length); 46 46 47 47 OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){ … … 56 56 xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx); 57 57 if(!xpathObj->nodesetval){ 58 map* tmp=createMap("text","Unable to parse Input Polygon"); 59 addToMap(tmp,"code","InvalidParameterValue"); 60 printExceptionReportResponse(conf,tmp); 61 exit(0); 58 setMapInMaps(conf,"lenv","message",_ss("Unable to parse Input Polygon")); 59 setMapInMaps(conf,"lenv","code","InvalidParameterValue"); 60 return NULL; 62 61 } 63 62 int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0; … … 80 79 xmlFreeDoc(doc); 81 80 xmlFreeDoc(ndoc); 81 #ifndef WIN32 82 82 xmlCleanupParser(); 83 #endif 83 84 #ifdef DEBUG 84 85 fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ..."); … … 94 95 } 95 96 97 #ifdef WIN32 98 __declspec(dllexport) 99 #endif 96 100 int Simplify(maps*& conf,maps*& inputs,maps*& outputs){ 97 101 maps* cursor=inputs; … … 104 108 else 105 109 tolerance=atof(tmp0->value); 110 #ifdef DEBUG 106 111 fprintf(stderr,"Tolerance for Simplify %f",tolerance); 112 #endif 107 113 map* tmp=getMapFromMaps(inputs,"InputPolygon","value"); 108 114 if(!tmp){ … … 126 132 return SERVICE_FAILED; 127 133 } 134 #ifdef DEBUG 128 135 fprintf(stderr,"Create GEOSGeometry object"); 136 #endif 129 137 GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS(); 130 138 GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance); 131 res= OGRGeometryFactory::createFromGEOS(gres);139 res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres); 132 140 tmp1=getMapFromMaps(outputs,"Result","mimeType"); 133 141 if(tmp1!=NULL){ … … 136 144 char *tmpS=OGR_G_ExportToJson(res); 137 145 setMapInMaps(outputs,"Result","value",tmpS); 146 #ifndef WIN32 138 147 setMapInMaps(outputs,"Result","mimeType","text/plain"); 139 148 setMapInMaps(outputs,"Result","encoding","UTF-8"); 140 149 free(tmpS); 150 #endif 141 151 } 142 152 else{ 143 153 char *tmpS=OGR_G_ExportToGML(res); 144 154 setMapInMaps(outputs,"Result","value",tmpS); 155 #ifndef WIN32 145 156 setMapInMaps(outputs,"Result","mimeType","text/xml"); 146 157 setMapInMaps(outputs,"Result","encoding","UTF-8"); 147 158 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 148 159 free(tmpS); 160 #endif 149 161 } 150 162 }else{ 151 char *tmpS=OGR_G_ExportToJson( tmp->value);163 char *tmpS=OGR_G_ExportToJson(res); 152 164 setMapInMaps(outputs,"Result","value",tmpS); 165 #ifndef WIN32 153 166 setMapInMaps(outputs,"Result","mimeType","text/plain"); 154 167 setMapInMaps(outputs,"Result","encoding","UTF-8"); 155 168 free(tmpS); 169 #endif 156 170 } 157 171 outputs->next=NULL; … … 178 192 return SERVICE_FAILED; 179 193 } 194 #ifdef DEBUG 180 195 fprintf(stderr,"Service internal print \n"); 181 196 dumpMaps(inputs); 182 197 fprintf(stderr,"/Service internal print \n"); 198 #endif 183 199 map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType"); 200 #ifdef DEBUG 184 201 fprintf(stderr,"Service internal print \n"); 185 202 dumpMap(tmp1); 186 203 fprintf(stderr,"/Service internal print \n"); 204 #endif 187 205 if(tmp1!=NULL){ 188 206 if(strncmp(tmp1->value,"text/js",7)==0 || … … 199 217 } 200 218 res=(*myFunc)(geometry); 219 #ifdef DEBUG 201 220 fprintf(stderr,"Service internal print \n"); 202 221 dumpMaps(outputs); 203 222 fprintf(stderr,"/Service internal print \n"); 223 #endif 204 224 map *tmp_2=getMapFromMaps(outputs,"Result","mimeType"); 225 #ifdef DEBUG 205 226 fprintf(stderr,"Service internal print \n"); 206 227 dumpMap(tmp_2); 207 228 fprintf(stderr,"/Service internal print \n"); 229 #endif 208 230 if(tmp_2!=NULL){ 209 231 if(strncmp(tmp_2->value,"text/js",7)==0 || … … 211 233 char *tmpS=OGR_G_ExportToJson(res); 212 234 setMapInMaps(outputs,"Result","value",tmpS); 235 #ifndef WIN32 213 236 setMapInMaps(outputs,"Result","mimeType","text/plain"); 214 237 setMapInMaps(outputs,"Result","encoding","UTF-8"); 215 238 free(tmpS); 239 #endif 216 240 } 217 241 else{ 218 242 char *tmpS=OGR_G_ExportToGML(res); 219 243 setMapInMaps(outputs,"Result","value",tmpS); 244 #ifndef WIN32 220 245 setMapInMaps(outputs,"Result","mimeType","text/xml"); 221 246 setMapInMaps(outputs,"Result","encoding","UTF-8"); 222 247 setMapInMaps(outputs,"Result","schema",schema); 223 248 free(tmpS); 249 #endif 224 250 } 225 251 }else{ 226 252 char *tmpS=OGR_G_ExportToJson(res); 227 253 setMapInMaps(outputs,"Result","value",tmpS); 254 #ifndef WIN32 228 255 setMapInMaps(outputs,"Result","mimeType","text/plain"); 229 256 setMapInMaps(outputs,"Result","encoding","UTF-8"); 230 257 free(tmpS); 231 } 232 outputs->next=NULL; 258 #endif 259 } 260 //outputs->next=NULL; 233 261 #ifdef DEBUG 234 262 dumpMaps(outputs); … … 239 267 //CPLFree(res); 240 268 //CPLFree(geometry); 269 #ifdef DEBUG 241 270 fprintf(stderr,"Service internal print \n"); 242 271 dumpMaps(outputs); 243 272 fprintf(stderr,"/Service internal print \n"); 273 #endif 244 274 return SERVICE_SUCCEEDED; 245 275 } … … 276 306 bufferDistance=atof(tmp->value); 277 307 res=OGR_G_Buffer(geometry,bufferDistance,30); 308 dumpMap(tmp); 278 309 tmp1=getMapFromMaps(outputs,"Result","mimeType"); 310 dumpMap(tmp); 279 311 if(strncmp(tmp1->value,"application/json",16)==0){ 280 312 char *tmpS=OGR_G_ExportToJson(res); 281 313 setMapInMaps(outputs,"Result","value",tmpS); 314 dumpMap(tmp); 315 #ifndef WIN32 282 316 setMapInMaps(outputs,"Result","mimeType","text/plain"); 283 317 setMapInMaps(outputs,"Result","encoding","UTF-8"); 284 318 free(tmpS); 319 #endif 285 320 } 286 321 else{ 287 322 char *tmpS=OGR_G_ExportToGML(res); 288 323 setMapInMaps(outputs,"Result","value",tmpS); 324 dumpMap(tmp); 325 #ifndef WIN32 289 326 free(tmpS); 290 327 setMapInMaps(outputs,"Result","mimeType","text/xml"); 291 328 setMapInMaps(outputs,"Result","encoding","UTF-8"); 292 329 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 330 #endif 293 331 } 294 outputs->next=NULL;332 //outputs->next=NULL; 295 333 OGR_G_DestroyGeometry(geometry); 296 334 OGR_G_DestroyGeometry(res); … … 335 373 fprintf(stderr,"\nService internal print1\n"); 336 374 fflush(stderr); 337 #endif338 375 fprintf(stderr,"\nService internal print1\n"); 339 376 dumpMaps(inputs); 340 377 fprintf(stderr,"\nService internal print1\n"); 378 #endif 341 379 342 380 maps* cursor=inputs; … … 357 395 if(geometry1==NULL){ 358 396 setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1.")); 397 #ifdef DEBUG 359 398 fprintf(stderr,"SERVICE FAILED !\n"); 360 return SERVICE_FAILED; 361 } 399 #endif 400 return SERVICE_FAILED; 401 } 402 #ifdef DEBUG 362 403 fprintf(stderr,"\nService internal print1 InputEntity1\n"); 404 #endif 363 405 { 364 406 map* tmp=getMapFromMaps(inputs,"InputEntity2","value"); 365 407 map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType"); 366 //#ifdef DEBUG408 #ifdef DEBUG 367 409 fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16)); 368 410 //dumpMap(tmp); 369 411 fprintf(stderr,"MY MAP\n"); 370 ///#endif371 412 fprintf(stderr,"\nService internal print1 InputEntity2\n"); 413 #endif 372 414 if(tmp1!=NULL){ 373 415 if(strncmp(tmp1->value,"application/json",16)==0){ 416 #ifdef DEBUG 374 417 fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n"); 418 #endif 375 419 geometry2=OGR_G_CreateGeometryFromJson(tmp->value); 376 420 } 377 421 else{ 422 #ifdef DEBUG 378 423 fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n"); 424 #endif 379 425 geometry2=createGeometryFromGML(conf,tmp->value); 380 426 } … … 382 428 else 383 429 geometry2=createGeometryFromGML(conf,tmp->value); 430 #ifdef DEBUG 384 431 fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n"); 385 } 432 #endif 433 } 434 #ifdef DEBUG 386 435 fprintf(stderr,"\nService internal print1 InputEntity2 Final\n"); 436 #endif 387 437 if(geometry2==NULL){ 388 438 setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2.")); 439 #ifdef DEBUG 389 440 fprintf(stderr,"SERVICE FAILED !\n"); 390 return SERVICE_FAILED; 391 } 441 #endif 442 return SERVICE_FAILED; 443 } 444 #ifdef DEBUG 392 445 fprintf(stderr,"\nService internal print1\n"); 446 #endif 393 447 res=(*myFunc)(geometry1,geometry2); 448 #ifdef DEBUG 394 449 fprintf(stderr,"\nService internal print1\n"); 395 450 #endif 396 451 /* nuova parte */ 397 452 map* tmp2=getMapFromMaps(outputs,"Result","mimeType"); … … 399 454 char *tmpS=OGR_G_ExportToJson(res); 400 455 setMapInMaps(outputs,"Result","value",tmpS); 456 #ifndef WIN32 401 457 setMapInMaps(outputs,"Result","mimeType","text/plain"); 402 458 setMapInMaps(outputs,"Result","encoding","UTF-8"); 403 459 free(tmpS); 460 #endif 404 461 } 405 462 else{ 406 463 char *tmpS=OGR_G_ExportToGML(res); 407 464 setMapInMaps(outputs,"Result","value",tmpS); 465 #ifndef WIN32 408 466 setMapInMaps(outputs,"Result","mimeType","text/xml"); 409 467 setMapInMaps(outputs,"Result","encoding","UTF-8"); 410 468 setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd"); 411 469 free(tmpS); 470 #endif 412 471 } 413 472
Note: See TracChangeset
for help on using the changeset viewer.