SDTS_AL
Main Page
Related Pages
Classes
Files
File List
File Members
sdts_al.h
1
/******************************************************************************
2
* $Id: sdts_al.h 19952 2010-07-02 05:44:18Z warmerdam $
3
*
4
* Project: SDTS Translator
5
* Purpose: Include file for entire SDTS Abstraction Layer functions.
6
* Author: Frank Warmerdam, warmerdam@pobox.com
7
*
8
******************************************************************************
9
* Copyright (c) 1999, Frank Warmerdam
10
*
11
* Permission is hereby granted, free of charge, to any person obtaining a
12
* copy of this software and associated documentation files (the "Software"),
13
* to deal in the Software without restriction, including without limitation
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
* and/or sell copies of the Software, and to permit persons to whom the
16
* Software is furnished to do so, subject to the following conditions:
17
*
18
* The above copyright notice and this permission notice shall be included
19
* in all copies or substantial portions of the Software.
20
*
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
* DEALINGS IN THE SOFTWARE.
28
****************************************************************************/
29
30
#ifndef SDTS_AL_H_INCLUDED
31
#define STDS_AL_H_INCLUDED
32
33
#include "
cpl_conv.h
"
34
#include "iso8211.h"
35
36
class
SDTS_IREF
;
37
class
SDTSModId
;
38
class
SDTSTransfer
;
39
40
#define SDTS_SIZEOF_SADR 8
41
42
char
**SDTSScanModuleReferences(
DDFModule
*,
const
char
* );
43
44
/************************************************************************/
45
/* SDTS_IREF */
46
/************************************************************************/
47
53
class
SDTS_IREF
54
{
55
int
nDefaultSADRFormat;
56
57
public
:
58
SDTS_IREF
();
59
~
SDTS_IREF
();
60
61
int
Read(
const
char
*pszFilename );
62
63
char
*pszXAxisName;
/* XLBL */
64
char
*pszYAxisName;
/* YLBL */
65
66
double
dfXScale;
/* SFAX */
67
double
dfYScale;
/* SFAY */
68
69
double
dfXOffset;
/* XORG */
70
double
dfYOffset;
/* YORG */
71
72
double
dfXRes;
/* XHRS */
73
double
dfYRes;
/* YHRS */
74
75
char
*pszCoordinateFormat;
/* HFMT */
76
77
int
GetSADRCount(
DDFField
* );
78
int
GetSADR(
DDFField
*,
int
,
double
*,
double
*,
double
* );
79
};
80
81
/************************************************************************/
82
/* SDTS_XREF */
83
/************************************************************************/
84
90
class
SDTS_XREF
91
{
92
public
:
93
SDTS_XREF
();
94
~
SDTS_XREF
();
95
96
int
Read(
const
char
*pszFilename );
97
100
char
*
pszSystemName
;
101
102
105
char
*
pszDatum
;
106
108
int
nZone
;
109
};
110
111
/************************************************************************/
112
/* SDTS_CATD */
113
/************************************************************************/
114
class
SDTS_CATDEntry
;
115
120
typedef
enum
{
121
SLTUnknown,
122
SLTPoint,
123
SLTLine,
124
SLTAttr,
125
SLTPoly,
126
SLTRaster
127
} SDTSLayerType;
128
133
class
SDTS_CATD
134
{
135
char
*pszPrefixPath;
136
137
int
nEntries;
138
SDTS_CATDEntry
**papoEntries;
139
140
public
:
141
SDTS_CATD
();
142
~
SDTS_CATD
();
143
144
int
Read(
const
char
* pszFilename );
145
146
const
char
*GetModuleFilePath(
const
char
* pszModule );
147
148
int
GetEntryCount() {
return
nEntries; }
149
const
char
* GetEntryModule(
int
);
150
const
char
*
GetEntryTypeDesc
(
int
);
151
const
char
*
GetEntryFilePath
(
int
);
152
SDTSLayerType
GetEntryType
(
int
);
153
};
154
155
/************************************************************************/
156
/* SDTSModId */
157
/************************************************************************/
158
163
class
SDTSModId
164
{
165
public
:
166
SDTSModId
() {
szModule
[0] =
'\0'
;
167
nRecord
= -1;
168
szOBRP
[0] =
'\0'
; }
169
170
int
Set(
DDFField
* );
171
172
const
char
*GetName();
173
175
char
szModule
[8];
176
179
long
nRecord
;
180
183
char
szOBRP
[8];
184
};
185
186
/************************************************************************/
187
/* SDTSFeature */
188
/************************************************************************/
189
194
class
SDTSFeature
195
{
196
public
:
197
198
SDTSFeature
();
199
virtual
~
SDTSFeature
();
200
202
SDTSModId
oModId
;
203
205
int
nAttributes
;
206
209
SDTSModId
*
paoATID
;
210
211
void
ApplyATID(
DDFField
* );
212
213
215
virtual
void
Dump
( FILE * ) = 0;
216
};
217
218
/************************************************************************/
219
/* SDTSIndexedReader */
220
/************************************************************************/
221
227
class
SDTSIndexedReader
228
{
229
int
nIndexSize;
230
SDTSFeature
**papoFeatures;
231
232
int
iCurrentFeature;
233
234
protected
:
235
DDFModule
oDDFModule;
236
237
public
:
238
SDTSIndexedReader
();
239
virtual
~
SDTSIndexedReader
();
240
241
virtual
SDTSFeature
*GetNextRawFeature() = 0;
242
243
SDTSFeature
*
GetNextFeature
();
244
245
virtual
void
Rewind
();
246
247
void
FillIndex
();
248
void
ClearIndex
();
249
int
IsIndexed
();
250
251
SDTSFeature
*
GetIndexedFeatureRef
(
int
);
252
char
**
ScanModuleReferences
(
const
char
* =
"ATID"
);
253
254
DDFModule
*GetModule() {
return
&oDDFModule; }
255
};
256
257
258
/************************************************************************/
259
/* SDTSRawLine */
260
/************************************************************************/
261
264
class
SDTSRawLine
:
public
SDTSFeature
265
{
266
public
:
267
SDTSRawLine
();
268
virtual
~
SDTSRawLine
();
269
270
int
Read(
SDTS_IREF
*,
DDFRecord
* );
271
273
int
nVertices
;
274
276
double
*
padfX
;
278
double
*
padfY
;
280
double
*
padfZ
;
281
284
SDTSModId
oLeftPoly
;
285
288
SDTSModId
oRightPoly
;
289
292
SDTSModId
oStartNode
;
/* SNID */
293
296
SDTSModId
oEndNode
;
/* ENID */
297
298
void
Dump
( FILE * );
299
};
300
301
/************************************************************************/
302
/* SDTSLineReader */
303
/* */
304
/* Class for reading any of the files lines. */
305
/************************************************************************/
306
315
class
SDTSLineReader
:
public
SDTSIndexedReader
316
{
317
SDTS_IREF
*poIREF;
318
319
public
:
320
SDTSLineReader
(
SDTS_IREF
* );
321
~
SDTSLineReader
();
322
323
int
Open(
const
char
* );
324
SDTSRawLine
*GetNextLine(
void
);
325
void
Close();
326
327
SDTSFeature
*GetNextRawFeature(
void
) {
return
GetNextLine(); }
328
329
void
AttachToPolygons
(
SDTSTransfer
*,
int
iPolyLayer );
330
};
331
332
/************************************************************************/
333
/* SDTSAttrRecord */
334
/************************************************************************/
335
345
class
SDTSAttrRecord
:
public
SDTSFeature
346
{
347
public
:
348
SDTSAttrRecord
();
349
virtual
~
SDTSAttrRecord
();
350
352
DDFRecord
*
poWholeRecord
;
353
357
DDFField
*
poATTR
;
358
359
virtual
void
Dump
( FILE * );
360
};
361
362
/************************************************************************/
363
/* SDTSAttrReader */
364
/************************************************************************/
365
371
class
SDTSAttrReader
:
public
SDTSIndexedReader
372
{
373
SDTS_IREF
*poIREF;
374
375
int
bIsSecondary;
376
377
public
:
378
SDTSAttrReader
(
SDTS_IREF
* );
379
virtual
~
SDTSAttrReader
();
380
381
int
Open(
const
char
* );
382
DDFField
*GetNextRecord(
SDTSModId
* = NULL,
383
DDFRecord
** = NULL,
384
int
bDuplicate = FALSE );
385
SDTSAttrRecord
*GetNextAttrRecord();
386
void
Close();
387
392
int
IsSecondary
() {
return
bIsSecondary; }
393
394
SDTSFeature
*GetNextRawFeature(
void
) {
return
GetNextAttrRecord(); }
395
};
396
397
/************************************************************************/
398
/* SDTSRawPoint */
399
/************************************************************************/
400
404
class
SDTSRawPoint
:
public
SDTSFeature
405
{
406
public
:
407
SDTSRawPoint
();
408
virtual
~
SDTSRawPoint
();
409
410
int
Read(
SDTS_IREF
*,
DDFRecord
* );
411
413
double
dfX
;
415
double
dfY
;
417
double
dfZ
;
418
420
SDTSModId
oAreaId
;
/* ARID */
421
422
virtual
void
Dump
( FILE * );
423
};
424
425
/************************************************************************/
426
/* SDTSPointReader */
427
/************************************************************************/
428
434
class
SDTSPointReader
:
public
SDTSIndexedReader
435
{
436
SDTS_IREF
*poIREF;
437
438
public
:
439
SDTSPointReader
(
SDTS_IREF
* );
440
virtual
~
SDTSPointReader
();
441
442
int
Open(
const
char
* );
443
SDTSRawPoint
*GetNextPoint(
void
);
444
void
Close();
445
446
SDTSFeature
*GetNextRawFeature(
void
) {
return
GetNextPoint(); }
447
};
448
449
/************************************************************************/
450
/* SDTSRawPolygon */
451
/************************************************************************/
452
470
class
SDTSRawPolygon
:
public
SDTSFeature
471
{
472
void
AddEdgeToRing(
int
,
double
*,
double
*,
double
*,
int
,
int
);
473
474
public
:
475
SDTSRawPolygon
();
476
virtual
~
SDTSRawPolygon
();
477
478
int
Read(
DDFRecord
* );
479
480
int
nEdges;
481
SDTSRawLine
**papoEdges;
482
483
void
AddEdge(
SDTSRawLine
* );
484
487
int
AssembleRings
();
488
490
int
nRings
;
492
int
nVertices
;
495
int
*
panRingStart
;
496
499
double
*
padfX
;
502
double
*
padfY
;
505
double
*
padfZ
;
506
507
virtual
void
Dump
( FILE * );
508
};
509
510
/************************************************************************/
511
/* SDTSPolygonReader */
512
/************************************************************************/
513
516
class
SDTSPolygonReader
:
public
SDTSIndexedReader
517
{
518
int
bRingsAssembled;
519
520
public
:
521
SDTSPolygonReader
();
522
virtual
~
SDTSPolygonReader
();
523
524
int
Open(
const
char
* );
525
SDTSRawPolygon
*GetNextPolygon(
void
);
526
void
Close();
527
528
SDTSFeature
*GetNextRawFeature(
void
) {
return
GetNextPolygon(); }
529
530
void
AssembleRings
(
SDTSTransfer
*,
int
iPolyLayer );
531
};
532
533
/************************************************************************/
534
/* SDTSRasterReader */
535
/************************************************************************/
536
545
class
SDTSRasterReader
546
{
547
DDFModule
oDDFModule;
548
549
char
szModule[20];
550
551
int
nXSize;
552
int
nYSize;
553
int
nXBlockSize;
554
int
nYBlockSize;
555
556
int
nXStart;
/* SOCI */
557
int
nYStart;
/* SORI */
558
559
double
adfTransform[6];
560
561
public
:
562
char
szINTR[4];
/* CE is center, TL is top left */
563
char
szFMT[32];
564
char
szUNITS[64];
565
char
szLabel[64];
566
567
SDTSRasterReader
();
568
~
SDTSRasterReader
();
569
570
int
Open(
SDTS_CATD
* poCATD,
SDTS_IREF
*,
571
const
char
* pszModule );
572
void
Close();
573
574
int
GetRasterType
();
/* 1 = int16, see GDAL types */
575
#define SDTS_RT_INT16 1
576
#define SDTS_RT_FLOAT32 6
577
578
int
GetTransform
(
double
* );
579
580
int
GetMinMax
(
double
* pdfMin,
double
* pdfMax,
581
double
dfNoData );
582
588
int
GetXSize
() {
return
nXSize; }
594
int
GetYSize
() {
return
nYSize; }
595
597
int
GetBlockXSize
() {
return
nXBlockSize; }
599
int
GetBlockYSize
() {
return
nYBlockSize; }
600
601
int
GetBlock
(
int
nXOffset,
int
nYOffset,
void
* pData );
602
};
603
604
/************************************************************************/
605
/* SDTSTransfer */
606
/************************************************************************/
607
616
class
SDTSTransfer
617
{
618
public
:
619
SDTSTransfer
();
620
~
SDTSTransfer
();
621
622
int
Open
(
const
char
* );
623
void
Close();
624
625
int
FindLayer
(
const
char
* );
626
int
GetLayerCount() {
return
nLayers; }
627
SDTSLayerType
GetLayerType
(
int
);
628
int
GetLayerCATDEntry
(
int
);
629
630
SDTSLineReader
*GetLayerLineReader(
int
);
631
SDTSPointReader
*GetLayerPointReader(
int
);
632
SDTSPolygonReader
*GetLayerPolygonReader(
int
);
633
SDTSAttrReader
*GetLayerAttrReader(
int
);
634
SDTSRasterReader
*
GetLayerRasterReader
(
int
);
635
DDFModule
*GetLayerModuleReader(
int
);
636
637
SDTSIndexedReader
*
GetLayerIndexedReader
(
int
);
638
644
SDTS_CATD
*
GetCATD
() {
return
&oCATD ; }
645
646
SDTS_IREF
*GetIREF() {
return
&oIREF; }
647
653
SDTS_XREF
*
GetXREF
() {
return
&oXREF; }
654
655
SDTSFeature
*GetIndexedFeatureRef(
SDTSModId
*,
656
SDTSLayerType *peType = NULL);
657
658
DDFField
*
GetAttr
(
SDTSModId
* );
659
660
int
GetBounds
(
double
*pdfMinX,
double
*pdfMinY,
661
double
*pdfMaxX,
double
*pdfMaxY );
662
663
private
:
664
665
SDTS_CATD
oCATD;
666
SDTS_IREF
oIREF;
667
SDTS_XREF
oXREF;
668
669
int
nLayers;
670
int
*panLayerCATDEntry;
671
SDTSIndexedReader
**papoLayerReader;
672
};
673
674
#endif
/* ndef SDTS_AL_H_INCLUDED */
Generated by
1.8.1.2