MCPcopy Index your code
hub / github.com/MapServer/MapServer / msSHPWriteShape

Function msSHPWriteShape

mapshape.c:674–978  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672}
673
674int msSHPWriteShape(SHPHandle psSHP, shapeObj *shape )
675{
676 int nRecordOffset, i, j, k, nRecordSize=0;
677 uchar *pabyRec;
678 int nShapeType;
679
680 ms_int32 i32, nPoints, nParts;
681#ifdef USE_POINT_Z_M
682 double dfMMin, dfMMax = 0;
683#endif
684 psSHP->bUpdated = MS_TRUE;
685
686 /* Fill the SHX buffer if it is not already full. */
687 if( ! psSHP->panRecAllLoaded ) msSHXLoadAll( psSHP );
688
689 /* -------------------------------------------------------------------- */
690 /* Add the new entity to the in memory index. */
691 /* -------------------------------------------------------------------- */
692 psSHP->nRecords++;
693 if( psSHP->nRecords > psSHP->nMaxRecords ) {
694 psSHP->nMaxRecords = (int) (psSHP->nMaxRecords * 1.3 + 100);
695
696 psSHP->panRecOffset = (int *) SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords );
697 psSHP->panRecSize = (int *) SfRealloc(psSHP->panRecSize,sizeof(int) * psSHP->nMaxRecords );
698 }
699
700 /* -------------------------------------------------------------------- */
701 /* Compute a few things. */
702 /* -------------------------------------------------------------------- */
703 nPoints = 0;
704 for(i=0; i<shape->numlines; i++)
705 nPoints += shape->line[i].numpoints;
706
707 nParts = shape->numlines;
708
709 /* -------------------------------------------------------------------- */
710 /* Initialize record. */
711 /* -------------------------------------------------------------------- */
712 psSHP->panRecOffset[psSHP->nRecords-1] = nRecordOffset = psSHP->nFileSize;
713
714 pabyRec = (uchar *) msSmallMalloc(nPoints * 4 * sizeof(double) + nParts * 8 + 128);
715 nShapeType = psSHP->nShapeType;
716
717 if (shape->type == MS_SHAPE_NULL) {
718 nShapeType = 0;
719 nRecordSize = 12;
720 }
721 /* -------------------------------------------------------------------- */
722 /* Write vertices for a Polygon or Arc. */
723 /* -------------------------------------------------------------------- */
724 else if(psSHP->nShapeType == SHP_POLYGON || psSHP->nShapeType == SHP_ARC ||
725 psSHP->nShapeType == SHP_POLYGONM || psSHP->nShapeType == SHP_ARCM ||
726 psSHP->nShapeType == SHP_ARCZ || psSHP->nShapeType == SHP_POLYGONZ) {
727 ms_int32 t_nParts, t_nPoints, partSize;
728
729 t_nParts = nParts;
730 t_nPoints = nPoints;
731

Callers 4

process_shapefilesFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
shapefileObj_addFunction · 0.85

Calls 5

msSHXLoadAllFunction · 0.85
msSmallMallocFunction · 0.85
writeBoundsFunction · 0.85
SfReallocFunction · 0.70
SwapWordFunction · 0.70

Tested by

no test coverage detected