Ignore:
Timestamp:
May 31, 2011, 3:30:49 AM (13 years ago)
Author:
djay
Message:

Merge trunk r111:r216 into branch-1.2

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  
    4343
    4444  void printExceptionReportResponse(maps*,map*);
    45   char *base64(const unsigned char *input, int length);
     45  char *base64(const char *input, int length);
    4646
    4747  OGRGeometryH createGeometryFromGML(maps* conf,char* inputStr){
     
    5656    xpathObj = xmlXPathEvalExpression(BAD_CAST xpathExpr,xpathCtx);
    5757    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;
    6261    }
    6362    int size = (xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0;
     
    8079    xmlFreeDoc(doc);
    8180    xmlFreeDoc(ndoc);
     81#ifndef WIN32
    8282    xmlCleanupParser();
     83#endif
    8384#ifdef DEBUG
    8485    fprintf(stderr,"\nService internal print\n Loading the geometry from GML string ...");
     
    9495  }
    9596
     97#ifdef WIN32
     98  __declspec(dllexport)
     99#endif
    96100  int Simplify(maps*& conf,maps*& inputs,maps*& outputs){
    97101    maps* cursor=inputs;
     
    104108    else
    105109      tolerance=atof(tmp0->value);
     110#ifdef DEBUG
    106111    fprintf(stderr,"Tolerance for Simplify %f",tolerance);
     112#endif
    107113    map* tmp=getMapFromMaps(inputs,"InputPolygon","value");
    108114    if(!tmp){
     
    126132      return SERVICE_FAILED;
    127133    }
     134#ifdef DEBUG
    128135    fprintf(stderr,"Create GEOSGeometry object");
     136#endif
    129137    GEOSGeometry* ggeometry=((OGRGeometry *) geometry)->exportToGEOS();
    130138    GEOSGeometry* gres=GEOSTopologyPreserveSimplify(ggeometry,tolerance);
    131     res=OGRGeometryFactory::createFromGEOS(gres);
     139    res=(OGRGeometryH)OGRGeometryFactory::createFromGEOS(gres);
    132140    tmp1=getMapFromMaps(outputs,"Result","mimeType");
    133141    if(tmp1!=NULL){
     
    136144        char *tmpS=OGR_G_ExportToJson(res);
    137145        setMapInMaps(outputs,"Result","value",tmpS);
     146#ifndef WIN32
    138147        setMapInMaps(outputs,"Result","mimeType","text/plain");
    139148        setMapInMaps(outputs,"Result","encoding","UTF-8");
    140149        free(tmpS);
     150#endif
    141151      }
    142152      else{
    143153        char *tmpS=OGR_G_ExportToGML(res);
    144154        setMapInMaps(outputs,"Result","value",tmpS);
     155#ifndef WIN32
    145156        setMapInMaps(outputs,"Result","mimeType","text/xml");
    146157        setMapInMaps(outputs,"Result","encoding","UTF-8");
    147158        setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    148159        free(tmpS);
     160#endif
    149161      }
    150162    }else{
    151       char *tmpS=OGR_G_ExportToJson(tmp->value);
     163      char *tmpS=OGR_G_ExportToJson(res);
    152164      setMapInMaps(outputs,"Result","value",tmpS);
     165#ifndef WIN32
    153166      setMapInMaps(outputs,"Result","mimeType","text/plain");
    154167      setMapInMaps(outputs,"Result","encoding","UTF-8");
    155168      free(tmpS);
     169#endif
    156170    }
    157171    outputs->next=NULL;
     
    178192      return SERVICE_FAILED;
    179193    }
     194#ifdef DEBUG
    180195    fprintf(stderr,"Service internal print \n");
    181196    dumpMaps(inputs);
    182197    fprintf(stderr,"/Service internal print \n");
     198#endif
    183199    map* tmp1=getMapFromMaps(inputs,"InputPolygon","mimeType");
     200#ifdef DEBUG
    184201    fprintf(stderr,"Service internal print \n");
    185202    dumpMap(tmp1);
    186203    fprintf(stderr,"/Service internal print \n");
     204#endif
    187205    if(tmp1!=NULL){
    188206      if(strncmp(tmp1->value,"text/js",7)==0 ||
     
    199217    }
    200218    res=(*myFunc)(geometry);
     219#ifdef DEBUG
    201220    fprintf(stderr,"Service internal print \n");
    202221    dumpMaps(outputs);
    203222    fprintf(stderr,"/Service internal print \n");
     223#endif
    204224    map *tmp_2=getMapFromMaps(outputs,"Result","mimeType");
     225#ifdef DEBUG
    205226    fprintf(stderr,"Service internal print \n");
    206227    dumpMap(tmp_2);
    207228    fprintf(stderr,"/Service internal print \n");
     229#endif
    208230    if(tmp_2!=NULL){
    209231      if(strncmp(tmp_2->value,"text/js",7)==0 ||
     
    211233        char *tmpS=OGR_G_ExportToJson(res);
    212234        setMapInMaps(outputs,"Result","value",tmpS);
     235#ifndef WIN32
    213236        setMapInMaps(outputs,"Result","mimeType","text/plain");
    214237        setMapInMaps(outputs,"Result","encoding","UTF-8");
    215238        free(tmpS);
     239#endif
    216240      }
    217241      else{
    218242        char *tmpS=OGR_G_ExportToGML(res);
    219243        setMapInMaps(outputs,"Result","value",tmpS);
     244#ifndef WIN32
    220245        setMapInMaps(outputs,"Result","mimeType","text/xml");
    221246        setMapInMaps(outputs,"Result","encoding","UTF-8");
    222247        setMapInMaps(outputs,"Result","schema",schema);
    223248        free(tmpS);
     249#endif
    224250      }
    225251    }else{
    226252      char *tmpS=OGR_G_ExportToJson(res);
    227253      setMapInMaps(outputs,"Result","value",tmpS);
     254#ifndef WIN32
    228255      setMapInMaps(outputs,"Result","mimeType","text/plain");
    229256      setMapInMaps(outputs,"Result","encoding","UTF-8");
    230257      free(tmpS);
    231     }
    232     outputs->next=NULL;
     258#endif
     259    }
     260    //outputs->next=NULL;
    233261#ifdef DEBUG
    234262    dumpMaps(outputs);
     
    239267    //CPLFree(res);
    240268    //CPLFree(geometry);
     269#ifdef DEBUG
    241270    fprintf(stderr,"Service internal print \n");
    242271    dumpMaps(outputs);
    243272    fprintf(stderr,"/Service internal print \n");
     273#endif
    244274    return SERVICE_SUCCEEDED;
    245275  }
     
    276306     bufferDistance=atof(tmp->value);
    277307   res=OGR_G_Buffer(geometry,bufferDistance,30);
     308   dumpMap(tmp);
    278309   tmp1=getMapFromMaps(outputs,"Result","mimeType");
     310   dumpMap(tmp);
    279311   if(strncmp(tmp1->value,"application/json",16)==0){
    280312     char *tmpS=OGR_G_ExportToJson(res);
    281313     setMapInMaps(outputs,"Result","value",tmpS);
     314     dumpMap(tmp);
     315#ifndef WIN32
    282316     setMapInMaps(outputs,"Result","mimeType","text/plain");
    283317     setMapInMaps(outputs,"Result","encoding","UTF-8");
    284318     free(tmpS);
     319#endif
    285320   }
    286321   else{
    287322     char *tmpS=OGR_G_ExportToGML(res);
    288323     setMapInMaps(outputs,"Result","value",tmpS);
     324     dumpMap(tmp);
     325#ifndef WIN32
    289326     free(tmpS);
    290327     setMapInMaps(outputs,"Result","mimeType","text/xml");
    291328     setMapInMaps(outputs,"Result","encoding","UTF-8");
    292329     setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
     330#endif
    293331   }
    294    outputs->next=NULL;
     332   //outputs->next=NULL;
    295333   OGR_G_DestroyGeometry(geometry);
    296334   OGR_G_DestroyGeometry(res);
     
    335373    fprintf(stderr,"\nService internal print1\n");
    336374    fflush(stderr);
    337 #endif
    338375    fprintf(stderr,"\nService internal print1\n");
    339376    dumpMaps(inputs);
    340377    fprintf(stderr,"\nService internal print1\n");
     378#endif
    341379
    342380    maps* cursor=inputs;
     
    357395    if(geometry1==NULL){
    358396      setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity1."));
     397#ifdef DEBUG
    359398      fprintf(stderr,"SERVICE FAILED !\n");
    360       return SERVICE_FAILED;
    361     }
     399#endif
     400      return SERVICE_FAILED;
     401    }
     402#ifdef DEBUG
    362403    fprintf(stderr,"\nService internal print1 InputEntity1\n");
     404#endif
    363405    {
    364406      map* tmp=getMapFromMaps(inputs,"InputEntity2","value");
    365407      map* tmp1=getMapFromMaps(inputs,"InputEntity2","mimeType");
    366       //#ifdef DEBUG
     408#ifdef DEBUG
    367409      fprintf(stderr,"MY MAP \n[%s] - %i\n",tmp1->value,strncmp(tmp1->value,"application/json",16));
    368410      //dumpMap(tmp);
    369411      fprintf(stderr,"MY MAP\n");
    370       ///#endif
    371412      fprintf(stderr,"\nService internal print1 InputEntity2\n");
     413#endif
    372414      if(tmp1!=NULL){
    373415        if(strncmp(tmp1->value,"application/json",16)==0){
     416#ifdef DEBUG
    374417          fprintf(stderr,"\nService internal print1 InputEntity2 as JSON\n");
     418#endif
    375419          geometry2=OGR_G_CreateGeometryFromJson(tmp->value);
    376420        }
    377421        else{
     422#ifdef DEBUG
    378423          fprintf(stderr,"\nService internal print1 InputEntity2 as GML\n");
     424#endif
    379425          geometry2=createGeometryFromGML(conf,tmp->value);
    380426        }
     
    382428      else
    383429        geometry2=createGeometryFromGML(conf,tmp->value);
     430#ifdef DEBUG
    384431      fprintf(stderr,"\nService internal print1 InputEntity2 PreFinal\n");
    385     }
     432#endif
     433    }
     434#ifdef DEBUG
    386435    fprintf(stderr,"\nService internal print1 InputEntity2 Final\n");
     436#endif
    387437    if(geometry2==NULL){
    388438      setMapInMaps(conf,"lenv","message",_ss("Unable to parse input geometry for InputEntity2."));
     439#ifdef DEBUG
    389440      fprintf(stderr,"SERVICE FAILED !\n");
    390       return SERVICE_FAILED;
    391     }
     441#endif
     442      return SERVICE_FAILED;
     443    }
     444#ifdef DEBUG
    392445    fprintf(stderr,"\nService internal print1\n");
     446#endif
    393447    res=(*myFunc)(geometry1,geometry2);
     448#ifdef DEBUG
    394449    fprintf(stderr,"\nService internal print1\n");
    395    
     450#endif   
    396451    /* nuova parte */
    397452    map* tmp2=getMapFromMaps(outputs,"Result","mimeType");
     
    399454      char *tmpS=OGR_G_ExportToJson(res);
    400455      setMapInMaps(outputs,"Result","value",tmpS);
     456#ifndef WIN32
    401457      setMapInMaps(outputs,"Result","mimeType","text/plain");
    402458      setMapInMaps(outputs,"Result","encoding","UTF-8");
    403459      free(tmpS);
     460#endif
    404461    }
    405462    else{
    406463      char *tmpS=OGR_G_ExportToGML(res);
    407464      setMapInMaps(outputs,"Result","value",tmpS);
     465#ifndef WIN32
    408466      setMapInMaps(outputs,"Result","mimeType","text/xml");
    409467      setMapInMaps(outputs,"Result","encoding","UTF-8");
    410468      setMapInMaps(outputs,"Result","schema","http://fooa/gml/3.1.0/polygon.xsd");
    411469      free(tmpS);
     470#endif
    412471    }
    413472   
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png