Permalink
Browse files

Fix OGR output to make it work with KML, GPX (#4776)

  • Loading branch information...
rouault committed Oct 2, 2013
1 parent 051e2aa commit 9521529da1f33810b53850fbc06edb6296abdb6b
Showing with 11 additions and 4 deletions.
  1. +10 −3 mapogroutput.c
  2. +1 −1 msautotest
View
@@ -227,7 +227,8 @@ static void msOGRSetPoints( OGRGeometryH hGeom, lineObj *line, int bWant2DOutput
/************************************************************************/
static int msOGRWriteShape( layerObj *map_layer, OGRLayerH hOGRLayer,
shapeObj *shape, gmlItemListObj *item_list )
shapeObj *shape, gmlItemListObj *item_list,
int nFirstOGRFieldIndex )
{
OGRGeometryH hGeom = NULL;
@@ -435,7 +436,7 @@ static int msOGRWriteShape( layerObj *map_layer, OGRLayerH hOGRLayer,
/* -------------------------------------------------------------------- */
/* Set attributes. */
/* -------------------------------------------------------------------- */
out_field = 0;
out_field = nFirstOGRFieldIndex;
for( i = 0; i < item_list->numitems; i++ ) {
gmlItemObj *item = item_list->items + i;
@@ -641,6 +642,7 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
const char *value;
char *pszWKT;
int reproject = MS_FALSE;
int nFirstOGRFieldIndex = -1;
if( !layer->resultcache || layer->resultcache->numresults == 0 )
continue;
@@ -792,6 +794,11 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
msOGRCleanupDS( datasource_name );
return MS_FAILURE;
}
/* The index of the first field we create is not necessarily 0 */
if( nFirstOGRFieldIndex < 0 )
nFirstOGRFieldIndex = OGR_FD_GetFieldCount(
OGR_L_GetLayerDefn( hOGRLayer ) ) - 1;
}
/* -------------------------------------------------------------------- */
@@ -868,7 +875,7 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
if( status == MS_SUCCESS )
status = msOGRWriteShape( layer, hOGRLayer, &resultshape,
item_list );
item_list, nFirstOGRFieldIndex );
if(status != MS_SUCCESS) {
OGR_DS_Destroy( hDS );
Submodule msautotest updated from 1f0ea1 to ed1a6e

0 comments on commit 9521529

Please sign in to comment.