Changes between Version 44 and Version 45 of ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices
- Timestamp:
- Oct 16, 2010, 1:32:56 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ZooWorkshop/FOSS4GJapan/CreatingOGRBasedWebServices
v44 v45 643 643 }}} 644 644 645 This 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_GetBoundaryyou 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 :645 This 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 : 646 646 647 647 {{{ … … 673 673 }}} 674 674 675 Then, a function pointer called myFunc rather than the full function name can be used. This way we can re-implement our Boundary Service this way :675 Then, a function pointer called {{{myFunc}}} rather than the full function name can be used. This way we can re-implement our Boundary Service this way : 676 676 677 677 {{{ … … 682 682 }}} 683 683 684 Using this applyOne local function defined in the service.csource code, we can define other Services this way :684 Using this {{{applyOne}}} local function defined in the {{{service.c}}} source code, we can define other Services this way : 685 685 686 686 {{{ … … 694 694 }}} 695 695 696 The genericity of the applyOnefunction let you add two new Services in your ZOO Services Provider : !ConvexHull and Centroid.696 The genericity of the {{{applyOne}}} function let you add two new Services in your ZOO Services Provider : !ConvexHull and Centroid. 697 697 698 698 Note 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 : … … 712 712 }}} 713 713 714 To deploy your Services, you only have to copy the Boundary.zcfgmetadata 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.715 716 Note here that the !GetCapabilities and !DescribeProcessrequests 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.714 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. 715 716 Note 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. 717 717 718 718 ==== Python Version ====