/ writeHeader() */ / Write out a header for the .shp and .shx files as well as the */ contents of the index (.shx) file. */ /
| 88 | /* contents of the index (.shx) file. */ |
| 89 | /************************************************************************/ |
| 90 | static void writeHeader( SHPHandle psSHP ) |
| 91 | { |
| 92 | uchar abyHeader[100]; |
| 93 | int i; |
| 94 | ms_int32 i32; |
| 95 | double dValue; |
| 96 | ms_int32 *panSHX; |
| 97 | |
| 98 | /* -------------------------------------------------------------------- */ |
| 99 | /* Prepare header block for .shp file. */ |
| 100 | /* -------------------------------------------------------------------- */ |
| 101 | for( i = 0; i < 100; i++ ) |
| 102 | abyHeader[i] = 0; |
| 103 | |
| 104 | abyHeader[2] = 0x27; /* magic cookie */ |
| 105 | abyHeader[3] = 0x0a; |
| 106 | |
| 107 | i32 = psSHP->nFileSize/2; /* file size */ |
| 108 | ByteCopy( &i32, abyHeader+24, 4 ); |
| 109 | if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); |
| 110 | |
| 111 | i32 = 1000; /* version */ |
| 112 | ByteCopy( &i32, abyHeader+28, 4 ); |
| 113 | if( bBigEndian ) SwapWord( 4, abyHeader+28 ); |
| 114 | |
| 115 | i32 = psSHP->nShapeType; /* shape type */ |
| 116 | ByteCopy( &i32, abyHeader+32, 4 ); |
| 117 | if( bBigEndian ) SwapWord( 4, abyHeader+32 ); |
| 118 | |
| 119 | dValue = psSHP->adBoundsMin[0]; /* set bounds */ |
| 120 | ByteCopy( &dValue, abyHeader+36, 8 ); |
| 121 | if( bBigEndian ) SwapWord( 8, abyHeader+36 ); |
| 122 | |
| 123 | dValue = psSHP->adBoundsMin[1]; |
| 124 | ByteCopy( &dValue, abyHeader+44, 8 ); |
| 125 | if( bBigEndian ) SwapWord( 8, abyHeader+44 ); |
| 126 | |
| 127 | dValue = psSHP->adBoundsMax[0]; |
| 128 | ByteCopy( &dValue, abyHeader+52, 8 ); |
| 129 | if( bBigEndian ) SwapWord( 8, abyHeader+52 ); |
| 130 | |
| 131 | dValue = psSHP->adBoundsMax[1]; |
| 132 | ByteCopy( &dValue, abyHeader+60, 8 ); |
| 133 | if( bBigEndian ) SwapWord( 8, abyHeader+60 ); |
| 134 | |
| 135 | dValue = psSHP->adBoundsMin[2]; /* z */ |
| 136 | ByteCopy( &dValue, abyHeader+68, 8 ); |
| 137 | if( bBigEndian ) SwapWord( 8, abyHeader+68 ); |
| 138 | |
| 139 | dValue = psSHP->adBoundsMax[2]; |
| 140 | ByteCopy( &dValue, abyHeader+76, 8 ); |
| 141 | if( bBigEndian ) SwapWord( 8, abyHeader+76 ); |
| 142 | |
| 143 | |
| 144 | dValue = psSHP->adBoundsMin[3]; /* m */ |
| 145 | ByteCopy( &dValue, abyHeader+84, 8 ); |
| 146 | if( bBigEndian ) SwapWord( 8, abyHeader+84 ); |
| 147 |
no test coverage detected