~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/georss/ogrgeorssdatasource.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: ogrgeorssdatasource.cpp 17848 2009-10-17 12:59:16Z rouault $
 
2
 * $Id: ogrgeorssdatasource.cpp 23557 2011-12-12 22:08:17Z rouault $
3
3
 *
4
4
 * Project:  GeoRSS Translator
5
5
 * Purpose:  Implements OGRGeoRSSDataSource class
32
32
#include "cpl_string.h"
33
33
#include "cpl_csv.h"
34
34
 
35
 
CPL_CVSID("$Id: ogrgeorssdatasource.cpp 17848 2009-10-17 12:59:16Z rouault $");
 
35
CPL_CVSID("$Id: ogrgeorssdatasource.cpp 23557 2011-12-12 22:08:17Z rouault $");
36
36
 
37
37
/************************************************************************/
38
38
/*                          OGRGeoRSSDataSource()                          */
67
67
        {
68
68
            if (eFormat == GEORSS_RSS)
69
69
            {
70
 
                VSIFPrintf(fpOutput, "  </channel>\n");
71
 
                VSIFPrintf(fpOutput, "</rss>\n");
 
70
                VSIFPrintfL(fpOutput, "  </channel>\n");
 
71
                VSIFPrintfL(fpOutput, "</rss>\n");
72
72
            }
73
73
            else
74
74
            {
75
 
                VSIFPrintf(fpOutput, "</feed>\n");
 
75
                VSIFPrintfL(fpOutput, "</feed>\n");
76
76
            }
77
77
        }
78
 
        if ( fpOutput != stdout )
79
 
            VSIFClose( fpOutput);
 
78
        VSIFCloseL( fpOutput);
80
79
    }
81
80
 
82
81
    for( int i = 0; i < nLayers; i++ )
164
163
            validity = GEORSS_VALIDITY_VALID;
165
164
            eFormat = GEORSS_ATOM;
166
165
        }
 
166
        else if (strcmp(pszName, "rdf:RDF") == 0)
 
167
        {
 
168
            const char** ppszIter = ppszAttr;
 
169
            while(*ppszIter)
 
170
            {
 
171
                if (strcmp(*ppszIter, "xmlns:georss") == 0)
 
172
                {
 
173
                    validity = GEORSS_VALIDITY_VALID;
 
174
                    eFormat = GEORSS_RSS_RDF;
 
175
                }
 
176
                ppszIter += 2;
 
177
            }
 
178
        }
167
179
        else
168
180
        {
169
181
            validity = GEORSS_VALIDITY_INVALID;
217
229
    pszName = CPLStrdup( pszFilename );
218
230
 
219
231
/* -------------------------------------------------------------------- */
220
 
/*      Determine what sort of object this is.                          */
 
232
/*      Try to open the file.                                           */
221
233
/* -------------------------------------------------------------------- */
222
 
    VSIStatBufL sStatBuf;
223
 
 
224
 
    if( VSIStatL( pszFilename, &sStatBuf ) != 0 )
225
 
        return FALSE;
226
 
    
227
 
    if( VSI_ISDIR(sStatBuf.st_mode) )
228
 
        return FALSE;
229
 
 
230
 
    FILE* fp = VSIFOpenL(pszFilename, "r");
 
234
    VSILFILE* fp = VSIFOpenL(pszFilename, "r");
231
235
    if (fp == NULL)
232
236
        return FALSE;
233
237
    
304
308
    return (validity == GEORSS_VALIDITY_VALID);
305
309
#else
306
310
    char aBuf[256];
307
 
    FILE* fp = VSIFOpenL(pszFilename, "r");
 
311
    VSILFILE* fp = VSIFOpenL(pszFilename, "r");
308
312
    if (fp)
309
313
    {
310
314
        unsigned int nLen = (unsigned int)VSIFReadL( aBuf, 1, 255, fp );
334
338
        return FALSE;
335
339
    }
336
340
 
 
341
    if (strcmp(pszFilename, "/dev/stdout") == 0)
 
342
        pszFilename = "/vsistdout/";
 
343
 
337
344
/* -------------------------------------------------------------------- */
338
345
/*     Do not override exiting file.                                    */
339
346
/* -------------------------------------------------------------------- */
352
359
/* -------------------------------------------------------------------- */
353
360
    pszName = CPLStrdup( pszFilename );
354
361
 
355
 
    if( EQUAL(pszFilename,"stdout") )
356
 
        fpOutput = stdout;
357
 
    else
358
 
        fpOutput = VSIFOpen( pszFilename, "w" );
 
362
    fpOutput = VSIFOpenL( pszFilename, "w" );
359
363
    if( fpOutput == NULL )
360
364
    {
361
365
        CPLError( CE_Failure, CPLE_OpenFailed, 
451
455
/* -------------------------------------------------------------------- */
452
456
/*     Output header of GeoRSS file.                                       */
453
457
/* -------------------------------------------------------------------- */
454
 
    VSIFPrintf(fpOutput, "<?xml version=\"1.0\"?>\n");
 
458
    VSIFPrintfL(fpOutput, "<?xml version=\"1.0\"?>\n");
455
459
    if (eFormat == GEORSS_RSS)
456
460
    {
457
 
        VSIFPrintf(fpOutput, "<rss version=\"2.0\" ");
 
461
        VSIFPrintfL(fpOutput, "<rss version=\"2.0\" ");
458
462
        if (eGeomDialect == GEORSS_GML)
459
 
            VSIFPrintf(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\"");
 
463
            VSIFPrintfL(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\" xmlns:gml=\"http://www.opengis.net/gml\"");
460
464
        else if (eGeomDialect == GEORSS_SIMPLE)
461
 
            VSIFPrintf(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\"");
 
465
            VSIFPrintfL(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\"");
462
466
        else
463
 
            VSIFPrintf(fpOutput, "xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"");
464
 
        VSIFPrintf(fpOutput, ">\n");
465
 
        VSIFPrintf(fpOutput, "  <channel>\n");
 
467
            VSIFPrintfL(fpOutput, "xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"");
 
468
        VSIFPrintfL(fpOutput, ">\n");
 
469
        VSIFPrintfL(fpOutput, "  <channel>\n");
466
470
        if (pszHeader)
467
471
        {
468
 
            VSIFPrintf(fpOutput, "%s", pszHeader);
 
472
            VSIFPrintfL(fpOutput, "%s", pszHeader);
469
473
        }
470
474
        else
471
475
        {
472
 
            VSIFPrintf(fpOutput, "    <title>%s</title>\n", pszTitle);
473
 
            VSIFPrintf(fpOutput, "    <description>%s</description>\n", pszDescription);
474
 
            VSIFPrintf(fpOutput, "    <link>%s</link>\n", pszLink);
 
476
            VSIFPrintfL(fpOutput, "    <title>%s</title>\n", pszTitle);
 
477
            VSIFPrintfL(fpOutput, "    <description>%s</description>\n", pszDescription);
 
478
            VSIFPrintfL(fpOutput, "    <link>%s</link>\n", pszLink);
475
479
        }
476
480
    }
477
481
    else
478
482
    {
479
 
        VSIFPrintf(fpOutput, "<feed xmlns=\"http://www.w3.org/2005/Atom\" ");
 
483
        VSIFPrintfL(fpOutput, "<feed xmlns=\"http://www.w3.org/2005/Atom\" ");
480
484
        if (eGeomDialect == GEORSS_GML)
481
 
            VSIFPrintf(fpOutput, "xmlns:gml=\"http://www.opengis.net/gml\"");
 
485
            VSIFPrintfL(fpOutput, "xmlns:gml=\"http://www.opengis.net/gml\"");
482
486
        else if (eGeomDialect == GEORSS_SIMPLE)
483
 
            VSIFPrintf(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\"");
 
487
            VSIFPrintfL(fpOutput, "xmlns:georss=\"http://www.georss.org/georss\"");
484
488
        else
485
 
            VSIFPrintf(fpOutput, "xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"");
486
 
        VSIFPrintf(fpOutput, ">\n");
 
489
            VSIFPrintfL(fpOutput, "xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"");
 
490
        VSIFPrintfL(fpOutput, ">\n");
487
491
        if (pszHeader)
488
492
        {
489
 
            VSIFPrintf(fpOutput, "%s", pszHeader);
 
493
            VSIFPrintfL(fpOutput, "%s", pszHeader);
490
494
        }
491
495
        else
492
496
        {
493
 
            VSIFPrintf(fpOutput, "  <title>%s</title>\n", pszTitle);
494
 
            VSIFPrintf(fpOutput, "  <updated>%s</updated>\n", pszUpdated);
495
 
            VSIFPrintf(fpOutput, "  <author><name>%s</name></author>\n", pszAuthorName);
496
 
            VSIFPrintf(fpOutput, "  <id>%s</id>\n", pszId);
 
497
            VSIFPrintfL(fpOutput, "  <title>%s</title>\n", pszTitle);
 
498
            VSIFPrintfL(fpOutput, "  <updated>%s</updated>\n", pszUpdated);
 
499
            VSIFPrintfL(fpOutput, "  <author><name>%s</name></author>\n", pszAuthorName);
 
500
            VSIFPrintfL(fpOutput, "  <id>%s</id>\n", pszId);
497
501
        }
498
502
    }
499
503