From 860d578fb594fbff41360f390a6749b1050edb78 Mon Sep 17 00:00:00 2001 From: markpet49 Date: Wed, 21 Apr 2021 22:35:02 -0500 Subject: [PATCH 01/13] Formatting --- nbproject/build-impl.xml | 1 + nbproject/genfiles.properties | 4 +- src/config/worldwind.xml | 60 +- .../formats/shapefile/Shapefile.java | 1600 ++++++++--------- .../shapefile/ShapefileLayerFactory.java | 674 +++---- .../formats/shapefile/ShapefileRecord.java | 329 ++-- src/gov/nasa/worldwind/geom/Sector.java | 1214 +++++++------ src/gov/nasa/worldwind/geom/Triangle.java | 677 ++++--- .../worldwind/terrain/SectorGeometryList.java | 310 ++-- 9 files changed, 2420 insertions(+), 2449 deletions(-) diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 4afb9b93a0..2e5268b58c 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1686,6 +1686,7 @@ is divided into following sections: + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index ec6652016b..80786b06c2 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=f85dc8f2@1.95.0.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=6106e3d1 -nbproject/build-impl.xml.script.CRC32=f2cfd8e0 -nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.95.0.48 +nbproject/build-impl.xml.script.CRC32=8e6690c6 +nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.97.0.48 diff --git a/src/config/worldwind.xml b/src/config/worldwind.xml index ee08552899..c11a2c1527 100644 --- a/src/config/worldwind.xml +++ b/src/config/worldwind.xml @@ -1,31 +1,31 @@ +~ Copyright 2006-2009, 2017, 2020 United States Government, as represented by the +~ Administrator of the National Aeronautics and Space Administration. +~ All rights reserved. +~ +~ The NASA World Wind Java (WWJ) platform is licensed under the Apache License, +~ Version 2.0 (the "License"); you may not use this file except in compliance +~ with the License. You may obtain a copy of the License at +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, software distributed +~ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +~ CONDITIONS OF ANY KIND, either express or implied. See the License for the +~ specific language governing permissions and limitations under the License. +~ +~ NASA World Wind Java (WWJ) also contains the following 3rd party Open Source +~ software: +~ +~ Jackson Parser – Licensed under Apache 2.0 +~ GDAL – Licensed under MIT +~ JOGL – Licensed under Berkeley Software Distribution (BSD) +~ Gluegen – Licensed under Berkeley Software Distribution (BSD) +~ +~ A complete listing of 3rd Party software notices and licenses included in +~ NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party +~ notices and licenses PDF found in code directory. +--> @@ -116,10 +116,10 @@ +See https://goworldwind.org/developers-guide/symbology/tactical-symbols/#offline-use for more information on how +to configure a local symbol repository. +Examples: http://myserver.com/milstd2525/ (web server) + jar:file:milstd2525-symbols.zip! (local zip archive) --> \ No newline at end of file diff --git a/src/gov/nasa/worldwind/formats/shapefile/Shapefile.java b/src/gov/nasa/worldwind/formats/shapefile/Shapefile.java index 3dca302b66..45bd27565b 100644 --- a/src/gov/nasa/worldwind/formats/shapefile/Shapefile.java +++ b/src/gov/nasa/worldwind/formats/shapefile/Shapefile.java @@ -25,7 +25,6 @@ * NASA World Wind Java (WWJ) can be found in the WorldWindJava-v2.2 3rd-party * notices and licenses PDF found in code directory. */ - package gov.nasa.worldwind.formats.shapefile; import com.jogamp.common.nio.Buffers; @@ -46,11 +45,14 @@ import java.util.logging.Level; /** - * Parses an ESRI Shapefile (.shp) and provides access to its contents. For details on the Shapefile format see the ESRI - * documentation at http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. + * Parses an ESRI Shapefile (.shp) and provides access to its contents. For + * details on the Shapefile format see the ESRI documentation at + * http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. *

