Exemple #1
0
        public static VPFLibrary readLibrary(VPFDatabase database, String name)
        {
            if (database == null)
            {
                String message = Logging.getMessage("nullValue.DatabaseIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (name == null)
            {
                String message = Logging.getMessage("nullValue.NameIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            try
            {
                return(VPFLibrary.fromFile(database, name));
            }
            catch (WWRuntimeException e)
            {
                // Exception already logged by VPFLibrary.
                return(null);
            }
        }
Exemple #2
0
        public static VPFCoverage readCoverage(VPFLibrary library, String name)
        {
            if (library == null)
            {
                String message = Logging.getMessage("nullValue.LibraryIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (name == null)
            {
                String message = Logging.getMessage("nullValue.NameIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            try
            {
                return(VPFCoverage.fromFile(library, name));
            }
            catch (WWRuntimeException e)
            {
                // Exception already logged by VPFCoverage.
                return(null);
            }
        }
        protected VPFCoverage(VPFLibrary library)
        {
            if (library == null)
            {
                String message = Logging.getMessage("nullValue.LibraryIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            this.library = library;
        }
        /**
         * Constructs a VPF Coverage from a specified VPF Library and coverage name. This initializes the Coverage's Feature
         * Class Schema table, the Feature Class Attribute table, the Character Value Description table, the Integer Value
         * Descrption table, and the Symbol Related Attribute table.
         *
         * @param library the Library which the Coverage resides in.
         * @param name    the Coverage's name.
         *
         * @return a new Coverage from the specified Library with the specified name.
         *
         * @throws ArgumentException if the library is null, or if the name is null or empty.
         */
        public static VPFCoverage fromFile(VPFLibrary library, String name)
        {
            if (library == null)
            {
                String message = Logging.getMessage("nullValue.LibraryIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (WWUtil.isEmpty(name))
            {
                String message = Logging.getMessage("nullValue.NameIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            File file = new File(library.getFilePath(), name);

            if (!file.exists())
            {
                String message = Logging.getMessage("generic.FileNotFound", file.getPath());
                Logging.logger().severe(message);
                throw new WWRuntimeException(message);
            }

            // Coverage tables.
            VPFBufferedRecordData fcs = VPFUtils.readTable(new File(file, VPFConstants.FEATURE_CLASS_SCHEMA_TABLE));

            if (fcs == null)
            {
                String message = Logging.getMessage("VPF.FeatureClassSchemaTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFBufferedRecordData fca = VPFUtils.readTable(
                new File(file, VPFConstants.FEATURE_CLASS_ATTRIBUTE_TABLE));
            VPFBufferedRecordData char_vdt = VPFUtils.readTable(
                new File(file, VPFConstants.CHARACTER_VALUE_DESCRIPTION_TABLE));
            VPFBufferedRecordData int_vdt = VPFUtils.readTable(
                new File(file, VPFConstants.INTEGER_VALUE_DESCRIPTION_TABLE));
            VPFBufferedRecordData symbol_rat = VPFUtils.readTable(
                new File(file, "symbol" + VPFConstants.RELATED_ATTRIBUTE_TABLE));

            VPFCoverage coverage = new VPFCoverage(library);

            coverage.setFeatureClassSchemaTable(fcs);
            coverage.setFeatureClassAttributeTable(fca);
            coverage.setCharacterValueDescriptionTable(char_vdt);
            coverage.setIntegerValueDescriptionTable(int_vdt);
            coverage.setSymbolRelatedAttributeTable(symbol_rat);

            // Coverage metadata attributes.
            VPFRecord record = library.getCoverageAttributeTable().getRecord("coverage_name", name);

            if (record != null)
            {
                VPFUtils.checkAndSetValue(record, "coverage_name", AVKey.DISPLAY_NAME, coverage);
                VPFUtils.checkAndSetValue(record, "description", AVKey.DESCRIPTION, coverage);
            }

            return(coverage);
        }
Exemple #5
0
        /**
         * Constructs a VPF Library from the specified VPF Database and library name. This initializes the Library Header
         * Table, the Coverage Attribute Table, and the Geographic Reference Table.
         *
         * @param database the Database which the Library resides in.
         * @param name     the Library's name.
         *
         * @return a new Library from the specified Database with the specified name.
         *
         * @throws ArgumentException if the database is null, or if the name is null or empty.
         */
        public static VPFLibrary fromFile(VPFDatabase database, String name)
        {
            if (database == null)
            {
                String message = Logging.getMessage("nullValue.DatabaseIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (WWUtil.isEmpty(name))
            {
                String message = Logging.getMessage("nullValue.NameIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            File file = new File(database.getFilePath(), name);

            if (!file.exists())
            {
                String message = Logging.getMessage("generic.FileNotFound", file.getPath());
                Logging.logger().severe(message);
                throw new WWRuntimeException(message);
            }

            // Library tables.
            VPFBufferedRecordData lht = VPFUtils.readTable(new File(file, VPFConstants.LIBRARY_HEADER_TABLE));

            if (lht == null)
            {
                String message = Logging.getMessage("VPF.LibraryHeaderTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFBufferedRecordData cat = VPFUtils.readTable(new File(file, VPFConstants.COVERAGE_ATTRIBUTE_TABLE));

            if (cat == null)
            {
                String message = Logging.getMessage("VPF.CoverageAttributeTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFBufferedRecordData grt = VPFUtils.readTable(new File(file, VPFConstants.GEOGRAPHIC_REFERENCE_TABLE));

            if (grt == null)
            {
                String message = Logging.getMessage("VPF.GeographicReferenceTableMissing");
                throw new WWRuntimeException(message);
            }

            VPFLibrary library = new VPFLibrary(database);

            library.setLibraryHeaderTable(lht);
            library.setCoverageAttributeTable(cat);
            library.setGeographicReferenceTable(grt);

            // Library metadata attributes.
            VPFRecord record = database.getLibraryAttributeTable().getRecord("library_name", name);

            if (record != null)
            {
                library.bounds = VPFUtils.getExtent(record);
            }

            record = lht.getRecord(1);
            if (record != null)
            {
                VPFUtils.checkAndSetValue(record, "library_name", AVKey.DISPLAY_NAME, library);
                VPFUtils.checkAndSetValue(record, "description", AVKey.DESCRIPTION, library);
            }

            // Library Coverages.
            Collection <VPFCoverage> col = createCoverages(library, cat);

            if (col != null)
            {
                library.setCoverages(col);
            }

            // Library tiles.
            VPFCoverage cov = library.getCoverage(VPFConstants.TILE_REFERENCE_COVERAGE);

            if (cov != null)
            {
                VPFTile[] tiles = createTiles(cov);
                if (tiles != null)
                {
                    library.setTiles(tiles);
                }
                else
                {
                    String message = Logging.getMessage("VPF.NoTilesInTileReferenceCoverage");
                    Logging.logger().warning(message);
                }
            }

            // Coverage tiled attributes.
            foreach (VPFCoverage coverage in library.getCoverages())
            {
                bool tiled = isCoverageTiled(library, coverage);
                coverage.setTiled(tiled);
            }

            return(library);
        }