<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    All,<br>
    <br>
    Since this is my first post to this list I'd like to introduce
    myself. I am working at the company EOX with Stephan Meissl (I think
    he is known as "schpidi" in the svn system). I was involved with the
    developement of the WCS 2.0 extension to MapServer, so I'm quite
    familiar with the OWS, WCS and some dependent source code files.<br>
    <br>
    I would like to suggest a performance improvement for the dispatch
    of OWS requests.<br>
    <br>
    The current situation is something like that:<br>
    <ol>
      <li>A CGI request is dispatched in the mapserv.c:main</li>
      <li>This is forwarded to the mapows.c:msOWSDispatch function.</li>
      <li>Now, for every handler, the request has to be completely
        parsed to an according parameters object.&nbsp;</li>
      <li>When the right handler was found, the request is processed and
        the afterward dispatch of further handlers is stopped.</li>
    </ol>
    In most of the cases, the parsing of the parameters within the
    handler is unnecessary, since it was the wrong handler for the
    requested service.<br>
    To decide if a handler can handle an OWS request, only the
    service-type, the version and the request method are needed.<br>
    <br>
    I suggest to change the dispatching process in the following manner:<br>
    <ol>
      <li>In msOWSDispatch, a preliminary parsing function determines
        the service, version and the request from the KVP or XML
        request.</li>
      <li>According to these parameters the suited handler is called. If
        no handler is acceptable, the program continues as usual.</li>
    </ol>
    In pseudo-code, this might look something like this:<br>
    <br>
    function msOWSDispatch(request)<br>
    &nbsp;&nbsp;&nbsp; service, version, method := preliminaryParseRequest(request)<br>
    &nbsp;&nbsp;&nbsp; <br>
    &nbsp;&nbsp;&nbsp; if service is "WMS" then<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; msWMSDispatch(request, version, method)<br>
    &nbsp;&nbsp;&nbsp; else if service is "WCS" then<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; msWCSDispatch(request, version, method)<br>
    &nbsp;&nbsp;&nbsp; else if ... <br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...<br>
    &nbsp;&nbsp;&nbsp; else if service is NULL then<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return error<br>
    &nbsp;&nbsp;&nbsp; end if<br>
    end function<br>
    <br>
    The benefits of this method are:<br>
    <ul>
      <li>The request only has to be parsed once in the according
        handler function. Of course, the preliminary parsing function
        has to parse a part of the request also.</li>
      <li>XML requests can be parsed to a DOM-structure (with libxml)
        once, and do not have to be created for every handler only to
        become destroyed again.</li>
      <li>A lot of the program logic is currently duplicated in every
        handler. I think with the adjustments above, the code might
        become more maintainable.</li>
    </ul>
    Following cons have to be considered:<br>
    <ul>
      <li>The msWxSDispatch (and msSOSDispatch) functions have to be
        adjusted. Also some legacy code can be thrown away (e.g: check
        if the service type is correct, since this was already
        determined on a higher level)<br>
      </li>
    </ul>
    <br>
    I would offer to write a patch with the above changes but first I
    wanted to know if the above changes are appreciated or if these
    enhancements are not desired.<br>
    <br>
    Regards,<br>
    Fabian Schindler<br>
    <br>
  </body>
</html>