- * The Shapefile provides a streaming interface for parsing a Shapefile's contents. The streaming interface enables - * applications to read Shapefiles that do not fit in memory. A typical usage pattern is as follows:


+ * The Shapefile provides a streaming interface for parsing a Shapefile's
+ * contents. The streaming interface enables applications to read Shapefiles
+ * that do not fit in memory. A typical usage pattern is as follows:
+ * 

  * Object source = "MyShapefile.shp";
  * Shapefile sf = new Shapefile(source);
  * try
@@ -67,49 +69,70 @@
  * }
  * 
*

- * The source Shapefile may be accompanied by an optional index file, attribute file, and projection file. Shapefile - * constructors that accept a generic source such as {@link #Shapefile(Object)} expect accompanying files to be in the - * same logical folder as the Shapefile, have the same filename as the Shapefile, and have suffixes ".shx", ".dbf", and - * ".prj" respectively. If any of these files do not exist, or cannot be read for any reason, the Shapefile opens - * without that information. Alternatively, the Shapefile can be constructed by providing a direct {@link - * java.io.InputStream} to any of the accompanying sources by using the InputStream based constructors, such as {@link + * The source Shapefile may be accompanied by an optional index file, attribute + * file, and projection file. Shapefile constructors that accept a generic + * source such as {@link #Shapefile(Object)} expect accompanying files to be in + * the same logical folder as the Shapefile, have the same filename as the + * Shapefile, and have suffixes ".shx", ".dbf", and ".prj" respectively. If any + * of these files do not exist, or cannot be read for any reason, the Shapefile + * opens without that information. Alternatively, the Shapefile can be + * constructed by providing a direct {@link + * java.io.InputStream} to any of the accompanying sources by using the + * InputStream based constructors, such as {@link * #Shapefile(java.io.InputStream, java.io.InputStream, java.io.InputStream, java.io.InputStream)}. *

Coordinate System

*

- * The Shapefile's coordinate system affects how the Shapefile's point coordinates are interpreted as follows:

    - *
  • Unspecified - coordinates are not changed.
  • Geographic - coordinates are validated during parsing. - * Coordinates outside the standard range of +90/-90 latitude and +180/-180 longitude cause the Shapefile to throw an - * exception during construction if the Shapefile's header contains an invalid coordinate, or in {@link - * #readNextRecord()} if any of the Shapefile's records contain an invalid coordinate.
  • Universal Transverse - * Mercator (UTM) - UTM coordinates are converted to geographic coordinates during parsing.
  • Unsupported - the - * Shapefile throws a {@link gov.nasa.worldwind.exception.WWRuntimeException} during construction.
+ * The Shapefile's coordinate system affects how the Shapefile's point + * coordinates are interpreted as follows:
    + *
  • Unspecified - coordinates are not changed.
  • Geographic - + * coordinates are validated during parsing. Coordinates outside the standard + * range of +90/-90 latitude and +180/-180 longitude cause the Shapefile to + * throw an exception during construction if the Shapefile's header contains an + * invalid coordinate, or in {@link + * #readNextRecord()} if any of the Shapefile's records contain an invalid + * coordinate.
  • Universal Transverse Mercator (UTM) - UTM coordinates + * are converted to geographic coordinates during parsing.
  • Unsupported + * - the Shapefile throws a + * {@link gov.nasa.worldwind.exception.WWRuntimeException} during + * construction.
*

- * The Shapefile's coordinate system can be specified in either an accompanying projection file, or by specifying the - * coordinate system parameters in an {@link gov.nasa.worldwind.avlist.AVList} during Shapefile's construction. The - * Shapefile gives priority to the AVList if an accompanying projection file is available and AVList projection - * parameters are specified. If an accompanying projection file is available, the Shapefile attempts to parse the - * projection file as an OGC coordinate system encoded in well-known text format. For details, see the OGC Coordinate - * Transform Service (CT) specification at http://www.opengeospatial.org/standards/ct. - * The Shapefile expects the AVList specifying its coordinate system parameters to contain the following properties: + * The Shapefile's coordinate system can be specified in either an accompanying + * projection file, or by specifying the coordinate system parameters in an + * {@link gov.nasa.worldwind.avlist.AVList} during Shapefile's construction. The + * Shapefile gives priority to the AVList if an accompanying projection file is + * available and AVList projection parameters are specified. If an accompanying + * projection file is available, the Shapefile attempts to parse the projection + * file as an OGC coordinate system encoded in well-known text format. For + * details, see the OGC Coordinate Transform Service (CT) specification at + * http://www.opengeospatial.org/standards/ct. + * The Shapefile expects the AVList specifying its coordinate system parameters + * to contain the following properties: *

  • {@link gov.nasa.worldwind.avlist.AVKey#COORDINATE_SYSTEM} - either {@link - * gov.nasa.worldwind.avlist.AVKey#COORDINATE_SYSTEM_GEOGRAPHIC} or {@link gov.nasa.worldwind.avlist.AVKey#COORDINATE_SYSTEM_PROJECTED}.
  • - *
  • {@link gov.nasa.worldwind.avlist.AVKey#PROJECTION_ZONE} - the UTM zone (if coordinate system projection is UTM); - * an integer in the range 1-60.
  • {@link gov.nasa.worldwind.avlist.AVKey#PROJECTION_HEMISPHERE} - the UTM - * hemisphere (if coordinate system is UTM); either {@link gov.nasa.worldwind.avlist.AVKey#NORTH} or {@link + * gov.nasa.worldwind.avlist.AVKey#COORDINATE_SYSTEM_GEOGRAPHIC} or + * {@link gov.nasa.worldwind.avlist.AVKey#COORDINATE_SYSTEM_PROJECTED}.
  • + *
  • {@link gov.nasa.worldwind.avlist.AVKey#PROJECTION_ZONE} - the UTM zone + * (if coordinate system projection is UTM); an integer in the range 1-60.
  • + *
  • {@link gov.nasa.worldwind.avlist.AVKey#PROJECTION_HEMISPHERE} - the UTM + * hemisphere (if coordinate system is UTM); either + * {@link gov.nasa.worldwind.avlist.AVKey#NORTH} or {@link * gov.nasa.worldwind.avlist.AVKey#SOUTH}.
*

- * Subclasses can override how the Shapefile reads and interprets its coordinate system. Override {@link - * #readCoordinateSystem()} and {@link #validateCoordinateSystem(gov.nasa.worldwind.avlist.AVList)} to change how the - * Shapefile parses an accompanying projection file and validates the coordinate system parameters. Override - * {@link #readBoundingRectangle(java.nio.ByteBuffer)} - * and {@link #readPoints(gov.nasa.worldwind.formats.shapefile.ShapefileRecord,java.nio.ByteBuffer)} to change how the - * Shapefile's point coordinates are interpreted according to its coordinate system. + * Subclasses can override how the Shapefile reads and interprets its coordinate + * system. Override {@link + * #readCoordinateSystem()} and + * {@link #validateCoordinateSystem(gov.nasa.worldwind.avlist.AVList)} to change + * how the Shapefile parses an accompanying projection file and validates the + * coordinate system parameters. Override + * {@link #readBoundingRectangle(java.nio.ByteBuffer)} and + * {@link #readPoints(gov.nasa.worldwind.formats.shapefile.ShapefileRecord,java.nio.ByteBuffer)} + * to change how the Shapefile's point coordinates are interpreted according to + * its coordinate system. * * @author Patrick Murris * @version $Id: Shapefile.java 3426 2015-09-30 23:19:16Z dcollins $ */ -public class Shapefile extends AVListImpl implements Closeable, Exportable -{ +public class Shapefile extends AVListImpl implements Closeable, Exportable { + protected static final int FILE_CODE = 0x0000270A; protected static final int HEADER_LENGTH = 100; @@ -118,22 +141,22 @@ public class Shapefile extends AVListImpl implements Closeable, Exportable protected static final String ATTRIBUTE_FILE_SUFFIX = ".dbf"; protected static final String PROJECTION_FILE_SUFFIX = ".prj"; - protected static final String[] SHAPE_CONTENT_TYPES = - { - "application/shp", - "application/octet-stream" - }; - protected static final String[] INDEX_CONTENT_TYPES = - { - "application/shx", - "application/octet-stream" - }; - protected static final String[] PROJECTION_CONTENT_TYPES = - { - "application/prj", - "application/octet-stream", - "text/plain" - }; + protected static final String[] SHAPE_CONTENT_TYPES + = { + "application/shp", + "application/octet-stream" + }; + protected static final String[] INDEX_CONTENT_TYPES + = { + "application/shx", + "application/octet-stream" + }; + protected static final String[] PROJECTION_CONTENT_TYPES + = { + "application/prj", + "application/octet-stream", + "text/plain" + }; public static final String SHAPE_NULL = "gov.nasa.worldwind.formats.shapefile.Shapefile.ShapeNull"; public static final String SHAPE_POINT = "gov.nasa.worldwind.formats.shapefile.Shapefile.ShapePoint"; @@ -154,21 +177,21 @@ public class Shapefile extends AVListImpl implements Closeable, Exportable public static final String SHAPE_MULTI_PATCH = "gov.nasa.worldwind.formats.shapefile.Shapefile.ShapeMultiPatch"; protected static List measureTypes = new ArrayList(Arrays.asList( - Shapefile.SHAPE_POINT_M, Shapefile.SHAPE_POINT_Z, - Shapefile.SHAPE_MULTI_POINT_M, Shapefile.SHAPE_MULTI_POINT_Z, - Shapefile.SHAPE_POLYLINE_M, Shapefile.SHAPE_POLYLINE_Z, - Shapefile.SHAPE_POLYGON_M, Shapefile.SHAPE_POLYGON_Z + Shapefile.SHAPE_POINT_M, Shapefile.SHAPE_POINT_Z, + Shapefile.SHAPE_MULTI_POINT_M, Shapefile.SHAPE_MULTI_POINT_Z, + Shapefile.SHAPE_POLYLINE_M, Shapefile.SHAPE_POLYLINE_Z, + Shapefile.SHAPE_POLYGON_M, Shapefile.SHAPE_POLYGON_Z )); protected static List zTypes = new ArrayList(Arrays.asList( - Shapefile.SHAPE_POINT_Z, - Shapefile.SHAPE_MULTI_POINT_Z, - Shapefile.SHAPE_POLYLINE_Z, - Shapefile.SHAPE_POLYGON_Z + Shapefile.SHAPE_POINT_Z, + Shapefile.SHAPE_MULTI_POINT_Z, + Shapefile.SHAPE_POLYLINE_Z, + Shapefile.SHAPE_POLYGON_Z )); - protected static class Header - { + protected static class Header { + public int fileCode = FILE_CODE; public int fileLength; public int version; @@ -188,9 +211,11 @@ protected static class Header protected DBaseFile attributeFile; protected boolean open; /** - * Indicates if the shapefile's point coordinates should be normalized. Defaults to false. This is used by Point - * records to determine if its points should be normalized. MultiPoint, Polyline, and Polygon records use their - * bounding rectangles to determine if they should be normalized, and therefore ignore this property. + * Indicates if the shapefile's point coordinates should be normalized. + * Defaults to false. This is used by Point records to determine if its + * points should be normalized. MultiPoint, Polyline, and Polygon records + * use their bounding rectangles to determine if they should be normalized, + * and therefore ignore this property. */ protected boolean normalizePoints; protected int numRecordsRead; @@ -200,121 +225,129 @@ protected static class Header protected MappedByteBuffer mappedShpBuffer; /** - * Opens an Shapefile from a general source. The source type may be one of the following:

  • {@link + * Opens an Shapefile from a general source. The source type may be one of + * the following:
    • {@link * java.io.InputStream}
    • {@link java.net.URL}
    • absolute {@link java.net.URI}
    • {@link - * File}
    • {@link String} containing a valid URL description or a file or resource name available on the - * classpath.
    + * File}
  • {@link String} containing a valid URL description or a + * file or resource name available on the classpath.
*

- * The source Shapefile may be accompanied by an optional index file, attribute file, and projection file. To be - * recognized by this Shapefile, accompanying files must be in the same logical folder as the Shapefile, have the - * same filename as the Shapefile, and have suffixes ".shx", ".dbf", and ".prj" respectively. If any of these files - * do not exist, or cannot be read for any reason, the Shapefile opens without that information. + * The source Shapefile may be accompanied by an optional index file, + * attribute file, and projection file. To be recognized by this Shapefile, + * accompanying files must be in the same logical folder as the Shapefile, + * have the same filename as the Shapefile, and have suffixes ".shx", + * ".dbf", and ".prj" respectively. If any of these files do not exist, or + * cannot be read for any reason, the Shapefile opens without that + * information. *

- * This throws an exception if the shapefile's coordinate system is unsupported. + * This throws an exception if the shapefile's coordinate system is + * unsupported. * * @param source the source of the shapefile. - * @param params parameter list describing metadata about the Shapefile, such as its map projection. + * @param params parameter list describing metadata about the Shapefile, + * such as its map projection. * - * @throws IllegalArgumentException if the source is null or an empty string. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason, or if the shapefile's - * coordinate system is unsupported. + * @throws IllegalArgumentException if the source is null or an empty + * string. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason, or if the shapefile's coordinate system is unsupported. */ - public Shapefile(Object source, AVList params) - { - if (source == null || WWUtil.isEmpty(source)) - { + public Shapefile(Object source, AVList params) { + if (source == null || WWUtil.isEmpty(source)) { String message = Logging.getMessage("nullValue.SourceIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } - try - { + try { this.setValue(AVKey.DISPLAY_NAME, source.toString()); - if (source instanceof File) + if (source instanceof File) { this.initializeFromFile((File) source, params); - else if (source instanceof URL) + } else if (source instanceof URL) { this.initializeFromURL((URL) source, params); - else if (source instanceof InputStream) + } else if (source instanceof InputStream) { this.initializeFromStreams((InputStream) source, null, null, null, params); - else if (source instanceof String) + } else if (source instanceof String) { this.initializeFromPath((String) source, params); - else - { + } else { String message = Logging.getMessage("generic.UnrecognizedSourceType", source); Logging.logger().severe(message); throw new IllegalArgumentException(message); } - } - catch (Exception e) - { + } catch (Exception e) { String message = Logging.getMessage("SHP.ExceptionAttemptingToReadShapefile", - this.getValue(AVKey.DISPLAY_NAME)); + this.getValue(AVKey.DISPLAY_NAME)); Logging.logger().log(Level.SEVERE, message, e); throw new WWRuntimeException(message, e); } } /** - * Opens an Shapefile from a general source. The source type may be one of the following:

  • {@link - * java.io.InputStream}
  • {@link java.net.URL}
  • {@link File}
  • {@link String} containing a - * valid URL description or a file or resource name available on the classpath.
+ * Opens an Shapefile from a general source. The source type may be one of + * the following:
  • {@link + * java.io.InputStream}
  • {@link java.net.URL}
  • + *
  • {@link File}
  • {@link String} containing a valid URL + * description or a file or resource name available on the classpath.
  • + *
*

- * The source Shapefile may be accompanied by an optional index file, attribute file, and projection file. To be - * recognized by this Shapefile, accompanying files must be in the same logical folder as the Shapefile, have the - * same filename as the Shapefile, and have suffixes ".shx", ".dbf", and ".prj" respectively. If any of these files - * do not exist, or cannot be read for any reason, the Shapefile opens without that information. + * The source Shapefile may be accompanied by an optional index file, + * attribute file, and projection file. To be recognized by this Shapefile, + * accompanying files must be in the same logical folder as the Shapefile, + * have the same filename as the Shapefile, and have suffixes ".shx", + * ".dbf", and ".prj" respectively. If any of these files do not exist, or + * cannot be read for any reason, the Shapefile opens without that + * information. *

- * This throws an exception if the shapefile's coordinate system is unsupported, or if the shapefile's coordinate - * system is unsupported. + * This throws an exception if the shapefile's coordinate system is + * unsupported, or if the shapefile's coordinate system is unsupported. * * @param source the source of the shapefile. * - * @throws IllegalArgumentException if the source is null or an empty string. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason. + * @throws IllegalArgumentException if the source is null or an empty + * string. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason. */ - public Shapefile(Object source) - { + public Shapefile(Object source) { this(source, null); } /** - * Opens a Shapefile from an InputStream, and InputStreams to its optional resources. + * Opens a Shapefile from an InputStream, and InputStreams to its optional + * resources. *

- * The source Shapefile may be accompanied optional streams to an index resource stream, an attribute resource - * stream, and a projection resource stream. If any of these streams are null or cannot be read for any reason, the - * Shapefile opens without that information. + * The source Shapefile may be accompanied optional streams to an index + * resource stream, an attribute resource stream, and a projection resource + * stream. If any of these streams are null or cannot be read for any + * reason, the Shapefile opens without that information. *

- * This throws an exception if the shapefile's coordinate system is unsupported. + * This throws an exception if the shapefile's coordinate system is + * unsupported. * * @param shpStream the shapefile geometry file stream. * @param shxStream the index file stream, can be null. * @param dbfStream the attribute file stream, can be null. * @param prjStream the projection file stream, can be null. - * @param params parameter list describing metadata about the Shapefile, such as its map projection. + * @param params parameter list describing metadata about the Shapefile, + * such as its map projection. * - * @throws IllegalArgumentException if the shapefile geometry stream shpStream is null. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason, or if the shapefile's - * coordinate system is unsupported. + * @throws IllegalArgumentException if the shapefile geometry stream + * shpStream is null. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason, or if the shapefile's coordinate system is unsupported. */ public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream, InputStream prjStream, - AVList params) - { - if (shpStream == null) - { + AVList params) { + if (shpStream == null) { String message = Logging.getMessage("nullValue.InputStreamIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } - try - { + try { this.setValue(AVKey.DISPLAY_NAME, shpStream.toString()); this.initializeFromStreams(shpStream, shxStream, dbfStream, prjStream, params); - } - catch (Exception e) - { + } catch (Exception e) { String message = Logging.getMessage("SHP.ExceptionAttemptingToReadShapefile", shpStream); Logging.logger().log(Level.SEVERE, message, e); throw new WWRuntimeException(message, e); @@ -322,154 +355,173 @@ public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfSt } /** - * Opens a Shapefile from an InputStream, and InputStreams to its optional resources. + * Opens a Shapefile from an InputStream, and InputStreams to its optional + * resources. *

- * The source Shapefile may be accompanied optional streams to an index resource stream, an attribute resource - * stream, and a projection resource stream. If any of these streams are null or cannot be read for any reason, the - * Shapefile opens without that information. + * The source Shapefile may be accompanied optional streams to an index + * resource stream, an attribute resource stream, and a projection resource + * stream. If any of these streams are null or cannot be read for any + * reason, the Shapefile opens without that information. *

- * This throws an exception if the shapefile's coordinate system is unsupported. + * This throws an exception if the shapefile's coordinate system is + * unsupported. * * @param shpStream the shapefile geometry file stream. * @param shxStream the index file stream, can be null. * @param dbfStream the attribute file stream, can be null. * @param prjStream the projection file stream, can be null. * - * @throws IllegalArgumentException if the shapefile geometry stream shpStream is null. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason, or if the shapefile's - * coordinate system is unsupported. + * @throws IllegalArgumentException if the shapefile geometry stream + * shpStream is null. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason, or if the shapefile's coordinate system is unsupported. */ - public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream, InputStream prjStream) - { + public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream, InputStream prjStream) { this(shpStream, shxStream, dbfStream, prjStream, null); } /** - * Opens a Shapefile from an InputStream, and InputStreams to its optional resources. + * Opens a Shapefile from an InputStream, and InputStreams to its optional + * resources. *

- * The source Shapefile may be accompanied optional streams to an index resource stream, and an attribute resource - * stream. If any of these streams are null or cannot be read for any reason, the Shapefile opens without that - * information. + * The source Shapefile may be accompanied optional streams to an index + * resource stream, and an attribute resource stream. If any of these + * streams are null or cannot be read for any reason, the Shapefile opens + * without that information. *

- * This throws an exception if the shapefile's coordinate system is unsupported. + * This throws an exception if the shapefile's coordinate system is + * unsupported. * * @param shpStream the shapefile geometry file stream. * @param shxStream the index file stream, can be null. * @param dbfStream the attribute file stream, can be null. - * @param params parameter list describing metadata about the Shapefile, such as its map projection. + * @param params parameter list describing metadata about the Shapefile, + * such as its map projection. * - * @throws IllegalArgumentException if the shapefile geometry stream shpStream is null. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason, or if the shapefile's - * coordinate system is unsupported. + * @throws IllegalArgumentException if the shapefile geometry stream + * shpStream is null. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason, or if the shapefile's coordinate system is unsupported. */ - public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream, AVList params) - { + public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream, AVList params) { this(shpStream, shxStream, dbfStream, null, params); } /** - * Opens a Shapefile from an InputStream, and InputStreams to its optional resources. + * Opens a Shapefile from an InputStream, and InputStreams to its optional + * resources. *

- * The source Shapefile may be accompanied optional streams to an index resource stream, and an attribute resource - * stream. If any of these streams are null or cannot be read for any reason, the Shapefile opens without that - * information. + * The source Shapefile may be accompanied optional streams to an index + * resource stream, and an attribute resource stream. If any of these + * streams are null or cannot be read for any reason, the Shapefile opens + * without that information. * * @param shpStream the shapefile geometry file stream. * @param shxStream the index file stream, can be null. * @param dbfStream the attribute file stream, can be null. * - * @throws IllegalArgumentException if the shapefile geometry stream shpStream is null. - * @throws WWRuntimeException if the shapefile cannot be opened for any reason. + * @throws IllegalArgumentException if the shapefile geometry stream + * shpStream is null. + * @throws WWRuntimeException if the shapefile cannot be opened for any + * reason. */ - public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream) - { + public Shapefile(InputStream shpStream, InputStream shxStream, InputStream dbfStream) { this(shpStream, shxStream, dbfStream, null, null); } /** - * Returns the shapefile's version field, or -1 if the Shapefile failed to open. + * Returns the shapefile's version field, or -1 if the Shapefile failed to + * open. * - * @return the shapefile's version field, or -1 to denote the Shapefile failed to open. + * @return the shapefile's version field, or -1 to denote the Shapefile + * failed to open. */ - public int getVersion() - { + public int getVersion() { return this.header != null ? this.header.version : -1; } /** - * Returns the raw shapefile's length, or -1 if the Shapefile failed to open. + * Returns the raw shapefile's length, or -1 if the Shapefile failed to + * open. * - * @return the raw shapefile's length in bytes, or -1 to denote the Shapefile failed to open. + * @return the raw shapefile's length in bytes, or -1 to denote the + * Shapefile failed to open. */ - public int getLength() - { + public int getLength() { return this.header != null ? this.header.fileLength : -1; } /** - * Returns the shapefile's shape type: null if the Shapefile failed to open, otherwise one of the following symbolic - * constants: