Opened 9 years ago

Closed 5 years ago

#5803 closed defect (wontfix)

OGR can't create PCIDSK polygon file

Reported by: liminlu0314 Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: OGR_SF Version: unspecified
Severity: normal Keywords: PCIDSK Polygon
Cc:

Description (last modified by liminlu0314)

OGR cannot create the PCIDSK polygon vector data, Found in the GDAL library code is not achieved, I realize part of the code, surface vector data can create PCIDSK type.

The modified code is as follows: ogrpcidsklayer.cpp file OGRErr OGRPCIDSKLayer::SetFeature( OGRFeature *poFeature ):

		else if( wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon )
		{
			OGRPolygon *poPoly = (OGRPolygon *) poGeometry;
			OGRLinearRing *poRing = NULL;
			poRing = poPoly->getExteriorRing();
			
			aoVertices.resize(poRing->getNumPoints());
			for(int i = 0; i < aoVertices.size(); i++ )
			{
				aoVertices[i].x = poRing->getX(i);
				aoVertices[i].y = poRing->getY(i);
				aoVertices[i].z = poRing->getZ(i);
			}

			int nRingSize = poPoly->getNumInteriorRings();
			if(nRingSize > 0 )
			{
				std::vector<PCIDSK::int32> anRingStart;
				anRingStart.resize(nRingSize+1);
				anRingStart[0] = poRing->getNumPoints();

				for (int iRing=0; iRing < nRingSize; iRing++)
				{
					int nCurrentStart = aoVertices.size();
					poRing = poPoly->getInteriorRing(iRing);
					anRingStart[iRing+1] = nCurrentStart + poRing->getNumPoints();
					aoVertices.resize(nCurrentStart + poRing->getNumPoints());

					for(int i = nCurrentStart; i < aoVertices.size(); i++ )
					{
						aoVertices[i].x = poRing->getX(i-nCurrentStart);
						aoVertices[i].y = poRing->getY(i-nCurrentStart);
						aoVertices[i].z = poRing->getZ(i-nCurrentStart);
					}
				}
				
				if(iRingStartField == -1)
				{
					iRingStartField = poVecSeg->GetFieldCount();
					OGRFieldDefn oField( "RingStart", OFTIntegerList );
					CreateField( &oField );
				}

				std::vector<PCIDSK::ShapeField> aoShapeFields;
				poVecSeg->GetFields(id, aoShapeFields);
				aoShapeFields[iRingStartField].SetValue(anRingStart);
				poVecSeg->SetFields( id, aoShapeFields );
			}
		}

Change History (4)

comment:1 by liminlu0314, 9 years ago

Description: modified (diff)

comment:2 by Even Rouault, 9 years ago

The creation of the RingStart field is inappropriate in SetFeature() as it modifies the schema of existing features and could result in crashes. That field should be available as soon GetLayerDefn() is called.

comment:3 by Even Rouault, 9 years ago

Milestone: 1.11.2

comment:4 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.