1 : /******************************************************************************
2 : * $Id: sdtsxref.cpp 10645 2007-01-18 02:22:39Z warmerdam $
3 : *
4 : * Project: SDTS Translator
5 : * Purpose: Implementation of SDTS_XREF class for reading XREF module.
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 : #include "sdts_al.h"
31 :
32 : CPL_CVSID("$Id: sdtsxref.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
33 :
34 : /************************************************************************/
35 : /* SDTS_XREF() */
36 : /************************************************************************/
37 :
38 19 : SDTS_XREF::SDTS_XREF()
39 :
40 : {
41 19 : pszSystemName = CPLStrdup( "" );
42 19 : pszDatum = CPLStrdup( "" );
43 19 : nZone = 0;
44 19 : }
45 :
46 : /************************************************************************/
47 : /* ~SDTS_XREF() */
48 : /************************************************************************/
49 :
50 19 : SDTS_XREF::~SDTS_XREF()
51 : {
52 19 : CPLFree( pszSystemName );
53 19 : CPLFree( pszDatum );
54 19 : }
55 :
56 : /************************************************************************/
57 : /* Read() */
58 : /* */
59 : /* Read the named file to initialize this structure. */
60 : /************************************************************************/
61 :
62 3 : int SDTS_XREF::Read( const char * pszFilename )
63 :
64 : {
65 3 : DDFModule oXREFFile;
66 : DDFRecord *poRecord;
67 :
68 : /* -------------------------------------------------------------------- */
69 : /* Open the file, and read the header. */
70 : /* -------------------------------------------------------------------- */
71 3 : if( !oXREFFile.Open( pszFilename ) )
72 0 : return FALSE;
73 :
74 : /* -------------------------------------------------------------------- */
75 : /* Read the first record, and verify that this is an XREF record. */
76 : /* -------------------------------------------------------------------- */
77 3 : poRecord = oXREFFile.ReadRecord();
78 3 : if( poRecord == NULL )
79 0 : return FALSE;
80 :
81 3 : if( poRecord->GetStringSubfield( "XREF", 0, "MODN", 0 ) == NULL )
82 0 : return FALSE;
83 :
84 : /* -------------------------------------------------------------------- */
85 : /* Read fields of interest. */
86 : /* -------------------------------------------------------------------- */
87 :
88 3 : CPLFree( pszSystemName );
89 : pszSystemName =
90 3 : CPLStrdup( poRecord->GetStringSubfield( "XREF", 0, "RSNM", 0 ) );
91 :
92 3 : CPLFree( pszDatum );
93 : pszDatum =
94 3 : CPLStrdup( poRecord->GetStringSubfield( "XREF", 0, "HDAT", 0 ) );
95 :
96 3 : nZone = poRecord->GetIntSubfield( "XREF", 0, "ZONE", 0 );
97 :
98 3 : return TRUE;
99 : }
|