Changeset 11226

Show
Ignore:
Timestamp:
04/08/07 10:54:41 (2 years ago)
Author:
mloskot
Message:

Fixed detecting 4-dim coords in EWKB stream as unsupported variant and return NULL geometry (Ticket #1323). Submitted to the trunk in r11041.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/ogr/ogrsf_frmts/pg/ogrpglayer.cpp

    r11225 r11226  
    3232#include "ogr_pg.h" 
    3333#include "ogrpgutility.h" 
     34#include "ogr_p.h" 
    3435#include "cpl_conv.h" 
    3536#include "cpl_string.h" 
     
    267268            GByte * pabyWkb = (GByte *)PQgetvalue( hCursorResult, 
    268269                                                   iRecord, iField); 
     270 
     271 
     272 
    269273            OGRGeometry * poGeom = NULL; 
    270274            OGRGeometryFactory::createFromWkb(pabyWkb,NULL,&poGeom); 
     
    625629 
    626630{ 
    627     GByte       *pabyWKB; 
    628     int iSrc=0, iDst=0; 
    629     OGRGeometry *poGeometry; 
     631    GByte   *pabyWKB = NULL; 
     632    int     iSrc=0; 
     633    int     iDst=0; 
     634    OGRGeometry *poGeometry = NULL; 
     635    unsigned int ewkbFlags = 0; 
    630636 
    631637    if( pszBytea == NULL ) 
     
    665671 
    666672/* -------------------------------------------------------------------- */ 
     673/*      Detect XYZM variant of PostGIS EWKB                             */ 
     674/*                                                                      */ 
     675/*      OGR does not support parsing M coordinate,                      */ 
     676/*      so we return NULL geometry.                                     */ 
     677/* -------------------------------------------------------------------- */ 
     678    memcpy(&ewkbFlags, pabyWKB+1, 4); 
     679    OGRwkbByteOrder eByteOrder = (pabyWKB[0] == 0 ? wkbXDR : wkbNDR); 
     680    if( OGR_SWAP( eByteOrder ) ) 
     681        ewkbFlags= CPL_SWAP32(ewkbFlags); 
     682 
     683    if (ewkbFlags & 0x40000000) 
     684    { 
     685        CPLError( CE_Failure, CPLE_AppDefined, 
     686            "Reading EWKB with 4-dimensional coordinates (XYZM) is not supported" ); 
     687 
     688        CPLFree( pabyWKB ); 
     689        return NULL; 
     690    } 
     691 
     692/* -------------------------------------------------------------------- */ 
    667693/*      PostGIS EWKB format includes an  SRID, but this won't be        */ 
    668694/*      understood by OGR, so if the SRID flag is set, we remove the    */