Changes between Version 36 and Version 37 of ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices


Ignore:
Timestamp:
Oct 16, 2010, 1:05:22 AM (14 years ago)
Author:
djay
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices

    v36 v37  
    610610==== C Version ====
    611611
    612 Please add first the following code to the service.c source code :
     612Please add first the following code to the {{{service.c}}} source code :
    613613
    614614{{{
     
    627627  tmp1=getMapFromMaps(outputs,"Result","mimeType");
    628628  if(strncmp(tmp1->value,"application/json",16)==0){
    629     addToMap(outputs->content,"value",OGR_G_ExportToJson(res));
    630     addToMap(outputs->content,"mimeType","text/plain");
     629    char* tmp=OGR_G_ExportToJson(res);
     630    setMapInMaps(outputs,"Result","value",tmp);
     631    setMapInMaps(outputs,"Result","mimeType","text/plain");
     632    free(tmp);
    631633  }
    632634  else{
    633     addToMap(outputs->content,"value",OGR_G_ExportToGML(res));
    634   }
    635   outputs->next=NULL;
     635    char* tmp=OGR_G_ExportToGML(res);
     636    setMapInMaps(outputs,"Result","value",tmp);
     637    free(tmp);
     638  }
    636639  OGR_G_DestroyGeometry(geometry);
    637640  OGR_G_DestroyGeometry(res);
     
    640643}}}
    641644
    642 This new code is exactly the same as for the Boundary Service. The only thing we modified is the line where the OGR_G_ConvexHull function is called (rather than the OGR_G_GetBoundary you used before). It is better to not copy and paste the whole function and find a more generic way to define your new Services as the function body will be the same in every case. The following generic function is proposed to make things simpler :
     645This new code is exactly the same as for the Boundary Service. The only thing we modified is the line where the [http://www.gdal.org/ogr/ogr__api_8h.html#7a93026cfae8ee6ce25546dba1b2df7d OGR_G_ConvexHull] function is called (rather than the OGR_G_GetBoundary you used before). It is better to not copy and paste the whole function and find a more generic way to define your new Services as the function body will be the same in every case. The following generic function is proposed to make things simpler :
    643646
    644647{{{
     
    693696The genericity of the applyOne function let you add two new Services in your ZOO Services Provider : !ConvexHull and Centroid.
    694697
    695 Note that you should define MY_OGR_Centroid function before the Centroid one as OGR_G_Centroid don't return a geometry object but set the value to an already existing one and support only Polygon as input, so to ensure we use the !ConvexHull for MultiPolygon. So please use the code bellow :
     698Note that you should define MY_OGR_Centroid function before the Centroid one as [http://www.gdal.org/ogr/ogr__api_8h.html#23f5a19a81628af7f9cc59a37378cb2b OGR_G_Centroid] don't return a geometry object but set the value to an already existing one and support only Polygon as input, so to ensure we use the !ConvexHull for MultiPolygon. So please use the code bellow :
    696699
    697700{{{
     
    709712}}}
    710713
    711 To deploy your Services, you only have to copy the Boundary.zcfg metadata file from your cgi-env directory as !ConvexHull.zcfg and Centroid.zcfg. Then, you must rename the Service name on the first line to be able to run and test the Execute request in the same way you did before. You only have to set the Identifier value to !ConvexHull or Centroid in your request depending on the Service you want to run.
     714To deploy your Services, you only have to copy the Boundary.zcfg metadata file from your cgi-env directory as {{{ConvexHull.zcfg}}} and {{{Centroid.zcfg}}}. Then, you must rename the Service name on the first line to be able to run and test the Execute request in the same way you did before. You only have to set the Identifier value to !ConvexHull or Centroid in your request depending on the Service you want to run.
    712715
    713716Note here that the !GetCapabilities and !DescribeProcess requests will return odd results as we didn't modified any metadata informations, you can edit the .zcfg files to set correct values. By the way it can be used for testing purpose, as the input and output get the same name and default/supported formats.

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