diff --git a/.github/workflows/ubuntu_24.04/expected_ogrinfo_formats.txt b/.github/workflows/ubuntu_24.04/expected_ogrinfo_formats.txt index a48a3b66fd8d..d0a94beb584f 100644 --- a/.github/workflows/ubuntu_24.04/expected_ogrinfo_formats.txt +++ b/.github/workflows/ubuntu_24.04/expected_ogrinfo_formats.txt @@ -81,7 +81,6 @@ Supported Formats: (ro:read-only, rw:read-write, +:update, v:virtual-I/O s:subda MiraMonVector -vector- (rw+v): MiraMon Vectors (.pol, .arc, .pnt) (*.pol, *.arc, *.pnt) XODR -vector- (ro): OpenDRIVE - Open Dynamic Road Information for Vehicle Environment (*.xodr) ADBC -vector- (ro): Arrow Database Connectivity - TIGER -vector- (rov): U.S. Census TIGER/Line AVCBin -vector- (rov): Arc/Info Binary Coverage AVCE00 -vector- (rov): Arc/Info E00 (ASCII) Coverage (*.e00) AIVector -vector- (ro): Artificial Intelligence powered vector driver diff --git a/.github/workflows/windows_conda_expected_ogrinfo_formats.txt b/.github/workflows/windows_conda_expected_ogrinfo_formats.txt index 807172e9b1e6..744a9af312b4 100644 --- a/.github/workflows/windows_conda_expected_ogrinfo_formats.txt +++ b/.github/workflows/windows_conda_expected_ogrinfo_formats.txt @@ -76,7 +76,6 @@ Supported Formats: (ro:read-only, rw:read-write, +:update, v:virtual-I/O s:subda JSONFG -vector- (rw+v): OGC Features and Geometries JSON (*.json) MiraMonVector -vector- (rw+v): MiraMon Vectors (.pol, .arc, .pnt) (*.pol, *.arc, *.pnt) ADBC -vector- (ro): Arrow Database Connectivity - TIGER -vector- (rov): U.S. Census TIGER/Line AVCBin -vector- (rov): Arc/Info Binary Coverage AVCE00 -vector- (rov): Arc/Info E00 (ASCII) Coverage (*.e00) AIVector -vector- (ro): Artificial Intelligence powered vector driver diff --git a/autotest/ogr/ogr_tiger.py b/autotest/ogr/ogr_tiger.py deleted file mode 100755 index e24371d11087..000000000000 --- a/autotest/ogr/ogr_tiger.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env pytest -############################################################################### -# -# Project: GDAL/OGR Test Suite -# Purpose: Test read functionality for OGR TIGER driver. -# Author: Even Rouault -# -############################################################################### -# Copyright (c) 2011-2012, Even Rouault -# -# SPDX-License-Identifier: MIT -############################################################################### - -import os -import pathlib - -import gdaltest -import ogrtest -import pytest - -from osgeo import gdal, ogr - -pytestmark = pytest.mark.require_driver("Tiger") - -############################################################################### - - -@pytest.fixture(scope="module") -def TGR01001_dir(): - - gdaltest.download_or_skip( - "http://www2.census.gov/geo/tiger/tiger2006se/AL/TGR01001.ZIP", "TGR01001.ZIP" - ) - - dirname = pathlib.Path("tmp") / "cache" / "TGR01001" - - try: - os.stat("tmp/cache/TGR01001/TGR01001.MET") - except OSError: - try: - try: - os.stat("tmp/cache/TGR01001") - except OSError: - os.mkdir("tmp/cache/TGR01001") - gdaltest.unzip("tmp/cache/TGR01001", "tmp/cache/TGR01001.ZIP") - try: - os.stat("tmp/cache/TGR01001/TGR01001.MET") - except OSError: - pytest.skip() - except Exception: - pytest.skip() - - return dirname - - -def test_ogr_tiger_1(TGR01001_dir): - - tiger_ds = ogr.Open(TGR01001_dir) - assert tiger_ds is not None - - tiger_ds = None - # also test opening with a filename (#4443) - tiger_ds = ogr.Open(TGR01001_dir / "TGR01001.RT1") - assert tiger_ds is not None - - # Check a few features. - cc_layer = tiger_ds.GetLayerByName("CompleteChain") - assert cc_layer.GetFeatureCount() == 19289, "wrong cc feature count" - - feat = cc_layer.GetNextFeature() - feat = cc_layer.GetNextFeature() - feat = cc_layer.GetNextFeature() - - assert ( - feat.TLID == 2833200 and feat.FRIADDL is None and feat.BLOCKL == 5000 - ), "wrong attribute on cc feature." - - ogrtest.check_feature_geometry( - feat, - "LINESTRING (-86.4402 32.504137,-86.440313 32.504009,-86.440434 32.503884,-86.440491 32.503805,-86.44053 32.503757,-86.440578 32.503641,-86.440593 32.503515,-86.440588 32.503252,-86.440596 32.50298)", - max_error=0.000001, - ) - - feat = tiger_ds.GetLayerByName("TLIDRange").GetNextFeature() - assert ( - feat.MODULE == "TGR01001" and feat.TLMINID == 2822718 - ), "got wrong TLIDRange attributes" - - -############################################################################### -# Run test_ogrsf - - -def test_ogr_tiger_2(TGR01001_dir): - - import test_cli_utilities - - if test_cli_utilities.get_test_ogrsf_path() is None: - pytest.skip() - - ret = gdaltest.runexternal( - test_cli_utilities.get_test_ogrsf_path() + f" -ro {TGR01001_dir}" - ) - - assert ret.find("INFO") != -1 and ret.find("ERROR") == -1 - - -############################################################################### -# Load into a /vsimem instance to test virtualization. - - -def test_ogr_tiger_4(tmp_vsimem, TGR01001_dir): - - # load all the files into memory. - for filename in gdal.ReadDir(TGR01001_dir): - - if filename.startswith("."): - continue - - data = open(TGR01001_dir / filename, "r").read() - - f = gdal.VSIFOpenL(tmp_vsimem / filename, "wb") - gdal.VSIFWriteL(data, 1, len(data), f) - gdal.VSIFCloseL(f) - - # Try reading. - ogrtest.tiger_ds = ogr.Open(tmp_vsimem / "TGR01001.RT1") - assert ogrtest.tiger_ds is not None, "fail to open." - - ogrtest.tiger_ds = None - # also test opening with a filename (#4443) - ogrtest.tiger_ds = ogr.Open(tmp_vsimem / "TGR01001.RT1") - assert ogrtest.tiger_ds is not None - - # Check a few features. - cc_layer = ogrtest.tiger_ds.GetLayerByName("CompleteChain") - assert cc_layer.GetFeatureCount() == 19289, "wrong cc feature count" - - feat = cc_layer.GetNextFeature() - feat = cc_layer.GetNextFeature() - feat = cc_layer.GetNextFeature() - - assert ( - feat.TLID == 2833200 and feat.FRIADDL is None and feat.BLOCKL == 5000 - ), "wrong attribute on cc feature." - - ogrtest.check_feature_geometry( - feat, - "LINESTRING (-86.4402 32.504137,-86.440313 32.504009,-86.440434 32.503884,-86.440491 32.503805,-86.44053 32.503757,-86.440578 32.503641,-86.440593 32.503515,-86.440588 32.503252,-86.440596 32.50298)", - max_error=0.000001, - ) - - feat = ogrtest.tiger_ds.GetLayerByName("TLIDRange").GetNextFeature() - assert ( - feat.MODULE == "TGR01001" and feat.TLMINID == 2822718 - ), "got wrong TLIDRange attributes" diff --git a/doc/source/drivers/vector/index.rst b/doc/source/drivers/vector/index.rst index bd839e29d832..910d20d02dea 100644 --- a/doc/source/drivers/vector/index.rst +++ b/doc/source/drivers/vector/index.rst @@ -96,7 +96,6 @@ Vector drivers sqlite svg sxf - tiger tiledb topojson vdv diff --git a/doc/source/drivers/vector/tiger.rst b/doc/source/drivers/vector/tiger.rst deleted file mode 100644 index f94136c5dbfb..000000000000 --- a/doc/source/drivers/vector/tiger.rst +++ /dev/null @@ -1,245 +0,0 @@ -.. _vector.tiger: - -U.S. Census TIGER/Line -====================== - -.. shortname:: TIGER - -.. built_in_by_default:: - -TIGER/Line file sets are support for read access. - -TIGER/Line files are a digital database of geographic features, such as -roads, railroads, rivers, lakes, political boundaries, census -statistical boundaries, etc. covering the entire United States. The data -base contains information about these features such as their location in -latitude and longitude, the name, the type of feature, address ranges -for most streets, the geographic relationship to other features, and -other related information. They are the public product created from the -Census Bureau's TIGER (Topologically Integrated Geographic Encoding and -Referencing) data base of geographic information. TIGER was developed at -the Census Bureau to support the mapping and related geographic -activities required by the decennial census and sample survey programs. - -Note that the TIGER/Line product does not include census demographic -statistics. Those are sold by the Census Bureau in a separate format -(not directly supported by FME), but those statistics do relate back to -census blocks in TIGER/Line files. - -To open a TIGER/Line dataset, select the directory containing one or -more sets of data files. The regions are counties, or county -equivalents. Each county consists of a series of files with a common -basename, and different extensions. For instance, county 1 in state 26 -(Michigan) consists of the following file set in Tiger98. - -:: - - TGR26001.RT1 - TGR26001.RT2 - TGR26001.RT3 - TGR26001.RT4 - TGR26001.RT5 - TGR26001.RT6 - TGR26001.RT7 - TGR26001.RT8 - TGR26001.RT9 - TGR26001.RTA - TGR26001.RTC - TGR26001.RTH - TGR26001.RTI - TGR26001.RTP - TGR26001.RTR - TGR26001.RTS - TGR26001.RTZ - -The TIGER/Line coordinate system is hardcoded to NAD83 lat/long degrees. -This should be appropriate for all recent years of TIGER/Line -production. - -There is no update or creation support in the TIGER/Line driver. - -The reader was implemented for TIGER/Line 1998 files, but some effort -has gone into ensuring compatibility with 1992, 1995, 1997, 1999, 2000, -2002, 2003 and 2004 TIGER/Line products as well. The 2005 products have -also been reported to work fine. It is believe that any TIGER/Line -product from the 1990's should work with the reader, with the possible -loss of some version specific information. - -Driver capabilities -------------------- - -.. supports_georeferencing:: - -.. supports_virtualio:: - -Feature Representation ----------------------- - -With a few exceptions, a feature is created for each record of a -TIGER/Line data file. Each file (i.e. .RT1, .RTA) is translated to an -appropriate OGR feature type, with attribute names matching those in the -TIGER/Line product manual. - -The TIGER/Line RT (record type), and VERSION attributes are generally -discarded, but the MODULE attribute is added to each feature. The MODULE -attribute contains the basename (eg. TGR26001) of the county module from -which the feature originated. For some keys (such as LAND, POLYID, and -CENID) this MODULE attribute is needed to make the key unique when the -dataset (directory) consists of more than one county of data. - -Following is a list of feature types, and their relationship to the -TIGER/Line product. - -CompleteChain -^^^^^^^^^^^^^ - -A CompleteChain is a polyline with an associated TLID (TIGER/Line ID). -The CompleteChain features are established from a type 1 record -(Complete Chain Basic Data Record), and if available it is associated -type 3 record (Complete Chain Geographic Entity Codes). As well, any -type 2 records (Complete Chain Shape Coordinates) available are used to -fill in intermediate shape points on the arc. The TLID is the primary -key, and is unique within the entire national TIGER/Line coverage. - -These features always have a line geometry. - -AltName -^^^^^^^ - -These features are derived from the type 4 record (Index to Alternate -Feature Identifiers), and relate a TLID to 1 to 4 alternate feature name -numbers (the FEAT attribute) which are kept separately as FeatureIds -features. The standard reader pipeline attaches the names from the -FeatureIds features as array attributes ALT_FEDIRS{}, ALT_FEDIRP{}, -ALT_FENAME{} and ALT_FETYPE{}. The ALT_FENAME{} is a list of feature -names associated with the TLID on the AltName feature. - -Note that zero, one or more AltName records may exist for a given TLID, -and each AltName record can contain between one and four alternate -names. Because it is still very difficult to utilize AltName features to -relate altername names to CompleteChains, it is anticipated that the -standard reader pipeline for TIGER/Line files will be upgraded in the -future, resulting in a simplification of alternate names. - -These features have no associated geometry. - -FeatureIds -^^^^^^^^^^ - -These features are derived from type 5 (Complete Chain Feature -Identifiers) records. Each feature contains a feature name (FENAME), and -it is associated feature id code (FEAT). The FEAT attribute is the -primary key, and is unique within the county module. FeatureIds have a -one to many relationship with AltName features, and KeyFeatures -features. - -These features have no associated geometry. - -ZipCodes -^^^^^^^^ - -These features are derived from type 6 (Additional Address Range and ZIP -Code Data) records. These features are intended to augment the ZIP Code -information kept directly on CompleteChain features, and there is a many -to one relationship between ZipCodes features and CompleteChain -features. - -These features have no associated geometry. - -Landmarks -^^^^^^^^^ - -These features are derived from type 7 (Landmark Features) records. They -relate to point, or area landmarks. For area landmarks there is a one to -one relationship with an AreaLandmark record. The LAND attribute is the -primary key, and is unique within the county module. - -These features may have an associated point geometry. Landmarks -associated with polygons will not have the polygon geometry attached. It -would need to be collected (via the AreaLandmark feature) from a Polygon -feature. - -AreaLandmarks -^^^^^^^^^^^^^ - -These features are derived from type 8 (Polygons Linked to Area -Landmarks) records. Each associates a Landmark feature (attribute LAND) -with a Polygon feature (attribute POLYID). This feature has a many to -many relationship with Polygon features. - -These features have no associated geometry. - -KeyFeatures -^^^^^^^^^^^ - -These features are derived from type 9 (Polygon Geographic Entity Codes) -records. They may be associated with a FeatureIds feature (via the FEAT -attribute), and a Polygon feature (via the POLYID attribute). - -These features have no associated geometry. - -Polygon -^^^^^^^ - -These features are derived from type A (Polygon Geographic Entity Codes) -records and if available the related type S (Polygon Additional -Geographic Entity Codes) records. The POLYID attribute is the primary -key, uniquely identifying a polygon within a county module. - -These features do not have any geometry associated with them as read by -the OGR TIGER driver. It needs to be externally related using the -PolyChainLink. The gdal/pymod/samples/tigerpoly.py script may be used to -read a TIGER dataset and extract the polygon layer **with geometry** as -a shapefile. - -EntityNames -^^^^^^^^^^^ - -These features are derived from type C (Geographic Entity Names) -records. - -These features have no associated geometry. - -IDHistory -^^^^^^^^^ - -These features are derived from type H (TIGER/Line ID History) records. -They can be used to trace the splitting, merging, creation and deletion -of CompleteChain features. - -These features have no associated geometry. - -PolyChainLink -^^^^^^^^^^^^^ - -These features are derived from type I (Link Between Complete Chains and -Polygons) records. They are normally all consumed by the standard reader -pipeline while attaching CompleteChain geometries to Polygon features to -establish their polygon geometries. PolyChainLink features have a many -to one relationship with Polygon features, and a one to one relationship -with CompleteChain features. - -These features have no associated geometry. - -PIP -^^^ - -These features are derived from type P (Polygon Internal Point) records. -They relate to a Polygon feature via the POLYID attribute, and can be -used to establish an internal point for Polygon features. - -These features have a point geometry. - -ZipPlus4 -^^^^^^^^ - -These features are derived from type Z (ZIP+4 Codes) records. ZipPlus4 -features have a many to one relationship with CompleteChain features. - -These features have no associated geometry. - -See Also --------- - -http://www.census.gov/geo/www/tiger/: More information on the TIGER/Line -file format, and data product can be found on this U.S. Census web page. diff --git a/ogr/ogrsf_frmts/CMakeLists.txt b/ogr/ogrsf_frmts/CMakeLists.txt index 873959393660..54ec9e8c3181 100644 --- a/ogr/ogrsf_frmts/CMakeLists.txt +++ b/ogr/ogrsf_frmts/CMakeLists.txt @@ -68,7 +68,6 @@ ogr_optional_driver(csv CSV) ogr_optional_driver(dgn DGN) ogr_optional_driver(gmt GMT) ogr_optional_driver(s57 S57) -ogr_optional_driver(tiger "U.S. Census TIGER/Line") ogr_optional_driver(geoconcept GEOCONCEPT) ogr_optional_driver(georss GEORSS) ogr_optional_driver(dxf DXF) diff --git a/ogr/ogrsf_frmts/generic/ogrregisterall.cpp b/ogr/ogrsf_frmts/generic/ogrregisterall.cpp index c9d4145a417a..c6b2920f18a3 100644 --- a/ogr/ogrsf_frmts/generic/ogrregisterall.cpp +++ b/ogr/ogrsf_frmts/generic/ogrregisterall.cpp @@ -258,10 +258,7 @@ void OGRRegisterAllInternal() // NOTE: frmts/drivers.ini in the same directory should be kept in same // order as this file -/* Put TIGER and AVCBIN at end since they need poOpenInfo->GetSiblingFiles() */ -#ifdef TIGER_ENABLED - RegisterOGRTiger(); -#endif +/* Put AVCBIN at end since they need poOpenInfo->GetSiblingFiles() */ #ifdef AVC_ENABLED RegisterOGRAVCBin(); RegisterOGRAVCE00(); diff --git a/ogr/ogrsf_frmts/ogrsf_frmts.h b/ogr/ogrsf_frmts/ogrsf_frmts.h index 282bf6f2be91..03f7265256d7 100644 --- a/ogr/ogrsf_frmts/ogrsf_frmts.h +++ b/ogr/ogrsf_frmts/ogrsf_frmts.h @@ -670,7 +670,6 @@ void OGRRegisterAllInternal(); void CPL_DLL RegisterOGRFileGDB(); void DeclareDeferredOGRFileGDBPlugin(); void CPL_DLL RegisterOGRShape(); -void CPL_DLL RegisterOGRTiger(); void CPL_DLL RegisterOGRS57(); void CPL_DLL RegisterOGRTAB(); void CPL_DLL RegisterOGRMIF(); diff --git a/ogr/ogrsf_frmts/tiger/CMakeLists.txt b/ogr/ogrsf_frmts/tiger/CMakeLists.txt deleted file mode 100644 index 3a2ab318a747..000000000000 --- a/ogr/ogrsf_frmts/tiger/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -add_gdal_driver( - TARGET ogr_Tiger - SOURCES ogr_tiger.h - tigerarealandmarks.cpp - tigeridhistory.cpp - tigerpoint.cpp - tigerspatialmetadata.cpp - ogrtigerdatasource.cpp - tigercompletechain.cpp - tigerkeyfeatures.cpp - tigerpolychainlink.cpp - tigertlidrange.cpp - ogrtigerdriver.cpp - tigerentitynames.cpp - tigerlandmarks.cpp - tigerpolygon.cpp - tigerzerocellid.cpp - ogrtigerlayer.cpp - tigerfeatureids.cpp - tigeroverunder.cpp - tigerpolygoncorrections.cpp - tigerzipcodes.cpp - tigeraltname.cpp - tigerfilebase.cpp - tigerpip.cpp - tigerpolygoneconomic.cpp - tigerzipplus4.cpp - PLUGIN_CAPABLE - NO_DEPS) -gdal_standard_includes(ogr_Tiger) diff --git a/ogr/ogrsf_frmts/tiger/ogr_tiger.h b/ogr/ogrsf_frmts/tiger/ogr_tiger.h deleted file mode 100644 index 26ba20043daa..000000000000 --- a/ogr/ogrsf_frmts/tiger/ogr_tiger.h +++ /dev/null @@ -1,555 +0,0 @@ -/*-*-C++-*-*/ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Main declarations for Tiger translator. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2008-2011, Even Rouault - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#ifndef OGR_TIGER_H_INCLUDED -#define OGR_TIGER_H_INCLUDED - -#include "cpl_conv.h" -#include "ogrsf_frmts.h" - -class OGRTigerDataSource; - -/* -** TIGER Versions -** -** 0000 TIGER/Line Precensus Files, 1990 -** 0002 TIGER/Line Initial Voting District Codes Files, 1990 -** 0003 TIGER/Line Files, 1990 -** 0005 TIGER/Line Files, 1992 -** 0021 TIGER/Line Files, 1994 -** 0024 TIGER/Line Files, 1995 -** 0697 to 1098 TIGER/Line Files, 1997 -** 1298 to 0499 TIGER/Line Files, 1998 -** 0600 to 0800 TIGER/Line Files, 1999 -** 1000 to 1100 TIGER/Line Files, Redistricting Census 2000 -** 0301 to 0801 TIGER/Line Files, Census 2000 -** -** 0302 to 0502 TIGER/Line Files, UA 2000 -** ???? ???? -** -** 0602 & higher TIGER/Line Files, 2002 -** ???? ???? -*/ - -typedef enum -{ - TIGER_1990_Precensus = 0, - TIGER_1990 = 1, - TIGER_1992 = 2, - TIGER_1994 = 3, - TIGER_1995 = 4, - TIGER_1997 = 5, - TIGER_1998 = 6, - TIGER_1999 = 7, - TIGER_2000_Redistricting = 8, - TIGER_2000_Census = 9, - TIGER_UA2000 = 10, - TIGER_2002 = 11, - TIGER_2003 = 12, - TIGER_2004 = 13, - TIGER_Unknown -} TigerVersion; - -TigerVersion TigerClassifyVersion(int); -const char *TigerVersionString(TigerVersion); - -/*****************************************************************************/ -/* The TigerFieldInfo and TigerRecordInfo structures hold information about */ -/* the schema of a TIGER record type. In each layer implementation file */ -/* there are statically initialized variables of these types that describe */ -/* the record types associated with that layer. In the case where different */ -/* TIGER versions have different schemas, there is a */ -/* TigerFieldInfo/TigerRecordInfo for each version, and the constructor */ -/* for the layer chooses a pointer to the correct set based on the version. */ -/*****************************************************************************/ - -typedef struct TigerFieldInfo -{ - char pszFieldName[11]; // name of the field - char cFmt; // format of the field ('L' or 'R') - char cType; // type of the field ('A' or 'N') - char OGRtype; // OFTType of the field (OFTInteger, OFTString, ...?) - unsigned char nBeg; // beginning column number for field - unsigned char nEnd; // ending column number for field - unsigned char nLen; // length of field - - unsigned int bDefine : 1; // whether to add this field to the FeatureDefn - unsigned int bSet : 1; // whether to set this field in GetFeature() -} TigerFieldInfo; - -typedef struct TigerRecordInfo -{ - const TigerFieldInfo *pasFields; - unsigned char nFieldCount; - unsigned char nRecordLength; -} TigerRecordInfo; - -// OGR_TIGER_RECBUF_LEN should be a number that is larger than the -// longest possible record length for any record type; it is used to -// create arrays to hold the records. At the time of this writing the -// longest record (RT1) has length 228, but I'm choosing 500 because -// it is a good round number and will allow for growth without having -// to modify this file. The code never holds more than a few records -// in memory at a time, so having OGR_TIGER_RECBUF_LEN be much larger -// than is really necessary won't affect the amount of memory required -// in a substantial way. -// mbp Fri Dec 20 19:19:59 2002 -// Note: OGR_TIGER_RECBUF_LEN should also be larger than 255, since -// TigerRecordInfo::nRecordLength fits on unsigned char. -#define OGR_TIGER_RECBUF_LEN 500 - -/************************************************************************/ -/* TigerFileBase */ -/************************************************************************/ - -class TigerFileBase CPL_NON_FINAL -{ - protected: - OGRTigerDataSource *poDS; - - char *pszModule; - char *pszShortModule; - VSILFILE *fpPrimary; - - OGRFeatureDefn *poFeatureDefn; - - int nFeatures; - int nRecordLength; - - int OpenFile(const char *, const char *); - void EstablishFeatureCount(); - - static int EstablishRecordLength(VSILFILE *); - - void SetupVersion(); - - int nVersionCode; - TigerVersion nVersion; - - public: - explicit TigerFileBase(const TigerRecordInfo *psRTInfoIn = nullptr, - const char *m_pszFileCodeIn = nullptr); - virtual ~TigerFileBase(); - - TigerVersion GetVersion() - { - return nVersion; - } - - int GetVersionCode() - { - return nVersionCode; - } - - virtual const char *GetShortModule() - { - return pszShortModule; - } - - virtual const char *GetModule() - { - return pszModule; - } - - virtual int GetFeatureCount() - { - return nFeatures; - } - - OGRFeatureDefn *GetFeatureDefn() - { - return poFeatureDefn; - } - - static const char *GetField(const char *, int, int); - static void SetField(OGRFeature *, const char *, const char *, int, int); - - virtual bool SetModule(const char *pszModule); - virtual OGRFeature *GetFeature(int nRecordId); - - protected: - static void AddFieldDefns(const TigerRecordInfo *psRTInfo, - OGRFeatureDefn *poFeatureDefn); - - static void SetFields(const TigerRecordInfo *psRTInfo, - OGRFeature *poFeature, char *achRecord); - - const TigerRecordInfo *psRTInfo; - const char *m_pszFileCode; -}; - -/************************************************************************/ -/* TigerCompleteChain */ -/************************************************************************/ - -class TigerCompleteChain final : public TigerFileBase -{ - VSILFILE *fpShape; - int *panShapeRecordId; - - VSILFILE *fpRT3; - bool bUsingRT3; - int nRT1RecOffset; - - int GetShapeRecordId(int, int); - bool AddShapePoints(int, int, OGRLineString *, int); - - void AddFieldDefnsPre2002(); - OGRFeature *GetFeaturePre2002(int); - - OGRFeature *GetFeature2002(int); - void AddFieldDefns2002(); - - const TigerRecordInfo *psRT1Info; - const TigerRecordInfo *psRT2Info; - const TigerRecordInfo *psRT3Info; - - public: - TigerCompleteChain(OGRTigerDataSource *, const char *); - virtual ~TigerCompleteChain(); - - virtual bool SetModule(const char *) override; - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerAltName (Type 4 records) */ -/************************************************************************/ - -class TigerAltName final : public TigerFileBase -{ - public: - TigerAltName(OGRTigerDataSource *, const char *); - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerFeatureIds (Type 5 records) */ -/************************************************************************/ - -class TigerFeatureIds final : public TigerFileBase -{ - public: - TigerFeatureIds(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerZipCodes (Type 6 records) */ -/************************************************************************/ - -class TigerZipCodes final : public TigerFileBase -{ - public: - TigerZipCodes(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerPoint */ -/* This is an abstract base class for TIGER layers with point geometry. */ -/* Since much of the implementation of these layers is similar, I've */ -/* put it into this base class to avoid duplication in the actual */ -/* layer classes. mbp Sat Jan 4 16:41:19 2003. */ -/************************************************************************/ - -class TigerPoint CPL_NON_FINAL : public TigerFileBase -{ - protected: - explicit TigerPoint(const TigerRecordInfo *psRTInfoIn = nullptr, - const char *m_pszFileCodeIn = nullptr); - - public: - virtual OGRFeature *GetFeature(int nFID) override - { - return TigerFileBase::GetFeature(nFID); - } /* to avoid -Woverloaded-virtual warnings */ - - OGRFeature *GetFeature(int nRecordId, int nX0, int nX1, int nY0, int nY1); -}; - -/************************************************************************/ -/* TigerLandmarks (Type 7 records) */ -/************************************************************************/ - -class TigerLandmarks final : public TigerPoint -{ - public: - TigerLandmarks(OGRTigerDataSource *, const char *); - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerAreaLandmarks (Type 8 records) */ -/************************************************************************/ - -class TigerAreaLandmarks final : public TigerFileBase -{ - public: - TigerAreaLandmarks(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerKeyFeatures (Type 9 records) */ -/************************************************************************/ - -class TigerKeyFeatures final : public TigerFileBase -{ - public: - TigerKeyFeatures(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerPolygon (Type A&S records) */ -/************************************************************************/ - -class TigerPolygon final : public TigerFileBase -{ - private: - const TigerRecordInfo *psRTAInfo; - const TigerRecordInfo *psRTSInfo; - - VSILFILE *fpRTS; - bool bUsingRTS; - int nRTSRecLen; - - public: - TigerPolygon(OGRTigerDataSource *, const char *); - virtual ~TigerPolygon(); - - virtual bool SetModule(const char *) override; - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerPolygonCorrections (Type B records) */ -/************************************************************************/ - -class TigerPolygonCorrections final : public TigerFileBase -{ - public: - TigerPolygonCorrections(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerEntityNames (Type C records) */ -/************************************************************************/ - -class TigerEntityNames final : public TigerFileBase -{ - public: - TigerEntityNames(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerPolygonEconomic (Type E records) */ -/************************************************************************/ - -class TigerPolygonEconomic final : public TigerFileBase -{ - public: - TigerPolygonEconomic(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerIDHistory (Type H records) */ -/************************************************************************/ - -class TigerIDHistory final : public TigerFileBase -{ - public: - TigerIDHistory(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerPolyChainLink (Type I records) */ -/************************************************************************/ - -class TigerPolyChainLink final : public TigerFileBase -{ - public: - TigerPolyChainLink(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerSpatialMetadata (Type M records) */ -/************************************************************************/ - -class TigerSpatialMetadata final : public TigerFileBase -{ - public: - TigerSpatialMetadata(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerPIP (Type P records) */ -/************************************************************************/ - -class TigerPIP final : public TigerPoint -{ - public: - TigerPIP(OGRTigerDataSource *, const char *); - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerTLIDRange (Type R records) */ -/************************************************************************/ - -class TigerTLIDRange final : public TigerFileBase -{ - public: - TigerTLIDRange(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerZeroCellID (Type T records) */ -/************************************************************************/ - -class TigerZeroCellID final : public TigerFileBase -{ - public: - TigerZeroCellID(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* TigerOverUnder (Type U records) */ -/************************************************************************/ - -class TigerOverUnder final : public TigerPoint -{ - public: - TigerOverUnder(OGRTigerDataSource *, const char *); - - virtual OGRFeature *GetFeature(int) override; -}; - -/************************************************************************/ -/* TigerZipPlus4 (Type Z records) */ -/************************************************************************/ - -class TigerZipPlus4 final : public TigerFileBase -{ - public: - TigerZipPlus4(OGRTigerDataSource *, const char *); -}; - -/************************************************************************/ -/* OGRTigerLayer */ -/************************************************************************/ - -class OGRTigerLayer final : public OGRLayer -{ - TigerFileBase *poReader; - - OGRTigerDataSource *poDS; - - int nFeatureCount; - int *panModuleFCount; - int *panModuleOffset; - - int iLastFeatureId; - int iLastModule; - - public: - OGRTigerLayer(OGRTigerDataSource *poDS, TigerFileBase *); - virtual ~OGRTigerLayer(); - - void ResetReading() override; - OGRFeature *GetNextFeature() override; - OGRFeature *GetFeature(GIntBig nFeatureId) override; - - OGRFeatureDefn *GetLayerDefn() override; - - GIntBig GetFeatureCount(int) override; - - int TestCapability(const char *) override; -}; - -/************************************************************************/ -/* OGRTigerDataSource */ -/************************************************************************/ - -class OGRTigerDataSource final : public GDALDataset -{ - int nLayers; - OGRTigerLayer **papoLayers; - - OGRSpatialReference *poSpatialRef; - - char **papszOptions; - - char *pszPath; - - int nModules; - char **papszModules; - - int nVersionCode; - TigerVersion nVersion; - - TigerVersion TigerCheckVersion(TigerVersion, const char *); - - CPL_DISALLOW_COPY_ASSIGN(OGRTigerDataSource) - - public: - OGRTigerDataSource(); - virtual ~OGRTigerDataSource(); - - TigerVersion GetVersion() const - { - return nVersion; - } - - int GetVersionCode() const - { - return nVersionCode; - } - - const char *GetOption(const char *); - - int Open(const char *pszName, int bTestOpen = FALSE, - char **papszFileList = nullptr); - - int GetLayerCount() override; - OGRLayer *GetLayer(int) override; - OGRLayer *GetLayer(const char *pszLayerName); - - void AddLayer(OGRTigerLayer *); - - OGRSpatialReference *DSGetSpatialRef() - { - return poSpatialRef; - } - - const char *GetDirPath() - { - return pszPath; - } - - char *BuildFilename(const char *pszModule, const char *pszExtension); - - int GetModuleCount() const - { - return nModules; - } - - const char *GetModule(int); - bool CheckModule(const char *pszModule); - void AddModule(const char *pszModule); -}; - -#endif /* ndef OGR_TIGER_H_INCLUDED */ diff --git a/ogr/ogrsf_frmts/tiger/ogrtigerdatasource.cpp b/ogr/ogrsf_frmts/tiger/ogrtigerdatasource.cpp deleted file mode 100644 index edaacdaa8092..000000000000 --- a/ogr/ogrsf_frmts/tiger/ogrtigerdatasource.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements OGRTigerDataSource class - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "cpl_conv.h" -#include "cpl_string.h" -#include "ogr_tiger.h" - -#include -#include - -#define DIGIT_ZERO '0' - -/************************************************************************/ -/* TigerClassifyVersion() */ -/************************************************************************/ - -TigerVersion TigerClassifyVersion(int nVersionCode) - -{ - TigerVersion nVersion; - int nYear, nMonth; - - /* - ** TIGER Versions - ** - ** 0000 TIGER/Line Precensus Files, 1990 - ** 0002 TIGER/Line Initial Voting District Codes Files, 1990 - ** 0003 TIGER/Line Files, 1990 - ** 0005 TIGER/Line Files, 1992 - ** 0021 TIGER/Line Files, 1994 - ** 0024 TIGER/Line Files, 1995 - ** 9706 to 9810 TIGER/Line Files, 1997 - ** 9812 to 9904 TIGER/Line Files, 1998 - ** 0006 to 0008 TIGER/Line Files, 1999 - ** 0010 to 0011 TIGER/Line Files, Redistricting Census 2000 - ** 0103 to 0108 TIGER/Line Files, Census 2000 - ** - ** 0203 to 0205 TIGER/Line Files, UA 2000 - ** ???? ???? - ** - ** 0206 to 0299 TIGER/Line Files, 2002 - ** 0300 to 0399 TIGER/Line Files, 2003 - ** 0400+ TIGER/Line Files, 2004 - one sample is 0405 - ** ???? - */ - - nVersion = TIGER_Unknown; - if (nVersionCode == 0) - nVersion = TIGER_1990_Precensus; - else if (nVersionCode == 2) - nVersion = TIGER_1990; - else if (nVersionCode == 3) - nVersion = TIGER_1992; - else if (nVersionCode == 5) - nVersion = TIGER_1994; - else if (nVersionCode == 21) - nVersion = TIGER_1994; - else if (nVersionCode == 24) - nVersion = TIGER_1995; - - else if (nVersionCode == 9999) /* special hack, fme bug 7625 */ - nVersion = TIGER_UA2000; - - nYear = nVersionCode % 100; - nMonth = nVersionCode / 100; - - nVersionCode = nYear * 100 + nMonth; - - if (nVersion != TIGER_Unknown) - /* do nothing */; - else if (nVersionCode >= 9706 && nVersionCode <= 9810) - nVersion = TIGER_1997; - else if (nVersionCode >= 9812 && nVersionCode <= 9904) - nVersion = TIGER_1998; - else if (nVersionCode >= 6 /*0006*/ && nVersionCode <= 8 /*0008*/) - nVersion = TIGER_1999; - else if (nVersionCode >= 10 /*0010*/ && nVersionCode <= 11 /*0011*/) - nVersion = TIGER_2000_Redistricting; - else if (nVersionCode >= 103 /*0103*/ && nVersionCode <= 108 /*0108*/) - nVersion = TIGER_2000_Census; - else if (nVersionCode >= 203 /*0302*/ && nVersionCode <= 205 /*0502*/) - nVersion = TIGER_UA2000; - else if (nVersionCode >= 210 /*1002*/ && nVersionCode <= 306 /*0603*/) - nVersion = TIGER_2002; - else if (nVersionCode >= 312 /*1203*/ && nVersionCode <= 403 /*0304*/) - nVersion = TIGER_2003; - else if (nVersionCode >= 404) - nVersion = TIGER_2004; - - return nVersion; -} - -/************************************************************************/ -/* TigerVersionString() */ -/************************************************************************/ - -const char *TigerVersionString(TigerVersion nVersion) -{ - - if (nVersion == TIGER_1990_Precensus) - { - return "TIGER_1990_Precensus"; - } - if (nVersion == TIGER_1990) - { - return "TIGER_1990"; - } - if (nVersion == TIGER_1992) - { - return "TIGER_1992"; - } - if (nVersion == TIGER_1994) - { - return "TIGER_1994"; - } - if (nVersion == TIGER_1995) - { - return "TIGER_1995"; - } - if (nVersion == TIGER_1997) - { - return "TIGER_1997"; - } - if (nVersion == TIGER_1998) - { - return "TIGER_1998"; - } - if (nVersion == TIGER_1999) - { - return "TIGER_1999"; - } - if (nVersion == TIGER_2000_Redistricting) - { - return "TIGER_2000_Redistricting"; - } - if (nVersion == TIGER_UA2000) - { - return "TIGER_UA2000"; - } - if (nVersion == TIGER_2002) - { - return "TIGER_2002"; - } - if (nVersion == TIGER_2003) - { - return "TIGER_2003"; - } - if (nVersion == TIGER_2004) - { - return "TIGER_2004"; - } - if (nVersion == TIGER_Unknown) - { - return "TIGER_Unknown"; - } - return "???"; -} - -/************************************************************************/ -/* TigerCheckVersion() */ -/* */ -/* Some tiger products seem to be generated with version info */ -/* that doesn't match the tiger specs. We can sometimes */ -/* recognise the wrongness by checking the record length of */ -/* some well known changing files and adjusting the version */ -/* based on this. */ -/************************************************************************/ - -TigerVersion OGRTigerDataSource::TigerCheckVersion(TigerVersion nOldVersion, - const char *pszFilename) - -{ - if (nOldVersion != TIGER_2002) - return nOldVersion; - - char *pszRTCFilename = BuildFilename(pszFilename, "C"); - VSILFILE *fp = VSIFOpenL(pszRTCFilename, "rb"); - CPLFree(pszRTCFilename); - - if (fp == nullptr) - return nOldVersion; - - char szHeader[115]; - - if (VSIFReadL(szHeader, sizeof(szHeader) - 1, 1, fp) < 1) - { - VSIFCloseL(fp); - return nOldVersion; - } - - VSIFCloseL(fp); - - /* -------------------------------------------------------------------- */ - /* Is the record length 112? If so, it is an older version */ - /* than 2002. */ - /* -------------------------------------------------------------------- */ - if (szHeader[112] == 10 || szHeader[112] == 13) - { - CPLDebug("TIGER", - "Forcing version back to UA2000 since RTC records are short."); - return TIGER_UA2000; - } - - return nOldVersion; -} - -/************************************************************************/ -/* OGRTigerDataSource() */ -/************************************************************************/ - -OGRTigerDataSource::OGRTigerDataSource() - : nLayers(0), papoLayers(nullptr), poSpatialRef(new OGRSpatialReference()), - papszOptions(nullptr), pszPath(nullptr), nModules(0), - papszModules(nullptr), nVersionCode(0), nVersion(TIGER_Unknown) -{ - poSpatialRef->SetWellKnownGeogCS("NAD83"); - poSpatialRef->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); -} - -/************************************************************************/ -/* ~OGRTigerDataSource() */ -/************************************************************************/ - -OGRTigerDataSource::~OGRTigerDataSource() - -{ - for (int i = 0; i < nLayers; i++) - delete papoLayers[i]; - - CPLFree(papoLayers); - - CPLFree(pszPath); - - CSLDestroy(papszOptions); - - CSLDestroy(papszModules); - - delete poSpatialRef; -} - -/************************************************************************/ -/* AddLayer() */ -/************************************************************************/ - -void OGRTigerDataSource::AddLayer(OGRTigerLayer *poNewLayer) - -{ - poNewLayer->SetDescription(poNewLayer->GetName()); - papoLayers = static_cast( - CPLRealloc(papoLayers, sizeof(void *) * ++nLayers)); - - papoLayers[nLayers - 1] = poNewLayer; -} - -/************************************************************************/ -/* GetLayer() */ -/************************************************************************/ - -OGRLayer *OGRTigerDataSource::GetLayer(int iLayer) - -{ - if (iLayer < 0 || iLayer >= nLayers) - return nullptr; - - return papoLayers[iLayer]; -} - -/************************************************************************/ -/* GetLayer() */ -/************************************************************************/ - -OGRLayer *OGRTigerDataSource::GetLayer(const char *pszLayerName) - -{ - for (int iLayer = 0; iLayer < nLayers; iLayer++) - { - if (EQUAL(papoLayers[iLayer]->GetLayerDefn()->GetName(), pszLayerName)) - return papoLayers[iLayer]; - } - - return nullptr; -} - -/************************************************************************/ -/* GetLayerCount() */ -/************************************************************************/ - -int OGRTigerDataSource::GetLayerCount() - -{ - return nLayers; -} - -/************************************************************************/ -/* Open() */ -/************************************************************************/ - -int OGRTigerDataSource::Open(const char *pszFilename, int bTestOpen, - char **papszLimitedFileList) - -{ - /* -------------------------------------------------------------------- */ - /* Is the given path a directory or a regular file? */ - /* -------------------------------------------------------------------- */ - VSIStatBufL stat; - - if (VSIStatExL(pszFilename, &stat, - VSI_STAT_EXISTS_FLAG | VSI_STAT_NATURE_FLAG) != 0 || - (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode))) - { - if (!bTestOpen) - CPLError( - CE_Failure, CPLE_AppDefined, - "%s is neither a file or directory, Tiger access failed.\n", - pszFilename); - - return FALSE; - } - - /* -------------------------------------------------------------------- */ - /* Build a list of filenames we figure are Tiger files. */ - /* -------------------------------------------------------------------- */ - char **papszFileList = nullptr; - if (VSI_ISREG(stat.st_mode)) - { - char szModule[128]; - - if (strlen(CPLGetFilename(pszFilename)) == 0) - { - return FALSE; - } - - pszPath = CPLStrdup(CPLGetPathSafe(pszFilename).c_str()); - - strncpy(szModule, CPLGetFilename(pszFilename), sizeof(szModule) - 1); - /* Make sure the buffer is 0 terminated */ - szModule[sizeof(szModule) - 1] = '\0'; - - /* And now remove last character of filename */ - szModule[strlen(szModule) - 1] = '\0'; - - papszFileList = CSLAddString(papszFileList, szModule); - } - else - { - char **candidateFileList = VSIReadDir(pszFilename); - - pszPath = CPLStrdup(pszFilename); - - for (int i = 0; - candidateFileList != nullptr && candidateFileList[i] != nullptr; - i++) - { - size_t nCandidateLen = strlen(candidateFileList[i]); - - if (papszLimitedFileList != nullptr && - CSLFindString( - papszLimitedFileList, - CPLGetBasenameSafe(candidateFileList[i]).c_str()) == -1) - { - continue; - } - - if (nCandidateLen > 4 && - candidateFileList[i][nCandidateLen - 4] == '.' && - candidateFileList[i][nCandidateLen - 1] == '1') - { - char szModule[128]; - - snprintf(szModule, sizeof(szModule), "%s", - candidateFileList[i]); - const size_t nLen = strlen(szModule); - if (nLen) - szModule[nLen - 1] = '\0'; - - papszFileList = CSLAddString(papszFileList, szModule); - } - } - - CSLDestroy(candidateFileList); - - if (CSLCount(papszFileList) == 0) - { - if (!bTestOpen) - CPLError(CE_Failure, CPLE_OpenFailed, - "No candidate Tiger files (TGR*.RT1) found in\n" - "directory: %s", - pszFilename); - CSLDestroy(papszFileList); - return FALSE; - } - } - - /* -------------------------------------------------------------------- */ - /* Loop over all these files trying to open them. In testopen */ - /* mode we first read the first 80 characters, to verify that */ - /* it looks like an Tiger file. Note that we don't keep the file */ - /* open ... we don't want to occupy a lot of file handles when */ - /* handling a whole directory. */ - /* -------------------------------------------------------------------- */ - papszModules = nullptr; - - for (int i = 0; papszFileList && papszFileList[i] != nullptr; i++) - { - if (bTestOpen || i == 0) - { - char *l_pszFilename = BuildFilename(papszFileList[i], "1"); - - VSILFILE *fp = VSIFOpenL(l_pszFilename, "rb"); - CPLFree(l_pszFilename); - - if (fp == nullptr) - continue; - - char szHeader[500] = {}; - if (VSIFReadL(szHeader, sizeof(szHeader) - 1, 1, fp) < 1) - { - VSIFCloseL(fp); - continue; - } - - VSIFCloseL(fp); - - char *pszRecStart = szHeader; - szHeader[sizeof(szHeader) - 1] = '\0'; - - bool bIsGDT = false; - - if (STARTS_WITH_CI(pszRecStart, "Copyright (C)") && - strstr(pszRecStart, "Geographic Data Tech") != nullptr) - { - bIsGDT = true; - - while (*pszRecStart != '\0' && *pszRecStart != 10 && - *pszRecStart != 13) - pszRecStart++; - - while (*pszRecStart == 10 || *pszRecStart == 13) - pszRecStart++; - } - - if (pszRecStart[0] != '1') - continue; - - if (!isdigit(static_cast(pszRecStart[1])) || - !isdigit(static_cast(pszRecStart[2])) || - !isdigit(static_cast(pszRecStart[3])) || - !isdigit(static_cast(pszRecStart[4]))) - continue; - - nVersionCode = atoi(TigerFileBase::GetField(pszRecStart, 2, 5)); - nVersion = TigerClassifyVersion(nVersionCode); - nVersion = TigerCheckVersion(nVersion, papszFileList[i]); - - CPLDebug("OGR", "Tiger Version Code=%d, Classified as %s ", - nVersionCode, TigerVersionString(nVersion)); - - if (nVersionCode != 0 && nVersionCode != 2 && nVersionCode != 3 && - nVersionCode != 5 && nVersionCode != 21 && nVersionCode != 24 && - pszRecStart[3] != '9' && pszRecStart[3] != DIGIT_ZERO && - !bIsGDT) - continue; - - // we could (and should) add a bunch more validation here. - } - - papszModules = CSLAddString(papszModules, papszFileList[i]); - } - - CSLDestroy(papszFileList); - - nModules = CSLCount(papszModules); - - if (nModules == 0 || papszModules == nullptr) - { - if (!bTestOpen) - { - if (VSI_ISREG(stat.st_mode)) - CPLError(CE_Failure, CPLE_OpenFailed, - "No TIGER/Line files (TGR*.RT1) found in\n" - "directory: %s", - pszFilename); - else - CPLError( - CE_Failure, CPLE_OpenFailed, - "File %s does not appear to be a TIGER/Line .RT1 file.", - pszFilename); - } - - return FALSE; - } - - /* -------------------------------------------------------------------- */ - /* Do we have a user provided version override? */ - /* -------------------------------------------------------------------- */ - const char *pszRequestedVersion = - CPLGetConfigOption("TIGER_VERSION", nullptr); - if (pszRequestedVersion != nullptr) - { - - if (STARTS_WITH_CI(pszRequestedVersion, "TIGER_")) - { - int iCode = 1; // Used after for. - - for (; iCode < TIGER_Unknown; iCode++) - { - if (EQUAL(TigerVersionString((TigerVersion)iCode), - pszRequestedVersion)) - { - nVersion = (TigerVersion)iCode; - break; - } - } - - if (iCode == TIGER_Unknown) - { - CPLError(CE_Failure, CPLE_AppDefined, - "Failed to recognise TIGER_VERSION setting: %s", - pszRequestedVersion); - return FALSE; - } - - CPLDebug("OGR", "OVERRIDE Tiger Version %s ", - TigerVersionString(nVersion)); - } - else - { - nVersionCode = atoi(pszRequestedVersion); - nVersion = TigerClassifyVersion(nVersionCode); - - CPLDebug("OGR", "OVERRIDE Tiger Version Code=%d, Classified as %s ", - nVersionCode, TigerVersionString(nVersion)); - } - } - - /* -------------------------------------------------------------------- */ - /* Create the layers which appear to exist. */ - /* -------------------------------------------------------------------- */ - // RT1, RT2, RT3 - AddLayer( - new OGRTigerLayer(this, new TigerCompleteChain(this, papszModules[0]))); - - /* should we have kept track of whether we encountered an RT4 file? */ - // RT4 - AddLayer(new OGRTigerLayer(this, new TigerAltName(this, papszModules[0]))); - - // RT5 - AddLayer( - new OGRTigerLayer(this, new TigerFeatureIds(this, papszModules[0]))); - - // RT6 - AddLayer(new OGRTigerLayer(this, new TigerZipCodes(this, papszModules[0]))); - // RT7 - AddLayer( - new OGRTigerLayer(this, new TigerLandmarks(this, papszModules[0]))); - - // RT8 - AddLayer( - new OGRTigerLayer(this, new TigerAreaLandmarks(this, papszModules[0]))); - - // RT9 - if (nVersion < TIGER_2002) - { - AddLayer(new OGRTigerLayer( - this, new TigerKeyFeatures(this, papszModules[0]))); - } - - // RTA, RTS - AddLayer(new OGRTigerLayer(this, new TigerPolygon(this, papszModules[0]))); - - // RTB - if (nVersion >= TIGER_2002) - { - AddLayer(new OGRTigerLayer( - this, new TigerPolygonCorrections(this, papszModules[0]))); - } - - // RTC - AddLayer( - new OGRTigerLayer(this, new TigerEntityNames(this, papszModules[0]))); - - // RTE - if (nVersion >= TIGER_2002) - { - AddLayer(new OGRTigerLayer( - this, new TigerPolygonEconomic(this, papszModules[0]))); - } - - // RTH - AddLayer( - new OGRTigerLayer(this, new TigerIDHistory(this, papszModules[0]))); - - // RTI - AddLayer( - new OGRTigerLayer(this, new TigerPolyChainLink(this, papszModules[0]))); - - // RTM - AddLayer(new OGRTigerLayer( - this, new TigerSpatialMetadata(this, papszModules[0]))); - - // RTP - AddLayer(new OGRTigerLayer(this, new TigerPIP(this, papszModules[0]))); - - // RTR - AddLayer( - new OGRTigerLayer(this, new TigerTLIDRange(this, papszModules[0]))); - - // RTT - if (nVersion >= TIGER_2002) - { - AddLayer(new OGRTigerLayer(this, - new TigerZeroCellID(this, papszModules[0]))); - } - - // RTU - if (nVersion >= TIGER_2002) - { - AddLayer( - new OGRTigerLayer(this, new TigerOverUnder(this, papszModules[0]))); - } - - // RTZ - AddLayer(new OGRTigerLayer(this, new TigerZipPlus4(this, papszModules[0]))); - - return TRUE; -} - -/************************************************************************/ -/* GetOption() */ -/************************************************************************/ - -const char *OGRTigerDataSource::GetOption(const char *pszOption) - -{ - return CSLFetchNameValue(papszOptions, pszOption); -} - -/************************************************************************/ -/* GetModule() */ -/************************************************************************/ - -const char *OGRTigerDataSource::GetModule(int iModule) - -{ - if (iModule < 0 || iModule >= nModules) - return nullptr; - else - return papszModules[iModule]; -} - -/************************************************************************/ -/* CheckModule() */ -/* */ -/* This is used by the writer to check if this module has been */ -/* written to before. */ -/************************************************************************/ - -bool OGRTigerDataSource::CheckModule(const char *pszModule) - -{ - for (int i = 0; i < nModules; i++) - { - if (EQUAL(pszModule, papszModules[i])) - return true; - } - return false; -} - -/************************************************************************/ -/* AddModule() */ -/************************************************************************/ - -void OGRTigerDataSource::AddModule(const char *pszModule) - -{ - if (CheckModule(pszModule)) - return; - - papszModules = CSLAddString(papszModules, pszModule); - nModules++; -} - -/************************************************************************/ -/* BuildFilename() */ -/************************************************************************/ - -char *OGRTigerDataSource::BuildFilename(const char *pszModuleName, - const char *pszExtension) - -{ - /* -------------------------------------------------------------------- */ - /* Force the record type to lower case if the filename appears */ - /* to be in lower case. */ - /* -------------------------------------------------------------------- */ - char szLCExtension[3] = {}; - if (*pszExtension >= 'A' && *pszExtension <= 'Z' && *pszModuleName == 't') - { - szLCExtension[0] = (*pszExtension) + 'a' - 'A'; - szLCExtension[1] = '\0'; - pszExtension = szLCExtension; - } - - /* -------------------------------------------------------------------- */ - /* Build the filename. */ - /* -------------------------------------------------------------------- */ - const size_t nFilenameLen = strlen(GetDirPath()) + strlen(pszModuleName) + - strlen(pszExtension) + 10; - char *pszFilename = (char *)CPLMalloc(nFilenameLen); - - if (strlen(GetDirPath()) == 0) - snprintf(pszFilename, nFilenameLen, "%s%s", pszModuleName, - pszExtension); - else - snprintf(pszFilename, nFilenameLen, "%s/%s%s", GetDirPath(), - pszModuleName, pszExtension); - - return pszFilename; -} diff --git a/ogr/ogrsf_frmts/tiger/ogrtigerdriver.cpp b/ogr/ogrsf_frmts/tiger/ogrtigerdriver.cpp deleted file mode 100644 index 29f41a4a6536..000000000000 --- a/ogr/ogrsf_frmts/tiger/ogrtigerdriver.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements OGRTigerDriver - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -/************************************************************************/ -/* Open() */ -/************************************************************************/ - -static GDALDataset *OGRTigerDriverOpen(GDALOpenInfo *poOpenInfo) - -{ - if (!poOpenInfo->bStatOK) - return nullptr; - char **papszSiblingFiles = poOpenInfo->GetSiblingFiles(); - if (papszSiblingFiles != nullptr) - { - bool bFoundCompatibleFile = false; - for (int i = 0; papszSiblingFiles[i] != nullptr; i++) - { - int nLen = (int)strlen(papszSiblingFiles[i]); - if (nLen > 4 && papszSiblingFiles[i][nLen - 4] == '.' && - papszSiblingFiles[i][nLen - 1] == '1') - { - bFoundCompatibleFile = true; - break; - } - } - if (!bFoundCompatibleFile) - return nullptr; - } - - OGRTigerDataSource *poDS = new OGRTigerDataSource; - - if (!poDS->Open(poOpenInfo->pszFilename, TRUE)) - { - delete poDS; - poDS = nullptr; - } - - if (poDS != nullptr && poOpenInfo->eAccess == GA_Update) - { - CPLError(CE_Failure, CPLE_OpenFailed, - "Tiger Driver doesn't support update."); - delete poDS; - poDS = nullptr; - } - - return poDS; -} - -/************************************************************************/ -/* RegisterOGRTiger() */ -/************************************************************************/ - -void RegisterOGRTiger() - -{ - if (GDALGetDriverByName("TIGER") != nullptr) - return; - - GDALDriver *poDriver = new GDALDriver(); - - poDriver->SetDescription("TIGER"); - poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); - poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "U.S. Census TIGER/Line"); - poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/tiger.html"); - poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); - poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); - - poDriver->pfnOpen = OGRTigerDriverOpen; - - GetGDALDriverManager()->RegisterDriver(poDriver); -} diff --git a/ogr/ogrsf_frmts/tiger/ogrtigerlayer.cpp b/ogr/ogrsf_frmts/tiger/ogrtigerlayer.cpp deleted file mode 100644 index 38481b2ed501..000000000000 --- a/ogr/ogrsf_frmts/tiger/ogrtigerlayer.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements OGRTigerLayer class. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" - -/************************************************************************/ -/* OGRTigerLayer() */ -/* */ -/* Note that the OGRTigerLayer assumes ownership of the passed */ -/* OGRFeatureDefn object. */ -/************************************************************************/ - -OGRTigerLayer::OGRTigerLayer(OGRTigerDataSource *poDSIn, - TigerFileBase *poReaderIn) - : poReader(poReaderIn), poDS(poDSIn), nFeatureCount(0), - panModuleFCount(nullptr), panModuleOffset(nullptr), iLastFeatureId(0), - iLastModule(-1) -{ - /* -------------------------------------------------------------------- */ - /* Setup module feature counts. */ - /* -------------------------------------------------------------------- */ - panModuleFCount = (int *)CPLCalloc(poDS->GetModuleCount(), sizeof(int)); - panModuleOffset = (int *)CPLCalloc(poDS->GetModuleCount() + 1, sizeof(int)); - - nFeatureCount = 0; - - for (int iModule = 0; iModule < poDS->GetModuleCount(); iModule++) - { - if (poReader->SetModule(poDS->GetModule(iModule))) - panModuleFCount[iModule] = poReader->GetFeatureCount(); - else - panModuleFCount[iModule] = 0; - - panModuleOffset[iModule] = nFeatureCount; - nFeatureCount += panModuleFCount[iModule]; - } - - // this entry is just to make range comparisons easy without worrying - // about falling off the end of the array. - panModuleOffset[poDS->GetModuleCount()] = nFeatureCount; - - poReader->SetModule(nullptr); -} - -/************************************************************************/ -/* ~OGRTigerLayer() */ -/************************************************************************/ - -OGRTigerLayer::~OGRTigerLayer() - -{ - if (m_nFeaturesRead > 0 && poReader->GetFeatureDefn() != nullptr) - { - CPLDebug("TIGER", "%d features read on layer '%s'.", - (int)m_nFeaturesRead, poReader->GetFeatureDefn()->GetName()); - } - - delete poReader; - - CPLFree(panModuleFCount); - CPLFree(panModuleOffset); -} - -/************************************************************************/ -/* ResetReading() */ -/************************************************************************/ - -void OGRTigerLayer::ResetReading() - -{ - iLastFeatureId = 0; - iLastModule = -1; -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ - -OGRFeature *OGRTigerLayer::GetFeature(GIntBig nFeatureId) - -{ - if (nFeatureId < 1 || nFeatureId > nFeatureCount) - return nullptr; - - /* -------------------------------------------------------------------- */ - /* If we don't have the current module open for the requested */ - /* data, then open it now. */ - /* -------------------------------------------------------------------- */ - if (iLastModule == -1 || nFeatureId <= panModuleOffset[iLastModule] || - nFeatureId > panModuleOffset[iLastModule + 1]) - { - for (iLastModule = 0; iLastModule < poDS->GetModuleCount() && - nFeatureId > panModuleOffset[iLastModule + 1]; - iLastModule++) - { - } - - if (!poReader->SetModule(poDS->GetModule(iLastModule))) - { - return nullptr; - } - } - - /* -------------------------------------------------------------------- */ - /* Fetch the feature associated with the record. */ - /* -------------------------------------------------------------------- */ - OGRFeature *poFeature = poReader->GetFeature( - (int)nFeatureId - panModuleOffset[iLastModule] - 1); - - if (poFeature != nullptr) - { - poFeature->SetFID(nFeatureId); - - if (poFeature->GetGeometryRef() != nullptr) - poFeature->GetGeometryRef()->assignSpatialReference( - poDS->DSGetSpatialRef()); - - poFeature->SetField(0, poReader->GetShortModule()); - - m_nFeaturesRead++; - } - - return poFeature; -} - -/************************************************************************/ -/* GetNextFeature() */ -/************************************************************************/ - -OGRFeature *OGRTigerLayer::GetNextFeature() - -{ - /* -------------------------------------------------------------------- */ - /* Read features till we find one that satisfies our current */ - /* spatial criteria. */ - /* -------------------------------------------------------------------- */ - while (iLastFeatureId < nFeatureCount) - { - OGRFeature *poFeature = GetFeature(++iLastFeatureId); - - if (poFeature == nullptr) - break; - - if ((m_poFilterGeom == nullptr || - FilterGeometry(poFeature->GetGeometryRef())) && - (m_poAttrQuery == nullptr || m_poAttrQuery->Evaluate(poFeature))) - return poFeature; - - delete poFeature; - } - - return nullptr; -} - -/************************************************************************/ -/* TestCapability() */ -/************************************************************************/ - -int OGRTigerLayer::TestCapability(const char *pszCap) - -{ - if (EQUAL(pszCap, OLCRandomRead)) - return TRUE; - - else if (EQUAL(pszCap, OLCFastFeatureCount)) - return TRUE; - - else - return FALSE; -} - -/************************************************************************/ -/* GetLayerDefn() */ -/************************************************************************/ - -OGRFeatureDefn *OGRTigerLayer::GetLayerDefn() - -{ - OGRFeatureDefn *poFDefn = poReader->GetFeatureDefn(); - if (poFDefn != nullptr) - { - if (poFDefn->GetGeomFieldCount() > 0) - poFDefn->GetGeomFieldDefn(0)->SetSpatialRef( - poDS->DSGetSpatialRef()); - } - return poFDefn; -} - -/************************************************************************/ -/* GetFeatureCount() */ -/************************************************************************/ - -GIntBig OGRTigerLayer::GetFeatureCount(int bForce) - -{ - if (m_poFilterGeom == nullptr && m_poAttrQuery == nullptr) - return nFeatureCount; - else - return OGRLayer::GetFeatureCount(bForce); -} diff --git a/ogr/ogrsf_frmts/tiger/tigeraltname.cpp b/ogr/ogrsf_frmts/tiger/tigeraltname.cpp deleted file mode 100644 index f270d794460c..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigeraltname.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerAltName, providing access to RT4 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -#include - -static const char FOUR_FILE_CODE[] = "4"; - -static const TigerFieldInfo rt4_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"RTSQ", 'R', 'N', OFTInteger, 16, 18, 3, 1, 1}, - {"FEAT", ' ', ' ', OFTIntegerList, 0, 0, 8, 1, 0} - // Note: we don't mention the FEAT1, FEAT2, FEAT3, FEAT4, FEAT5 fields - // here because they're handled separately in the code below; they - // correspond - // to the FEAT array field here. -}; - -static const TigerRecordInfo rt4_info = { - rt4_fields, sizeof(rt4_fields) / sizeof(TigerFieldInfo), 58}; - -/************************************************************************/ -/* TigerAltName() */ -/************************************************************************/ - -TigerAltName::TigerAltName(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rt4_info, FOUR_FILE_CODE) -{ - OGRFieldDefn oField("", OFTInteger); - - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("AltName"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type 4 record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ - -OGRFeature *TigerAltName::GetFeature(int nRecordId) - -{ - char achRecord[OGR_TIGER_RECBUF_LEN]; - - if (nRecordId < 0 || nRecordId >= nFeatures) - { - CPLError(CE_Failure, CPLE_FileIO, - "Request for out-of-range feature %d of %s4", nRecordId, - pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Read the raw record data from the file. */ - /* -------------------------------------------------------------------- */ - if (fpPrimary == nullptr) - return nullptr; - - const auto nOffset = static_cast(nRecordId) * nRecordLength; - if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s4", nOffset, pszModule); - return nullptr; - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRecord, psRTInfo->nRecordLength, 1, fpPrimary) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %s4", - nRecordId, pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Set fields. */ - /* -------------------------------------------------------------------- */ - - OGRFeature *poFeature = new OGRFeature(poFeatureDefn); - int anFeatList[5] = {0}; - int nFeatCount = 0; - - SetFields(psRTInfo, poFeature, achRecord); - - for (int iFeat = 0; iFeat < 5; iFeat++) - { - const char *pszFieldText = - GetField(achRecord, 19 + iFeat * 8, 26 + iFeat * 8); - - if (*pszFieldText != '\0') - anFeatList[nFeatCount++] = atoi(pszFieldText); - } - - poFeature->SetField("FEAT", nFeatCount, anFeatList); - - return poFeature; -} diff --git a/ogr/ogrsf_frmts/tiger/tigerarealandmarks.cpp b/ogr/ogrsf_frmts/tiger/tigerarealandmarks.cpp deleted file mode 100644 index 8ec1ec7fa7ef..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerarealandmarks.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerAreaLandmarks, providing access to .RT8 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char EIGHT_FILE_CODE[] = "8"; - -static const TigerFieldInfo rt8_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"LAND", 'R', 'N', OFTInteger, 26, 35, 10, 1, 1}}; - -static const TigerRecordInfo rt8_info = { - rt8_fields, sizeof(rt8_fields) / sizeof(TigerFieldInfo), 36}; - -/************************************************************************/ -/* TigerAreaLandmarks() */ -/************************************************************************/ - -TigerAreaLandmarks::TigerAreaLandmarks( - OGRTigerDataSource *poDSIn, CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rt8_info, EIGHT_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("AreaLandmarks"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type 8 record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigercompletechain.cpp b/ogr/ogrsf_frmts/tiger/tigercompletechain.cpp deleted file mode 100644 index a281e5a42d89..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigercompletechain.cpp +++ /dev/null @@ -1,652 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerCompleteChain, providing access to RT1 and - * related files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -#include - -static const TigerFieldInfo rt1_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"SIDE1", 'R', 'N', OFTInteger, 16, 16, 1, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 17, 17, 1, 1, 1}, - {"FEDIRP", 'L', 'A', OFTString, 18, 19, 2, 1, 1}, - {"FENAME", 'L', 'A', OFTString, 20, 49, 30, 1, 1}, - {"FETYPE", 'L', 'A', OFTString, 50, 53, 4, 1, 1}, - {"FEDIRS", 'L', 'A', OFTString, 54, 55, 2, 1, 1}, - {"CFCC", 'L', 'A', OFTString, 56, 58, 3, 1, 1}, - {"FRADDL", 'R', 'A', OFTString, 59, 69, 11, 1, 1}, - {"TOADDL", 'R', 'A', OFTString, 70, 80, 11, 1, 1}, - {"FRADDR", 'R', 'A', OFTString, 81, 91, 11, 1, 1}, - {"TOADDR", 'R', 'A', OFTString, 92, 102, 11, 1, 1}, - {"FRIADDL", 'L', 'A', OFTString, 103, 103, 1, 1, 1}, - {"TOIADDL", 'L', 'A', OFTString, 104, 104, 1, 1, 1}, - {"FRIADDR", 'L', 'A', OFTString, 105, 105, 1, 1, 1}, - {"TOIADDR", 'L', 'A', OFTString, 106, 106, 1, 1, 1}, - {"ZIPL", 'L', 'N', OFTInteger, 107, 111, 5, 1, 1}, - {"ZIPR", 'L', 'N', OFTInteger, 112, 116, 5, 1, 1}, - {"AIANHHFPL", 'L', 'N', OFTInteger, 117, 121, 5, 1, 1}, - {"AIANHHFPR", 'L', 'N', OFTInteger, 122, 126, 5, 1, 1}, - {"AIHHTLIL", 'L', 'A', OFTString, 127, 127, 1, 1, 1}, - {"AIHHTLIR", 'L', 'A', OFTString, 128, 128, 1, 1, 1}, - {"CENSUS1", 'L', 'A', OFTString, 129, 129, 1, 1, 1}, - {"CENSUS2", 'L', 'A', OFTString, 130, 130, 1, 1, 1}, - {"STATEL", 'L', 'N', OFTInteger, 131, 132, 2, 1, 1}, - {"STATER", 'L', 'N', OFTInteger, 133, 134, 2, 1, 1}, - {"COUNTYL", 'L', 'N', OFTInteger, 135, 137, 3, 1, 1}, - {"COUNTYR", 'L', 'N', OFTInteger, 138, 140, 3, 1, 1}, - - {"COUSUBL", 'L', 'N', OFTInteger, 141, 145, 5, 1, 1}, - {"COUSUBR", 'L', 'N', OFTInteger, 146, 150, 5, 1, 1}, - {"SUBMCDL", 'L', 'N', OFTInteger, 151, 155, 5, 1, 1}, - {"SUBMCDR", 'L', 'N', OFTInteger, 156, 160, 5, 1, 1}, - {"PLACEL", 'L', 'N', OFTInteger, 161, 165, 5, 1, 1}, - {"PLACER", 'L', 'N', OFTInteger, 166, 170, 5, 1, 1}, - {"TRACTL", 'L', 'N', OFTInteger, 171, 176, 6, 1, 1}, - {"TRACTR", 'L', 'N', OFTInteger, 177, 182, 6, 1, 1}, - {"BLOCKL", 'L', 'N', OFTInteger, 183, 186, 4, 1, 1}, - {"BLOCKR", 'L', 'N', OFTInteger, 187, 190, 4, 1, 1}}; -static const TigerRecordInfo rt1_2002_info = { - rt1_2002_fields, sizeof(rt1_2002_fields) / sizeof(TigerFieldInfo), 228}; - -static const TigerFieldInfo rt1_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"SIDE1", 'R', 'N', OFTInteger, 16, 16, 1, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 17, 17, 1, 1, 1}, - {"FEDIRP", 'L', 'A', OFTString, 18, 19, 2, 1, 1}, - {"FENAME", 'L', 'A', OFTString, 20, 49, 30, 1, 1}, - {"FETYPE", 'L', 'A', OFTString, 50, 53, 4, 1, 1}, - {"FEDIRS", 'L', 'A', OFTString, 54, 55, 2, 1, 1}, - {"CFCC", 'L', 'A', OFTString, 56, 58, 3, 1, 1}, - {"FRADDL", 'R', 'A', OFTString, 59, 69, 11, 1, 1}, - {"TOADDL", 'R', 'A', OFTString, 70, 80, 11, 1, 1}, - {"FRADDR", 'R', 'A', OFTString, 81, 91, 11, 1, 1}, - {"TOADDR", 'R', 'A', OFTString, 92, 102, 11, 1, 1}, - {"FRIADDL", 'L', 'A', OFTInteger, 103, 103, 1, 1, 1}, - {"TOIADDL", 'L', 'A', OFTInteger, 104, 104, 1, 1, 1}, - {"FRIADDR", 'L', 'A', OFTInteger, 105, 105, 1, 1, 1}, - {"TOIADDR", 'L', 'A', OFTInteger, 106, 106, 1, 1, 1}, - {"ZIPL", 'L', 'N', OFTInteger, 107, 111, 5, 1, 1}, - {"ZIPR", 'L', 'N', OFTInteger, 112, 116, 5, 1, 1}, - {"FAIRL", 'L', 'N', OFTInteger, 117, 121, 5, 1, 1}, - {"FAIRR", 'L', 'N', OFTInteger, 122, 126, 5, 1, 1}, - {"TRUSTL", 'L', 'A', OFTString, 127, 127, 1, 1, 1}, - {"TRUSTR", 'L', 'A', OFTString, 128, 128, 1, 1, 1}, - {"CENSUS1", 'L', 'A', OFTString, 129, 129, 1, 1, 1}, - {"CENSUS2", 'L', 'A', OFTString, 130, 130, 1, 1, 1}, - {"STATEL", 'L', 'N', OFTInteger, 131, 132, 2, 1, 1}, - {"STATER", 'L', 'N', OFTInteger, 133, 134, 2, 1, 1}, - {"COUNTYL", 'L', 'N', OFTInteger, 135, 137, 3, 1, 1}, - {"COUNTYR", 'L', 'N', OFTInteger, 138, 140, 3, 1, 1}, - - {"FMCDL", 'L', 'N', OFTInteger, 141, 145, 5, 1, 1}, - {"FMCDR", 'L', 'N', OFTInteger, 146, 150, 5, 1, 1}, - {"FSMCDL", 'L', 'N', OFTInteger, 151, 155, 5, 1, 1}, - {"FSMCDR", 'L', 'N', OFTInteger, 156, 160, 5, 1, 1}, - {"FPLL", 'L', 'N', OFTInteger, 161, 165, 5, 1, 1}, - {"FPLR", 'L', 'N', OFTInteger, 166, 170, 5, 1, 1}, - {"CTBNAL", 'L', 'N', OFTInteger, 171, 176, 6, 1, 1}, - {"CTBNAR", 'L', 'N', OFTInteger, 177, 182, 6, 1, 1}, - {"BLKL", 'L', 'N', OFTString, 183, 186, 4, 1, 1}, - {"BLKR", 'L', 'N', OFTString, 187, 190, 4, 1, 1}}; -static const TigerRecordInfo rt1_info = { - rt1_fields, sizeof(rt1_fields) / sizeof(TigerFieldInfo), 228}; - -static const TigerRecordInfo rt2_info = { - nullptr, // RT2 is handled specially in the code below; the only - 0, // thing from this structure that is used is: - 208 // <--- nRecordLength -}; - -static const TigerFieldInfo rt3_2000_Redistricting_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 0, 0}, - {"STATE90L", 'L', 'N', OFTInteger, 16, 17, 2, 1, 1}, - {"STATE90R", 'L', 'N', OFTInteger, 18, 19, 2, 1, 1}, - {"COUN90L", 'L', 'N', OFTInteger, 20, 22, 3, 1, 1}, - {"COUN90R", 'L', 'N', OFTInteger, 23, 25, 3, 1, 1}, - {"FMCD90L", 'L', 'N', OFTInteger, 26, 30, 5, 1, 1}, - {"FMCD90R", 'L', 'N', OFTInteger, 31, 35, 5, 1, 1}, - {"FPL90L", 'L', 'N', OFTInteger, 36, 40, 5, 1, 1}, - {"FPL90R", 'L', 'N', OFTInteger, 41, 45, 5, 1, 1}, - {"CTBNA90L", 'L', 'N', OFTInteger, 46, 51, 6, 1, 1}, - {"CTBNA90R", 'L', 'N', OFTInteger, 52, 57, 6, 1, 1}, - {"AIR90L", 'L', 'N', OFTInteger, 58, 61, 4, 1, 1}, - {"AIR90R", 'L', 'N', OFTInteger, 62, 65, 4, 1, 1}, - {"TRUST90L", 'L', 'A', OFTString, 66, 66, 1, 1, 1}, - {"TRUST90R", 'L', 'A', OFTString, 67, 67, 1, 1, 1}, - {"BLK90L", 'L', 'A', OFTString, 70, 73, 4, 1, 1}, - {"BLK90R", 'L', 'A', OFTString, 74, 77, 4, 1, 1}, - {"AIRL", 'L', 'N', OFTInteger, 78, 81, 4, 1, 1}, - {"AIRR", 'L', 'N', OFTInteger, 82, 85, 4, 1, 1}, - - {"ANRCL", 'L', 'N', OFTInteger, 86, 90, 5, 1, 1}, - {"ANRCR", 'L', 'N', OFTInteger, 91, 95, 5, 1, 1}, - {"AITSCEL", 'L', 'N', OFTInteger, 96, 98, 3, 1, 1}, - {"AITSCER", 'L', 'N', OFTInteger, 99, 101, 3, 1, 1}, - {"AITSL", 'L', 'N', OFTInteger, 102, 106, 5, 1, 1}, - {"AITSR", 'L', 'N', OFTInteger, 107, 111, 5, 1, 1}}; -static const TigerRecordInfo rt3_2000_Redistricting_info = { - rt3_2000_Redistricting_fields, - sizeof(rt3_2000_Redistricting_fields) / sizeof(TigerFieldInfo), 111}; - -static const TigerFieldInfo rt3_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 0, 0}, - {"STATE90L", 'L', 'N', OFTInteger, 16, 17, 2, 1, 1}, - {"STATE90R", 'L', 'N', OFTInteger, 18, 19, 2, 1, 1}, - {"COUN90L", 'L', 'N', OFTInteger, 20, 22, 3, 1, 1}, - {"COUN90R", 'L', 'N', OFTInteger, 23, 25, 3, 1, 1}, - {"FMCD90L", 'L', 'N', OFTInteger, 26, 30, 5, 1, 1}, - {"FMCD90R", 'L', 'N', OFTInteger, 31, 35, 5, 1, 1}, - {"FPL90L", 'L', 'N', OFTInteger, 36, 40, 5, 1, 1}, - {"FPL90R", 'L', 'N', OFTInteger, 41, 45, 5, 1, 1}, - {"CTBNA90L", 'L', 'N', OFTInteger, 46, 51, 6, 1, 1}, - {"CTBNA90R", 'L', 'N', OFTInteger, 52, 57, 6, 1, 1}, - {"AIR90L", 'L', 'N', OFTInteger, 58, 61, 4, 1, 1}, - {"AIR90R", 'L', 'N', OFTInteger, 62, 65, 4, 1, 1}, - {"TRUST90L", 'L', 'A', OFTInteger, 66, 66, 1, 1, 1}, - {"TRUST90R", 'L', 'A', OFTInteger, 67, 67, 1, 1, 1}, - {"BLK90L", 'L', 'A', OFTString, 70, 73, 4, 1, 1}, - {"BLK90R", 'L', 'A', OFTString, 74, 77, 4, 1, 1}, - {"AIRL", 'L', 'N', OFTInteger, 78, 81, 4, 1, 1}, - {"AIRR", 'L', 'N', OFTInteger, 82, 85, 4, 1, 1}, - - {"VTDL", 'L', 'A', OFTString, 104, 107, 4, 1, 1}, - {"VTDR", 'L', 'A', OFTString, 108, 111, 4, 1, 1}}; - -static const TigerRecordInfo rt3_info = { - rt3_fields, sizeof(rt3_fields) / sizeof(TigerFieldInfo), 111}; - -/************************************************************************/ -/* TigerCompleteChain() */ -/************************************************************************/ - -TigerCompleteChain::TigerCompleteChain(OGRTigerDataSource *poDSIn, - const char * /* pszPrototypeModule */) - : fpShape(nullptr), panShapeRecordId(nullptr), fpRT3(nullptr), - bUsingRT3(false), psRT1Info(nullptr), psRT2Info(nullptr), - psRT3Info(nullptr) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("CompleteChain"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbLineString); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRT1Info = &rt1_2002_info; - // bUsingRT3 = false; - } - else - { - psRT1Info = &rt1_info; - bUsingRT3 = true; - } - - psRT2Info = &rt2_info; - - nRT1RecOffset = 0; - - if (poDS->GetVersion() >= TIGER_2000_Redistricting) - { - psRT3Info = &rt3_2000_Redistricting_info; - } - else - { - psRT3Info = &rt3_info; - } - - /* -------------------------------------------------------------------- */ - /* Fields from type 1 record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRT1Info, poFeatureDefn); - - /* -------------------------------------------------------------------- */ - /* Fields from type 3 record. Eventually we should verify that */ - /* a .RT3 file is available before adding these fields. */ - /* -------------------------------------------------------------------- */ - if (bUsingRT3) - { - AddFieldDefns(psRT3Info, poFeatureDefn); - } -} - -/************************************************************************/ -/* ~TigerCompleteChain() */ -/************************************************************************/ - -TigerCompleteChain::~TigerCompleteChain() - -{ - CPLFree(panShapeRecordId); - - if (fpRT3 != nullptr) - VSIFCloseL(fpRT3); - - if (fpShape != nullptr) - VSIFCloseL(fpShape); -} - -/************************************************************************/ -/* SetModule() */ -/************************************************************************/ - -bool TigerCompleteChain::SetModule(const char *pszModuleIn) - -{ - if (!OpenFile(pszModuleIn, "1")) - return false; - - EstablishFeatureCount(); - - /* -------------------------------------------------------------------- */ - /* Is this a copyright record inserted at the beginning of the */ - /* RT1 file by the folks at GDT? If so, setup to ignore the */ - /* first record. */ - /* -------------------------------------------------------------------- */ - nRT1RecOffset = 0; - if (pszModuleIn) - { - char achHeader[10]; - - VSIFSeekL(fpPrimary, 0, SEEK_SET); - VSIFReadL(achHeader, sizeof(achHeader), 1, fpPrimary); - - if (STARTS_WITH_CI(achHeader, "Copyright")) - { - nRT1RecOffset = 1; - nFeatures--; - } - } - - /* -------------------------------------------------------------------- */ - /* Open the RT3 file */ - /* -------------------------------------------------------------------- */ - if (bUsingRT3) - { - if (fpRT3 != nullptr) - { - VSIFCloseL(fpRT3); - fpRT3 = nullptr; - } - - if (pszModuleIn) - { - char *pszFilename = poDS->BuildFilename(pszModuleIn, "3"); - - fpRT3 = VSIFOpenL(pszFilename, "rb"); - - CPLFree(pszFilename); - } - } - - /* -------------------------------------------------------------------- */ - /* Close the shape point file, if open and free the list of */ - /* record ids. */ - /* -------------------------------------------------------------------- */ - if (fpShape != nullptr) - { - VSIFCloseL(fpShape); - fpShape = nullptr; - } - - CPLFree(panShapeRecordId); - panShapeRecordId = nullptr; - - /* -------------------------------------------------------------------- */ - /* Try to open the RT2 file corresponding to this RT1 file. */ - /* -------------------------------------------------------------------- */ - if (pszModuleIn != nullptr) - { - char *pszFilename = poDS->BuildFilename(pszModuleIn, "2"); - - fpShape = VSIFOpenL(pszFilename, "rb"); - - if (fpShape == nullptr) - { - if (nRT1RecOffset == 0) - CPLError(CE_Warning, CPLE_OpenFailed, - "Failed to open %s, intermediate shape arcs will not " - "be available.\n", - pszFilename); - } - else - panShapeRecordId = - (int *)CPLCalloc(sizeof(int), (size_t)GetFeatureCount()); - - CPLFree(pszFilename); - } - - return true; -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ - -OGRFeature *TigerCompleteChain::GetFeature(int nRecordId) - -{ - char achRecord[OGR_TIGER_RECBUF_LEN]; - - if (nRecordId < 0 || nRecordId >= nFeatures) - { - CPLError(CE_Failure, CPLE_FileIO, - "Request for out-of-range feature %d of %s1", nRecordId, - pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Read the raw record data from the file. */ - /* -------------------------------------------------------------------- */ - if (fpPrimary == nullptr) - return nullptr; - - { - const auto nOffset = - static_cast(nRecordId + nRT1RecOffset) * nRecordLength; - if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s1", nOffset, - pszModule); - return nullptr; - } - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRecord, psRT1Info->nRecordLength, 1, fpPrimary) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to read %d bytes of record %d of %s1 at offset %d", - psRT1Info->nRecordLength, nRecordId, pszModule, - (nRecordId + nRT1RecOffset) * nRecordLength); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Set fields. */ - /* -------------------------------------------------------------------- */ - - auto poFeature = std::make_unique(poFeatureDefn); - - SetFields(psRT1Info, poFeature.get(), achRecord); - - /* -------------------------------------------------------------------- */ - /* Read RT3 record, and apply fields. */ - /* -------------------------------------------------------------------- */ - - if (fpRT3 != nullptr) - { - char achRT3Rec[OGR_TIGER_RECBUF_LEN]; - int nRT3RecLen = - psRT3Info->nRecordLength + nRecordLength - psRT1Info->nRecordLength; - - const auto nOffset = static_cast(nRecordId) * nRT3RecLen; - if (VSIFSeekL(fpRT3, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s3", nOffset, - pszModule); - return nullptr; - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRT3Rec, psRT3Info->nRecordLength, 1, fpRT3) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %s3", - nRecordId, pszModule); - return nullptr; - } - - SetFields(psRT3Info, poFeature.get(), achRT3Rec); - } - - /* -------------------------------------------------------------------- */ - /* Set geometry */ - /* -------------------------------------------------------------------- */ - auto poLine = std::make_unique(); - - poLine->setPoint(0, atoi(GetField(achRecord, 191, 200)) / 1000000.0, - atoi(GetField(achRecord, 201, 209)) / 1000000.0); - - if (!AddShapePoints(poFeature->GetFieldAsInteger("TLID"), nRecordId, - poLine.get(), 0)) - { - return nullptr; - } - - poLine->addPoint(atoi(GetField(achRecord, 210, 219)) / 1000000.0, - atoi(GetField(achRecord, 220, 228)) / 1000000.0); - - poFeature->SetGeometryDirectly(poLine.release()); - - return poFeature.release(); -} - -/************************************************************************/ -/* AddShapePoints() */ -/* */ -/* Record zero or more shape records associated with this line */ -/* and add the points to the passed line geometry. */ -/************************************************************************/ - -bool TigerCompleteChain::AddShapePoints(int nTLID, int nRecordId, - OGRLineString *poLine, - CPL_UNUSED int nSeqNum) -{ - int nShapeRecId = GetShapeRecordId(nRecordId, nTLID); - - // -2 means an error occurred. - if (nShapeRecId == -2) - return false; - - // -1 means there are no extra shape vertices, but things worked fine. - if (nShapeRecId == -1) - return true; - - /* -------------------------------------------------------------------- */ - /* Read all the sequential records with the same TLID. */ - /* -------------------------------------------------------------------- */ - char achShapeRec[OGR_TIGER_RECBUF_LEN]; - const int nShapeRecLen = - psRT2Info->nRecordLength + nRecordLength - psRT1Info->nRecordLength; - - for (; true; nShapeRecId++) - { - int nBytesRead = 0; - - const auto nOffset = - static_cast(nShapeRecId - 1) * nShapeRecLen; - if (VSIFSeekL(fpShape, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s2", nOffset, - pszModule); - return false; - } - - nBytesRead = static_cast( - VSIFReadL(achShapeRec, 1, psRT2Info->nRecordLength, fpShape)); - - /* - ** Handle case where the last record in the file is full. We will - ** try to read another record but not find it. We require that we - ** have found at least one shape record for this case though. - */ - if (nBytesRead <= 0 && VSIFEofL(fpShape) && poLine->getNumPoints() > 0) - break; - - if (nBytesRead != psRT2Info->nRecordLength) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to read %d bytes of record %d of %s2 at offset %d", - psRT2Info->nRecordLength, nShapeRecId, pszModule, - (nShapeRecId - 1) * nShapeRecLen); - return false; - } - - if (atoi(GetField(achShapeRec, 6, 15)) != nTLID) - break; - - /* -------------------------------------------------------------------- - */ - /* Translate the locations into OGRLineString vertices. */ - /* -------------------------------------------------------------------- - */ - int iVertex = 0; // Used after for. - - for (; iVertex < 10; iVertex++) - { - const int iStart = 19 + 19 * iVertex; - const int nX = atoi(GetField(achShapeRec, iStart, iStart + 9)); - const int nY = - atoi(GetField(achShapeRec, iStart + 10, iStart + 18)); - - if (nX == 0 && nY == 0) - break; - - poLine->addPoint(nX / 1000000.0, nY / 1000000.0); - } - - /* -------------------------------------------------------------------- - */ - /* Don't get another record if this one was incomplete. */ - /* -------------------------------------------------------------------- - */ - if (iVertex < 10) - break; - } - - return true; -} - -/************************************************************************/ -/* GetShapeRecordId() */ -/* */ -/* Get the record id of the first record of shape points for */ -/* the provided TLID (complete chain). */ -/************************************************************************/ - -int TigerCompleteChain::GetShapeRecordId(int nChainId, int nTLID) - -{ - CPLAssert(nChainId >= 0 && nChainId < GetFeatureCount()); - - if (fpShape == nullptr || panShapeRecordId == nullptr) - return -1; - - /* -------------------------------------------------------------------- */ - /* Do we already have the answer? */ - /* -------------------------------------------------------------------- */ - if (panShapeRecordId[nChainId] != 0) - return panShapeRecordId[nChainId]; - - /* -------------------------------------------------------------------- */ - /* If we don't already have this value, then search from the */ - /* previous known record. */ - /* -------------------------------------------------------------------- */ - int iTestChain, nWorkingRecId; - - for (iTestChain = nChainId - 1; - iTestChain >= 0 && panShapeRecordId[iTestChain] <= 0; iTestChain--) - { - } - - if (iTestChain < 0) - { - iTestChain = -1; - nWorkingRecId = 1; - } - else - { - nWorkingRecId = panShapeRecordId[iTestChain] + 1; - } - - /* -------------------------------------------------------------------- */ - /* If we have non existent records following (-1's) we can */ - /* narrow our search a bit. */ - /* -------------------------------------------------------------------- */ - while (panShapeRecordId[iTestChain + 1] == -1) - { - iTestChain++; - } - - /* -------------------------------------------------------------------- */ - /* Read records up to the maximum distance that is possibly */ - /* required, looking for our target TLID. */ - /* -------------------------------------------------------------------- */ - int nMaxChainToRead = nChainId - iTestChain; - int nChainsRead = 0; - char achShapeRec[OGR_TIGER_RECBUF_LEN]; - int nShapeRecLen = - psRT2Info->nRecordLength + nRecordLength - psRT1Info->nRecordLength; - - if (nShapeRecLen <= 0) - { - return -2; - } - - while (nChainsRead < nMaxChainToRead) - { - const auto nOffset = - static_cast(nWorkingRecId - 1) * nShapeRecLen; - if (VSIFSeekL(fpShape, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s2", nOffset, - pszModule); - return -2; - } - - if (VSIFReadL(achShapeRec, psRT2Info->nRecordLength, 1, fpShape) != 1) - { - if (!VSIFEofL(fpShape)) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to read record %d of %s2", nWorkingRecId - 1, - pszModule); - return -2; - } - else - return -1; - } - - if (atoi(GetField(achShapeRec, 6, 15)) == nTLID) - { - panShapeRecordId[nChainId] = nWorkingRecId; - - return nWorkingRecId; - } - - if (atoi(GetField(achShapeRec, 16, 18)) == 1) - { - nChainsRead++; - } - - nWorkingRecId++; - } - - panShapeRecordId[nChainId] = -1; - - return -1; -} diff --git a/ogr/ogrsf_frmts/tiger/tigerentitynames.cpp b/ogr/ogrsf_frmts/tiger/tigerentitynames.cpp deleted file mode 100644 index c822eb78afac..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerentitynames.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerEntityNames, providing access to .RTC files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2011, Even Rouault - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char C_FILE_CODE[] = "C"; - -static const TigerFieldInfo rtC_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"DATAYR", 'L', 'A', OFTString, 11, 14, 4, 1, 1}, - {"FIPS", 'L', 'N', OFTInteger, 15, 19, 5, 1, 1}, - {"FIPSCC", 'L', 'A', OFTString, 20, 21, 2, 1, 1}, - {"PLACEDC", 'L', 'A', OFTString, 22, 22, 1, 1, 1}, - {"LSADC", 'L', 'A', OFTString, 23, 24, 2, 1, 1}, - {"ENTITY", 'L', 'A', OFTString, 25, 25, 1, 1, 1}, - {"MA", 'L', 'N', OFTInteger, 26, 29, 4, 1, 1}, - {"SD", 'L', 'N', OFTInteger, 30, 34, 5, 1, 1}, - {"AIANHH", 'L', 'N', OFTInteger, 35, 38, 4, 1, 1}, - {"VTDTRACT", 'R', 'A', OFTString, 39, 44, 6, 1, 1}, - {"UAUGA", 'L', 'N', OFTInteger, 45, 49, 5, 1, 1}, - {"AITSCE", 'L', 'N', OFTInteger, 50, 52, 3, 1, 1}, - {"RS_C1", 'L', 'N', OFTInteger, 53, 54, 2, 1, 1}, - {"RS_C2", 'L', 'N', OFTInteger, 55, 62, 8, 1, 1}, - {"NAME", 'L', 'A', OFTString, 63, 122, 60, 1, 1}, -}; -static const TigerRecordInfo rtC_2002_info = { - rtC_2002_fields, sizeof(rtC_2002_fields) / sizeof(TigerFieldInfo), 122}; - -static const TigerFieldInfo rtC_2000_Redistricting_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"FIPSYR", 'L', 'N', OFTString, 11, 14, 4, 1, 1}, - {"FIPS", 'L', 'N', OFTInteger, 15, 19, 5, 1, 1}, - {"FIPSCC", 'L', 'A', OFTString, 20, 21, 2, 1, 1}, - {"PDC", 'L', 'A', OFTString, 22, 22, 1, 1, 1}, - {"LASAD", 'L', 'A', OFTString, 23, 24, 2, 1, 1}, - {"ENTITY", 'L', 'A', OFTString, 25, 25, 1, 1, 1}, - {"MA", 'L', 'N', OFTInteger, 26, 29, 4, 1, 1}, - {"SD", 'L', 'N', OFTInteger, 30, 34, 5, 1, 1}, - {"AIR", 'L', 'N', OFTInteger, 35, 38, 4, 1, 1}, - {"VTD", 'R', 'A', OFTString, 39, 44, 6, 1, 1}, - {"UA", 'L', 'N', OFTInteger, 45, 49, 5, 1, 1}, - {"AITSCE", 'L', 'N', OFTInteger, 50, 52, 3, 1, 1}, - {"NAME", 'L', 'A', OFTString, 53, 112, 66, 1, 1}}; -static const TigerRecordInfo rtC_2000_Redistricting_info = { - rtC_2000_Redistricting_fields, - sizeof(rtC_2000_Redistricting_fields) / sizeof(TigerFieldInfo), 112}; - -static const TigerFieldInfo rtC_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"FIPSYR", 'L', 'N', OFTString, 11, 12, 4, 1, 1}, - {"FIPS", 'L', 'N', OFTInteger, 13, 17, 5, 1, 1}, - {"FIPSCC", 'L', 'A', OFTString, 18, 19, 2, 1, 1}, - {"PDC", 'L', 'A', OFTString, 20, 20, 1, 1, 1}, - {"LASAD", 'L', 'A', OFTString, 21, 22, 2, 1, 1}, - {"ENTITY", 'L', 'A', OFTString, 23, 23, 1, 1, 1}, - {"MA", 'L', 'N', OFTInteger, 24, 27, 4, 1, 1}, - {"SD", 'L', 'N', OFTInteger, 28, 32, 5, 1, 1}, - {"AIR", 'L', 'N', OFTInteger, 33, 36, 4, 1, 1}, - {"VTD", 'R', 'A', OFTString, 37, 42, 6, 1, 1}, - {"UA", 'L', 'N', OFTInteger, 43, 46, 4, 1, 1}, - {"NAME", 'L', 'A', OFTString, 47, 112, 66, 1, 1}}; -static const TigerRecordInfo rtC_info = { - rtC_fields, sizeof(rtC_fields) / sizeof(TigerFieldInfo), 112}; - -/************************************************************************/ -/* TigerEntityNames() */ -/************************************************************************/ - -TigerEntityNames::TigerEntityNames(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(nullptr, C_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("EntityNames"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbPoint); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rtC_2002_info; - } - else if (poDS->GetVersion() >= TIGER_2000_Redistricting) - { - psRTInfo = &rtC_2000_Redistricting_info; - } - else - { - psRTInfo = &rtC_info; - } - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerfeatureids.cpp b/ogr/ogrsf_frmts/tiger/tigerfeatureids.cpp deleted file mode 100644 index 644320b199cc..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerfeatureids.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerFeatureIds, providing access to .RT5 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char FILE_CODE[] = "5"; - -static const TigerFieldInfo rt5_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"FEAT", 'R', 'N', OFTInteger, 11, 18, 8, 1, 1}, - {"FEDIRP", 'L', 'A', OFTString, 19, 20, 2, 1, 1}, - {"FENAME", 'L', 'A', OFTString, 21, 50, 30, 1, 1}, - {"FETYPE", 'L', 'A', OFTString, 51, 54, 4, 1, 1}, - {"FEDIRS", 'L', 'A', OFTString, 55, 56, 2, 1, 1}, -}; -static const TigerRecordInfo rt5_2002_info = { - rt5_2002_fields, sizeof(rt5_2002_fields) / sizeof(TigerFieldInfo), 56}; - -static const TigerFieldInfo rt5_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 2, 6, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 2, 3, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 4, 6, 3, 1, 1}, - {"FEAT", 'R', 'N', OFTInteger, 7, 14, 8, 1, 1}, - {"FEDIRP", 'L', 'A', OFTString, 15, 16, 2, 1, 1}, - {"FENAME", 'L', 'A', OFTString, 17, 46, 30, 1, 1}, - {"FETYPE", 'L', 'A', OFTString, 47, 50, 4, 1, 1}, - {"FEDIRS", 'L', 'A', OFTString, 51, 52, 2, 1, 1}}; - -static const TigerRecordInfo rt5_info = { - rt5_fields, sizeof(rt5_fields) / sizeof(TigerFieldInfo), 52}; - -/************************************************************************/ -/* TigerFeatureIds() */ -/************************************************************************/ - -TigerFeatureIds::TigerFeatureIds(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(nullptr, FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("FeatureIds"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rt5_2002_info; - } - else - { - psRTInfo = &rt5_info; - } - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerfilebase.cpp b/ogr/ogrsf_frmts/tiger/tigerfilebase.cpp deleted file mode 100644 index 0917aa025b9b..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerfilebase.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerBaseFile class, providing common services to all - * the tiger file readers. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2009-2013, Even Rouault - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" -#include "cpl_error.h" -#include "cpl_string.h" - -#include - -/************************************************************************/ -/* TigerFileBase() */ -/************************************************************************/ - -TigerFileBase::TigerFileBase(const TigerRecordInfo *psRTInfoIn, - const char *m_pszFileCodeIn) - : poDS(nullptr), pszModule(nullptr), pszShortModule(nullptr), - fpPrimary(nullptr), poFeatureDefn(nullptr), nFeatures(0), - nRecordLength(0), nVersionCode(0), nVersion(TIGER_Unknown), - psRTInfo(psRTInfoIn), m_pszFileCode(m_pszFileCodeIn) -{ -} - -/************************************************************************/ -/* ~TigerFileBase() */ -/************************************************************************/ - -TigerFileBase::~TigerFileBase() - -{ - CPLFree(pszModule); - CPLFree(pszShortModule); - - if (poFeatureDefn != nullptr) - { - poFeatureDefn->Release(); - poFeatureDefn = nullptr; - } - - if (fpPrimary != nullptr) - { - VSIFCloseL(fpPrimary); - fpPrimary = nullptr; - } -} - -/************************************************************************/ -/* OpenFile() */ -/************************************************************************/ - -int TigerFileBase::OpenFile(const char *pszModuleToOpen, - const char *pszExtension) - -{ - - CPLFree(pszModule); - pszModule = nullptr; - CPLFree(pszShortModule); - pszShortModule = nullptr; - - if (fpPrimary != nullptr) - { - VSIFCloseL(fpPrimary); - fpPrimary = nullptr; - } - - if (pszModuleToOpen == nullptr) - return TRUE; - - char *pszFilename = poDS->BuildFilename(pszModuleToOpen, pszExtension); - - fpPrimary = VSIFOpenL(pszFilename, "rb"); - - CPLFree(pszFilename); - - if (fpPrimary == nullptr) - return FALSE; - - pszModule = CPLStrdup(pszModuleToOpen); - pszShortModule = CPLStrdup(pszModuleToOpen); - for (int i = 0; pszShortModule[i] != '\0'; i++) - { - if (pszShortModule[i] == '.') - pszShortModule[i] = '\0'; - } - - SetupVersion(); - - return TRUE; -} - -/************************************************************************/ -/* SetupVersion() */ -/************************************************************************/ - -void TigerFileBase::SetupVersion() - -{ - char aszRecordHead[6]; - - VSIFSeekL(fpPrimary, 0, SEEK_SET); - VSIFReadL(aszRecordHead, 1, 5, fpPrimary); - aszRecordHead[5] = '\0'; - nVersionCode = atoi(aszRecordHead + 1); - VSIFSeekL(fpPrimary, 0, SEEK_SET); - - nVersion = TigerClassifyVersion(nVersionCode); -} - -/************************************************************************/ -/* EstablishRecordLength() */ -/************************************************************************/ - -int TigerFileBase::EstablishRecordLength(VSILFILE *fp) - -{ - if (fp == nullptr || VSIFSeekL(fp, 0, SEEK_SET) != 0) - return -1; - - /* -------------------------------------------------------------------- */ - /* Read through to the end of line. */ - /* -------------------------------------------------------------------- */ - int nRecLen = 0; - char chCurrent = '\0'; - while (VSIFReadL(&chCurrent, 1, 1, fp) == 1 && chCurrent != 10 && - chCurrent != 13) - { - nRecLen++; - } - - /* -------------------------------------------------------------------- */ - /* Is the file zero length? */ - /* -------------------------------------------------------------------- */ - if (nRecLen == 0) - { - return -1; - } - - nRecLen++; /* for the 10 or 13 we encountered */ - - /* -------------------------------------------------------------------- */ - /* Read through line terminator characters. We are trying to */ - /* handle cases of CR, CR/LF and LF/CR gracefully. */ - /* -------------------------------------------------------------------- */ - while (VSIFReadL(&chCurrent, 1, 1, fp) == 1 && - (chCurrent == 10 || chCurrent == 13)) - { - nRecLen++; - } - - VSIFSeekL(fp, 0, SEEK_SET); - - return nRecLen; -} - -/************************************************************************/ -/* EstablishFeatureCount() */ -/************************************************************************/ - -void TigerFileBase::EstablishFeatureCount() - -{ - if (fpPrimary == nullptr) - return; - - nRecordLength = EstablishRecordLength(fpPrimary); - - if (nRecordLength == -1) - { - nRecordLength = 1; - nFeatures = 0; - return; - } - - /* -------------------------------------------------------------------- */ - /* Now we think we know the fixed record length for the file */ - /* (including line terminators). Get the total file size, and */ - /* divide by this length to get the presumed number of records. */ - /* -------------------------------------------------------------------- */ - - VSIFSeekL(fpPrimary, 0, SEEK_END); - const vsi_l_offset nFileSize = VSIFTellL(fpPrimary); - - if ((nFileSize % (vsi_l_offset)nRecordLength) != 0) - { - CPLError(CE_Warning, CPLE_FileIO, - "TigerFileBase::EstablishFeatureCount(): " - "File length %d doesn't divide by record length %d.\n", - (int)nFileSize, (int)nRecordLength); - } - - if (nFileSize / (vsi_l_offset)nRecordLength > (vsi_l_offset)INT_MAX) - nFeatures = INT_MAX; - else - nFeatures = static_cast(nFileSize / (vsi_l_offset)nRecordLength); -} - -/************************************************************************/ -/* GetField() */ -/************************************************************************/ - -const char *TigerFileBase::GetField(const char *pachRawDataRecord, - int nStartChar, int nEndChar) - -{ - char aszField[128]; - int nLength = nEndChar - nStartChar + 1; - - CPLAssert(nEndChar - nStartChar + 2 < (int)sizeof(aszField)); - - strncpy(aszField, pachRawDataRecord + nStartChar - 1, nLength); - - aszField[nLength] = '\0'; - while (nLength > 0 && aszField[nLength - 1] == ' ') - aszField[--nLength] = '\0'; - - return CPLSPrintf("%s", aszField); -} - -/************************************************************************/ -/* SetField() */ -/* */ -/* Set a field on an OGRFeature from a tiger record, or leave */ -/* NULL if the value isn't found. */ -/************************************************************************/ - -void TigerFileBase::SetField(OGRFeature *poFeature, const char *pszField, - const char *pachRecord, int nStart, int nEnd) - -{ - const char *pszFieldValue = GetField(pachRecord, nStart, nEnd); - - if (pszFieldValue[0] == '\0') - return; - - poFeature->SetField(pszField, pszFieldValue); -} - -/************************************************************************/ -/* AddFieldDefns() */ -/************************************************************************/ -void TigerFileBase::AddFieldDefns(const TigerRecordInfo *psRTInfoIn, - OGRFeatureDefn *poFeatureDefnIn) -{ - OGRFieldDefn oField("", OFTInteger); - int i, bLFieldHack; - - bLFieldHack = - CPLTestBool(CPLGetConfigOption("TIGER_LFIELD_AS_STRING", "NO")); - - for (i = 0; i < psRTInfoIn->nFieldCount; ++i) - { - if (psRTInfoIn->pasFields[i].bDefine) - { - OGRFieldType eFT = (OGRFieldType)psRTInfoIn->pasFields[i].OGRtype; - - if (bLFieldHack && psRTInfoIn->pasFields[i].cFmt == 'L' && - psRTInfoIn->pasFields[i].cType == 'N') - eFT = OFTString; - - oField.Set(psRTInfoIn->pasFields[i].pszFieldName, eFT, - psRTInfoIn->pasFields[i].nLen); - poFeatureDefnIn->AddFieldDefn(&oField); - } - } -} - -/************************************************************************/ -/* SetFields() */ -/************************************************************************/ - -void TigerFileBase::SetFields(const TigerRecordInfo *psRTInfoIn, - OGRFeature *poFeature, char *achRecord) -{ - for (int i = 0; i < psRTInfoIn->nFieldCount; ++i) - { - if (psRTInfoIn->pasFields[i].bSet) - { - SetField(poFeature, psRTInfoIn->pasFields[i].pszFieldName, - achRecord, psRTInfoIn->pasFields[i].nBeg, - psRTInfoIn->pasFields[i].nEnd); - } - } -} - -/************************************************************************/ -/* SetModule() */ -/************************************************************************/ - -bool TigerFileBase::SetModule(const char *pszModuleIn) - -{ - if (m_pszFileCode == nullptr) - return false; - - if (!OpenFile(pszModuleIn, m_pszFileCode)) - return false; - - EstablishFeatureCount(); - - return true; -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ - -OGRFeature *TigerFileBase::GetFeature(int nRecordId) - -{ - char achRecord[OGR_TIGER_RECBUF_LEN]; - - if (psRTInfo == nullptr) - return nullptr; - - if (nRecordId < 0 || nRecordId >= nFeatures) - { - CPLError(CE_Failure, CPLE_FileIO, - "Request for out-of-range feature %d of %s", nRecordId, - pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Read the raw record data from the file. */ - /* -------------------------------------------------------------------- */ - if (fpPrimary == nullptr) - return nullptr; - - { - const auto nOffset = static_cast(nRecordId) * nRecordLength; - if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %s", nOffset, pszModule); - return nullptr; - } - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRecord, psRTInfo->nRecordLength, 1, fpPrimary) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %s", - nRecordId, pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Set fields. */ - /* -------------------------------------------------------------------- */ - OGRFeature *poFeature = new OGRFeature(poFeatureDefn); - - SetFields(psRTInfo, poFeature, achRecord); - - return poFeature; -} diff --git a/ogr/ogrsf_frmts/tiger/tigeridhistory.cpp b/ogr/ogrsf_frmts/tiger/tigeridhistory.cpp deleted file mode 100644 index 48307081ca49..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigeridhistory.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerIDHistory, providing access to .RTH files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char FILE_CODE[] = "H"; - -static const TigerFieldInfo rtH_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"TLID", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"HIST", 'L', 'A', OFTString, 21, 21, 1, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 22, 22, 1, 1, 1}, - {"TLIDFR1", 'R', 'N', OFTInteger, 23, 32, 10, 1, 1}, - {"TLIDFR2", 'R', 'N', OFTInteger, 33, 42, 10, 1, 1}, - {"TLIDTO1", 'R', 'N', OFTInteger, 43, 52, 10, 1, 1}, - {"TLIDTO2", 'R', 'N', OFTInteger, 53, 62, 10, 1, 1}}; -static const TigerRecordInfo rtH_info = { - rtH_fields, sizeof(rtH_fields) / sizeof(TigerFieldInfo), 62}; - -/************************************************************************/ -/* TigerIDHistory() */ -/************************************************************************/ - -TigerIDHistory::TigerIDHistory(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rtH_info, FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("IDHistory"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from record type H */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerkeyfeatures.cpp b/ogr/ogrsf_frmts/tiger/tigerkeyfeatures.cpp deleted file mode 100644 index 9e4fed7fbd54..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerkeyfeatures.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerKeyFeatures, providing access to .RT9 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char NINE_FILE_CODE[] = "9"; - -static const TigerFieldInfo rt9_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 26, 26, 1, 1, 1}, - {"CFCC", 'L', 'A', OFTString, 27, 29, 3, 1, 1}, - {"KGLNAME", 'L', 'A', OFTString, 30, 59, 30, 1, 1}, - {"KGLADD", 'R', 'A', OFTString, 60, 70, 11, 1, 1}, - {"KGLZIP", 'L', 'N', OFTInteger, 71, 75, 5, 1, 1}, - {"KGLZIP4", 'L', 'N', OFTInteger, 76, 79, 4, 1, 1}, - {"FEAT", 'R', 'N', OFTInteger, 80, 87, 8, 1, 1}}; - -static const TigerRecordInfo rt9_info = { - rt9_fields, sizeof(rt9_fields) / sizeof(TigerFieldInfo), 88}; - -/************************************************************************/ -/* TigerKeyFeatures() */ -/************************************************************************/ - -TigerKeyFeatures::TigerKeyFeatures(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rt9_info, NINE_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("KeyFeatures"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type 9 record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerlandmarks.cpp b/ogr/ogrsf_frmts/tiger/tigerlandmarks.cpp deleted file mode 100644 index c86dcfa74633..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerlandmarks.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerLandmarks, providing access to .RT7 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char SEVEN_FILE_CODE[] = "7"; - -static const TigerFieldInfo rt7_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"LAND", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 21, 21, 1, 1, 1}, - {"CFCC", 'L', 'A', OFTString, 22, 24, 3, 1, 1}, - {"LANAME", 'L', 'A', OFTString, 25, 54, 30, 1, 1}, - {"LALONG", 'R', 'N', OFTInteger, 55, 64, 10, 1, 1}, - {"LALAT", 'R', 'N', OFTInteger, 65, 73, 9, 1, 1}, - {"FILLER", 'L', 'A', OFTString, 74, 74, 1, 1, 1}, -}; -static const TigerRecordInfo rt7_2002_info = { - rt7_2002_fields, sizeof(rt7_2002_fields) / sizeof(TigerFieldInfo), 74}; - -static const TigerFieldInfo rt7_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"LAND", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 21, 21, 1, 1, 1}, - {"CFCC", 'L', 'A', OFTString, 22, 24, 3, 1, 1}, - {"LANAME", 'L', 'A', OFTString, 25, 54, 30, 1, 1}}; -static const TigerRecordInfo rt7_info = { - rt7_fields, sizeof(rt7_fields) / sizeof(TigerFieldInfo), 74}; - -/************************************************************************/ -/* TigerLandmarks() */ -/************************************************************************/ - -TigerLandmarks::TigerLandmarks(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerPoint(nullptr, SEVEN_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("Landmarks"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbPoint); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rt7_2002_info; - } - else - { - psRTInfo = &rt7_info; - } - - AddFieldDefns(psRTInfo, poFeatureDefn); -} - -OGRFeature *TigerLandmarks::GetFeature(int nRecordId) -{ - return TigerPoint::GetFeature(nRecordId, 55, 64, 65, 73); -} diff --git a/ogr/ogrsf_frmts/tiger/tigeroverunder.cpp b/ogr/ogrsf_frmts/tiger/tigeroverunder.cpp deleted file mode 100644 index db41e092b620..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigeroverunder.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerOverUnder, providing access to .RTU files. - * Author: Mark Phillips, mbp@geomtech.com - * - ****************************************************************************** - * Copyright (c) 2002, Frank Warmerdam, Mark Phillips - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char U_FILE_CODE[] = "U"; - -static const TigerFieldInfo rtU_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"TZID", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"RTSQ", 'R', 'N', OFTInteger, 21, 21, 1, 1, 1}, - {"TLIDOV1", 'R', 'N', OFTInteger, 22, 31, 10, 1, 1}, - {"TLIDOV2", 'R', 'N', OFTInteger, 32, 41, 10, 1, 1}, - {"TLIDUN1", 'R', 'N', OFTInteger, 42, 51, 10, 1, 1}, - {"TLIDUN2", 'R', 'N', OFTInteger, 52, 61, 10, 1, 1}, - {"FRLONG", 'R', 'N', OFTInteger, 62, 71, 10, 1, 1}, - {"FRLAT", 'R', 'N', OFTInteger, 72, 80, 9, 1, 1}, -}; -static const TigerRecordInfo rtU_info = { - rtU_fields, sizeof(rtU_fields) / sizeof(TigerFieldInfo), 80}; - -/************************************************************************/ -/* TigerOverUnder() */ -/************************************************************************/ - -TigerOverUnder::TigerOverUnder(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerPoint(&rtU_info, U_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("OverUnder"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - AddFieldDefns(psRTInfo, poFeatureDefn); -} - -OGRFeature *TigerOverUnder::GetFeature(int nRecordId) -{ - return TigerPoint::GetFeature(nRecordId, 62, 71, 72, 80); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpip.cpp b/ogr/ogrsf_frmts/tiger/tigerpip.cpp deleted file mode 100644 index bf8610b0c6e2..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpip.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPIP, providing access to .RTP files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char P_FILE_CODE[] = "P"; - -static const TigerFieldInfo rtP_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"POLYLONG", 'R', 'N', OFTInteger, 26, 35, 10, 1, 1}, - {"POLYLAT", 'R', 'N', OFTInteger, 36, 44, 9, 1, 1}, - {"WATER", 'L', 'N', OFTInteger, 45, 45, 1, 1, 1}, -}; -static const TigerRecordInfo rtP_2002_info = { - rtP_2002_fields, sizeof(rtP_2002_fields) / sizeof(TigerFieldInfo), 45}; - -static const TigerFieldInfo rtP_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}}; -static const TigerRecordInfo rtP_info = { - rtP_fields, sizeof(rtP_fields) / sizeof(TigerFieldInfo), 44}; - -/************************************************************************/ -/* TigerPIP() */ -/************************************************************************/ - -TigerPIP::TigerPIP(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerPoint(nullptr, P_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("PIP"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbPoint); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rtP_2002_info; - } - else - { - psRTInfo = &rtP_info; - } - AddFieldDefns(psRTInfo, poFeatureDefn); -} - -OGRFeature *TigerPIP::GetFeature(int nRecordId) -{ - return TigerPoint::GetFeature(nRecordId, 26, 35, 36, 44); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpoint.cpp b/ogr/ogrsf_frmts/tiger/tigerpoint.cpp deleted file mode 100644 index a8f0abca8292..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpoint.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPoint class. - * Author: Mark Phillips, mbp@geomtech.com - * - ****************************************************************************** - * Copyright (c) 2002, Mark Phillips - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -#include - -/************************************************************************/ -/* TigerPoint() */ -/************************************************************************/ -TigerPoint::TigerPoint(const TigerRecordInfo *psRTInfoIn, - const char *m_pszFileCodeIn) - : TigerFileBase(psRTInfoIn, m_pszFileCodeIn) -{ -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ -OGRFeature *TigerPoint::GetFeature(int nRecordId, int nX0, int nX1, int nY0, - int nY1) -{ - char achRecord[OGR_TIGER_RECBUF_LEN]; - - if (nRecordId < 0 || nRecordId >= nFeatures) - { - CPLError(CE_Failure, CPLE_FileIO, - "Request for out-of-range feature %d of %sP", nRecordId, - pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Read the raw record data from the file. */ - /* -------------------------------------------------------------------- */ - - if (fpPrimary == nullptr) - return nullptr; - - { - const auto nOffset = static_cast(nRecordId) * nRecordLength; - if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %sP", nOffset, - pszModule); - return nullptr; - } - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRecord, psRTInfo->nRecordLength, 1, fpPrimary) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %sP", - nRecordId, pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Set fields. */ - /* -------------------------------------------------------------------- */ - - OGRFeature *poFeature = new OGRFeature(poFeatureDefn); - - SetFields(psRTInfo, poFeature, achRecord); - - /* -------------------------------------------------------------------- */ - /* Set geometry */ - /* -------------------------------------------------------------------- */ - - const double dfX = atoi(GetField(achRecord, nX0, nX1)) / 1000000.0; - const double dfY = atoi(GetField(achRecord, nY0, nY1)) / 1000000.0; - - if (dfX != 0.0 || dfY != 0.0) - { - poFeature->SetGeometryDirectly(new OGRPoint(dfX, dfY)); - } - - return poFeature; -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpolychainlink.cpp b/ogr/ogrsf_frmts/tiger/tigerpolychainlink.cpp deleted file mode 100644 index 7efbeac44fca..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpolychainlink.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPolyChainLink, providing access to .RTI files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char I_FILE_CODE[] = "I"; - -static const TigerFieldInfo rtI_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"TLID", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"TZIDS", 'R', 'N', OFTInteger, 21, 30, 10, 1, 1}, - {"TZIDE", 'R', 'N', OFTInteger, 31, 40, 10, 1, 1}, - {"CENIDL", 'L', 'A', OFTString, 41, 45, 5, 1, 1}, - {"POLYIDL", 'R', 'N', OFTInteger, 46, 55, 10, 1, 1}, - {"CENIDR", 'L', 'A', OFTString, 56, 60, 5, 1, 1}, - {"POLYIDR", 'R', 'N', OFTInteger, 61, 70, 10, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 71, 80, 10, 1, 1}, - {"FTSEG", 'L', 'A', OFTString, 81, 97, 17, 1, 1}, - {"RS_I1", 'L', 'A', OFTString, 98, 107, 10, 1, 1}, - {"RS_I2", 'L', 'A', OFTString, 108, 117, 10, 1, 1}, - {"RS_I3", 'L', 'A', OFTString, 118, 127, 10, 1, 1}, -}; -static const TigerRecordInfo rtI_2002_info = { - rtI_2002_fields, sizeof(rtI_2002_fields) / sizeof(TigerFieldInfo), 127}; - -static const TigerFieldInfo rtI_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"FILE", 'L', 'N', OFTString, 16, 20, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 16, 17, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 18, 20, 3, 1, 1}, - {"RTLINK", 'L', 'A', OFTString, 21, 21, 1, 1, 1}, - {"CENIDL", 'L', 'A', OFTString, 22, 26, 5, 1, 1}, - {"POLYIDL", 'R', 'N', OFTInteger, 27, 36, 10, 1, 1}, - {"CENIDR", 'L', 'A', OFTString, 37, 41, 5, 1, 1}, - {"POLYIDR", 'R', 'N', OFTInteger, 42, 51, 10, 1, 1}}; -static const TigerRecordInfo rtI_info = { - rtI_fields, sizeof(rtI_fields) / sizeof(TigerFieldInfo), 52}; - -/************************************************************************/ -/* TigerPolyChainLink() */ -/************************************************************************/ - -TigerPolyChainLink::TigerPolyChainLink( - OGRTigerDataSource *poDSIn, CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(nullptr, I_FILE_CODE) -{ - OGRFieldDefn oField("", OFTInteger); - - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("PolyChainLink"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rtI_2002_info; - } - else - { - psRTInfo = &rtI_info; - } - - /* -------------------------------------------------------------------- */ - /* Fields from type I record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpolygon.cpp b/ogr/ogrsf_frmts/tiger/tigerpolygon.cpp deleted file mode 100644 index 36b395a7a46b..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpolygon.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPolygon, providing access to .RTA files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * Copyright (c) 2011, Even Rouault - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -#include - -static const TigerFieldInfo rtA_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"STATECU", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTYCU", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - - {"TRACT", 'L', 'N', OFTInteger, 31, 36, 6, 1, 1}, - {"BLOCK", 'L', 'N', OFTInteger, 37, 40, 4, 1, 1}, - {"BLOCKSUFCU", 'L', 'A', OFTString, 41, 41, 1, 1, 1}, - - {"RS_A1", 'L', 'A', OFTString, 42, 42, 1, 1, 1}, - {"AIANHHFPCU", 'L', 'N', OFTInteger, 43, 47, 5, 1, 1}, - {"AIANHHCU", 'L', 'N', OFTInteger, 48, 51, 4, 1, 1}, - {"AIHHTLICU", 'L', 'A', OFTString, 52, 52, 1, 1, 1}, - {"ANRCCU", 'L', 'N', OFTInteger, 53, 57, 5, 1, 1}, - {"AITSCECU", 'L', 'N', OFTInteger, 58, 60, 3, 1, 1}, - {"AITSCU", 'L', 'N', OFTInteger, 61, 65, 5, 1, 1}, - {"CONCITCU", 'L', 'N', OFTInteger, 66, 70, 5, 1, 1}, - {"COUSUBCU", 'L', 'N', OFTInteger, 71, 75, 5, 1, 1}, - {"SUBMCDCU", 'L', 'N', OFTInteger, 76, 80, 5, 1, 1}, - {"PLACECU", 'L', 'N', OFTInteger, 81, 85, 5, 1, 1}, - {"SDELMCU", 'L', 'A', OFTString, 86, 90, 5, 1, 1}, - {"SDSECCU", 'L', 'A', OFTString, 91, 95, 5, 1, 1}, - {"SDUNICU", 'L', 'A', OFTString, 96, 100, 5, 1, 1}, - {"MSACMSACU", 'L', 'N', OFTInteger, 101, 104, 4, 1, 1}, - {"PMSACU", 'L', 'N', OFTInteger, 105, 108, 4, 1, 1}, - {"NECMACU", 'L', 'N', OFTInteger, 109, 112, 4, 1, 1}, - {"CDCU", 'R', 'N', OFTInteger, 113, 114, 2, 1, 1}, - {"RS_A2", 'L', 'A', OFTString, 115, 119, 5, 1, 1}, - {"RS_A3", 'R', 'A', OFTString, 120, 122, 3, 1, 1}, - {"RS_A4", 'R', 'A', OFTString, 123, 128, 6, 1, 1}, - {"RS_A5", 'R', 'A', OFTString, 129, 131, 3, 1, 1}, - {"RS_A6", 'R', 'A', OFTString, 132, 134, 3, 1, 1}, - {"RS_A7", 'R', 'A', OFTString, 135, 139, 5, 1, 1}, - {"RS_A8", 'R', 'A', OFTString, 140, 145, 6, 1, 1}, - {"RS_A9", 'L', 'A', OFTString, 146, 151, 6, 1, 1}, - {"RS_A10", 'L', 'A', OFTString, 152, 157, 6, 1, 1}, - {"RS_A11", 'L', 'A', OFTString, 158, 163, 6, 1, 1}, - {"RS_A12", 'L', 'A', OFTString, 164, 169, 6, 1, 1}, - {"RS_A13", 'L', 'A', OFTString, 170, 175, 6, 1, 1}, - {"RS_A14", 'L', 'A', OFTString, 176, 181, 6, 1, 1}, - {"RS_A15", 'L', 'A', OFTString, 182, 186, 5, 1, 1}, - {"RS_A16", 'L', 'A', OFTString, 187, 187, 1, 1, 1}, - {"RS_A17", 'L', 'A', OFTString, 188, 193, 6, 1, 1}, - {"RS_A18", 'L', 'A', OFTString, 194, 199, 6, 1, 1}, - {"RS_A19", 'L', 'A', OFTString, 200, 210, 11, 1, 1}, -}; -static const TigerRecordInfo rtA_2002_info = { - rtA_2002_fields, sizeof(rtA_2002_fields) / sizeof(TigerFieldInfo), 210}; - -static const TigerFieldInfo rtA_2003_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"STATECU", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTYCU", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - - {"TRACT", 'L', 'N', OFTInteger, 31, 36, 6, 1, 1}, - {"BLOCK", 'L', 'N', OFTInteger, 37, 40, 4, 1, 1}, - {"BLOCKSUFCU", 'L', 'A', OFTString, 41, 41, 1, 1, 1}, - - {"RS_A1", 'L', 'A', OFTString, 42, 42, 1, 1, 1}, - {"AIANHHFPCU", 'L', 'N', OFTInteger, 43, 47, 5, 1, 1}, - {"AIANHHCU", 'L', 'N', OFTInteger, 48, 51, 4, 1, 1}, - {"AIHHTLICU", 'L', 'A', OFTString, 52, 52, 1, 1, 1}, - {"ANRCCU", 'L', 'N', OFTInteger, 53, 57, 5, 1, 1}, - {"AITSCECU", 'L', 'N', OFTInteger, 58, 60, 3, 1, 1}, - {"AITSCU", 'L', 'N', OFTInteger, 61, 65, 5, 1, 1}, - {"CONCITCU", 'L', 'N', OFTInteger, 66, 70, 5, 1, 1}, - {"COUSUBCU", 'L', 'N', OFTInteger, 71, 75, 5, 1, 1}, - {"SUBMCDCU", 'L', 'N', OFTInteger, 76, 80, 5, 1, 1}, - {"PLACECU", 'L', 'N', OFTInteger, 81, 85, 5, 1, 1}, - {"SDELMCU", 'L', 'A', OFTString, 86, 90, 5, 1, 1}, - {"SDSECCU", 'L', 'A', OFTString, 91, 95, 5, 1, 1}, - {"SDUNICU", 'L', 'A', OFTString, 96, 100, 5, 1, 1}, - {"RS_A20", 'L', 'A', OFTString, 101, 104, 4, 1, 1}, - {"RS_A21", 'L', 'A', OFTString, 105, 108, 4, 1, 1}, - {"RS_A22", 'L', 'A', OFTString, 109, 112, 4, 1, 1}, - {"CDCU", 'R', 'N', OFTInteger, 113, 114, 2, 1, 1}, - {"ZCTA5CU", 'L', 'A', OFTString, 115, 119, 5, 1, 1}, - {"ZCTA3CU", 'R', 'A', OFTString, 120, 122, 3, 1, 1}, - {"RS_A4", 'R', 'A', OFTString, 123, 128, 6, 1, 1}, - {"RS_A5", 'R', 'A', OFTString, 129, 131, 3, 1, 1}, - {"RS_A6", 'R', 'A', OFTString, 132, 134, 3, 1, 1}, - {"RS_A7", 'R', 'A', OFTString, 135, 139, 5, 1, 1}, - {"RS_A8", 'R', 'A', OFTString, 140, 145, 6, 1, 1}, - {"RS_A9", 'L', 'A', OFTString, 146, 151, 6, 1, 1}, - {"CBSACU", 'L', 'A', OFTInteger, 152, 156, 5, 1, 1}, - {"CSACU", 'L', 'A', OFTInteger, 157, 159, 3, 1, 1}, - {"NECTACU", 'L', 'A', OFTInteger, 160, 164, 5, 1, 1}, - {"CNECTACU", 'L', 'A', OFTInteger, 165, 167, 3, 1, 1}, - {"METDIVCU", 'L', 'A', OFTInteger, 168, 172, 5, 1, 1}, - {"NECTADIVCU", 'L', 'A', OFTInteger, 173, 177, 5, 1, 1}, - {"RS_A14", 'L', 'A', OFTString, 178, 181, 4, 1, 1}, - {"RS_A15", 'L', 'A', OFTString, 182, 186, 5, 1, 1}, - {"RS_A16", 'L', 'A', OFTString, 187, 187, 1, 1, 1}, - {"RS_A17", 'L', 'A', OFTString, 188, 193, 6, 1, 1}, - {"RS_A18", 'L', 'A', OFTString, 194, 199, 6, 1, 1}, - {"RS_A19", 'L', 'A', OFTString, 200, 210, 11, 1, 1}, -}; -static const TigerRecordInfo rtA_2003_info = { - rtA_2003_fields, sizeof(rtA_2003_fields) / sizeof(TigerFieldInfo), 210}; - -static const TigerFieldInfo rtA_2004_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"STATECU", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTYCU", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - - {"TRACT", 'L', 'N', OFTInteger, 31, 36, 6, 1, 1}, - {"BLOCK", 'L', 'N', OFTInteger, 37, 40, 4, 1, 1}, - {"BLOCKSUFCU", 'L', 'A', OFTString, 41, 41, 1, 1, 1}, - - {"RS_A1", 'L', 'A', OFTString, 42, 42, 1, 1, 1}, - {"AIANHHFPCU", 'L', 'N', OFTInteger, 43, 47, 5, 1, 1}, - {"AIANHHCU", 'L', 'N', OFTInteger, 48, 51, 4, 1, 1}, - {"AIHHTLICU", 'L', 'A', OFTString, 52, 52, 1, 1, 1}, - {"ANRCCU", 'L', 'N', OFTInteger, 53, 57, 5, 1, 1}, - {"AITSCECU", 'L', 'N', OFTInteger, 58, 60, 3, 1, 1}, - {"AITSCU", 'L', 'N', OFTInteger, 61, 65, 5, 1, 1}, - {"CONCITCU", 'L', 'N', OFTInteger, 66, 70, 5, 1, 1}, - {"COUSUBCU", 'L', 'N', OFTInteger, 71, 75, 5, 1, 1}, - {"SUBMCDCU", 'L', 'N', OFTInteger, 76, 80, 5, 1, 1}, - {"PLACECU", 'L', 'N', OFTInteger, 81, 85, 5, 1, 1}, - {"SDELMCU", 'L', 'A', OFTString, 86, 90, 5, 1, 1}, - {"SDSECCU", 'L', 'A', OFTString, 91, 95, 5, 1, 1}, - {"SDUNICU", 'L', 'A', OFTString, 96, 100, 5, 1, 1}, - {"RS_A20", 'L', 'A', OFTString, 101, 104, 4, 1, 1}, - {"RS_A21", 'L', 'A', OFTString, 105, 108, 4, 1, 1}, - {"RS_A22", 'L', 'A', OFTString, 109, 112, 4, 1, 1}, - {"CDCU", 'R', 'N', OFTInteger, 113, 114, 2, 1, 1}, - {"ZCTA5CU", 'L', 'A', OFTString, 115, 119, 5, 1, 1}, - {"ZCTA3CU", 'R', 'A', OFTString, 120, 122, 3, 1, 1}, - {"RS_A4", 'R', 'A', OFTString, 123, 128, 6, 1, 1}, - {"RS_A5", 'R', 'A', OFTString, 129, 131, 3, 1, 1}, - {"RS_A6", 'R', 'A', OFTString, 132, 134, 3, 1, 1}, - {"RS_A7", 'R', 'A', OFTString, 135, 139, 5, 1, 1}, - {"RS_A8", 'R', 'A', OFTString, 140, 145, 6, 1, 1}, - {"RS_A9", 'L', 'A', OFTString, 146, 151, 6, 1, 1}, - {"CBSACU", 'L', 'A', OFTInteger, 152, 156, 5, 1, 1}, - {"CSACU", 'L', 'A', OFTInteger, 157, 159, 3, 1, 1}, - {"NECTACU", 'L', 'A', OFTInteger, 160, 164, 5, 1, 1}, - {"CNECTACU", 'L', 'A', OFTInteger, 165, 167, 3, 1, 1}, - {"METDIVCU", 'L', 'A', OFTInteger, 168, 172, 5, 1, 1}, - {"NECTADIVCU", 'L', 'A', OFTInteger, 173, 177, 5, 1, 1}, - {"RS_A14", 'L', 'A', OFTString, 178, 181, 4, 1, 1}, - {"UACU", 'L', 'N', OFTInteger, 182, 186, 5, 1, 1}, - {"URCU", 'L', 'A', OFTString, 187, 187, 1, 1, 1}, - {"RS_A17", 'L', 'A', OFTString, 188, 193, 6, 1, 1}, - {"RS_A18", 'L', 'A', OFTString, 194, 199, 6, 1, 1}, - {"RS_A19", 'L', 'A', OFTString, 200, 210, 11, 1, 1}, -}; -static const TigerRecordInfo rtA_2004_info = { - rtA_2004_fields, sizeof(rtA_2004_fields) / sizeof(TigerFieldInfo), 210}; - -static const TigerFieldInfo rtA_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"FAIR", 'L', 'N', OFTInteger, 26, 30, 5, 1, 1}, - {"FMCD", 'L', 'N', OFTInteger, 31, 35, 5, 1, 1}, - {"FPL", 'L', 'N', OFTInteger, 36, 40, 5, 1, 1}, - {"CTBNA90", 'L', 'N', OFTInteger, 41, 46, 6, 1, 1}, - {"BLK90", 'L', 'A', OFTString, 47, 50, 4, 1, 1}, - {"CD106", 'L', 'N', OFTInteger, 51, 52, 2, 1, 1}, - {"CD108", 'L', 'N', OFTInteger, 53, 54, 2, 1, 1}, - {"SDELM", 'L', 'A', OFTString, 55, 59, 5, 1, 1}, - {"SDSEC", 'L', 'N', OFTString, 65, 69, 5, 1, 1}, - {"SDUNI", 'L', 'A', OFTString, 70, 74, 5, 1, 1}, - {"TAZ", 'R', 'A', OFTString, 75, 80, 6, 1, 1}, - {"UA", 'L', 'N', OFTInteger, 81, 84, 4, 1, 1}, - {"URBFLAG", 'L', 'A', OFTString, 85, 85, 1, 1, 1}, - {"CTPP", 'L', 'A', OFTString, 86, 89, 4, 1, 1}, - {"STATE90", 'L', 'N', OFTInteger, 90, 91, 2, 1, 1}, - {"COUN90", 'L', 'N', OFTInteger, 92, 94, 3, 1, 1}, - {"AIR90", 'L', 'N', OFTInteger, 95, 98, 4, 1, 1}}; - -static const TigerRecordInfo rtA_info = { - rtA_fields, sizeof(rtA_fields) / sizeof(TigerFieldInfo), 98}; - -static const TigerFieldInfo rtS_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 0, 0}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 0, 0}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 0, 0}, - {"STATE", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - {"TRACT", 'L', 'N', OFTInteger, 31, 36, 6, 0, 0}, - {"BLOCK", 'L', 'N', OFTInteger, 37, 40, 4, 0, 0}, - {"BLKGRP", 'L', 'N', OFTInteger, 41, 41, 1, 1, 1}, - {"AIANHHFP", 'L', 'N', OFTInteger, 42, 46, 5, 1, 1}, - {"AIANHH", 'L', 'N', OFTInteger, 47, 50, 4, 1, 1}, - {"AIHHTLI", 'L', 'A', OFTString, 51, 51, 1, 1, 1}, - {"ANRC", 'L', 'N', OFTInteger, 52, 56, 5, 1, 1}, - {"AITSCE", 'L', 'N', OFTInteger, 57, 59, 3, 1, 1}, - {"AITS", 'L', 'N', OFTInteger, 60, 64, 5, 1, 1}, - {"CONCIT", 'L', 'N', OFTInteger, 65, 69, 5, 1, 1}, - {"COUSUB", 'L', 'N', OFTInteger, 70, 74, 5, 1, 1}, - {"SUBMCD", 'L', 'N', OFTInteger, 75, 79, 5, 1, 1}, - {"PLACE", 'L', 'N', OFTInteger, 80, 84, 5, 1, 1}, - {"SDELM", 'L', 'N', OFTInteger, 85, 89, 5, 1, 1}, - {"SDSEC", 'L', 'N', OFTInteger, 90, 94, 5, 1, 1}, - {"SDUNI", 'L', 'N', OFTInteger, 95, 99, 5, 1, 1}, - {"MSACMSA", 'L', 'N', OFTInteger, 100, 103, 4, 1, 1}, - {"PMSA", 'L', 'N', OFTInteger, 104, 107, 4, 1, 1}, - {"NECMA", 'L', 'N', OFTInteger, 108, 111, 4, 1, 1}, - {"CD106", 'L', 'N', OFTInteger, 112, 113, 2, 1, 1}, - // Note: spec has CD106 with 'R', but sample data file (08005) seems to - // have been written with 'L', so I'm using 'L' here. mbp Tue Dec 24 - // 19:03:40 2002 - {"CD108", 'R', 'N', OFTInteger, 114, 115, 2, 1, 1}, - {"PUMA5", 'L', 'N', OFTInteger, 116, 120, 5, 1, 1}, - {"PUMA1", 'L', 'N', OFTInteger, 121, 125, 5, 1, 1}, - {"ZCTA5", 'L', 'A', OFTString, 126, 130, 5, 1, 1}, - {"ZCTA3", 'L', 'A', OFTString, 131, 133, 3, 1, 1}, - {"TAZ", 'L', 'A', OFTString, 134, 139, 6, 1, 1}, - {"TAZCOMB", 'L', 'A', OFTString, 140, 145, 6, 1, 1}, - {"UA", 'L', 'N', OFTInteger, 146, 150, 5, 1, 1}, - {"UR", 'L', 'A', OFTString, 151, 151, 1, 1, 1}, - {"VTD", 'R', 'A', OFTString, 152, 157, 6, 1, 1}, - {"SLDU", 'R', 'A', OFTString, 158, 160, 3, 1, 1}, - {"SLDL", 'R', 'A', OFTString, 161, 163, 3, 1, 1}, - {"UGA", 'L', 'A', OFTString, 164, 168, 5, 1, 1}, -}; -static const TigerRecordInfo rtS_2002_info = { - rtS_2002_fields, sizeof(rtS_2002_fields) / sizeof(TigerFieldInfo), 168}; - -static const TigerFieldInfo rtS_2000_Redistricting_fields[] = { - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 0, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 0, 0}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 0, 0}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 0, 0}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 0, 0}, - {"WATER", 'L', 'N', OFTString, 26, 26, 1, 1, 1}, - {"CMSAMSA", 'L', 'N', OFTInteger, 27, 30, 4, 1, 1}, - {"PMSA", 'L', 'N', OFTInteger, 31, 34, 4, 1, 1}, - {"AIANHH", 'L', 'N', OFTInteger, 35, 39, 5, 1, 1}, - {"AIR", 'L', 'N', OFTInteger, 40, 43, 4, 1, 1}, - {"TRUST", 'L', 'A', OFTString, 44, 44, 1, 1, 1}, - {"ANRC", 'L', 'A', OFTInteger, 45, 46, 2, 1, 1}, - {"STATECU", 'L', 'N', OFTInteger, 47, 48, 2, 1, 1}, - {"COUNTYCU", 'L', 'N', OFTInteger, 49, 51, 3, 1, 1}, - {"FCCITY", 'L', 'N', OFTInteger, 52, 56, 5, 1, 1}, - {"FMCD", 'L', 'N', OFTInteger, 57, 61, 5, 0, 0}, - {"FSMCD", 'L', 'N', OFTInteger, 62, 66, 5, 1, 1}, - {"PLACE", 'L', 'N', OFTInteger, 67, 71, 5, 1, 1}, - {"CTBNA00", 'L', 'N', OFTInteger, 72, 77, 6, 1, 1}, - {"BLK00", 'L', 'N', OFTString, 78, 81, 4, 1, 1}, - {"RS10", 'R', 'N', OFTInteger, 82, 82, 0, 0, 1}, - {"CDCU", 'L', 'N', OFTInteger, 83, 84, 2, 1, 1}, - - {"SLDU", 'R', 'A', OFTString, 85, 87, 3, 1, 1}, - {"SLDL", 'R', 'A', OFTString, 88, 90, 3, 1, 1}, - {"UGA", 'L', 'A', OFTString, 91, 95, 5, 1, 1}, - {"BLKGRP", 'L', 'N', OFTInteger, 96, 96, 1, 1, 1}, - {"VTD", 'R', 'A', OFTString, 97, 102, 6, 1, 1}, - {"STATECOL", 'L', 'N', OFTInteger, 103, 104, 2, 1, 1}, - {"COUNTYCOL", 'L', 'N', OFTInteger, 105, 107, 3, 1, 1}, - {"BLOCKCOL", 'R', 'N', OFTInteger, 108, 112, 5, 1, 1}, - {"BLKSUFCOL", 'L', 'A', OFTString, 113, 113, 1, 1, 1}, - {"ZCTA5", 'L', 'A', OFTString, 114, 118, 5, 1, 1}}; - -static const TigerRecordInfo rtS_2000_Redistricting_info = { - rtS_2000_Redistricting_fields, - sizeof(rtS_2000_Redistricting_fields) / sizeof(TigerFieldInfo), 120}; - -static const TigerFieldInfo rtS_fields[] = { - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 0, 0}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 0, 0}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 0, 0}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 0, 0}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 0, 0}, - - {"WATER", 'L', 'N', OFTString, 26, 26, 1, 1, 1}, - {"CMSAMSA", 'L', 'N', OFTInteger, 27, 30, 4, 1, 1}, - {"PMSA", 'L', 'N', OFTInteger, 31, 34, 4, 1, 1}, - {"AIANHH", 'L', 'N', OFTInteger, 35, 39, 5, 1, 1}, - {"AIR", 'L', 'N', OFTInteger, 40, 43, 4, 1, 1}, - {"TRUST", 'L', 'A', OFTString, 44, 44, 1, 1, 1}, - {"ANRC", 'L', 'A', OFTInteger, 45, 46, 2, 1, 1}, - {"STATECU", 'L', 'N', OFTInteger, 47, 48, 2, 1, 1}, - {"COUNTYCU", 'L', 'N', OFTInteger, 49, 51, 3, 1, 1}, - {"FCCITY", 'L', 'N', OFTInteger, 52, 56, 5, 1, 1}, - {"FMCD", 'L', 'N', OFTInteger, 57, 61, 5, 0, 0}, - {"FSMCD", 'L', 'N', OFTInteger, 62, 66, 5, 1, 1}, - {"PLACE", 'L', 'N', OFTInteger, 67, 71, 5, 1, 1}, - {"CTBNA00", 'L', 'N', OFTInteger, 72, 77, 6, 1, 1}, - {"BLK00", 'L', 'N', OFTString, 78, 81, 4, 1, 1}, - {"RS10", 'R', 'N', OFTInteger, 82, 82, 0, 0, 1}, - {"CDCU", 'L', 'N', OFTInteger, 83, 84, 2, 1, 1}, - - {"STSENATE", 'L', 'A', OFTString, 85, 90, 6, 1, 1}, - {"STHOUSE", 'L', 'A', OFTString, 91, 96, 6, 1, 1}, - {"VTD00", 'L', 'A', OFTString, 97, 102, 6, 1, 1}}; -static const TigerRecordInfo rtS_info = { - rtS_fields, sizeof(rtS_fields) / sizeof(TigerFieldInfo), 120}; - -/************************************************************************/ -/* TigerPolygon() */ -/************************************************************************/ - -TigerPolygon::TigerPolygon(OGRTigerDataSource *poDSIn, - const char * /* pszPrototypeModule */) - : psRTAInfo(nullptr), psRTSInfo(nullptr), fpRTS(nullptr), bUsingRTS(true), - nRTSRecLen(0) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("Polygon"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - if (poDS->GetVersion() >= TIGER_2004) - { - psRTAInfo = &rtA_2004_info; - } - else if (poDS->GetVersion() >= TIGER_2003) - { - psRTAInfo = &rtA_2003_info; - } - else if (poDS->GetVersion() >= TIGER_2002) - { - psRTAInfo = &rtA_2002_info; - } - else - { - psRTAInfo = &rtA_info; - } - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTSInfo = &rtS_2002_info; - } - else if (poDS->GetVersion() >= TIGER_2000_Redistricting) - { - psRTSInfo = &rtS_2000_Redistricting_info; - } - else - { - psRTSInfo = &rtS_info; - } - - /* -------------------------------------------------------------------- */ - /* Fields from type A record. */ - /* -------------------------------------------------------------------- */ - AddFieldDefns(psRTAInfo, poFeatureDefn); - - /* -------------------------------------------------------------------- */ - /* Add the RTS records if it is available. */ - /* -------------------------------------------------------------------- */ - if (bUsingRTS) - { - AddFieldDefns(psRTSInfo, poFeatureDefn); - } -} - -/************************************************************************/ -/* ~TigerPolygon() */ -/************************************************************************/ - -TigerPolygon::~TigerPolygon() - -{ - if (fpRTS != nullptr) - VSIFCloseL(fpRTS); -} - -/************************************************************************/ -/* SetModule() */ -/************************************************************************/ - -bool TigerPolygon::SetModule(const char *pszModuleIn) - -{ - if (!OpenFile(pszModuleIn, "A")) - return false; - - EstablishFeatureCount(); - - /* -------------------------------------------------------------------- */ - /* Open the RTS file */ - /* -------------------------------------------------------------------- */ - if (bUsingRTS) - { - if (fpRTS != nullptr) - { - VSIFCloseL(fpRTS); - fpRTS = nullptr; - } - - if (pszModuleIn) - { - char *pszFilename = poDS->BuildFilename(pszModuleIn, "S"); - - fpRTS = VSIFOpenL(pszFilename, "rb"); - - CPLFree(pszFilename); - - nRTSRecLen = EstablishRecordLength(fpRTS); - } - } - - return true; -} - -/************************************************************************/ -/* GetFeature() */ -/************************************************************************/ - -OGRFeature *TigerPolygon::GetFeature(int nRecordId) - -{ - char achRecord[OGR_TIGER_RECBUF_LEN]; - - if (nRecordId < 0 || nRecordId >= nFeatures) - { - CPLError(CE_Failure, CPLE_FileIO, - "Request for out-of-range feature %d of %sA", nRecordId, - pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Read the raw record data from the file. */ - /* -------------------------------------------------------------------- */ - if (fpPrimary == nullptr) - return nullptr; - - if (nRecordLength > static_cast(sizeof(achRecord))) - { - CPLError(CE_Failure, CPLE_AppDefined, "Record length too large"); - return nullptr; - } - - { - const auto nOffset = static_cast(nRecordId) * nRecordLength; - if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %sA", nOffset, - pszModule); - return nullptr; - } - } - - if (VSIFReadL(achRecord, nRecordLength, 1, fpPrimary) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %sA", - nRecordId, pszModule); - return nullptr; - } - - /* -------------------------------------------------------------------- */ - /* Set fields. */ - /* -------------------------------------------------------------------- */ - - OGRFeature *poFeature = new OGRFeature(poFeatureDefn); - - SetFields(psRTAInfo, poFeature, achRecord); - - /* -------------------------------------------------------------------- */ - /* Read RTS record, and apply fields. */ - /* -------------------------------------------------------------------- */ - - if (fpRTS != nullptr) - { - char achRTSRec[OGR_TIGER_RECBUF_LEN]; - - { - const auto nOffset = static_cast(nRecordId) * nRTSRecLen; - if (VSIFSeekL(fpRTS, nOffset, SEEK_SET) != 0) - { - CPLError(CE_Failure, CPLE_FileIO, - "Failed to seek to %" PRIu64 " of %sS", nOffset, - pszModule); - delete poFeature; - return nullptr; - } - } - - // Overflow cannot happen since psRTInfo->nRecordLength is unsigned - // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255 - if (VSIFReadL(achRTSRec, psRTSInfo->nRecordLength, 1, fpRTS) != 1) - { - CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %sS", - nRecordId, pszModule); - delete poFeature; - return nullptr; - } - - SetFields(psRTSInfo, poFeature, achRTSRec); - } - - return poFeature; -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpolygoncorrections.cpp b/ogr/ogrsf_frmts/tiger/tigerpolygoncorrections.cpp deleted file mode 100644 index b19aa77076e9..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpolygoncorrections.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPolygonCorrections, providing access to .RTB files. - * Author: Mark Phillips, mbp@geomtech.com - * - ****************************************************************************** - * Copyright (c) 2002, Frank Warmerdam, Mark Phillips - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char B_FILE_CODE[] = "B"; - -static const TigerFieldInfo rtB_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"STATECQ", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTYCQ", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - {"TRACTCQ", 'L', 'N', OFTInteger, 31, 36, 6, 1, 1}, - {"BLOCKCQ", 'L', 'A', OFTString, 37, 41, 5, 1, 1}, - {"AIANHHFPCQ", 'L', 'N', OFTInteger, 42, 46, 5, 1, 1}, - {"AIANHHCQ", 'L', 'N', OFTInteger, 47, 50, 4, 1, 1}, - {"AIHHTLICQ", 'L', 'A', OFTString, 51, 51, 1, 1, 1}, - {"AITSCECQ", 'L', 'N', OFTInteger, 52, 54, 3, 1, 1}, - {"AITSCQ", 'L', 'N', OFTInteger, 55, 59, 5, 1, 1}, - {"ANRCCQ", 'L', 'N', OFTInteger, 60, 64, 5, 1, 1}, - {"CONCITCQ", 'L', 'N', OFTInteger, 65, 69, 5, 1, 1}, - {"COUSUBCQ", 'L', 'N', OFTInteger, 70, 74, 5, 1, 1}, - {"SUBMCDCQ", 'L', 'N', OFTInteger, 75, 79, 5, 1, 1}, - {"PLACECQ", 'L', 'N', OFTInteger, 80, 84, 5, 1, 1}, - {"UACC", 'L', 'N', OFTInteger, 85, 89, 5, 1, 1}, - {"URCC", 'L', 'A', OFTString, 90, 90, 1, 1, 1}, - {"RS-B1", 'L', 'A', OFTString, 91, 98, 12, 1, 1}, -}; -static const TigerRecordInfo rtB_info = { - rtB_fields, sizeof(rtB_fields) / sizeof(TigerFieldInfo), 98}; - -/************************************************************************/ -/* TigerPolygonCorrections() */ -/************************************************************************/ - -TigerPolygonCorrections::TigerPolygonCorrections( - OGRTigerDataSource *poDSIn, const char * /* pszPrototypeModule */) - : TigerFileBase(&rtB_info, B_FILE_CODE) -{ - OGRFieldDefn oField("", OFTInteger); - - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("PolygonCorrections"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type B record. */ - /* -------------------------------------------------------------------- */ - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerpolygoneconomic.cpp b/ogr/ogrsf_frmts/tiger/tigerpolygoneconomic.cpp deleted file mode 100644 index fcd417c00d3e..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerpolygoneconomic.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerPolygonEconomic, providing access to .RTE files. - * Author: Mark Phillips, mbp@geomtech.com - * - ****************************************************************************** - * Copyright (c) 2002, Frank Warmerdam, Mark Phillips - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char FILE_CODE[] = "E"; - -/* I think this was the expected RTE format, but was never deployed, leaving - it in the code in case I am missing something. - -static TigerFieldInfo rtE_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - { "MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0 }, - { "FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1 }, - { "CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1 }, - { "POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1 }, - { "STATEEC", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1 }, - { "COUNTYEC", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1 }, - { "CONCITEC", 'L', 'N', OFTInteger, 31, 35, 5, 1, 1 }, - { "COUSUBEC", 'L', 'N', OFTInteger, 36, 40, 5, 1, 1 }, - { "PLACEEC", 'L', 'N', OFTInteger, 41, 45, 5, 1, 1 }, - { "AIANHHFPEC", 'L', 'N', OFTInteger, 46, 50, 5, 1, 1 }, - { "AIANHHEC", 'L', 'N', OFTInteger, 51, 54, 4, 1, 1 }, - { "AIAHHTLIEC", 'L', 'A', OFTString, 55, 55, 1, 1, 1 }, - { "RS_E1", 'L', 'A', OFTString, 56, 73, 18, 1, 1 } -}; -*/ - -static const TigerFieldInfo rtE_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"POLYID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"STATEEC", 'L', 'N', OFTInteger, 26, 27, 2, 1, 1}, - {"COUNTYEC", 'L', 'N', OFTInteger, 28, 30, 3, 1, 1}, - {"RS_E1", 'L', 'A', OFTString, 31, 35, 5, 1, 1}, - {"RS_E2", 'L', 'A', OFTString, 36, 40, 5, 1, 1}, - {"PLACEEC", 'L', 'N', OFTInteger, 41, 45, 5, 1, 1}, - {"RS-E3", 'L', 'A', OFTString, 46, 50, 5, 1, 1}, - {"RS-E4", 'L', 'A', OFTString, 51, 54, 4, 1, 1}, - {"RS-E5", 'L', 'A', OFTString, 55, 55, 1, 1, 1}, - {"COMMREGEC", 'L', 'N', OFTInteger, 56, 56, 1, 1, 1}, - {"RS_E6", 'L', 'A', OFTString, 57, 73, 17, 1, 1}}; -static const TigerRecordInfo rtE_info = { - rtE_fields, sizeof(rtE_fields) / sizeof(TigerFieldInfo), 73}; - -/************************************************************************/ -/* TigerPolygonEconomic() */ -/************************************************************************/ - -TigerPolygonEconomic::TigerPolygonEconomic( - OGRTigerDataSource *poDSIn, CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rtE_info, FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("PolygonEconomic"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type E record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerspatialmetadata.cpp b/ogr/ogrsf_frmts/tiger/tigerspatialmetadata.cpp deleted file mode 100644 index 9990767c7ace..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerspatialmetadata.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerSpatialMetadata, providing access to .RTM files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 2005, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char M_FILE_CODE[] = "M"; - -static const TigerFieldInfo rtM_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"RTSQ", 'R', 'N', OFTInteger, 16, 18, 3, 1, 1}, - {"SOURCEID", 'L', 'A', OFTString, 19, 28, 10, 1, 1}, - {"ID", 'L', 'A', OFTString, 29, 46, 18, 1, 1}, - {"IDFLAG", 'R', 'A', OFTString, 47, 47, 1, 1, 1}, - {"RS-M1", 'L', 'A', OFTString, 48, 65, 18, 1, 1}, - {"RS-M2", 'L', 'A', OFTString, 66, 67, 2, 1, 1}, - {"RS-M3", 'L', 'A', OFTString, 68, 90, 23, 1, 1}}; -static const TigerRecordInfo rtM_info = { - rtM_fields, sizeof(rtM_fields) / sizeof(TigerFieldInfo), 90}; - -/************************************************************************/ -/* TigerSpatialMetadata() */ -/************************************************************************/ - -TigerSpatialMetadata::TigerSpatialMetadata( - OGRTigerDataSource *poDSIn, CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rtM_info, M_FILE_CODE) - -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("SpatialMetadata"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from record type H */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigertlidrange.cpp b/ogr/ogrsf_frmts/tiger/tigertlidrange.cpp deleted file mode 100644 index 8cc04a5ff360..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigertlidrange.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerTLIDRange, providing access to .RTR files. - * Author: Frank Warmerdam, warmerda@home.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char R_FILE_CODE[] = "R"; - -static const TigerFieldInfo rtR_2002_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"TLMAXID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"TLMINID", 'R', 'N', OFTInteger, 26, 35, 10, 1, 1}, - {"TLIGHID", 'R', 'N', OFTInteger, 36, 45, 10, 1, 1}, - {"TZMAXID", 'R', 'N', OFTInteger, 46, 55, 10, 1, 1}, - {"TZMINID", 'R', 'N', OFTInteger, 56, 65, 10, 1, 1}, - {"TZHIGHID", 'R', 'N', OFTInteger, 66, 75, 10, 1, 1}, - {"FILLER", 'L', 'A', OFTString, 76, 76, 1, 1, 1}, -}; -static const TigerRecordInfo rtR_2002_info = { - rtR_2002_fields, sizeof(rtR_2002_fields) / sizeof(TigerFieldInfo), 76}; - -static const TigerFieldInfo rtR_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTString, 6, 10, 5, 1, 1}, - {"STATE", 'L', 'N', OFTInteger, 6, 7, 2, 1, 1}, - {"COUNTY", 'L', 'N', OFTInteger, 8, 10, 3, 1, 1}, - {"CENID", 'L', 'A', OFTString, 11, 15, 5, 1, 1}, - {"MAXID", 'R', 'N', OFTInteger, 16, 25, 10, 1, 1}, - {"MINID", 'R', 'N', OFTInteger, 26, 35, 10, 1, 1}, - {"HIGHID", 'R', 'N', OFTInteger, 36, 45, 10, 1, 1}}; - -static const TigerRecordInfo rtR_info = { - rtR_fields, sizeof(rtR_fields) / sizeof(TigerFieldInfo), 46}; - -/************************************************************************/ -/* TigerTLIDRange() */ -/************************************************************************/ - -TigerTLIDRange::TigerTLIDRange(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(nullptr, R_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("TLIDRange"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - if (poDS->GetVersion() >= TIGER_2002) - { - psRTInfo = &rtR_2002_info; - } - else - { - psRTInfo = &rtR_info; - } - - /* -------------------------------------------------------------------- */ - /* Fields from type R record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerzerocellid.cpp b/ogr/ogrsf_frmts/tiger/tigerzerocellid.cpp deleted file mode 100644 index 7c4cb9cc67a6..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerzerocellid.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerZeroCellID, providing access to .RTT files. - * Author: Mark Phillips, mbp@geomtech.com - * - ****************************************************************************** - * Copyright (c) 2002, Frank Warmerdam, Mark Phillips - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char T_FILE_CODE[] = "T"; - -static const TigerFieldInfo rtT_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"FILE", 'L', 'N', OFTInteger, 6, 10, 5, 1, 1}, - {"TZID", 'R', 'N', OFTInteger, 11, 20, 10, 1, 1}, - {"SOURCE", 'L', 'A', OFTString, 21, 30, 10, 1, 1}, - {"FTRP", 'L', 'A', OFTString, 31, 47, 17, 1, 1}}; -static const TigerRecordInfo rtT_info = { - rtT_fields, sizeof(rtT_fields) / sizeof(TigerFieldInfo), 47}; - -/************************************************************************/ -/* TigerZeroCellID() */ -/************************************************************************/ - -TigerZeroCellID::TigerZeroCellID(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rtT_info, T_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("ZeroCellID"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type T record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerzipcodes.cpp b/ogr/ogrsf_frmts/tiger/tigerzipcodes.cpp deleted file mode 100644 index c64ed7a561ca..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerzipcodes.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerZipCodes, providing access to .RT6 files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char SIX_FILE_CODE[] = "6"; - -static const TigerFieldInfo rt6_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"RTSQ", 'R', 'N', OFTInteger, 16, 18, 3, 1, 1}, - {"FRADDL", 'R', 'A', OFTString, 19, 29, 11, 1, 1}, - {"TOADDL", 'R', 'A', OFTString, 30, 40, 11, 1, 1}, - {"FRADDR", 'R', 'A', OFTString, 41, 51, 11, 1, 1}, - {"TOADDR", 'R', 'A', OFTString, 52, 62, 11, 1, 1}, - {"FRIADDL", 'L', 'A', OFTInteger, 63, 63, 1, 1, 1}, - {"TOIADDL", 'L', 'A', OFTInteger, 64, 64, 1, 1, 1}, - {"FRIADDR", 'L', 'A', OFTInteger, 65, 65, 1, 1, 1}, - {"TOIADDR", 'L', 'A', OFTInteger, 66, 66, 1, 1, 1}, - {"ZIPL", 'L', 'N', OFTInteger, 67, 71, 5, 1, 1}, - {"ZIPR", 'L', 'N', OFTInteger, 72, 76, 5, 1, 1}}; -static const TigerRecordInfo rt6_info = { - rt6_fields, sizeof(rt6_fields) / sizeof(TigerFieldInfo), 76}; - -/************************************************************************/ -/* TigerZipCodes() */ -/************************************************************************/ - -TigerZipCodes::TigerZipCodes(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rt6_info, SIX_FILE_CODE) - -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("ZipCodes"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type 6 record. */ - /* -------------------------------------------------------------------- */ - - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/ogr/ogrsf_frmts/tiger/tigerzipplus4.cpp b/ogr/ogrsf_frmts/tiger/tigerzipplus4.cpp deleted file mode 100644 index 8a7aea3a9374..000000000000 --- a/ogr/ogrsf_frmts/tiger/tigerzipplus4.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - * - * Project: TIGER/Line Translator - * Purpose: Implements TigerZipPlus4, providing access to .RTZ files. - * Author: Frank Warmerdam, warmerdam@pobox.com - * - ****************************************************************************** - * Copyright (c) 1999, Frank Warmerdam - * - * SPDX-License-Identifier: MIT - ****************************************************************************/ - -#include "ogr_tiger.h" -#include "cpl_conv.h" - -static const char Z_FILE_CODE[] = "Z"; - -static const TigerFieldInfo rtZ_fields[] = { - // fieldname fmt type OFTType beg end len bDefine bSet - {"MODULE", ' ', ' ', OFTString, 0, 0, 8, 1, 0}, - {"TLID", 'R', 'N', OFTInteger, 6, 15, 10, 1, 1}, - {"RTSQ", 'R', 'N', OFTInteger, 16, 18, 3, 1, 1}, - {"ZIP4L", 'L', 'N', OFTInteger, 19, 22, 4, 1, 1}, - {"ZIP4R", 'L', 'N', OFTInteger, 23, 26, 4, 1, 1}}; -static const TigerRecordInfo rtZ_info = { - rtZ_fields, sizeof(rtZ_fields) / sizeof(TigerFieldInfo), 26}; - -/************************************************************************/ -/* TigerZipPlus4() */ -/************************************************************************/ - -TigerZipPlus4::TigerZipPlus4(OGRTigerDataSource *poDSIn, - CPL_UNUSED const char *pszPrototypeModule) - : TigerFileBase(&rtZ_info, Z_FILE_CODE) -{ - poDS = poDSIn; - poFeatureDefn = new OGRFeatureDefn("ZipPlus4"); - poFeatureDefn->Reference(); - poFeatureDefn->SetGeomType(wkbNone); - - /* -------------------------------------------------------------------- */ - /* Fields from type Z record. */ - /* -------------------------------------------------------------------- */ - AddFieldDefns(psRTInfo, poFeatureDefn); -} diff --git a/port/cpl_known_config_options.h b/port/cpl_known_config_options.h index cc7ef9dbfe06..d7c5c998fe8f 100644 --- a/port/cpl_known_config_options.h +++ b/port/cpl_known_config_options.h @@ -992,8 +992,6 @@ constexpr static const char* const apszKnownConfigOptions[] = "THRESHOLD", // from ogrct.cpp "TIFF_READ_STREAMING", // from gtiffdataset_read.cpp "TIFF_USE_OVR", // from gtiffdataset_write.cpp - "TIGER_LFIELD_AS_STRING", // from tigerfilebase.cpp - "TIGER_VERSION", // from ogrtigerdatasource.cpp "TILEDB_ATTRIBUTE", // from tiledbdense.cpp "TILEDB_BINARY_TYPE", // from tiledbsparse.cpp "TILEDB_BUG", // from tiledbsparse.cpp