The acronym TIGERĀ® comes from
Topologically Integrated Geographic Encoding and Referencing, which
is the name for the system and digital database developed at the
U.S. Census Bureau to support its mapping needs for the Decennial
Census and other Bureau programs.
The TIGER/Line files are a digital database of
geographic features, such as roads, railroads, rivers, lakes, legal
boundaries, census statistical boundaries, and so on, covering the
entire United States. The database contains information about these
features, such as, their location in latitude and longitude, the
name of the feature, the type of feature, address ranges for most
streets, the geographic relationship to other features, and other
related information. TIGER/LineĀ®
files are a public product created from the TIGER database of the
Census Bureau.
The source code for the Map Builder demonstration, which contains
all of the code described in this section, can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html.
The IlvTigerDataSource class
The IlvTigerDataSource class is a data source
that reads TIGER/Line files. This data source is filtered so that
only selected features can be read from the file, the others
being ignored. These features can be supplied in code as an array
of strings or can be retrieved from a IlvFeatureSelectorPanel configured with the
TigerFeaturesEN.txt
file. This file contains the list of the Census Feature Class
Codes (CFCCs) and a description of the
corresponding features. Use the following lines to supply the
CFCCs in the code:
try { IlvTigerDataSource source = new IlvTigerDataSource(filename); source.setManager(manager); source.setCFCCCodeList(new String[]{"A41"}); source.start(); } catch (Exception e) { e.printStackTrace(); }
To retrieve the CFCC codes from an
IlvFeatureSelectiorPanel
, you can use the following code, which creates, instantiates and
starts a TIGER/Line data source with the selected features:
JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); final IlvFeatureSelectorPanel spanel = new IlvFeatureSelectorPanel(manager, "TigerFeaturesEN.txt"); JButton button = new JButton("OK"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Vector src = new Vector(); IlvFeatureSelectorPanel.Feature[] features = spanel.getSelectedFeatures(); ArrayList cfccCodes = new ArrayList(); if (features != null) { for (int j = 0; j < features.length; j++) { IlvFeatureSelectorPanel.Feature currentFeature = features[j]; IlvFeatureSelectorPanel.Feature currentChild; int nChildren = currentFeature.getChildCount(); if (nChildren != 0) {// major for (int i = 0; i < currentFeature.getChildCount(); i++) { currentChild = (IlvFeatureSelectorPanel.Feature) currentFeature.getChildAt(i); cfccCodes.add(currentChild.getMajorCode() + currentChild.getMinorCode()); } } else { cfccCodes.add(currentFeature.getMajorCode() + currentFeature.getMinorCode()); } } } String[] s = (String[])cfccCodes.toArray(new String[0]); try { source = new IlvTigerDataSource(filename); source.setManager(manager); source.setCFCCCodeList(s); source.start(); } catch (Exception e1) { e1.printStackTrace(); } }}); panel.add(button, BorderLayout.SOUTH); JScrollPane pane = new JScrollPane(spanel); panel.add(pane, BorderLayout.CENTER); JFrame f = new JFrame(); f.getContentPane().add(panel); f.pack(); f.setVisible(true);
The IlvTigerReader class
The IlvTigerReader class reads TIGER/Line
files. It can be used independently, but it is usually created
through the use of a IlvTigerDataSource. The method recordMatches can be overridden to select
features to be read or discarded by the TIGER/Line reader.
File file = new File(filename); IlvTigerReader reader = new IlvTigerReader(file.toURL().toExternalForm()) { public boolean recordMatches(IlvFeatureAttributeProperty properties) { if(properties == null) return false; return properties.getAttribute("CFCC").toString().equals("A41") ; } }; IlvMapFeature f = null; IlvCoordinateSystem source = IlvGeographicCoordinateSystem.WGS84; IlvCoordinateSystem dst = IlvGeographicCoordinateSystem.WGS84; IlvCoordinateTransformation tr = IlvCoordinateTransformation.CreateTransformation(source, dst); while ((f = reader.getNextFeature()) != null) { IlvGraphic g = reader.getDefaultFeatureRenderer().makeGraphic(f, tr); manager.addObject(g, false); }