1 /******************************************************************************
2 *
3 * Purpose: Implementation of the CPCIDSKToutinModelSegment class.
4 *
5 ******************************************************************************
6 * Copyright (c) 2009
7 * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 ****************************************************************************/
27
28 #include "segment/cpcidsksegment.h"
29 #include "core/pcidsk_utils.h"
30 #include "segment/cpcidsktoutinmodel.h"
31 #include "pcidsk_exception.h"
32 #include "core/pcidsk_utils.h"
33
34 #include <vector>
35 #include <string>
36 #include <cassert>
37 #include <cstring>
38
39 using namespace PCIDSK;
40
41 namespace
42 {
43 /**
44 * Function to get the minimum value of two values.
45 *
46 * @param a The first value.
47 * @param b The second value.
48 *
49 * @return The minimum value of the two specified values.
50 */
51 #if 0 /* Unused */
52 int MinFunction(int a,int b)
53 {
54 return (a<b)?a:b;
55 }
56 #endif
57 }
58
CPCIDSKToutinModelSegment(PCIDSKFile * file,int segment,const char * segment_pointer)59 CPCIDSKToutinModelSegment::CPCIDSKToutinModelSegment(PCIDSKFile *file,
60 int segment,
61 const char *segment_pointer) :
62 CPCIDSKEphemerisSegment(file, segment, segment_pointer,false)
63 {
64 loaded_ = false;
65 mbModified = false;
66 mpoInfo = NULL;
67 Load();
68 }
69
70
~CPCIDSKToutinModelSegment()71 CPCIDSKToutinModelSegment::~CPCIDSKToutinModelSegment()
72 {
73 delete mpoInfo;
74 }
75
76 /**
77 * Get the SRITInfo_t structure from read from the segment.
78 * @return the Toutin information structure.
79 */
GetInfo() const80 SRITInfo_t CPCIDSKToutinModelSegment::GetInfo() const
81 {
82 return (*mpoInfo);
83 }
84
85 /**
86 * Set the toutin information in the segment. The segment will be tag
87 * as modified and will be synchronize on disk with the next call to
88 * the function synchronize.
89 * @param oInfo the toutin information.
90 */
SetInfo(const SRITInfo_t & oInfo)91 void CPCIDSKToutinModelSegment::SetInfo(const SRITInfo_t& oInfo)
92 {
93 if(&oInfo == mpoInfo)
94 {
95 return ;
96 }
97 if(mpoInfo)
98 {
99 delete mpoInfo;
100 }
101
102 mpoInfo = new SRITInfo_t(oInfo);
103 mbModified = true;
104 }
105
106 /**
107 * Load the contents of the segment
108 */
Load()109 void CPCIDSKToutinModelSegment::Load()
110 {
111 // Check if we've already loaded the segment into memory
112 if (loaded_) {
113 return;
114 }
115
116 seg_data.SetSize((int)data_size - 1024);
117
118 ReadFromFile(seg_data.buffer, 0, data_size - 1024);
119
120 SRITInfo_t* poInfo = BinaryToSRITInfo();
121
122 mpoInfo = poInfo;
123
124 // We've now loaded the structure up with data. Mark it as being loaded
125 // properly.
126 loaded_ = true;
127
128 }
129
130 /**
131 * Write the segment on disk
132 */
Write(void)133 void CPCIDSKToutinModelSegment::Write(void)
134 {
135 //We are not writing if nothing was loaded.
136 if (!loaded_) {
137 return;
138 }
139
140 SRITInfoToBinary(mpoInfo);
141
142 WriteToFile(seg_data.buffer,0,seg_data.buffer_size);
143
144 mbModified = false;
145 }
146
147 /**
148 * Synchronize the segement, if it was modified then
149 * write it into disk.
150 */
Synchronize()151 void CPCIDSKToutinModelSegment::Synchronize()
152 {
153 if(mbModified)
154 {
155 this->Write();
156 }
157 }
158
159 /************************************************************************/
160 /* BinaryToSRITInfo() */
161 /************************************************************************/
162 /**
163 * Translate a block of binary data into a SRIT segment. the caller is
164 * responsible to free the returned memory with delete.
165 *
166 * @return Rational Satellite Model structure.
167 */
168 SRITInfo_t *
BinaryToSRITInfo()169 CPCIDSKToutinModelSegment::BinaryToSRITInfo()
170 {
171 int i,j,k,l;
172 SRITInfo_t *SRITModel;
173 bool bVersion9;
174
175 /* -------------------------------------------------------------------- */
176 /* Read the header block */
177 /* -------------------------------------------------------------------- */
178 // We test the name of the binary segment before starting to read
179 // the buffer.
180 if (std::strncmp(seg_data.buffer, "MODEL ", 8))
181 {
182 seg_data.Put("MODEL ",0,8);
183 return NULL;
184 // Something has gone terribly wrong!
185 /*throw PCIDSKException("A segment that was previously "
186 "identified as an RFMODEL "
187 "segment does not contain the appropriate data. Found: [%s]",
188 std::string(seg_data.buffer, 8).c_str());*/
189 }
190
191 bVersion9 = false;
192 int nVersion = seg_data.GetInt(8,1);
193 if (nVersion == 9)
194 {
195 bVersion9 = true;
196 }
197
198 /* -------------------------------------------------------------------- */
199 /* Allocate the SRITModel. */
200 /* -------------------------------------------------------------------- */
201 SRITModel = new SRITInfo_t();
202
203 SRITModel->GCPMeanHtFlag = 0;
204 SRITModel->nDownSample = 1;
205 if(std::strncmp(seg_data.Get(22,2) , "DS", 2)==0)
206 {
207 SRITModel->nDownSample = seg_data.GetInt(24,3);
208 }
209
210 /* -------------------------------------------------------------------- */
211 /* Read the Block 1 */
212 /* -------------------------------------------------------------------- */
213
214 SRITModel->N0x2 = seg_data.GetDouble(512,22);
215 SRITModel->aa = seg_data.GetDouble(512+22,22);
216 SRITModel->SmALPHA = seg_data.GetDouble(512+44,22);
217 SRITModel->bb = seg_data.GetDouble(512+66,22);
218 SRITModel->C0 = seg_data.GetDouble(512+88,22);
219 SRITModel->cc = seg_data.GetDouble(512+110,22);
220 SRITModel->COS_KHI = seg_data.GetDouble(512+132,22);
221 SRITModel->DELTA_GAMMA = seg_data.GetDouble(512+154,22);
222 SRITModel->GAMMA = seg_data.GetDouble(512+176,22);
223 SRITModel->K_1 = seg_data.GetDouble(512+198,22);
224 SRITModel->L0 = seg_data.GetDouble(512+220,22);
225 SRITModel->P = seg_data.GetDouble(512+242,22);
226 SRITModel->Q = seg_data.GetDouble(512+264,22);
227 SRITModel->TAU = seg_data.GetDouble(512+286,22);
228 SRITModel->THETA = seg_data.GetDouble(512+308,22);
229 SRITModel->THETA_SEC = seg_data.GetDouble(512+330,22);
230 SRITModel->X0 = seg_data.GetDouble(512+352,22);
231 SRITModel->Y0 = seg_data.GetDouble(512+374,22);
232 SRITModel->delh = seg_data.GetDouble(512+396,22);
233 SRITModel->COEF_Y2 = seg_data.GetDouble(512+418,22);
234
235 if (bVersion9)
236 {
237 SRITModel->delT = seg_data.GetDouble(512+440,22);
238 SRITModel->delL = seg_data.GetDouble(512+462,22);
239 SRITModel->delTau = seg_data.GetDouble(512+484,22);
240 }
241 else
242 {
243 SRITModel->delT = 0.0;
244 SRITModel->delL = 0.0;
245 SRITModel->delTau = 0.0;
246 }
247
248 /* -------------------------------------------------------------------- */
249 /* Read the GCP information in Block 2 */
250 /* -------------------------------------------------------------------- */
251
252 SRITModel->nGCPCount = seg_data.GetInt(2*512,10);
253 SRITModel->nEphemerisSegNo = seg_data.GetInt(2*512+10,10);
254 SRITModel->nAttitudeFlag = seg_data.GetInt(2*512+20,10);
255 SRITModel->GCPUnit = seg_data.Get(2*512+30,16);
256
257 SRITModel->dfGCPMeanHt = seg_data.GetDouble(2*512+50,22);
258 SRITModel->dfGCPMinHt = seg_data.GetDouble(2*512+72,22);
259 SRITModel->dfGCPMaxHt = seg_data.GetDouble(2*512+94,22);
260
261 /* -------------------------------------------------------------------- */
262 /* Initialize a simple GeoTransform. */
263 /* -------------------------------------------------------------------- */
264
265 SRITModel->utmunit = seg_data.Get(2*512+225,16);
266
267 if (std::strcmp(seg_data.Get(2*512+245,8),"ProjInfo")==0)
268 {
269 SRITModel->oProjectionInfo = seg_data.Get(2*512+255,256);
270 }
271
272 /* -------------------------------------------------------------------- */
273 /* Read the GCPs */
274 /* -------------------------------------------------------------------- */
275 l = 0;
276 k = 4;
277 for (j=0; j<SRITModel->nGCPCount; j++)
278 {
279 SRITModel->nGCPIds[j] =
280 seg_data.GetInt((k-1)*512+10*l,5);
281 SRITModel->nPixel[j] =
282 seg_data.GetInt((k-1)*512+10*(l+1),5);
283 SRITModel->nLine[j] =
284 seg_data.GetInt((k-1)*512+10*(l+1)+5,5);
285 SRITModel->dfElev[j] =
286 seg_data.GetInt((k-1)*512+10*(l+2),10);
287 l+=3;
288
289 if (l<50)
290 continue;
291
292 k++;
293 l = 0;
294 }
295
296 /* -------------------------------------------------------------------- */
297 /* Call BinaryToEphemeris to get the orbital data */
298 /* -------------------------------------------------------------------- */
299 SRITModel->OrbitPtr =
300 BinaryToEphemeris( 512*21 );
301
302 /* -------------------------------------------------------------------- */
303 /* Pass the sensor back to SRITModel */
304 /* -------------------------------------------------------------------- */
305 SRITModel->Sensor = SRITModel->OrbitPtr->SatelliteSensor;
306
307 /* -------------------------------------------------------------------- */
308 /* Assign nSensor value */
309 /* -------------------------------------------------------------------- */
310
311 SRITModel->nSensor = GetSensor (SRITModel->OrbitPtr);
312 SRITModel->nModel = GetModel (SRITModel->nSensor);
313
314 if( SRITModel->nSensor == -999)
315 {
316 throw PCIDSKException("Invalid Sensor : %s.",
317 SRITModel->OrbitPtr->SatelliteSensor.c_str());
318 }
319 if( SRITModel->nModel == -999)
320 {
321 throw PCIDSKException("Invalid Model from sensor number: %d.",
322 SRITModel->nSensor);
323 }
324
325 /* -------------------------------------------------------------------- */
326 /* Get the attitude data for SPOT */
327 /* -------------------------------------------------------------------- */
328 if (SRITModel->OrbitPtr->AttitudeSeg != NULL ||
329 SRITModel->OrbitPtr->RadarSeg != NULL)
330 {
331 if (SRITModel->OrbitPtr->Type == OrbAttitude)
332 {
333 int ndata;
334 AttitudeSeg_t *attitudeSeg
335 = SRITModel->OrbitPtr->AttitudeSeg;
336
337 ndata = SRITModel->OrbitPtr->AttitudeSeg->NumberOfLine;
338
339 for (i=0; i<ndata; i++)
340 {
341 SRITModel->Hdeltat.push_back(
342 attitudeSeg->Line[i].ChangeInAttitude);
343 SRITModel->Qdeltar.push_back(
344 attitudeSeg->Line[i].ChangeEarthSatelliteDist);
345 }
346 }
347 }
348 else
349 {
350 SRITModel->Qdeltar.clear();
351 SRITModel->Hdeltat.clear();
352 }
353
354 return SRITModel;
355 }
356
357 /************************************************************************/
358 /* SRITInfoToBinary() */
359 /************************************************************************/
360 /**
361 * Translate a SRITInfo_t into binary data.
362 * Translate a SRITInfo_t into the corresponding block of
363 * binary data. This function is expected to be used by
364 * ranslators such as iisopen.c (VISTA) so that our satellite
365 * models can be converted into some opaque serialized form.
366 * Translate a RFInfo_t into the corresponding block of binary data.
367 *
368 * @param SRITModel Satellite Model structure.
369 * @param pnBinaryLength Length of binary data.
370 * @return Binary data for a Satellite Model structure.
371 */
372 void
SRITInfoToBinary(SRITInfo_t * SRITModel)373 CPCIDSKToutinModelSegment::SRITInfoToBinary( SRITInfo_t *SRITModel )
374
375 {
376 int i,j,k,l;
377 double dfminht,dfmaxht,dfmeanht;
378 int nPos = 0;
379
380 /* -------------------------------------------------------------------- */
381 /* Create the data array. */
382 /* -------------------------------------------------------------------- */
383 seg_data.SetSize(512 * 21);
384
385 //clean the buffer
386 memset( seg_data.buffer , ' ', 512 * 21 );
387
388 /* -------------------------------------------------------------------- */
389 /* Initialize the header. */
390 /* -------------------------------------------------------------------- */
391 nPos = 512*0;
392 seg_data.Put("MODEL 9.0",0,nPos+11);
393
394 seg_data.Put("DS",nPos+22,2);
395 seg_data.Put(SRITModel->nDownSample,nPos+24,3);
396
397 /* -------------------------------------------------------------------- */
398 /* Write the model results to second segment */
399 /* -------------------------------------------------------------------- */
400 nPos = 512*1;
401
402 seg_data.Put(SRITModel->N0x2,nPos,22,"%22.14f");
403 seg_data.Put(SRITModel->aa,nPos+22,22,"%22.14f");
404 seg_data.Put(SRITModel->SmALPHA,nPos+22*2,22,"%22.14f");
405 seg_data.Put(SRITModel->bb,nPos+22*3,22,"%22.14f");
406 seg_data.Put(SRITModel->C0,nPos+22*4,22,"%22.14f");
407 seg_data.Put(SRITModel->cc,nPos+22*5,22,"%22.14f");
408 seg_data.Put(SRITModel->COS_KHI,nPos+22*6,22,"%22.14f");
409 seg_data.Put(SRITModel->DELTA_GAMMA,nPos+22*7,22,"%22.14f");
410 seg_data.Put(SRITModel->GAMMA,nPos+22*8,22,"%22.14f");
411 seg_data.Put(SRITModel->K_1,nPos+22*9,22,"%22.14f");
412 seg_data.Put(SRITModel->L0,nPos+22*10,22,"%22.14f");
413 seg_data.Put(SRITModel->P,nPos+22*11,22,"%22.14f");
414 seg_data.Put(SRITModel->Q,nPos+22*12,22,"%22.14f");
415 seg_data.Put(SRITModel->TAU,nPos+22*13,22,"%22.14f");
416 seg_data.Put(SRITModel->THETA,nPos+22*14,22,"%22.14f");
417 seg_data.Put(SRITModel->THETA_SEC,nPos+22*15,22,"%22.14f");
418 seg_data.Put(SRITModel->X0,nPos+22*16,22,"%22.14f");
419 seg_data.Put(SRITModel->Y0,nPos+22*17,22,"%22.14f");
420 seg_data.Put(SRITModel->delh,nPos+22*18,22,"%22.14f");
421 seg_data.Put(SRITModel->COEF_Y2,nPos+22*19,22,"%22.14f");
422 seg_data.Put(SRITModel->delT,nPos+22*20,22,"%22.14f");
423 seg_data.Put(SRITModel->delL,nPos+22*21,22,"%22.14f");
424 seg_data.Put(SRITModel->delTau,nPos+22*22,22,"%22.14f");
425
426 /* -------------------------------------------------------------------- */
427 /* Find the min and max height */
428 /* -------------------------------------------------------------------- */
429 nPos = 2*512;
430
431 if (SRITModel->nGCPCount != 0)
432 {
433 dfminht = 1.e38;
434 dfmaxht = -1.e38;
435 for (i=0; i<SRITModel->nGCPCount; i++)
436 {
437 if (SRITModel->dfElev[i] > dfmaxht)
438 dfmaxht = SRITModel->dfElev[i];
439 if (SRITModel->dfElev[i] < dfminht)
440 dfminht = SRITModel->dfElev[i];
441 }
442 }
443 else
444 {
445 dfminht = SRITModel->dfGCPMinHt;
446 dfmaxht = 0;
447 }
448
449 dfmeanht = (dfminht + dfmaxht)/2.;
450
451 seg_data.Put(SRITModel->nGCPCount,nPos,10);
452 seg_data.Put("2",nPos+10,1);
453 seg_data.Put("0",nPos+20,1);
454
455 if (SRITModel->OrbitPtr->AttitudeSeg != NULL ||
456 SRITModel->OrbitPtr->RadarSeg != NULL ||
457 SRITModel->OrbitPtr->AvhrrSeg != NULL )
458 {
459 if (SRITModel->OrbitPtr->Type == OrbAttitude)
460 {
461 if (SRITModel->OrbitPtr->AttitudeSeg->NumberOfLine != 0)
462 seg_data.Put("3",nPos+20,1);
463 }
464 }
465
466 seg_data.Put(SRITModel->GCPUnit.c_str(),nPos+30,16);
467 seg_data.Put("M",nPos+49,1);
468
469 seg_data.Put(dfmeanht,nPos+50,22,"%22.14f");
470 seg_data.Put(dfminht,nPos+72,22,"%22.14f");
471 seg_data.Put(dfmaxht,nPos+94,22,"%22.14f");
472
473 seg_data.Put("NEWGCP",nPos+116,6);
474
475 /* -------------------------------------------------------------------- */
476 /* Write the projection parameter if necessary */
477 /* -------------------------------------------------------------------- */
478
479 seg_data.Put(SRITModel->utmunit.c_str(),nPos+225,16);
480
481 if(SRITModel->oProjectionInfo.size() > 0)
482 {
483 seg_data.Put("ProjInfo: ",nPos+245,10);
484 seg_data.Put(SRITModel->oProjectionInfo.c_str(),
485 nPos+255,256);
486 }
487
488 /* -------------------------------------------------------------------- */
489 /* Write the GCP to third segment */
490 /* -------------------------------------------------------------------- */
491 nPos = 3*512;
492
493 l = 0;
494 k = 3;
495 for (j=0; j<SRITModel->nGCPCount; j++)
496 {
497 if (j > 255)
498 break;
499
500 seg_data.Put(SRITModel->nGCPIds[j],nPos+10*l,5);
501 seg_data.Put((int)(SRITModel->nPixel[j]+0.5),
502 nPos+10*(l+1),5);
503 seg_data.Put((int)(SRITModel->nLine[j]+0.5),
504 nPos+10*(l+1)+5,5);
505 seg_data.Put((int)SRITModel->dfElev[j],nPos+10*(l+2),10);
506
507 l+=3;
508
509 if (l<50)
510 continue;
511
512 k++;
513 nPos = 512*k;
514 l = 0;
515 }
516
517 /* -------------------------------------------------------------------- */
518 /* Add the serialized form of the EphemerisSeg_t. */
519 /* -------------------------------------------------------------------- */
520 EphemerisToBinary( SRITModel->OrbitPtr , 512*21 );
521 }
522
523 /**
524 * Get the sensor enum from the orbit segment.
525 * @param OrbitPtr the orbit segment
526 * @return the sensor type.
527 */
GetSensor(EphemerisSeg_t * OrbitPtr)528 int CPCIDSKToutinModelSegment::GetSensor( EphemerisSeg_t *OrbitPtr)
529 {
530 int nSensor;
531
532 nSensor = -999;
533
534 if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"AVHRR",5))
535 nSensor = AVHRR;
536 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"PLA",3))
537 nSensor = PLA_1;
538 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MLA",3))
539 nSensor = MLA_1;
540 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ASTER",5))
541 nSensor = ASTER;
542 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"SAR",3))
543 {
544 nSensor = SAR;
545 if (OrbitPtr->PixelRes == 6.25)
546 nSensor = RSAT_FIN;
547 }
548 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-1",6))
549 nSensor = LISS_1;
550 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-2",6))
551 nSensor = LISS_2;
552 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-3",6))
553 nSensor = LISS_3;
554 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-L3-L2",10))
555 nSensor = LISS_L3_L2;
556 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-L3",7))
557 nSensor = LISS_L3;
558 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-L4-L2",10))
559 nSensor = LISS_L4_L2;
560 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-L4",7))
561 nSensor = LISS_L4;
562 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-P3-L2",10))
563 nSensor = LISS_P3_L2;
564 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-P3",7))
565 nSensor = LISS_P3;
566 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-W3-L2",10))
567 nSensor = LISS_W3_L2;
568 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-W3",7))
569 nSensor = LISS_W3;
570 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-M3",7))
571 nSensor = LISS_M3;
572 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-AWF-L2",11))
573 nSensor = LISS_AWF_L2;
574 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"LISS-AWF",8))
575 nSensor = LISS_AWF;
576 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"EOC",3))
577 nSensor = EOC;
578 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"IRS",3))
579 nSensor = IRS_1;
580 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"TM",2))
581 {
582 nSensor = TM;
583 if (OrbitPtr->PixelRes == 15)
584 nSensor = ETM;
585 }
586 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ETM",3))
587 nSensor = ETM;
588 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"IKO",3))
589 {
590 nSensor = IKO_PAN;
591 if (OrbitPtr->PixelRes == 4)
592 nSensor = IKO_MULTI;
593 }
594 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ORBVIEW",7))
595 {
596 nSensor = ORBVIEW_PAN;
597 if (OrbitPtr->PixelRes == 4)
598 nSensor = ORBVIEW_MULTI;
599 }
600 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV",2))
601 {
602 if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV3_PAN_BASIC",13))
603 nSensor = OV3_PAN_BASIC;
604 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV3_PAN_GEO",11))
605 nSensor = OV3_PAN_GEO;
606 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV3_MULTI_BASIC",15))
607 nSensor = OV3_MULTI_BASIC;
608 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV3_MULTI_GEO",13))
609 nSensor = OV3_MULTI_GEO;
610 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV5_PAN_BASIC",13))
611 nSensor = OV5_PAN_BASIC;
612 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV5_PAN_GEO",11))
613 nSensor = OV5_PAN_GEO;
614 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV5_MULTI_BASIC",15))
615 nSensor = OV5_MULTI_BASIC;
616 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"OV5_MULTI_GEO",13))
617 nSensor = OV5_MULTI_GEO;
618 }
619 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_PAN_STD",13))
620 nSensor = QBIRD_PAN_STD; // this checking must go first
621 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_PAN_STH",13))
622 nSensor = QBIRD_PAN_STH;
623 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_PAN",9))
624 nSensor = QBIRD_PAN;
625 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_MULTI_STD",15))
626 nSensor = QBIRD_MULTI_STD; // this checking must go first
627 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_MULTI_STH",15))
628 nSensor = QBIRD_MULTI_STH;
629 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"QBIRD_MULTI",11))
630 nSensor = QBIRD_MULTI;
631 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW1_PAN_STD",14) ||
632 EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW_PAN_STD",13))
633 nSensor = WVIEW_PAN_STD; // this checking must go first
634 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW1_PAN",10) ||
635 EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW_PAN",9))
636 nSensor = WVIEW_PAN;
637 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW_MULTI_STD",15))
638 nSensor = WVIEW_MULTI_STD;
639 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"WVIEW_MULTI",11))
640 nSensor = WVIEW_MULTI;
641 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"FORMOSAT",8))
642 {
643 if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"FORMOSAT_PAN_L2",15))
644 nSensor = FORMOSAT_PAN_L2;
645 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"FORMOSAT_MULTIL2",16))
646 nSensor = FORMOSAT_MULTIL2;
647 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"FORMOSAT_PAN",12))
648 nSensor = FORMOSAT_PAN;
649 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"FORMOSAT_MULTI",14))
650 nSensor = FORMOSAT_MULTI;
651 }
652 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"SPOT5_PAN_2_5",13))
653 nSensor = SPOT5_PAN_2_5;
654 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"SPOT5_PAN_5",11))
655 nSensor = SPOT5_PAN_5;
656 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"SPOT5_HRS",9))
657 nSensor = SPOT5_HRS;
658 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"SPOT5_MULTI",11))
659 nSensor = SPOT5_MULTI;
660 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MERIS_FR",8))
661 nSensor = MERIS_FR;
662 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MERIS_RR",8))
663 nSensor = MERIS_RR;
664 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MERIS_LR",8))
665 nSensor = MERIS_LR;
666 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ASAR",4))
667 nSensor = ASAR;
668 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"EROS",4))
669 nSensor = EROS;
670 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MODIS_1000",10))
671 nSensor = MODIS_1000;
672 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MODIS_500",9))
673 nSensor = MODIS_500;
674 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"MODIS_250",9))
675 nSensor = MODIS_250;
676 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_HRC_L2",12))
677 nSensor = CBERS_HRC_L2;
678 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_HRC",9))
679 nSensor = CBERS_HRC;
680 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_CCD_L2",12))
681 nSensor = CBERS_CCD_L2;
682 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_CCD",9))
683 nSensor = CBERS_CCD;
684 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_IRM_80_L2",15))
685 nSensor = CBERS_IRM_80_L2;
686 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_IRM_80",12))
687 nSensor = CBERS_IRM_80;
688 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_IRM_160_L2",16))
689 nSensor = CBERS_IRM_160_L2;
690 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_IRM_160",13))
691 nSensor = CBERS_IRM_160;
692 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_WFI_L2",12))
693 nSensor = CBERS_WFI_L2;
694 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CBERS_WFI",9))
695 nSensor = CBERS_WFI;
696 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CARTOSAT1_L1",12))
697 nSensor = CARTOSAT1_L1;
698 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"CARTOSAT1_L2",12))
699 nSensor = CARTOSAT1_L2;
700 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"DMC_1R",6))
701 nSensor = DMC_1R;
702 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"DMC_1T",6))
703 nSensor = DMC_1T;
704 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ALOS_PRISM_L1",13))
705 nSensor = ALOS_PRISM_L1;
706 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ALOS_PRISM_L2",13))
707 nSensor = ALOS_PRISM_L2;
708 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ALOS_AVNIR_L1",13))
709 nSensor = ALOS_AVNIR_L1;
710 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"ALOS_AVNIR_L2",13))
711 nSensor = ALOS_AVNIR_L2;
712 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"PALSAR",6))
713 nSensor = PALSAR;
714 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"KOMPSAT2_PAN",12))
715 nSensor = KOMPSAT2_PAN;
716 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"KOMPSAT2_MULTI",14))
717 nSensor = KOMPSAT2_MULTI;
718 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"TERRASAR",8))
719 nSensor = TERRASAR;
720 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"RAPIDEYE",8))
721 nSensor = RAPIDEYE_L1B;
722 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"THEOS_PAN_L1",12))
723 nSensor = THEOS_PAN_L1;
724 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"THEOS_PAN_L2",12))
725 nSensor = THEOS_PAN_L2;
726 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"THEOS_MS_L1",11))
727 nSensor = THEOS_MS_L1;
728 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"THEOS_MS_L2",11))
729 nSensor = THEOS_MS_L2;
730 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"GOSAT_500_L1",12))
731 nSensor = GOSAT_500_L1;
732 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"GOSAT_500_L2",12))
733 nSensor = GOSAT_500_L2;
734 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"GOSAT_1500_L1",13))
735 nSensor = GOSAT_1500_L1;
736 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"GOSAT_1500_L2",13))
737 nSensor = GOSAT_1500_L2;
738 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"HJ_CCD_1A",9))
739 nSensor = HJ_CCD_1A;
740 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"HJ_CCD_1B",5))
741 nSensor = HJ_CCD_1B;
742 else if (EQUALN(OrbitPtr->SatelliteSensor.c_str(),"NEW",3))
743 nSensor = NEW;
744 else
745 {
746 throw PCIDSKException("Invalid Sensor %s",
747 OrbitPtr->SatelliteSensor.c_str());
748 }
749
750 return (nSensor);
751 }
752 /**
753 * Get the model of a sensor
754 * @param nSensor the sensor
755 * @return the model
756 */
GetModel(int nSensor)757 int CPCIDSKToutinModelSegment::GetModel( int nSensor )
758 {
759 int nModel;
760
761 nModel = -999;
762
763 switch (nSensor)
764 {
765 case PLA_1:
766 case PLA_2:
767 case PLA_3:
768 case PLA_4:
769 case MLA_1:
770 case MLA_2:
771 case MLA_3:
772 case MLA_4:
773 case NEW:
774 nModel = SRITModele;
775 break;
776
777 case ASTER:
778 case CBERS_CCD:
779 case CBERS_IRM_80:
780 case CBERS_IRM_160:
781 case CBERS_WFI:
782 case IRS_1:
783 case LISS_AWF:
784 case LISS_1:
785 case LISS_2:
786 case LISS_3:
787 case LISS_L3:
788 case LISS_L4:
789 case LISS_P3:
790 case LISS_W3:
791 case LISS_M3:
792 case EOC:
793 case SPOT5_PAN_5:
794 case SPOT5_HRS:
795 case SPOT5_MULTI:
796 case MERIS_FR:
797 case MERIS_RR:
798 case MERIS_LR:
799 case MODIS_1000:
800 case MODIS_500:
801 case MODIS_250:
802 case ALOS_AVNIR_L1:
803 case ALOS_AVNIR_L2:
804 case RAPIDEYE_L1B:
805 case THEOS_PAN_L1:
806 case THEOS_MS_L1:
807 case GOSAT_500_L1:
808 case GOSAT_1500_L1:
809 case HJ_CCD_1A:
810 nModel = SRITModele1A;
811 break;
812
813 case TM:
814 case ETM:
815 case LISS_P3_L2:
816 case LISS_L3_L2:
817 case LISS_W3_L2:
818 case LISS_L4_L2:
819 case LISS_AWF_L2:
820 case CBERS_IRM_80_L2:
821 case CBERS_IRM_160_L2:
822 case CBERS_WFI_L2:
823 case CBERS_CCD_L2:
824 case CBERS_HRC_L2:
825 case DMC_1R:
826 case DMC_1T:
827 case ALOS_PRISM_L2:
828 case THEOS_PAN_L2:
829 case THEOS_MS_L2:
830 case GOSAT_500_L2:
831 case GOSAT_1500_L2:
832 case HJ_CCD_1B:
833 nModel = SRITModele1B;
834 break;
835
836 case SAR:
837 case RSAT_FIN:
838 case RSAT_STD:
839 case ERS_1:
840 case ERS_2:
841 case ASAR:
842 case QBIRD_PAN_STD:
843 case QBIRD_MULTI_STD:
844 case WVIEW_PAN_STD:
845 case WVIEW_MULTI_STD:
846 case IKO_PAN:
847 case IKO_MULTI:
848 case CARTOSAT1_L2:
849 case PALSAR:
850 case FORMOSAT_PAN_L2:
851 case FORMOSAT_MULTIL2:
852 case TERRASAR:
853 case OV3_PAN_GEO:
854 case OV3_MULTI_GEO:
855 case OV5_PAN_GEO:
856 case OV5_MULTI_GEO:
857 nModel = SRITModeleSAR;
858 break;
859
860 case ORBVIEW_PAN:
861 case ORBVIEW_MULTI:
862 case QBIRD_PAN:
863 case QBIRD_MULTI:
864 case WVIEW_PAN:
865 case WVIEW_MULTI:
866 case SPOT5_PAN_2_5:
867 case CARTOSAT1_L1:
868 case ALOS_PRISM_L1:
869 case KOMPSAT2_PAN:
870 case KOMPSAT2_MULTI:
871 case CBERS_HRC:
872 case OV3_PAN_BASIC:
873 case OV3_MULTI_BASIC:
874 case OV5_PAN_BASIC:
875 case OV5_MULTI_BASIC:
876 nModel = SRITModele1AHR;
877 break;
878
879 case EROS:
880 case QBIRD_PAN_STH:
881 case QBIRD_MULTI_STH:
882 case FORMOSAT_PAN:
883 case FORMOSAT_MULTI:
884 nModel = SRITModeleEros;
885 break;
886
887 default:
888 throw PCIDSKException("Invalid sensor type.");
889 break;
890 }
891
892 return (nModel);
893 }
894
895