| | 1114 | } |
|---|
| | 1115 | |
|---|
| | 1116 | /************************************************************************/ |
|---|
| | 1117 | /* HFASetPEString() */ |
|---|
| | 1118 | /************************************************************************/ |
|---|
| | 1119 | |
|---|
| | 1120 | CPLErr HFASetPEString( HFAHandle hHFA, const char *pszPEString ) |
|---|
| | 1121 | |
|---|
| | 1122 | { |
|---|
| | 1123 | /* -------------------------------------------------------------------- */ |
|---|
| | 1124 | /* Verify we don't already have the node, since update-in-place */ |
|---|
| | 1125 | /* is likely to be more complicated. */ |
|---|
| | 1126 | /* -------------------------------------------------------------------- */ |
|---|
| | 1127 | if( hHFA->nBands == 0 ) |
|---|
| | 1128 | return CE_None; |
|---|
| | 1129 | |
|---|
| | 1130 | HFAEntry *poProX; |
|---|
| | 1131 | |
|---|
| | 1132 | poProX = hHFA->papoBand[0]->poNode->GetNamedChild( "ProjectionX" ); |
|---|
| | 1133 | if( poProX != NULL ) |
|---|
| | 1134 | { |
|---|
| | 1135 | CPLError( CE_Failure, CPLE_AppDefined, |
|---|
| | 1136 | "HFASetPEString() failed because the ProjectionX node\n" |
|---|
| | 1137 | "already exists and can't be reliably updated." ); |
|---|
| | 1138 | return CE_Failure; |
|---|
| | 1139 | } |
|---|
| | 1140 | |
|---|
| | 1141 | /* -------------------------------------------------------------------- */ |
|---|
| | 1142 | /* Create the node. */ |
|---|
| | 1143 | /* -------------------------------------------------------------------- */ |
|---|
| | 1144 | poProX = new HFAEntry( hHFA, "ProjectionX","Eprj_MapProjection842", |
|---|
| | 1145 | hHFA->papoBand[0]->poNode ); |
|---|
| | 1146 | if( poProX == NULL ) |
|---|
| | 1147 | return CE_Failure; |
|---|
| | 1148 | |
|---|
| | 1149 | GByte *pabyData = poProX->MakeData( 700 + strlen(pszPEString) ); |
|---|
| | 1150 | memset( pabyData, 0, 250+strlen(pszPEString) ); |
|---|
| | 1151 | |
|---|
| | 1152 | poProX->SetPosition(); |
|---|
| | 1153 | |
|---|
| | 1154 | poProX->SetStringField( "projection.type.string", "PE_COORDSYS" ); |
|---|
| | 1155 | poProX->SetStringField( "projection.MIFDictionary.string", |
|---|
| | 1156 | "{0:pcstring,}Emif_String,{1:x{0:pcstring,}Emif_String,coordSys,}PE_COORDSYS,." ); |
|---|
| | 1157 | |
|---|
| | 1158 | /* -------------------------------------------------------------------- */ |
|---|
| | 1159 | /* Use a gross hack to scan ahead to the actual projection */ |
|---|
| | 1160 | /* string. We do it this way because we don't have general */ |
|---|
| | 1161 | /* handling for MIFObjects. */ |
|---|
| | 1162 | /* -------------------------------------------------------------------- */ |
|---|
| | 1163 | pabyData = poProX->GetData(); |
|---|
| | 1164 | int nDataSize = poProX->GetDataSize(); |
|---|
| | 1165 | GUInt32 iOffset = poProX->GetDataPos(); |
|---|
| | 1166 | GUInt32 nSize; |
|---|
| | 1167 | |
|---|
| | 1168 | while( nDataSize > 10 |
|---|
| | 1169 | && !EQUALN((const char *) pabyData,"PE_COORDSYS,.",13) ) { |
|---|
| | 1170 | pabyData++; |
|---|
| | 1171 | nDataSize--; |
|---|
| | 1172 | iOffset++; |
|---|
| | 1173 | } |
|---|
| | 1174 | |
|---|
| | 1175 | CPLAssert( nDataSize > (int) strlen(pszPEString) + 10 ); |
|---|
| | 1176 | |
|---|
| | 1177 | pabyData += 14; |
|---|
| | 1178 | iOffset += 14; |
|---|
| | 1179 | |
|---|
| | 1180 | /* -------------------------------------------------------------------- */ |
|---|
| | 1181 | /* Set the size and offset of the mifobject. */ |
|---|
| | 1182 | /* -------------------------------------------------------------------- */ |
|---|
| | 1183 | iOffset += 8; |
|---|
| | 1184 | |
|---|
| | 1185 | nSize = strlen(pszPEString) + 9; |
|---|
| | 1186 | |
|---|
| | 1187 | HFAStandard( 4, nSize ); |
|---|
| | 1188 | memcpy( pabyData, &nSize, 4 ); |
|---|
| | 1189 | pabyData += 4; |
|---|
| | 1190 | |
|---|
| | 1191 | HFAStandard( 4, &iOffset ); |
|---|
| | 1192 | memcpy( pabyData, &iOffset, 4 ); |
|---|
| | 1193 | pabyData += 4; |
|---|
| | 1194 | |
|---|
| | 1195 | /* -------------------------------------------------------------------- */ |
|---|
| | 1196 | /* Set the size and offset of the string value. */ |
|---|
| | 1197 | /* -------------------------------------------------------------------- */ |
|---|
| | 1198 | nSize = strlen(pszPEString) + 1; |
|---|
| | 1199 | |
|---|
| | 1200 | HFAStandard( 4, nSize ); |
|---|
| | 1201 | memcpy( pabyData, &nSize, 4 ); |
|---|
| | 1202 | pabyData += 4; |
|---|
| | 1203 | |
|---|
| | 1204 | iOffset = 8; |
|---|
| | 1205 | HFAStandard( 4, &iOffset ); |
|---|
| | 1206 | memcpy( pabyData, &iOffset, 4 ); |
|---|
| | 1207 | pabyData += 4; |
|---|
| | 1208 | |
|---|
| | 1209 | /* -------------------------------------------------------------------- */ |
|---|
| | 1210 | /* Place the string itself. */ |
|---|
| | 1211 | /* -------------------------------------------------------------------- */ |
|---|
| | 1212 | memcpy( pabyData, pszPEString, strlen(pszPEString)+1 ); |
|---|
| | 1213 | |
|---|
| | 1214 | poProX->SetStringField( "title.string", "PE" ); |
|---|
| | 1215 | |
|---|
| | 1216 | return CE_None; |
|---|
| 1538 | 1644 | "{1:oEmif_String,dependent,}Eimg_DependentFile,{1:oEmif_String,ImageLayerName,}Eimg_DependentLayerName,{1:lnumrows,1:lnumcolumns,1:e13:EGDA_TYPE_U1,EGDA_TYPE_U2,EGDA_TYPE_U4,EGDA_TYPE_U8,EGDA_TYPE_S8,EGDA_TYPE_U16,EGDA_TYPE_S16,EGDA_TYPE_U32,EGDA_TYPE_S32,EGDA_TYPE_F32,EGDA_TYPE_F64,EGDA_TYPE_C64,EGDA_TYPE_C128,datatype,1:e4:EGDA_SCALAR_OBJECT,EGDA_TABLE_OBJECT,EGDA_MATRIX_OBJECT,EGDA_RASTER_OBJECT,objecttype,}Egda_BaseData,{1:*bvalueBD,}Eimg_NonInitializedValue,{1:dx,1:dy,}Eprj_Coordinate,{1:dwidth,1:dheight,}Eprj_Size,{0:pcproName,1:*oEprj_Coordinate,upperLeftCenter,", |
|---|
| 1539 | 1645 | "1:*oEprj_Coordinate,lowerRightCenter,1:*oEprj_Size,pixelSize,0:pcunits,}Eprj_MapInfo,{0:pcdatumname,1:e3:EPRJ_DATUM_PARAMETRIC,EPRJ_DATUM_GRID,EPRJ_DATUM_REGRESSION,type,0:pdparams,0:pcgridname,}Eprj_Datum,{0:pcsphereName,1:da,1:db,1:deSquared,1:dradius,}Eprj_Spheroid,{1:e2:EPRJ_INTERNAL,EPRJ_EXTERNAL,proType,1:lproNumber,0:pcproExeName,0:pcproName,1:lproZone,0:pdproParams,1:*oEprj_Spheroid,proSpheroid,}Eprj_ProParameters,{1:dminimum,1:dmaximum,1:dmean,1:dmedian,1:dmode,1:dstddev,}Esta_Statistics,{1:lnumBins,1:e4:direct,linear,logarithmic,explicit,binFunctionType,1:dminLimit,1:dmaxLimit,1:*bbinLimits,}Edsc_BinFunction,{0:poEmif_String,LayerNames,1:*bExcludedValues,1:oEmif_String,AOIname,", |
|---|
| 1540 | | "1:lSkipFactorX,1:lSkipFactorY,1:*oEdsc_BinFunction,BinFunction,}Eimg_StatisticsParameters830,{1:lnumrows,}Edsc_Table,{1:lnumRows,1:LcolumnDataPtr,1:e4:integer,real,complex,string,dataType,1:lmaxNumChars,}Edsc_Column,{1:lposition,0:pcname,1:e2:EMSC_FALSE,EMSC_TRUE,editable,1:e3:LEFT,CENTER,RIGHT,alignment,0:pcformat,1:e3:DEFAULT,APPLY,AUTO-APPLY,formulamode,0:pcformula,1:dcolumnwidth,0:pcunits,1:e5:NO_COLOR,RED,GREEN,BLUE,COLOR,colorflag,0:pcgreenname,0:pcbluename,}Eded_ColumnAttributes_1,{1:lversion,1:lnumobjects,1:e2:EAOI_UNION,EAOI_INTERSECTION,operation,}Eaoi_AreaOfInterest,.", |
|---|
| | 1646 | "1:lSkipFactorX,1:lSkipFactorY,1:*oEdsc_BinFunction,BinFunction,}Eimg_StatisticsParameters830,{1:lnumrows,}Edsc_Table,{1:lnumRows,1:LcolumnDataPtr,1:e4:integer,real,complex,string,dataType,1:lmaxNumChars,}Edsc_Column,{1:lposition,0:pcname,1:e2:EMSC_FALSE,EMSC_TRUE,editable,1:e3:LEFT,CENTER,RIGHT,alignment,0:pcformat,1:e3:DEFAULT,APPLY,AUTO-APPLY,formulamode,0:pcformula,1:dcolumnwidth,0:pcunits,1:e5:NO_COLOR,RED,GREEN,BLUE,COLOR,colorflag,0:pcgreenname,0:pcbluename,}Eded_ColumnAttributes_1,{1:lversion,1:lnumobjects,1:e2:EAOI_UNION,EAOI_INTERSECTION,operation,}Eaoi_AreaOfInterest,", |
|---|
| | 1647 | "{1:x{0:pcstring,}Emif_String,type,1:x{0:pcstring,}Emif_String,MIFDictionary,0:pCMIFObject,}Emif_MIFObject,", |
|---|
| | 1648 | "{1:x{1:x{0:pcstring,}Emif_String,type,1:x{0:pcstring,}Emif_String,MIFDictionary,0:pCMIFObject,}Emif_MIFObject,projection,1:x{0:pcstring,}Emif_String,title,}Eprj_MapProjection842,", |
|---|
| | 1649 | ".", |
|---|