[Mapserver-dev] FastCGI and MapServer 4.4

Fernando S. simon at inf.univali.br
Mon Sep 27 16:51:52 EDT 2004


Smith,
    Thank's for the code. This function I already rewrited/change in my 
local tree, I extended it but now I'm testing because occurred some 
problems when the user don't have a defined SRID in database and want's 
to use projection. SRID can be a requirement when use projection? I'm 
thinking about this.....
    If my last version pass in my tests I will commit in cvs. Do you 
have more hint for the code?
    Frank, sorry for may last e-mail, I forgot to explain I'm already 
following the colloquy, but I had not undestood before you explain. 
Thank's. Now I'm reading the wiki to understant more......
    About the maporaclespatial code, more hints?
    Sorry my english.
    Thank's.


----------------------------------------------------------------
Fernando Simon - simon at inf.univali.br
G10 - Laboratorio de Computacao Aplicada
http://g10.cttmar.univali.br
----------------------------------------------------------------   



Smith, Michael ERDC-CRREL-NH wrote:

> Fernando,
>
> If you have difficulties, we could probably assist you after Frank 
> finishes the FastCGI api.
>
> I also have some code for handling geodetic extents passed to the 
> apply_window part of msOracleSpatialLayerWhichShapes when a geodetic 
> srid is defined .
>
>
>
> /* create SQL statement for retrieving shapes */
> int msOracleSpatialLayerWhichShapes( layerObj *layer, rectObj rect )
> {
>   int success, apply_window, i;
>   char query_str[6000];
>   char table_name[2000], geom_column_name[100], srid[100];
>   OCIDefine *adtp = NULL, *items[ARRAY_SIZE] = { NULL };
>
>   /* get layerinfo */
>   msOracleSpatialLayerInfo *layerinfo = (msOracleSpatialLayerInfo 
> *)layer->layerinfo;
>   if (layerinfo == NULL) {
>     msSetError( MS_ORACLESPATIALERR,
>       "msOracleSpatialLayerWhichShapes called on unopened layer",
>       "msOracleSpatialLayerWhichShapes()" );
>     return MS_FAILURE;
>   }
>
>   /* allocate enough space for items */
>   if (layer->numitems > 0) {
>     layerinfo->items = (item_text_array *)malloc( 
> sizeof(item_text_array) * layer->numitems );
>     if (layerinfo->items == NULL) {
>       msSetError( MS_ORACLESPATIALERR,
>         "Cannot allocate items buffer",
>         "msOracleSpatialLayerWhichShapes()" );
>       return MS_FAILURE;
>     }
>   }
>
>   /* parse geom_column_name and table_name */
>   if (!msSplitData( layer->data, geom_column_name, table_name, srid )) {
>     msSetError( MS_ORACLESPATIALERR,
>       "Error parsing OracleSpatial DATA variable. Must be "
>       "'geometry_column FROM table_name [USING SRID srid#]' or "
>       "'geometry_column FROM (SELECT stmt)'.",
>       "msOracleSpatialLayerWhichShapes()" );
>     return MS_FAILURE;
>   }
>
>   /* define SQL query */
>   apply_window = (table_name[0] != '('); /* table isn´t a SELECT 
> statement */
>   strcpy( query_str, "SELECT rownum" );
>   for( i=0; i<layer->numitems; ++i )
>     sprintf( query_str + strlen(query_str), ", %s", layer->items[i] );
>   sprintf( query_str + strlen(query_str), ", %s FROM %s", 
> geom_column_name, table_name );
>   if (apply_window || layer->filter.string != NULL)
>     strcat( query_str, " WHERE " );
>   if (layer->filter.string != NULL) {
>     strcat( query_str, layer->filter.string );
>     if (apply_window) strcat( query_str, " AND " );
>   }
>   if (applywindow){
>   if (srid>=8192)&&(srid<=8316){
>   sprintf( query_str + strlen(query_str),
>         "SDO_FILTER( %s.%s, SDO_CS.VIEWPORT_TRANSFORM("
>           "MDSYS.SDO_GEOMETRY("
>           "2003, 0, NULL,"
>           "MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),"
>           "MDSYS.SDO_ORDINATE_ARRAY(%.9g,%.9g,%.9g,%.9g) ), %s),"
>         "'querytype=window') = 'TRUE'",
>         table_name, geom_column_name,
>         rect.minx, rect.miny, rect.maxx, rect.maxy, srid )}
>   else
>     {sprintf( query_str + strlen(query_str),
>         "SDO_FILTER( %s.%s, MDSYS.SDO_GEOMETRY("
>           "2003, %s, NULL,"
>           "MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),"
>           "MDSYS.SDO_ORDINATE_ARRAY(%.9g,%.9g,%.9g,%.9g) ),"
>         "'querytype=window') = 'TRUE'",
>         table_name, geom_column_name, srid,
>         rect.minx, rect.miny, rect.maxx, rect.maxy )
>         }
>       };
>
>   /* parse and execute SQL query */
>   success = TRY( layerinfo,
>     /* prepare */
>     OCIStmtPrepare( layerinfo->stmthp, layerinfo->errhp, (text 
> *)query_str, (ub4)strlen(query_str), (ub4)OCI_NTV_SYNTAX, 
> (ub4)OCI_DEFAULT) );
>
>   if (success && layer->numitems > 0) {
>     for( i=0; i<layer->numitems && success; ++i )
>       success = TRY( layerinfo,
>         OCIDefineByPos( layerinfo->stmthp, &items[i], 
> layerinfo->errhp, (ub4)i+2, (dvoid *)layerinfo->items[i], 
> (sb4)TEXT_SIZE, SQLT_STR, (dvoid *)0, (ub2 *)0, (ub2 *)0, 
> (ub4)OCI_DEFAULT ) );
>
>   }
>
>   if (success) {
>     success = TRY( layerinfo,
>       /* define spatial position adtp ADT object */
>       OCIDefineByPos( layerinfo->stmthp, &adtp, layerinfo->errhp, 
> (ub4)layer->numitems+2, (dvoid *)0, (sb4)0, SQLT_NTY, (dvoid *)0, (ub2 
> *)0, (ub2 *)0, (ub4)OCI_DEFAULT) )
>
>     && TRY( layerinfo,
>       /* define object tdo from adtp */
>       OCIDefineObject( adtp, layerinfo->errhp, layerinfo->tdo, (dvoid 
> **)layerinfo->obj, (ub4 *)0, (dvoid **)layerinfo->ind, (ub4 *)0 ) )
>
>     && TRY( layerinfo,
>       /* execute */
>       OCIStmtExecute( layerinfo->svchp, layerinfo->stmthp, 
> layerinfo->errhp, (ub4)ARRAY_SIZE, (ub4)0, (OCISnapshot *)NULL, 
> (OCISnapshot *)NULL, (ub4)OCI_DEFAULT ) )
>
>     &&  TRY( layerinfo,
>       /* get rows fetched */
>       OCIAttrGet( (dvoid *)layerinfo->stmthp, (ub4)OCI_HTYPE_STMT, 
> (dvoid *)&layerinfo->rows_fetched, (ub4 *)0, (ub4)OCI_ATTR_ROW_COUNT, 
> layerinfo->errhp ) );
>
>   }
>
>   if (!success)
>     sprintf( last_oci_call_ms_error + strlen(last_oci_call_ms_error), 
> ". SQL statement: %s", query_str );
>  
>   if (ERROR( "msOracleSpatialLayerWhichShapes()", layerinfo ))
>     return MS_FAILURE;
>
>   /* should begin processing first row */
>   layerinfo->row_num = layerinfo->row = 0;
>
>   return MS_SUCCESS;
> }
>
>
> Mike Smith
> GIS Specialist/Physical Scientist/Oracle Developer
> Remote Sensing/GIS Center of Expertise
> Army Engineer Research & Development Center
> Hanover, NH
> (603) 646-4765
> michael.smith at erdc.usace.army.mil
>
>  
>
> -----Original Message-----
> From: Fernando S. [mailto:simon at inf.univali.br]
> Sent: Monday, September 27, 2004 3:34 PM
> To: Frank Warmerdam; mapserver-dev at lists.gis.umn.edu
> Subject: Re: [Mapserver-dev] FastCGI and MapServer 4.4
>
> Hi,
>     It's very nice.
>     I started to write something for maporaclespatial some weeks ago. 
> I liked the fastcgi idea but when do you intend to include this 
> feature in the code? In the next version? 4.4 or 4.6?
>
>     I intend to start write oracle/fastcgi in the next week. But I 
> don't know if I can to finish until October. So, what can I follow? 
> Exist any step by step or a how to use for fastcgi?
>
>     Any hints?
>     Sorry my english.
>
>
> ----------------------------------------------------------------
> Fernando Simon - simon at inf.univali.br
> G10 - Laboratorio de Computacao Aplicada http://g10.cttmar.univali.br
> ----------------------------------------------------------------
>
>
>
> Frank Warmerdam wrote:
>
> > Smith, Michael ERDC-CRREL-NH wrote:
> >
> >> Frank,
> >>
> >> What extra would it take to extend the connection pooling to Oracle. 
> >> We may be able to provide that.
> >> If not for 4.4, then for 4.5.
> >
> >
> > Mike,
> >
> > My intention is to define fairly clear instructions on how to take
> > advantage of a "new" connection pooling API and those instructions
> > should make it pretty clear how it could be used.  Basically, I am
> > looking at an API like this:
> >
> > void MS_DLL_EXPORT *msConnPoolRequest( layerObj *layer ); void
> > MS_DLL_EXPORT *msConnPoolRelease( layerObj *layer, void * ); void
> > MS_DLL_EXPORT  msConnPoolRegister( layerObj *layer,
> >                                         void *connect_handle,
> >                                         void (*close)( void * ) );
> > void MS_DLL_EXPORT  msConnPoolMapDrawComplete(); void MS_DLL_EXPORT 
> > msConnPoolFinalCleanup();
> >
> > Particular format providers that want to support connection pooling
> > will call msConnPoolRequest() with their layer.  The connection
> > pooling code will look at the CONNECTION and CONNECTIONTYPE string,
> > and see if there is an existing handle associated with that pair.  If
> > so, it will be returned (as a void *).
> >
> > If not, the provider establishes a connection and then registers it
> > with msConnPoolRegister(), along with a function to be called when it
> > should be closed.
> >
> > When the LayerClose function is called for the provider, it would call
> > msConnPoolRelease() and the connection pooling code would decide
> > whether to invoke the low level close() or not.
> >
> > The connection pooling API would inspect some keyword(s) on the layer
> > to determine whether to keep a connection alive, or let it close
> > immediately after the last release against it.  I expect to use
> > PROCESSING options for this for now, though we might introduce a first
> > class keyword for this at a later date.
> >
> > So, I believe that updating particular providers such as the Oracle,
> > SDE, PostGIS, or OGR ones would be pretty straight forward.  The main
> > issue would be that it be done by some who can test if the code
> > changes work.
> > Ideally the
> > Oracle connecton maintainers would implement (or at least test)
> > changes for this.
> >
> > The actual work is likely not enough to justify cutting a contract of
> > some kind if that is what you are thinking.
> >
> > Best regards,
>
>
> _______________________________________________
> Mapserver-dev mailing list
> Mapserver-dev at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev
>




More information about the mapserver-dev mailing list