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