Changeset 862 for branches/prototype-v0
- Timestamp:
- Feb 1, 2018, 11:27:28 AM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r860 r862 298 298 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 299 299 300 if(getMap(content->content,icname)==NULL){ 300 if(getMap(content->content,icname)==NULL){ 301 301 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 302 302 if(fcontent == NULL){ … … 513 513 514 514 map* tmpMap=getMapOrFill(content,"value",""); 515 516 515 free(tmpMap->value); 517 516 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); -
branches/prototype-v0/zoo-project/zoo-kernel/response_print.c
r860 r862 2562 2562 xmlNodePtr txt=xmlNewText(BAD_CAST tmp->value); 2563 2563 xmlAddChild(nc1,txt); 2564 if(cnt==0) 2565 setMapInMaps(m,"lenv","message",tmp->value); 2564 2566 } 2565 2567 else{ … … 2718 2720 toto=getMap(tmpI->content,"asReference"); 2719 2721 #ifdef USE_MS 2720 restartNoMS:2721 2722 map* geodatatype=getMap(tmpI->content,"geodatatype"); 2722 2723 2723 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && 2724 2724 (testMap==NULL || … … 2749 2749 map *ext=getMap(tmpI->content,"extension"); 2750 2750 char file_ext[32]; 2751 2751 2752 2752 if( ext != NULL && ext->value != NULL) { 2753 2753 strncpy(file_ext, ext->value, 32); … … 2812 2812 } 2813 2813 addToMap(tmpI->content,"Reference",file_url); 2814 /*maps* curs=tmpI;2815 curs=curs->next;2816 map* test=getMap(tmpI->content,"replicateStorageNext");2817 if(test!=NULL && strncasecmp(test->value,"true",4)==0)2818 while(curs!=NULL){2819 addToMap(curs->content,"storage",file_path);2820 curs=curs->next;2821 }2822 if(file_path!=NULL)2823 free(file_path);*/2824 2814 if(file_name!=NULL) 2825 2815 free(file_name); … … 2830 2820 #ifdef USE_MS 2831 2821 else{ 2832 if(testMap!=NULL){2833 setMapInMaps(m,"lenv","state","out");2834 setReferenceUrl(m,tmpI);2835 geodatatype=getMap(tmpI->content,"geodatatype");2836 if(geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0)2837 goto restartNoMS;2838 }2839 2822 if(testMap!=NULL){ 2823 setMapInMaps(m,"lenv","state","out"); 2824 setReferenceUrl(m,tmpI); 2825 geodatatype=getMap(tmpI->content,"geodatatype"); 2826 if(geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) 2827 res=SERVICE_FAILED; 2828 } 2829 } 2840 2830 #endif 2841 2831 if(file_name!=NULL){ -
branches/prototype-v0/zoo-project/zoo-kernel/server_internal.c
r858 r862 377 377 struct stat file_status; 378 378 stat(filename, &file_status); 379 map* tmpMap1=getMap(content,"value"); 380 if(tmpMap1==NULL){ 381 addToMap(content,"value",""); 382 tmpMap1=getMap(content,"value"); 383 } 384 free(tmpMap1->value); 385 tmpMap1->value=(char*) malloc((count+1)*sizeof(char)); 386 fread(tmpMap1->value,1,count,file); 387 tmpMap1->value[count]=0; 379 if(getMap(content,"storage")==NULL){ 380 map* tmpMap1=getMap(content,"value"); 381 if(tmpMap1==NULL){ 382 addToMap(content,"value",""); 383 tmpMap1=getMap(content,"value"); 384 } 385 free(tmpMap1->value); 386 tmpMap1->value=(char*) malloc((count+1)*sizeof(char)); 387 if(tmpMap1->value==NULL){ 388 setMapInMaps(m,"lenv","message","Unable to allocate the memory required to read the produced file."); 389 } 390 fread(tmpMap1->value,1,count,file); 391 tmpMap1->value[count]=0; 392 } 388 393 fclose(file); 389 394 char rsize[1000]; … … 423 428 void dumpMapsValuesToFiles(maps** main_conf,maps** in){ 424 429 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); 430 map* tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); 425 431 map* tmpSid=getMapFromMaps(*main_conf,"lenv","usid"); 426 432 maps* inputs=*in; … … 450 456 setMapArray(cMap,"cache_file",k,val); 451 457 free(val); 458 val=(char*)malloc((strlen(tmpUrl->value)+strlen(inputs->name)+strlen(tmpSid->value)+strlen(file_ext)+16)*sizeof(char)); 459 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpUrl->value,inputs->name,tmpSid->value,k,file_ext); 460 setMapArray(cMap,"cache_url",k,val); 461 setMapArray(cMap,"byValue",k,"true"); 462 free(val); 452 463 } 453 464 }else{ … … 467 478 addToMap(cMap,"cache_file",val); 468 479 free(val); 469 } 470 addToMap(inputs->content,"byValue","true"); 480 val=(char*)malloc((strlen(tmpUrl->value)+strlen(inputs->name)+strlen(tmpSid->value)+strlen(file_ext)+16)*sizeof(char)); 481 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpUrl->value,inputs->name,tmpSid->value,0,file_ext); 482 addToMap(cMap,"cache_url",val); 483 addToMap(cMap,"byValue",val); 484 free(val); 485 } 471 486 } 472 487 inputs=inputs->next; … … 641 656 } 642 657 if(res==NULL){ 658 map* tmpMaxO0=getMap(tmpInputs->content,"useMapserver"); 659 if(tmpMaxO0!=NULL){ 660 if(tmpMaps2->content==NULL) 661 tmpMaps2->content=createMap("useMapserver",tmpMaxO0->value); 662 else 663 addToMap(tmpMaps2->content,"useMapserver",tmpMaxO0->value); 664 } 643 665 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 644 666 if(tmpMaxO!=NULL){ … … 714 736 * content map. 715 737 */ 716 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); 717 if(tmpMap1!=NULL){ 718 if(tmpMaps->content==NULL) 719 tmpMaps->content=createMap("minOccurs",tmpMap1->value); 720 else 721 addToMap(tmpMaps->content,"minOccurs",tmpMap1->value); 722 } 723 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 724 if(tmpMaxO!=NULL){ 725 if(tmpMaps->content==NULL) 726 tmpMaps->content=createMap("maxOccurs",tmpMaxO->value); 727 else 728 addToMap(tmpMaps->content,"maxOccurs",tmpMaxO->value); 729 } 730 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 731 if(tmpMaxMB!=NULL){ 732 if(tmpMaps->content==NULL) 733 tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value); 734 else 735 addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value); 738 char* keys[4]={ 739 "minOccurs", 740 "maxOccurs", 741 "maximumMegabytes", 742 "useMapserver" 743 }; 744 int i=0; 745 for(i=0;i<4;i++){ 746 map* tmpMap1=getMap(tmpInputs->content,keys[i]); 747 if(tmpMap1!=NULL){ 748 addToMap(tmpMaps->content,keys[i],tmpMap1->value); 749 } 736 750 } 737 751 /** … … 812 826 if(tmpCheck!=NULL && strncasecmp(tmpCheck->value,"true",4)==0){ 813 827 // Get the default value 828 addToMap(tmpMaps->content,"useMapserver","true"); 814 829 tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,NULL); 815 830 tmpCheck=getMap(tmpMaps->content,"mimeType"); -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r860 r862 112 112 } 113 113 114 115 114 /** 116 115 * Practically invoke the callback, meaning sending the HTTP POST request. … … 121 120 local_params* arg=(local_params*)args; 122 121 HINTERNET hInternet,res1; 122 const struct tm *tm; 123 size_t len; 124 time_t now; 125 char *tmp1; 126 map *tmpStatus; 123 127 hInternet=InternetOpen("ZooWPSClient\0", 124 128 INTERNET_OPEN_TYPE_PRECONFIG, … … 134 138 free(URL); 135 139 #ifdef CALLBACK_DEBUG 140 now = time ( NULL ); 141 tm = localtime ( &now ); 142 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char)); 143 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm ); 136 144 fprintf(stderr,"************************* From thread %d %s %d: REQUEST PARAMETERS cStep %d %d\n",pthread_self(),__FILE__,__LINE__,cStep,isOngoing); 137 145 fprintf(stderr," * JSON: [%s] \n",jsonStr); 138 146 fprintf(stderr," * URL: %s/ \n\n",hInternet.waitingRequests[0]); 147 fprintf(stderr," * DATE: %s/ \n\n",tmp1); 139 148 fprintf(stderr,"************************* From thread %d %s %d: REQUEST PARAMETERS\n",pthread_self(),__FILE__,__LINE__); 149 free(tmp1); 140 150 #endif 141 151 while( (arg->step!=7 || isOngoing>0) && … … 152 162 } 153 163 #endif 154 const struct tm *tm;155 size_t len;156 time_t now;157 char *tmp1;158 map *tmpStatus;159 164 160 165 now = time ( NULL ); … … 184 189 #ifdef CALLBACK_DEBUG 185 190 fprintf(stderr,"************************* From thread %d %s %d: REQUEST END (%s)\n\n",pthread_self(),__FILE__,__LINE__,tmp1); 186 #endif 191 #endif 187 192 free(tmp1); 188 193 char *tmp = (char *) malloc ((hInternet.ihandle[0].nDataLen + 1) … … 206 211 if(cStep==0 || cStep==6 || arg->state==1) 207 212 cStep=arg->step+1; 208 #ifdef CALLBACK_DEBUG 209 fprintf(stderr,"************************* From thread %d %s %d: RESPONSE CONTENT\n",pthread_self(),__FILE__,__LINE__); 213 #ifdef CALLBACK_DEBUG 214 now = time ( NULL ); 215 tm = localtime ( &now ); 216 tmp1 = (char*)malloc((TIME_SIZE+1)*sizeof(char)); 217 len = strftime ( tmp1, TIME_SIZE, "%Y-%m-%dT%I:%M:%SZ", tm ); 218 fprintf(stderr,"************************* From thread %d %s %d: RESPONSE CONTENT (%s)\n",pthread_self(),__FILE__,__LINE__,,tmp1); 210 219 for(i=0;i<7;i++){ 211 220 fprintf(stderr,"%d) %d %d\n",i,steps[i][0],steps[i][1]); … … 214 223 fprintf(stderr,"************************* From thread %d %s %d\n\n",pthread_self(),__FILE__,__LINE__); 215 224 fflush(stderr); 225 free(tmp1); 216 226 #endif 217 227 steps[arg->step][arg->state]=true; 218 228 free(tmp); 219 //free(args); 229 #ifdef CALLBACK_DEBUG 220 230 fprintf(stderr,"************************* From thread %d %s %d: EXIT\n\n",pthread_self(),__FILE__,__LINE__); 221 231 fflush(stderr); 232 #endif 222 233 pthread_exit(NULL); 223 234 } … … 305 316 // Update the execute request stored on disk at step 0,0 to modify the references used. 306 317 if(state==1){ 307 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);308 fflush(stderr);309 318 maps* curs=inputs; 310 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);311 fflush(stderr);312 319 xmlInitParser(); 313 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);314 fflush(stderr);315 320 map* xmlPath=getMapFromMaps(conf,"lenv","execute_file"); 316 dumpMap(xmlPath);317 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);318 fflush(stderr);319 321 while(curs!=NULL){ 320 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 321 fflush(stderr); 322 dumpMap(curs->content); 323 //map* bvMap=getMap(curs->content,"byValue"); 324 // TODO handle mapArray 325 //if(bvMap!=NULL && strncasecmp(bvMap->value,"true",4)==0){ 326 if(getMap(curs->content,"href")==NULL && getMap(curs->content,"mimeType")!=NULL){ 327 map* tmpMap=getMap(curs->content,"value"); 328 char tmpStr[100]; 329 sprintf(tmpStr,"%d",strlen(tmpMap->value)); 330 addToMap(curs->content,"size",tmpStr); 331 tmpMap=getMap(curs->content,"mimeType"); 332 addToMap(curs->content,"fmimeType",tmpMap->value); 333 tmpMap=getMap(curs->content,"cache_file"); 334 addToMap(curs->content,"generated_file",tmpMap->value); 335 addToMap(curs->content,"storage",tmpMap->value); 336 setReferenceUrl(conf,curs); 337 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 338 fflush(stderr); 339 dumpMap(curs->content); 340 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 341 fflush(stderr); 342 const char *params[5]; 343 int xmlLoadExtDtdDefaultValue; 344 int hasFile=-1; 345 map* xslPath=getMapFromMaps(conf,"callback","template"); 346 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 347 fflush(stderr); 348 dumpMap(xslPath); 349 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 350 fflush(stderr); 351 map* filePath=getMap(curs->content,"ref_wfs_link"); 352 if(filePath==NULL) 353 filePath=getMap(curs->content,"ref_wcs_link"); 354 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 355 fflush(stderr); 356 dumpMap(filePath); 357 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 358 fflush(stderr); 359 char* inputName=curs->name; 360 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 361 fflush(stderr); 362 if(xslPath==NULL || xmlPath==NULL || filePath==NULL) 363 break; 364 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 365 fflush(stderr); 366 char *tmpParam=(char*)malloc((strlen(curs->name)+11)*sizeof(char)); 367 char *tmpParam1=(char*)malloc((strlen(filePath->value)+11)*sizeof(char)); 368 addToMap(curs->content,"href",filePath->value); 369 addToMap(curs->content,"xlink:href",filePath->value); 370 sprintf(tmpParam,"string(\"%s\")",curs->name); 371 sprintf(tmpParam1,"string(\"%s\")",filePath->value); 372 params[0]="attr"; 373 params[1]=tmpParam; 374 params[2]="value"; 375 params[3]=tmpParam1;//filePath->value; 376 params[4]=NULL; 377 fprintf(stderr, "## XSLT PARAMETERS ATTR: %s VALUE: %s \n", 378 tmpParam,tmpParam1); 379 xmlSubstituteEntitiesDefault(1); 380 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 381 fflush(stderr); 382 xmlLoadExtDtdDefaultValue = 0; 383 xsltStylesheetPtr cur = NULL; 384 xmlDocPtr doc, res; 385 cur = xsltParseStylesheetFile(BAD_CAST xslPath->value); 386 doc = xmlParseFile(xmlPath->value); 387 fflush(stderr); 388 res = xsltApplyStylesheet(cur, doc, params); 389 xmlChar *xmlbuff; 390 int buffersize; 391 xmlDocDumpFormatMemory(res, &xmlbuff, &buffersize, 1); 392 // Store the executeRequest in file again 393 free(tmpParam); 394 free(tmpParam1); 395 fprintf(stderr," # Request / XSLT: %s\n",xmlbuff); 396 fflush(stderr); 397 FILE* saveExecute=fopen(xmlPath->value,"wb"); 398 fwrite(xmlbuff,1,buffersize,saveExecute); 399 fflush(saveExecute); 400 fclose(saveExecute); 401 xmlFree(xmlbuff); 402 xmlFreeDoc(doc); 403 xsltFreeStylesheet(cur); 322 map* length=getMap(curs->content,"length"); 323 map* useMS=getMap(curs->content,"useMapserver"); 324 if(length==NULL){ 325 addToMap(curs->content,"length","1"); 326 length=getMap(curs->content,"length"); 404 327 } 405 fprintf(stderr,"%s %d \n",__FILE__,__LINE__); 406 fflush(stderr); 328 int len=atoi(length->value); 329 for(int ii=0;ii<len;ii++){ 330 if(getMapArray(curs->content,"byValue",ii)!=NULL && getMapArray(curs->content,"mimeType",ii)!=NULL && useMS!=NULL && strncasecmp(useMS->value,"true",4)==0){ 331 map* tmpMap=getMapArray(curs->content,"value",ii); 332 char tmpStr[100]; 333 sprintf(tmpStr,"%d",strlen(tmpMap->value)); 334 setMapArray(curs->content,"size",ii,tmpStr); 335 tmpMap=getMapArray(curs->content,"mimeType",ii); 336 setMapArray(curs->content,"fmimeType",ii,tmpMap->value); 337 tmpMap=getMapArray(curs->content,"cache_file",ii); 338 setMapArray(curs->content,"generated_file",ii,tmpMap->value); 339 setMapArray(curs->content,"storage",ii,tmpMap->value); 340 setReferenceUrl(conf,curs); 341 addIntToMap(curs->content,"published_id",ii+1); 342 const char *params[7]; 343 int xmlLoadExtDtdDefaultValue; 344 int hasFile=-1; 345 map* xslPath=getMapFromMaps(conf,"callback","template"); 346 map* filePath=getMapArray(curs->content,"ref_wfs_link",ii); 347 if(filePath==NULL) 348 filePath=getMap(curs->content,"ref_wcs_link"); 349 char* inputName=curs->name; 350 if(xslPath==NULL || xmlPath==NULL || filePath==NULL) 351 break; 352 char *tmpParam=(char*)malloc((strlen(curs->name)+11)*sizeof(char)); 353 char *tmpParam1=(char*)malloc((strlen(filePath->value)+11)*sizeof(char)); 354 char tmpParam2[16]; 355 sprintf(tmpParam2,"string(\"%d\")",ii); 356 setMapArray(curs->content,"href",ii,filePath->value); 357 setMapArray(curs->content,"xlink:href",ii,filePath->value); 358 tmpMap=getMapArray(curs->content,"cache_url",ii); 359 if(tmpMap!=NULL) 360 setMapArray(curs->content,"xlink:href",ii,tmpMap->value); 361 else 362 setMapArray(curs->content,"xlink:href",ii,filePath->value); 363 sprintf(tmpParam,"string(\"%s\")",curs->name); 364 sprintf(tmpParam1,"string(\"%s\")",filePath->value); 365 sprintf(tmpParam2,"string(\"%d\")",ii); 366 params[0]="attr"; 367 params[1]=tmpParam; 368 params[2]="value"; 369 params[3]=tmpParam1;//filePath->value; 370 params[4]="cnt"; 371 params[5]=tmpParam2; 372 params[6]=NULL; 373 fprintf(stderr, "## XSLT PARAMETERS ATTR: %s VALUE: %s INDEX: %s\n", 374 tmpParam,tmpParam1,tmpParam2); 375 fflush(stderr); 376 xmlSubstituteEntitiesDefault(1); 377 xmlLoadExtDtdDefaultValue = 0; 378 xsltStylesheetPtr cur = NULL; 379 xmlDocPtr doc, res; 380 cur = xsltParseStylesheetFile(BAD_CAST xslPath->value); 381 doc = xmlParseFile(xmlPath->value); 382 fflush(stderr); 383 res = xsltApplyStylesheet(cur, doc, params); 384 xmlChar *xmlbuff; 385 int buffersize; 386 xmlDocDumpFormatMemory(res, &xmlbuff, &buffersize, 1); 387 // Store the executeRequest in file again 388 free(tmpParam); 389 free(tmpParam1); 390 fprintf(stderr," # Request / XSLT: %s\n",xmlbuff); 391 fflush(stderr); 392 FILE* saveExecute=fopen(xmlPath->value,"wb"); 393 if(saveExecute!=NULL){ 394 fwrite(xmlbuff,1,buffersize,saveExecute); 395 fflush(saveExecute); 396 fclose(saveExecute); 397 } 398 xmlFree(xmlbuff); 399 xmlFreeDoc(doc); 400 xsltFreeStylesheet(cur); 401 } 402 } 403 addIntToMap(curs->content,"published_id",0); 407 404 curs=curs->next; 408 405 } 409 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);410 fflush(stderr);411 406 xmlCleanupParser(); 412 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);413 fflush(stderr);414 407 FILE* f0=fopen(xmlPath->value,"rb"); 415 408 if(f0!=NULL){ … … 423 416 fcontent[flen]=0; 424 417 fclose(f0); 425 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);426 fflush(stderr);427 418 map *schema=getMapFromMaps(conf,"database","schema"); 428 419 map* sid=getMapFromMaps(conf,"lenv","usid"); 429 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);430 fflush(stderr);431 420 char *req=(char*)malloc((flen+strlen(schema->value)+strlen(sid->value)+66)*sizeof(char)); 432 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);433 fflush(stderr);434 421 sprintf(req,"UPDATE %s.services set request_execute_content=$$%s$$ WHERE uuid=$$%s$$",schema->value,fcontent,sid->value); 435 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);436 fflush(stderr);437 422 execSql(conf,1,req); 438 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);439 fflush(stderr);440 423 free(fcontent); 441 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);442 fflush(stderr);443 424 free(req); 444 fprintf(stderr,"%s %d \n",__FILE__,__LINE__);445 fflush(stderr);446 425 } 447 426 } … … 453 432 { 454 433 "xlink:href", 455 "ref "434 "ref_download_link" 456 435 }, 457 436 { … … 514 493 setMapArray(curs->content,"storage",ii,tmpMap->value); 515 494 } 516 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);517 dumpMap(curs->content);518 495 struct stat buf; 519 496 char timeStr[ 100 ] = ""; … … 553 530 if(hasRef<0) 554 531 json_object_put(res3); 555 else 556 json_object_object_add(res1,curs->name,res3); 532 else{ 533 json_object_object_add(res1,curs->name,json_object_get(res3)); 534 json_object_put(res3); 535 } 557 536 addIntToMap(curs->content,"published_id",0); 558 537 curs=curs->next; … … 570 549 if(length!=NULL){ 571 550 json_object *res1=json_object_new_object(); 572 json_object *res3=json_object_new_array();573 551 int limit=atoi(length->value); 574 552 int i=0; … … 589 567 json_object_object_add(res1,tmp0->value,res2); 590 568 }else{ 591 if(json_object_is_type(res4,json_type_object)){ 592 json_object_array_add(res3,res4); 593 } 594 json_object_array_add(res3,res2); 595 if(json_object_is_type(res4,json_type_object)){ 569 if(json_object_is_type(res4,json_type_object) && !json_object_is_type(res4, json_type_array)){ 570 json_object *res3=json_object_new_array(); 571 json_object_array_add(res3,json_object_get(res4)); 572 json_object_array_add(res3,res2); 596 573 json_object_object_del(res1,tmp0->value); 597 574 json_object_object_add(res1,tmp0->value,res3); 598 } 575 }else 576 json_object_array_add(res4,res2); 599 577 } 600 578 } 601 579 } 602 if(json_object_array_length(res3)==0)603 json_object_put(res3);604 580 json_object_object_add(res,"inputs",res1); 605 581 } 606 //json_object_object_add(res,"inputs",in);607 582 } 608 583 break; … … 631 606 case 5: { 632 607 // Downloading process outputs from cluster 633 //json_object* in=mapsToJson(outputs);634 608 maps* curs=outputs; 635 609 dumpMaps(curs); … … 708 682 json_object *jsStr=json_object_new_string(sid->value); 709 683 json_object_object_add(res2,keys[i][1],jsStr); 710 if(i==0) 684 if(i==0){ 711 685 hasRef=1; 686 json_object_object_add(res2,"ref_download_link",jsStr); 687 } 688 if(i==1){ 689 struct stat buf; 690 char timeStr[ 100 ] = ""; 691 if (stat(sid->value, &buf)==0){ 692 strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime)); 693 json_object *jsStr=json_object_new_string(timeStr); 694 json_object_object_add(res2,"creation_date",jsStr); 695 } 696 } 712 697 } 713 698 } … … 724 709 int i0=0; 725 710 for(;i0<6;i0++){ 726 if(i0==0) 727 sid=getMap(specificMaps->content,specifics[i][1]); 728 else 729 sid=getMap(specificMaps->content,keys[i0][0]); 711 sid=getMap(specificMaps->content,keys[i0][0]); 730 712 if(sid!=NULL){ 731 713 json_object *jsStr=json_object_new_string(sid->value); … … 760 742 json_object *jsStr=json_object_new_string(sid->value); 761 743 json_object_object_add(res3,keys[i0][1],jsStr); 762 //if(i0==0)763 744 hasRef0=1; 764 745 } … … 858 839 local_arguments[nbThreads]->step=step; 859 840 local_arguments[nbThreads]->state=state; 860 //pthread_t p1;861 841 if(myThreads==NULL) 862 842 myThreads=(pthread_t*)malloc((nbThreads+1)*sizeof(pthread_t)); … … 867 847 return false; 868 848 } 869 //free(argumentsA);870 849 nbThreads++; 871 850 return true; … … 878 857 int i=0; 879 858 for(i=0;i<nbThreads;i++){ 880 fprintf(stderr,"%s %d %d \n",__FILE__,__LINE__,i);881 fflush(stderr);882 859 pthread_join(myThreads[i],NULL); 883 860 free(local_arguments[i]); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c
r860 r862 62 62 if(itn<ZOO_LOCK_MAX_RETRY){ 63 63 itn++; 64 fprintf(stderr,"(%d) Wait for write lock on %s, tried %d times (sleep) ... \n",getpid(),myLock->filename,itn); 65 fflush(stderr); 64 66 sleep(5); 65 67 free(myLock->filename); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r860 r862 60 60 while(cur!=NULL && cur->defaults!=NULL){ 61 61 map* mimeType=getMap(cur->defaults->content,"mimeType"); 62 if(mimeType!=NULL){ 62 map* useMS=getMap(cur->defaults->content,"useMapserver"); 63 if(mimeType!=NULL && useMS!=NULL && strncasecmp(useMS->value,"true",4)==0){ 63 64 int geo=isGeographic(mimeType->value); 64 65 if(geo>0){ … … 159 160 free(tmp[0]); 160 161 //addToMap(cur->content,"internal","true"); 161 } 162 } 162 163 } 163 164 cur=cur->next; … … 332 333 int parameters_cnt=0; 333 334 while(input!=NULL && input->content!=NULL){ 334 if(getMaps(*real_outputs,input->name)==NULL){ 335 map* isInRequest=getMap(input->content,"inRequest"); 336 map* minNb=getMap(input->content,"minoccurs"); 337 if(getMaps(*real_outputs,input->name)==NULL && 338 ( (isInRequest!=NULL && strncasecmp(isInRequest->value,"true",4)==0) 339 || (minNb!=NULL && atoi(minNb->value)>0) ) ){ 335 340 parameters_cnt+=1; 336 341 if(parameters_cnt==1) … … 345 350 dumpMapsValuesToFiles(main_conf,&input); 346 351 addToMap(input->content,"toPublish","true"); 347 addToMap(input->content,"useMapserver","true");352 //addToMap(input->content,"useMapserver","true"); 348 353 } 349 354 if(getMap(input->content,"cache_file")!=NULL){ … … 362 367 setMapArray(input->content,"targetPath",i,targetPath); 363 368 setMapArray(input->content,"localPath",i,tmp->value); 364 addToUploadQueue(main_conf,input); 369 map* tmp1=getMapArray(input->content,"value",i); 370 if(tmp1!=NULL){ 371 free(tmp1->value); 372 tmp1->value=strdup("empty"); 373 } 365 374 if(i==0){ 366 375 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char)); 367 376 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath); 368 377 }else{ 378 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 379 fflush(stderr); 369 380 char *tmpStr=zStrdup(parameters[parameters_cnt-1]); 370 381 parameters[parameters_cnt-1]=(char*)realloc(parameters[parameters_cnt-1],(strlen(tmpStr)+strlen(targetPath)+2)*sizeof(char)); 371 382 sprintf(parameters[parameters_cnt-1],"%s %s",tmpStr,targetPath); 372 383 free(tmpStr); 384 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 385 fflush(stderr); 373 386 } 374 387 free(targetPath); 375 388 } 389 addToUploadQueue(main_conf,input); 376 390 }else{ 377 391 // ??? … … 396 410 #endif 397 411 invokeCallback(m,inputs,NULL,1,1); 412 invokeCallback(m,inputs,NULL,2,0); 398 413 if(getMapFromMaps(m,"lenv","mapError")!=NULL){ 399 invokeCallback( m,inputs,NULL,7,0);414 invokeCallback(*main_conf,inputs,NULL,7,0); 400 415 return -1; 401 416 } 402 invokeCallback(m,inputs,NULL,2,0);403 417 #ifdef HPC_DEBUG 404 418 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 408 422 // Upload data on HPC 409 423 if(runUpload(main_conf)==false){ 410 errorException ( m, _("Unable to lock the file for upload!"),424 errorException (*main_conf, _("Unable to lock the file for upload!"), 411 425 "InternalError", NULL); 412 426 #ifdef HPC_DEBUG 413 427 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 414 428 #endif 415 invokeCallback( m,inputs,NULL,7,0);429 invokeCallback(*main_conf,inputs,NULL,7,0); 416 430 #ifdef HPC_DEBUG 417 431 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 429 443 // Add the filename to generate for every output to parameters 430 444 input=*real_outputs; 431 // TODO: fix appendOutputParameters432 //appendOutputParameters(input,parameters,¶meters_cnt,s,uuid,targetPathMap);433 445 #ifdef HPC_DEBUG 434 446 dumpMaps(input); 435 447 #endif 436 448 while(input!=NULL){ 437 // TODO: parse all outputs including inner outputs if required.449 // Parse all outputs including inner outputs if required. 438 450 if(input->child==NULL){ 439 451 // Name every files that should be produced by the service execution … … 453 465 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 454 466 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 467 map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); 468 char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char)); 469 sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName); 455 470 free(targetName); 456 471 setMapInMaps(*real_outputs,input->name,"generated_file",targetPath); 457 if(strcasecmp(input->name,"wms_link")!=0&&458 strcasecmp(input->name,"wcs_link")!=0 && 459 strcasecmp(input->name,"wfs_link")!=0){472 addToMap(input->content,"generated_url",targetUrl); 473 free(targetUrl); 474 { 460 475 parameters_cnt+=1; 461 476 if(parameters_cnt==1) … … 494 509 char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char)); 495 510 sprintf(targetPath,"%s/%s",targetPathMap->value,targetName); 511 map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); 512 char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char)); 513 sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName); 496 514 free(targetName); 497 515 addToMap(input->content,"generated_file",targetPath); 498 516 addToMap(input->content,"storage",targetPath); 517 addToMap(input->content,"generated_url",targetUrl); 518 free(targetUrl); 499 519 if(strcasecmp(input->name,"wms_link")!=0&& 500 520 strcasecmp(input->name,"wcs_link")!=0 && … … 623 643 setMapInMaps(*main_conf,"lenv","message",_("There is no remote_work_path defined in your section!")); 624 644 setMapInMaps(*main_conf,"lenv","status","failed"); 625 errorException ( m, _("There is no remote_work_path defined in your section!"),645 errorException (*main_conf, _("There is no remote_work_path defined in your section!"), 626 646 "InternalError", NULL); 627 647 #ifdef HPC_DEBUG … … 629 649 fflush(stderr); 630 650 #endif 631 invokeCallback( m,NULL,NULL,7,0);651 invokeCallback(*main_conf,NULL,NULL,7,0); 632 652 #ifdef HPC_DEBUG 633 653 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 645 665 free(scriptPath); 646 666 if(copy0!=true){ 647 setMapInMaps( m,"lenv","message",_("Unable to upload the script"));648 invokeCallback( m,NULL,NULL,7,0);649 errorException( m,_("Unable to upload the script"),"NoApplicableCode",NULL);667 setMapInMaps(*main_conf,"lenv","message",_("Unable to upload the script")); 668 invokeCallback(*main_conf,NULL,NULL,7,0); 669 errorException(*main_conf,_("Unable to upload the script"),"NoApplicableCode",NULL); 650 670 return -1; 651 671 } … … 688 708 fflush(stderr); 689 709 #endif 690 invokeCallback( m,NULL,NULL,7,0);710 invokeCallback(*main_conf,NULL,NULL,7,0); 691 711 #ifdef HPC_DEBUG 692 712 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 694 714 #endif 695 715 sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s using %s: %s", s->name, configurationId, tmpPath->value); 696 errorException( m,tmpS,"NoApplicableCode",NULL);716 errorException(*main_conf,tmpS,"NoApplicableCode",NULL); 697 717 free(command); 698 718 free(targetPath); 699 719 ssh_close(*main_conf); 700 720 removeReadLocks(main_conf); 701 sleep(1);702 721 return -1; 703 722 } … … 728 747 if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { 729 748 perror("bind error"); 730 setMapInMaps( m,"lenv","message",_("Unable to bind socket!"));731 errorException ( m, _("Unable to bind socket!"),749 setMapInMaps(*main_conf,"lenv","message",_("Unable to bind socket!")); 750 errorException (*main_conf, _("Unable to bind socket!"), 732 751 "InternalError", NULL); 733 752 #ifdef HPC_DEBUG … … 735 754 fflush(stderr); 736 755 #endif 737 invokeCallback( m,NULL,NULL,7,0);756 invokeCallback(*main_conf,NULL,NULL,7,0); 738 757 removeReadLocks(main_conf); 739 758 #ifdef HPC_DEBUG … … 749 768 if (listen(fd, 5) == -1) { 750 769 setMapInMaps(*main_conf,"lenv","message",_("Listen error")); 751 errorException ( m, _("Listen error"),770 errorException (*main_conf, _("Listen error"), 752 771 "InternalError", NULL); 753 772 #ifdef HPC_DEBUG … … 755 774 fflush(stderr); 756 775 #endif 757 invokeCallback( m,NULL,NULL,7,0);776 invokeCallback(*main_conf,NULL,NULL,7,0); 758 777 removeReadLocks(main_conf); 759 778 #ifdef HPC_DEBUG … … 765 784 if ( (cl = accept(fd, NULL, NULL)) == -1) { 766 785 setMapInMaps(*main_conf,"lenv","message",_("Accept error")); 767 errorException ( m, _("Accept error"),786 errorException (*main_conf, _("Accept error"), 768 787 "InternalError", NULL); 769 788 #ifdef HPC_DEBUG … … 771 790 fflush(stderr); 772 791 #endif 773 invokeCallback( m,NULL,NULL,7,0);792 invokeCallback(*main_conf,NULL,NULL,7,0); 774 793 removeReadLocks(main_conf); 775 794 #ifdef HPC_DEBUG … … 788 807 while ( (rc=read(cl,buf,10)) ) { 789 808 if(rc==0){ 790 sleep(1);791 809 setMapInMaps(*main_conf,"lenv","message",_("Read closed")); 792 errorException ( m, _("Read closed"),810 errorException (*main_conf, _("Read closed"), 793 811 "InternalError", NULL); 794 812 #ifdef HPC_DEBUG … … 796 814 fflush(stderr); 797 815 #endif 798 invokeCallback( m,NULL,NULL,7,0);816 invokeCallback(*main_conf,NULL,NULL,7,0); 799 817 removeReadLocks(main_conf); 800 818 #ifdef HPC_DEBUG … … 806 824 if(rc<0){ 807 825 setMapInMaps(*main_conf,"lenv","message",_("Read error")); 808 errorException ( m, _("Read error"),826 errorException (*main_conf, _("Read error"), 809 827 "InternalError", NULL); 810 828 #ifdef HPC_DEBUG … … 812 830 fflush(stderr); 813 831 #endif 814 invokeCallback( m,NULL,NULL,7,0);832 invokeCallback(*main_conf,NULL,NULL,7,0); 815 833 removeReadLocks(main_conf); 816 834 #ifdef HPC_DEBUG … … 872 890 free(targetPath); 873 891 }else{ 874 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 875 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 876 setMapInMaps(m,"lenv","message",tmpStr); 877 free(tmpStr); 878 invokeCallback(m,NULL,NULL,7,0); 892 map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); 893 if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){ 894 struct stat f_status; 895 int ts=stat(targetPath, &f_status); 896 if(ts==0) { 897 char* fcontent = NULL; 898 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 899 FILE* f=fopen(targetPath,"rb"); 900 fread(fcontent,f_status.st_size,1,f); 901 int fsize=f_status.st_size; 902 fcontent[fsize]=0; 903 fclose(f); 904 setMapInMaps(*main_conf,"lenv","message",fcontent); 905 free(fcontent); 906 }else{ 907 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 908 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 909 setMapInMaps(*main_conf,"lenv","message",tmpStr); 910 free(tmpStr); 911 } 912 }else{ 913 char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 914 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename); 915 setMapInMaps(*main_conf,"lenv","message",tmpStr); 916 free(tmpStr); 917 } 918 invokeCallback(*main_conf,NULL,NULL,7,0); 879 919 return SERVICE_FAILED; 880 920 } … … 882 922 }else{ 883 923 map* generatedFile=getMap(input->content,"generated_file"); 924 map* generatedUrl=getMap(input->content,"generated_url"); 884 925 if(generatedFile!=NULL){ 885 926 char* filename=strrchr(generatedFile->value,'/'); … … 895 936 maps* output=getMaps(*real_outputs,input->name); 896 937 setMapInMaps(output->child,"download_link","generated_file",targetPath); 938 setMapInMaps(output->child,"download_link","generated_url",generatedUrl->value); 897 939 setMapInMaps(output->child,"download_link","storage",targetPath); 898 940 setMapInMaps(output->child,"download_link","useMapserver","false"); … … 908 950 if(getMaps(output->child,"wcs_link")!=NULL){ 909 951 sprintf(serviceName,"wcs_link"); 910 setMapInMaps(output->child,serviceName,"msOgc","WCS"); 911 setMapInMaps(output->child,serviceName,"requestedMimeType","image/tiff"); 912 } 913 else{ 952 setMapInMaps(output->child,"wcs_link","msOgc","WCS"); 953 }else{ 914 954 sprintf(serviceName,"wfs_link"); 915 setMapInMaps(output->child,serviceName,"msOgc","WFS"); 916 setMapInMaps(output->child,serviceName,"requestedMimeType","text/xml"); 917 } 955 setMapInMaps(output->child,"wfs_link","msOgc","WFS"); 956 } 918 957 setMapInMaps(output->child,serviceName,"storage",targetPath); 919 958 setMapInMaps(output->child,serviceName,"generated_file",targetPath); … … 958 997 }else{ 959 998 // Try to access remotely to the log file and return a more relevant error message 960 setMapInMaps( m,"lenv","message",_("HPC Execution failed!"));961 errorException ( m, _("HPC Execution failed!"),999 setMapInMaps(*main_conf,"lenv","message",_("HPC Execution failed!")); 1000 errorException (*main_conf, _("HPC Execution failed!"), 962 1001 "InternalError", NULL); 963 1002 #ifdef HPC_DEBUG … … 965 1004 fflush(stderr); 966 1005 #endif 967 invokeCallback( m,NULL,NULL,7,0);1006 invokeCallback(*main_conf,NULL,NULL,7,0); 968 1007 #ifdef HPC_DEBUG 969 1008 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 971 1010 #endif 972 1011 } 973 //free(buf);974 1012 } 975 1013 if(hasPassed<0){ 976 1014 perror("Failed to read"); 977 1015 setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution")); 978 errorException ( m, _("Unable to parse the value returned by remote execution"),1016 errorException (*main_conf, _("Unable to parse the value returned by remote execution"), 979 1017 "InternalError", NULL); 980 1018 #ifdef HPC_DEBUG … … 982 1020 fflush(stderr); 983 1021 #endif 984 invokeCallback( m,NULL,NULL,7,0);1022 invokeCallback(*main_conf,NULL,NULL,7,0); 985 1023 #ifdef HPC_DEBUG 986 1024 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); -
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 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.h
r586 r862 55 55 int tryGdal(maps* conf,maps* output,mapObj* m); 56 56 void outputMapfile(maps* conf,maps* outputs); 57 void saveMapNames(maps*,maps*,char*); 58 57 59 #ifdef __cplusplus 58 60 } -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r860 r862 205 205 return NULL; 206 206 207 libssh2_session_set_blocking(result->session, 0);207 libssh2_session_set_blocking(result->session, 1); 208 208 209 209 while ((rc = libssh2_session_handshake(result->session, result->sock_id)) … … 418 418 */ 419 419 int ssh_fetch(maps* conf,const char* localPath,const char* targetPath,int cnt){ 420 char mem[1024];421 420 size_t nread; 422 421 size_t memuse=0; … … 436 435 if (!sessions[cnt]->sftp_session && 437 436 (libssh2_session_last_errno(sessions[cnt]->session) != LIBSSH2_ERROR_EAGAIN)) { 438 439 437 fprintf(stderr, "Unable to init SFTP session\n"); 440 438 return -1; … … 452 450 } 453 451 else { 454 //non-blocking open455 452 waitsocket(sessions[cnt]->sock_id, sessions[cnt]->session); 456 453 } 457 454 } 455 if(!sftp_handle) 456 zSleep(100); 458 457 } while (!sftp_handle); 459 458 … … 461 460 do { 462 461 do { 463 rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem)); 464 /*fprintf(stderr, "libssh2_sftp_read returned %d\n", 465 rc);*/ 462 char* mem=(char*)malloc(16*1024*1024); 463 rc = libssh2_sftp_read(sftp_handle, mem,16*1024*1024); 466 464 if(rc > 0) { 467 //write(2, mem, rc);468 465 fwrite(mem, rc, 1, local); 469 466 } 467 free(mem); 470 468 } while (rc > 0); 471 469 … … 585 583 */ 586 584 bool ssh_close_session(maps* conf,SSHCON* con){ 585 if(con==NULL) 586 return true; 587 587 while (libssh2_session_disconnect(con->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi") 588 588 == LIBSSH2_ERROR_EAGAIN); … … 593 593 #endif 594 594 libssh2_session_free(con->session); 595 con=NULL; 595 596 return true; 596 597 } … … 639 640 getMapArray(input->content,"targetPath",i)}; 640 641 641 setMapArray(queueMaps->content,"input",queueIndex ,input->name);642 setMapArray(queueMaps->content,"localPath",queueIndex ,tmp[0]->value);643 setMapArray(queueMaps->content,"targetPath",queueIndex ,tmp[1]->value);644 queueIndex+=1; 642 setMapArray(queueMaps->content,"input",queueIndex+i,input->name); 643 setMapArray(queueMaps->content,"localPath",queueIndex+i,tmp[0]->value); 644 setMapArray(queueMaps->content,"targetPath",queueIndex+i,tmp[1]->value); 645 645 646 } 646 647 } 647 648 } 648 #ifdef SSH_DEBUG649 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);650 fflush(stderr);651 dumpMaps(queueMaps);652 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);653 fflush(stderr);654 dumpMaps(*conf);655 fprintf(stderr,"%s %d\n",__FILE__,__LINE__);656 fflush(stderr);657 #endif658 649 return true; 659 650 } … … 664 655 return false; 665 656 } 666 #ifdef SSH_DEBUG667 fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__);668 fflush(stderr);669 dumpMaps(getMaps(*conf,"uploadQueue"));670 fprintf(stderr,"*** %s %d\n",__FILE__,__LINE__);671 fflush(stderr);672 #endif673 657 map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length"); 674 658 maps* queueMaps=getMaps(*conf,"uploadQueue"); … … 682 666 getMapArray(queueMaps->content,"targetPath",i) 683 667 }; 684 #ifdef SSH_DEBUG685 fprintf(stderr,"*** %s %d %s %s\n",__FILE__,__LINE__,argv[1]->value,argv[2]->value);686 #endif687 668 /**/zooLock* lck; 688 669 if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/ … … 703 684 } 704 685 } 686 while (libssh2_session_disconnect(test->session, "Normal Shutdown, Thank you for using the ZOO-Project sshapi") 687 == LIBSSH2_ERROR_EAGAIN); 688 #ifdef WIN32 689 closesocket(test->sock_id); 690 #else 691 close(test->sock_id); 692 #endif 693 libssh2_session_free(test->session); 694 free(test); 695 test=NULL; 696 sessions[ssh_get_cnt(*conf)-1]=NULL; 697 maps* tmp=getMaps(*conf,"lenv"); 698 addIntToMap(tmp->content,"nb_sessions",ssh_get_cnt(*conf)-1); 699 705 700 return true; 706 701 } -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
r860 r862 29 29 #define MAX_WAIT_MSECS 180*1000 /* Wait max. 180 seconds */ 30 30 #include "ulinet.h" 31 #include "server_internal.h" 31 32 #include <assert.h> 32 33 #include <ctype.h> … … 67 68 return realsize; 68 69 } 70 71 /** 72 * Write the downloaded content to a _HINTERNET structure 73 * 74 * @param buffer the buffer to read 75 * @param size size of each member 76 * @param nmemb number of element to read 77 * @param data the _HINTERNET structure to write in 78 * @return the size red, -1 if buffer is NULL 79 */ 80 size_t write_data_into_file(void *buffer, size_t size, size_t nmemb, void *data) 81 { 82 size_t realsize = size * nmemb; 83 int writen=0; 84 _HINTERNET *psInternet; 85 if(buffer==NULL){ 86 buffer=NULL; 87 return -1; 88 } 89 psInternet=(_HINTERNET *)data; 90 writen+=fwrite(buffer, size, nmemb, psInternet->file); 91 if(psInternet->nDataLen>0){ 92 psInternet->nDataAlloc+=psInternet->nDataLen+writen+1; 93 psInternet->nDataLen += realsize; 94 }else 95 psInternet->nDataLen=realsize+1; 96 buffer=NULL; 97 return realsize; 98 } 99 69 100 70 101 /** … … 363 394 fclose(handle.file); 364 395 unlink(handle.filename); 396 free(handle.filename); 365 397 } 366 398 else{ … … 411 443 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file) 412 444 * @param dwContext not used 445 * @return the updated HINTERNET 413 446 */ 414 447 HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){ … … 447 480 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1); 448 481 #endif 449 450 482 451 483 switch(dwFlags) 452 484 { 453 485 case INTERNET_FLAG_NO_CACHE_WRITE: 454 hInternet->ihandle[hInternet->nb].hasCacheFile=-1;455 486 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into); 456 487 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]); 488 hInternet->ihandle[hInternet->nb].hasCacheFile=-1; 457 489 break; 458 490 default: 459 sprintf(hInternet->ihandle[hInternet->nb].filename,"/tmp/ZOO_Cache%d",(int)time(NULL)); 460 hInternet->ihandle[hInternet->nb].filename[24]=0; 461 #ifdef MSG_LAF_VERBOSE 462 fprintf(stderr,"file=%s",hInternet->ihandle[hInternet->nb].filename); 463 #endif 464 hInternet->ihandle[hInternet->nb].filename=filename; 491 memset(filename,0,255); 492 char* tmpUuid=get_uuid(); 493 sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid); 494 free(tmpUuid); 495 hInternet->ihandle[hInternet->nb].filename=strdup(filename); 465 496 hInternet->ihandle[hInternet->nb].file=fopen(hInternet->ihandle[hInternet->nb].filename,"w+"); 466 467 497 hInternet->ihandle[hInternet->nb].hasCacheFile=1; 468 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, NULL); 469 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, hInternet->ihandle[hInternet->nb].file); 470 hInternet->ihandle[hInternet->nb].nDataLen=0; 498 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into_file); 499 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]); 471 500 break; 472 501 } … … 514 543 */ 515 544 int processDownloads(HINTERNET* hInternet){ 516 int still_running=0 ;545 int still_running=0,numfds; 517 546 int msgs_left=0; 518 547 int i=0; 519 548 do{ 520 if(curl_multi_perform(hInternet->handle, &still_running)==CURLM_OK) 521 if(still_running){ 522 zSleep(10); 523 } 549 CURLMcode mc; 550 mc = curl_multi_perform(hInternet->handle, &still_running); 551 if(mc==CURLM_OK){ 552 mc = curl_multi_wait(hInternet->handle, NULL, 0, 1000, &numfds); 553 } 554 if(mc != CURLM_OK) { 555 fprintf(stderr, "curl_multi failed, code %d.n", mc); 556 break; 557 } 524 558 }while(still_running); 525 559 for(i=0;i<hInternet->nb;i++){ … … 565 599 fseek (hInternet.file , 0 , SEEK_END); 566 600 dwDataSize=ftell(hInternet.file); //taille du ficher 567 rewind (hInternet.file); 601 //dwDataSize=hInternet.nDataLen; 602 //rewind (hInternet.file); 603 fseek(hInternet.file, 0, SEEK_SET); 568 604 } 569 605 else{ … … 575 611 } 576 612 577 if( dwNumberOfBytesToRead /* buffer size */ < dwDataSize ) 613 if( dwNumberOfBytesToRead /* buffer size */ < dwDataSize ){ 578 614 return 0; 615 } 579 616 580 617 #ifdef MSG_LAF_VERBOSE 581 printf("\nfile size : %dko\n",dwDataSize/1024);618 fprintf(stderr,"\nfile size : %dko\n",dwDataSize/1024); 582 619 #endif 583 620 584 621 if(hInternet.hasCacheFile>0){ 585 *lpdwNumberOfBytesRead = fread(lpBuffer,1,dwDataSize,hInternet.file); 622 int freadRes = fread(lpBuffer,dwDataSize+1,1,hInternet.file); 623 *lpdwNumberOfBytesRead = hInternet.nDataLen; 586 624 } 587 625 else{ -
branches/prototype-v0/zoo-project/zoo-kernel/zoo_loader.c
r861 r862 64 64 #define FALSE -1 65 65 #endif 66 67 int cgiInit(){ 68 fprintf(FCGI_stderr,"ZOO-Kernel initialization %s %d ... \n",__FILE__,__LINE__); 69 fflush(FCGI_stderr); 70 } 66 71 67 72 /** -
branches/prototype-v0/zoo-project/zoo-services/cgal/Makefile
r779 r862 1 1 ZRPATH=../.. 2 2 include ${ZRPATH}/zoo-kernel/ZOOMakefile.opts 3 CFLAGS= -I${INST_INCLUDE}${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} ${CGAL_CFLAGS} -frounding-math -fPIC -DLINUX_FREE_ISSUE #-DDEBUG3 CFLAGS= ${ZOO_CFLAGS} ${XML2CFLAGS} ${GDAL_CFLAGS} ${PYTHONCFLAGS} ${CGAL_CFLAGS} -frounding-math -fPIC -DLINUX_FREE_ISSUE #-DDEBUG 4 4 CC=gcc 5 5 … … 7 7 g++ ${CFLAGS} -c ./delaunay.c 8 8 g++ ${CFLAGS} -c ./voronoi.c 9 g++ ${CFLAGS} -shared -o cgi-env/cgal_service.zo ./delaunay.o ./voronoi.o ./cgal_service.o ${GDAL_LIBS} ${ MACOS_LD_FLAGS} ${CGAL_LDFLAGS} -lCGAL -lgmp ${GDAL_LIBS} -L${ZRPATH}/zoo-kernel/ -lzoo_service9 g++ ${CFLAGS} -shared -o cgi-env/cgal_service.zo ./delaunay.o ./voronoi.o ./cgal_service.o ${GDAL_LIBS} ${CGAL_LDFLAGS} -lCGAL -lgmp ${GDAL_LIBS} -L${ZRPATH}/zoo-kernel/ -lzoo_service -lfcgi 10 10 11 11 cgal_service.o: cgal_service.c cgal_service.h -
branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c
r775 r862 24 24 #include "cgal_service.h" 25 25 26 int parseInput(maps* conf,maps* inputs, std::vector<Point >* points,char* filename){26 int parseInput(maps* conf,maps* inputs, std::vector<Pointz>* points,char* filename){ 27 27 map* tmpm=NULL; 28 28 tmpm=getMapFromMaps(inputs,"InputPoints","value"); … … 87 87 break; 88 88 if(poFeature->GetGeometryRef() != NULL){ 89 points->push_back(Point (OGR_G_GetX(poFeature->GetGeometryRef(),0),OGR_G_GetY(poFeature->GetGeometryRef(),0)));89 points->push_back(Pointz(OGR_G_GetX(poFeature->GetGeometryRef(),0),OGR_G_GetY(poFeature->GetGeometryRef(),0))); 90 90 } 91 91 } -
branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.h
r469 r862 38 38 39 39 typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; 40 typedef Kernel::Point_2 Point ;40 typedef Kernel::Point_2 Pointz; 41 41 42 int parseInput(maps*,maps*, std::vector<Point >*,char*);42 int parseInput(maps*,maps*, std::vector<Pointz>*,char*); 43 43 44 44 #endif -
branches/prototype-v0/zoo-project/zoo-services/cgal/cgi-env/Voronoi.zcfg
r536 r862 46 46 </Default> 47 47 <Supported> 48 mimeType = image/png 49 useMapserver = true 50 asReference = true 51 msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 0.3 OPACITY 65 END 52 </Supported> 53 <Supported> 48 54 mimeType = text/xml 49 55 encoding = base64 -
branches/prototype-v0/zoo-project/zoo-services/cgal/delaunay.c
r775 r862 40 40 OGRRegisterAll(); 41 41 42 std::vector<Point > points;42 std::vector<Pointz> points; 43 43 if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED) 44 44 return res; -
branches/prototype-v0/zoo-project/zoo-services/cgal/voronoi.c
r775 r862 24 24 25 25 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 26 #include <CGAL/Triangulation_euclidean_traits_xy_3.h>26 //#include <CGAL/Triangulation_euclidean_traits_2.h> 27 27 #include <CGAL/Delaunay_triangulation_2.h> 28 #include <CGAL/Constrained_Delaunay_triangulation_2.h>28 //#include <CGAL/Constrained_Delaunay_triangulation_2.h> 29 29 #include <CGAL/Triangulation_conformer_2.h> 30 30 #include <CGAL/Triangulation_face_base_2.h> … … 39 39 40 40 typedef CGAL::Delaunay_triangulation_2<Kernel> Triangulation; 41 typedef Triangulation::Face_iterator Face_iterator; 41 42 typedef Triangulation::Edge_iterator Edge_iterator; 42 43 typedef Triangulation::Vertex_circulator Vertex_circulator; … … 45 46 46 47 int Voronoi(maps*& conf,maps*& inputs,maps*& outputs){ 47 #ifdef DEBUG48 //#ifdef DEBUG 48 49 fprintf(stderr,"\nService internal print\nStarting\n"); 49 #endif 50 //#endif 51 //return SERVICE_FAILED; 50 52 maps* cursor=inputs; 51 53 OGRGeometryH geometry,res; … … 54 56 tmpm=getMapFromMaps(inputs,"InputPoints","value"); 55 57 58 fprintf(stderr," **** %s %d\n",__FILE__,__LINE__); 59 fflush(stderr); 60 56 61 OGRRegisterAll(); 57 62 58 std::vector<Point> points; 59 if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED) 60 return res; 63 std::vector<Pointz> points; 64 if(int res=parseInput(conf,inputs,&points,"/vsimem/tmp")!=SERVICE_SUCCEEDED){ 65 fprintf(stderr," **** %s %d\n",__FILE__,__LINE__); 66 fflush(stderr); 67 return SERVICE_FAILED; 68 } 69 fprintf(stderr," **** %s %d\n",__FILE__,__LINE__); 70 fflush(stderr); 61 71 62 72 Triangulation T; 63 73 T.insert(points.begin(), points.end()); 64 74 65 OGRRegisterAll();75 //OGRRegisterAll(); 66 76 /* -------------------------------------------------------------------- */ 67 77 /* Try opening the output datasource as an existing, writable */ … … 191 201 CGAL::Object o = T.dual(eit); 192 202 if (const Kernel::Segment_2 *tmp=CGAL::object_cast<Kernel::Segment_2>(&o)) { 193 const Point p1=tmp->source();194 const Point p2=tmp->target();203 const Pointz p1=tmp->source(); 204 const Pointz p2=tmp->target(); 195 205 #ifdef DEBUG 196 206 fprintf(stderr,"P1 %d %d | P2 %d %d\n",p1.x(),p1.y(),p2.x(),p2.y()); … … 210 220 } 211 221 else if (const Kernel::Ray_2 *tmp=CGAL::object_cast<Kernel::Ray_2>(&o)) { 212 const Point p1=tmp->source();213 const Point p2=tmp->point(2);222 const Pointz p1=tmp->source(); 223 const Pointz p2=tmp->point(2); 214 224 OGRFeatureH hFeature = OGR_F_Create( OGR_L_GetLayerDefn( poDstLayer ) ); 215 225 OGRGeometryH currLine=OGR_G_CreateGeometry(wkbLineString); … … 250 260 fprintf(stderr,"\nService internal print\n===\n"); 251 261 #endif 252 OGRCleanupAll();262 //OGRCleanupAll(); 253 263 return SERVICE_SUCCEEDED; 254 264 } -
branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c
r790 r862 96 96 #endif 97 97 { 98 const char *pszDialect = NULL; 98 99 const char *pszFormat = "ESRI Shapefile"; 99 100 const char *pszDataSource = NULL; … … 155 156 sprintf(serverAddress,"%s",tmpMap->value); 156 157 } 157 158 158 159 tmpMap=NULL; 159 160 char tmpurl[1024]; … … 223 224 if(tmpMap!=NULL && strncasecmp(tmpMap->value,"NULL",4)!=0){ 224 225 pszSQLStatement = tmpMap->value; 226 } 227 228 tmpMap=getMapFromMaps(inputs,"dialect","value"); 229 if(tmpMap!=NULL){ 230 pszDialect=strdup(tmpMap->value); 225 231 } 226 232 … … 367 373 }*/ 368 374 375 369 376 tmpMap=NULL; 370 377 tmpMap=getMapFromMaps(inputs,"InputDSN","value"); … … 825 832 826 833 poResultSet = poDS->ExecuteSQL( pszSQLStatement, poSpatialFilter, 827 NULL);834 pszDialect ); 828 835 829 836 if( poResultSet != NULL ) … … 841 848 } 842 849 poDS->ReleaseResultSet( poResultSet ); 843 } 844 } 850 }else{ 851 setMapInMaps(conf,"lenv","message","There was an error when running yoru SQL query."); 852 if(pszDialect!=NULL) 853 free(pszDialect); 854 return SERVICE_FAILED; 855 } 856 } 857 if(pszDialect!=NULL) 858 free(pszDialect); 845 859 846 860 /* -------------------------------------------------------------------- */ … … 901 915 902 916 #ifdef ZOO_SERVICE 903 outputs->content=createMap("value",(char*)pszwebDestData); 917 setMapInMaps(outputs,"OutputedDataSourceName","value",(char*)pszwebDestData); 918 //outputs->content=createMap("value",(char*)pszwebDestData); 904 919 #endif 905 920 … … 930 945 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 931 946 932 OGRCleanupAll();947 //OGRCleanupAll(); 933 948 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 934 949 … … 939 954 940 955 #ifdef ZOO_SERVICE 956 //sleep(10); 941 957 return SERVICE_SUCCEEDED; 942 958 #else -
branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service.c
r854 r862 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright 20 08-2009GeoLabs SARL. All rights reserved.4 * Copyright 2017 GeoLabs SARL. All rights reserved. 5 5 * 6 6 * This work was supported by public funds received in the framework of GEOSUD, -
branches/prototype-v0/zoo-project/zoo-services/utils/hpc/service2.c
r854 r862 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright 2008-2009 GeoLabs SARL. All rights reserved. 5 * 4 * Copyright 2017 GeoLabs SARL. All rights reserved. 5 * 6 * This work was supported by public funds received in the framework of GEOSUD, 7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed 8 * by the French National Research Agency 9 * 6 10 * This work was supported by public funds received in the framework of GEOSUD, 7 11 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed … … 42 46 43 47 #include <dirent.h> 48 #include <string.h> 49 #include <cerrno> 50 44 51 extern "C" { 52 53 /** 54 * Retrieve the error message which occured when trying to remove a file 55 * (return values can be EACCES, EBUSY, EFAULT, EIO, EISDIR, ELOOP, 56 * ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EPERM, EROFS, UNKNOWN). 57 * 58 * @param errn 59 * @result a string corresponding to the error number 60 */ 61 char* fetchErrno(int errn){ 62 switch(errn){ 63 case EACCES: 64 return "EACCES"; 65 case EBUSY: 66 return "EBUSY"; 67 case EFAULT: 68 return "EFAULT"; 69 case EIO: 70 return "EIO"; 71 case EISDIR: 72 return "EISDIR"; 73 case ELOOP: 74 return "ELOOP"; 75 case ENAMETOOLONG: 76 return "ENAMETOOLONG"; 77 case ENOENT: 78 return "ENOENT"; 79 case ENOMEM: 80 return "ENOMEM"; 81 case ENOTDIR: 82 return "ENOTDIR"; 83 case EPERM: 84 return "EPERM"; 85 case EROFS: 86 return "EROFS"; 87 default: 88 return "UNKNOWN"; 89 } 90 } 45 91 46 92 /** … … 78 124 */ 79 125 int tryDeleteDataFile(const char* storage,const char* filename){ 80 char* fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char)); 81 sprintf(fullpath,"%s/%s",storage,filename); 126 char* fullpath=NULL; 127 if(filename!=NULL){ 128 fullpath=(char*)malloc((strlen(storage)+strlen(filename)+2)*sizeof(char)); 129 sprintf(fullpath,"%s/%s",storage,filename); 130 } 131 else 132 fullpath=zStrdup(storage); 82 133 if(unlink(fullpath)==0){ 83 134 // TODO store the filename_full in the deletedfiles 84 fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__, filename);135 fprintf(stderr,"#### DeleteData #### %s %d %s has been successfully deleted\n",__FILE__,__LINE__,(strlen(filename)>0?filename:fullpath)); 85 136 }else{ 86 fprintf(stderr,"#### DeleteData #### unable to delete %s \n",fullpath);137 fprintf(stderr,"#### DeleteData #### unable to delete %s %s \n",fullpath,fetchErrno(errno)); 87 138 } 88 139 free(fullpath); … … 138 189 } 139 190 if(fcontent!=NULL && strcasecmp(fcontent,"SHARED")!=0){ 140 // Delete associated zcm and zcp191 // Delete associated zcm, zcp and maps files 141 192 tryDeleteCacheFile(cacheDir->value,filename->value,"zca"); 142 193 tryDeleteCacheFile(cacheDir->value,filename->value,"zcm"); 143 194 tryDeleteCacheFile(cacheDir->value,filename->value,"zcp"); 144 // Delete ZOO_DATA_<input>_<sid>.data and <input>_<sid>.map 195 tryDeleteCacheFile(tmpPath->value,filename->value,"maps"); 196 // Delete <input>_<sid>.map 145 197 char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char)); 146 sprintf(datafile,"ZOO_DATA_%s_%s.data",ioname->value,jobid->value);147 tryDeleteDataFile(dataPath->value,datafile);148 free(datafile);149 datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));150 198 sprintf(datafile,"%s_%s.map",ioname->value,jobid->value); 151 199 tryDeleteDataFile(dataPath->value,datafile); … … 160 208 char tmp1[8]; 161 209 snprintf(tmp1,7,"%s",filename->value); 162 if(strcasecmp(tmp1,"output")==0){ 163 tryDeleteDataFile(tmpPath->value,filename->value); 210 if(strcasecmp(tmp1,"output")==0 || strcasecmp(tmp1,"input_")==0){ 211 trydeletedatafile(tmppath->value,filename->value); 212 char *tmp=zStrdup(filename->value); 213 tmp[strlen(tmp)-strlen(strrchr(tmp,'.'))]=0; 214 char *mapsfile=(char*)malloc((strlen(tmp)+6)*sizeof(char)); 215 sprintf(mapsfile,"%s.maps",tmp); 216 char* mapPath=(char*)malloc((strlen(tmpPath->value)+strlen(mapsfile)+2)*sizeof(char)); 217 sprintf(mapPath,"%s/%s",tmpPath->value,mapsfile); 218 FILE* myMapsfile=fopen(mapPath,"r"); 219 if(myMapsfile!=NULL){ 220 char *buffer=(char*)malloc(1024*sizeof(char)); 221 while(fgets(buffer, 1024, myMapsfile) != NULL){ 222 buffer[strlen(buffer)-1]=0; 223 tryDeleteDataFile(buffer,NULL); 224 } 225 free(buffer); 226 fclose(myMapsfile); 227 } 228 tryDeleteDataFile(mapPath,NULL); 229 free(mapPath); 230 free(mapsfile); 164 231 // Delete ZOO_DATA_<output>_<sid>.data and <output>_<sid>.map 165 232 char* datafile=(char*)malloc((strlen(jobid->value)+strlen(ioname->value)+19)*sizeof(char));
Note: See TracChangeset
for help on using the changeset viewer.