Changes between Initial Version and Version 1 of Ticket #5803


Ignore:
Timestamp:
Jan 9, 2015, 4:33:43 AM (9 years ago)
Author:
liminlu0314
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5803 – Description

    initial v1  
    66
    77{{{
    8                 else if( wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon )
    9                 {
    10                         OGRPolygon *poPoly = (OGRPolygon *) poGeometry;
    11                         int nRingSize = poPoly->getNumInteriorRings();
    12                        
    13                         std::vector<PCIDSK::int32> anRingStart;
    14                         anRingStart.resize(nRingSize+1);
    15                        
    16                         OGRLinearRing *poRing = NULL;
    17                         poRing = poPoly->getExteriorRing();
    18                         anRingStart[0] = poRing->getNumPoints();
    19                        
    20                         aoVertices.resize(poRing->getNumPoints());
    21                         for(int i = 0; i < aoVertices.size(); i++ )
    22                         {
    23                                 aoVertices[i].x = poRing->getX(i);
    24                                 aoVertices[i].y = poRing->getY(i);
    25                                 aoVertices[i].z = poRing->getZ(i);
    26                         }
     8                else if( wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon )
     9                {
     10                        OGRPolygon *poPoly = (OGRPolygon *) poGeometry;
     11                        OGRLinearRing *poRing = NULL;
     12                        poRing = poPoly->getExteriorRing();
     13                       
     14                        aoVertices.resize(poRing->getNumPoints());
     15                        for(int i = 0; i < aoVertices.size(); i++ )
     16                        {
     17                                aoVertices[i].x = poRing->getX(i);
     18                                aoVertices[i].y = poRing->getY(i);
     19                                aoVertices[i].z = poRing->getZ(i);
     20                        }
    2721
    28                         for (int iRing=0; iRing < nRingSize; iRing++)
    29                         {
    30                                 int nCurrentStart = aoVertices.size();
    31                                 poRing = poPoly->getInteriorRing(iRing);
    32                                 anRingStart[iRing+1] = nCurrentStart + poRing->getNumPoints();
    33                                 aoVertices.resize(nCurrentStart + poRing->getNumPoints());
     22                        int nRingSize = poPoly->getNumInteriorRings();
     23                        if(nRingSize > 0 )
     24                        {
     25                                std::vector<PCIDSK::int32> anRingStart;
     26                                anRingStart.resize(nRingSize+1);
     27                                anRingStart[0] = poRing->getNumPoints();
    3428
    35                                 for(int i = nCurrentStart; i < aoVertices.size(); i++ )
    36                                 {
    37                                         aoVertices[i].x = poRing->getX(i-nCurrentStart);
    38                                         aoVertices[i].y = poRing->getY(i-nCurrentStart);
    39                                         aoVertices[i].z = poRing->getZ(i-nCurrentStart);
    40                                 }
    41                         }
    42                        
    43                         if(iRingStartField == -1)
    44                         {
    45                                 iRingStartField = poVecSeg->GetFieldCount();
    46                                 OGRFieldDefn oField( "RingStart", OFTIntegerList );
    47                                 CreateField( &oField );
    48                         }
     29                                for (int iRing=0; iRing < nRingSize; iRing++)
     30                                {
     31                                        int nCurrentStart = aoVertices.size();
     32                                        poRing = poPoly->getInteriorRing(iRing);
     33                                        anRingStart[iRing+1] = nCurrentStart + poRing->getNumPoints();
     34                                        aoVertices.resize(nCurrentStart + poRing->getNumPoints());
    4935
    50                         std::vector<PCIDSK::ShapeField> aoShapeFields;
    51                         poVecSeg->GetFields(id, aoShapeFields);
     36                                        for(int i = nCurrentStart; i < aoVertices.size(); i++ )
     37                                        {
     38                                                aoVertices[i].x = poRing->getX(i-nCurrentStart);
     39                                                aoVertices[i].y = poRing->getY(i-nCurrentStart);
     40                                                aoVertices[i].z = poRing->getZ(i-nCurrentStart);
     41                                        }
     42                                }
     43                               
     44                                if(iRingStartField == -1)
     45                                {
     46                                        iRingStartField = poVecSeg->GetFieldCount();
     47                                        OGRFieldDefn oField( "RingStart", OFTIntegerList );
     48                                        CreateField( &oField );
     49                                }
    5250
    53                         aoShapeFields[iRingStartField].SetValue(anRingStart);
    54                         poVecSeg->SetFields( id, aoShapeFields );
    55                 }
     51                                std::vector<PCIDSK::ShapeField> aoShapeFields;
     52                                poVecSeg->GetFields(id, aoShapeFields);
     53                                aoShapeFields[iRingStartField].SetValue(anRingStart);
     54                                poVecSeg->SetFields( id, aoShapeFields );
     55                        }
     56                }
     57
    5658}}}