Пример #1
0
        public static VPFFeatureClass[] readFeatureClasses(VPFCoverage coverage, FileFilter featureTableFilter)
        {
            if (coverage == null)
            {
                String message = Logging.getMessage("nullValue.CoverageIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

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

            VPFFeatureClassSchema[] schemas = coverage.getFeatureClasses(featureTableFilter);
            VPFFeatureClass[]       cls     = new VPFFeatureClass[schemas.length];

            VPFFeatureClassFactory factory = new VPFBasicFeatureClassFactory();

            for (int i = 0; i < schemas.length; i++)
            {
                cls[i] = factory.createFromSchema(coverage, schemas[i]);
            }

            return(cls);
        }
Пример #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);
            }
        }
Пример #3
0
        public VPFFeatureClass createFromSchema(VPFCoverage coverage, VPFFeatureClassSchema schema)
        {
            if (coverage == null)
            {
                String message = Logging.getMessage("nullValue.CoverageIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

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

            try
            {
                return(this.doCreateFromSchema(coverage, schema));
            }
            catch (Exception e)
            {
                String message = Logging.getMessage("generic.ExceptionWhileReading",
                                                    coverage.getFilePath() + File.separator + schema.getClassName());
                throw new WWRuntimeException(message, e);
            }
        }
Пример #4
0
        protected void buildNodePrimitives(VPFCoverage coverage, VPFTile tile, VPFPrimitiveData primitiveData)
        {
            VPFBufferedRecordData nodeTable = this.createPrimitiveTable(coverage, tile, VPFConstants.NODE_PRIMITIVE_TABLE);

            if (nodeTable != null && nodeTable.getNumRecords() > 0)
            {
                this.buildNodePrimitives(nodeTable, VPFConstants.NODE_PRIMITIVE_TABLE, primitiveData);
            }

            VPFBufferedRecordData entityNodeTable = this.createPrimitiveTable(coverage, tile,
                                                                              VPFConstants.ENTITY_NODE_PRIMITIVE_TABLE);

            if (entityNodeTable != null && entityNodeTable.getNumRecords() > 0)
            {
                this.buildNodePrimitives(entityNodeTable, VPFConstants.ENTITY_NODE_PRIMITIVE_TABLE, primitiveData);
            }

            VPFBufferedRecordData connectedNodeTable = this.createPrimitiveTable(coverage, tile,
                                                                                 VPFConstants.CONNECTED_NODE_PRIMITIVE_TABLE);

            if (connectedNodeTable != null && connectedNodeTable.getNumRecords() > 0)
            {
                this.buildNodePrimitives(connectedNodeTable, VPFConstants.CONNECTED_NODE_PRIMITIVE_TABLE, primitiveData);
            }
        }
Пример #5
0
        protected void buildTextPrimitives(VPFCoverage coverage, VPFTile tile, VPFPrimitiveData primitiveData)
        {
            VPFBufferedRecordData textTable = this.createPrimitiveTable(coverage, tile, VPFConstants.TEXT_PRIMITIVE_TABLE);

            if (textTable == null || textTable.getNumRecords() == 0)
            {
                return;
            }

            int numText = textTable.getNumRecords();

            VPFPrimitiveData.BasicPrimitiveInfo[] textInfo = new VPFPrimitiveData.BasicPrimitiveInfo[numText];
            VecBufferSequence     coords  = (VecBufferSequence)textTable.getRecordData("shape_line").getBackingData();
            CompoundStringBuilder strings = (CompoundStringBuilder)textTable.getRecordData("string").getBackingData();

            foreach (VPFRecord row in textTable)
            {
                int id = row.getId();

                textInfo[VPFBufferedRecordData.indexFromId(id)] = new VPFPrimitiveData.BasicPrimitiveInfo(
                    VPFBoundingBox.fromVecBuffer(coords.subBuffer(id)));
            }

            primitiveData.setPrimitiveInfo(VPFConstants.TEXT_PRIMITIVE_TABLE, textInfo);
            primitiveData.setPrimitiveCoords(VPFConstants.TEXT_PRIMITIVE_TABLE, coords);
            primitiveData.setPrimitiveStrings(VPFConstants.TEXT_PRIMITIVE_TABLE, strings);
        }
Пример #6
0
 public VPFFeatureClass(VPFCoverage coverage, VPFFeatureClassSchema schema, String joinTableName,
                        String primitiveTableName)
 {
     this.coverage           = coverage;
     this.schema             = schema;
     this.joinTableName      = joinTableName;
     this.primitiveTableName = primitiveTableName;
 }
Пример #7
0
        //**************************************************************//
        //********************  Primitive Assembly  ********************//
        //**************************************************************//

        protected VPFPrimitiveData doCreatePrimitives(VPFCoverage coverage)
        {
            VPFPrimitiveData primitiveData = new VPFPrimitiveData();

            this.buildNodePrimitives(coverage, this.tile, primitiveData);
            this.buildEdgePrimitives(coverage, this.tile, primitiveData);
            this.buildFacePrimitives(coverage, this.tile, primitiveData);
            this.buildTextPrimitives(coverage, this.tile, primitiveData);

            return(primitiveData);
        }
Пример #8
0
        public VPFPrimitiveData createPrimitiveData(VPFCoverage coverage)
        {
            if (coverage == null)
            {
                String message = Logging.getMessage("nullValue.CoverageIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            String path = getPrimitiveTablePath(coverage, this.tile, "");
            File   file = new File(path);

            if (!file.exists())
            {
                return(null);
            }

            return(this.doCreatePrimitives(coverage));
        }
Пример #9
0
        protected void buildEdgePrimitives(VPFCoverage coverage, VPFTile tile, VPFPrimitiveData primitiveData)
        {
            VPFBufferedRecordData edgeTable = this.createPrimitiveTable(coverage, tile, VPFConstants.EDGE_PRIMITIVE_TABLE);

            if (edgeTable == null || edgeTable.getNumRecords() == 0)
            {
                return;
            }

            VPFBufferedRecordData mbrTable = this.createPrimitiveTable(coverage, tile,
                                                                       VPFConstants.EDGE_BOUNDING_RECTANGLE_TABLE);

            if (mbrTable == null)
            {
                return;
            }

            int numEdges = edgeTable.getNumRecords();

            VPFPrimitiveData.EdgeInfo[] edgeInfo = new VPFPrimitiveData.EdgeInfo[numEdges];
            VecBufferSequence           coords   = (VecBufferSequence)edgeTable.getRecordData(
                "coordinates").getBackingData();

            foreach (VPFRecord row in edgeTable)
            {
                int       id     = row.getId();
                VPFRecord mbrRow = mbrTable.getRecord(id);

                edgeInfo[VPFBufferedRecordData.indexFromId(id)] = new VPFPrimitiveData.EdgeInfo(
                    getNumber(row.getValue("edge_type")),
                    getId(row.getValue("start_node")), getNumber(row.getValue("end_node")),
                    getId(row.getValue("left_face")), getId(row.getValue("right_face")),
                    getId(row.getValue("left_edge")), getId(row.getValue("right_edge")),
                    isEdgeOnTileBoundary(row),
                    VPFUtils.getExtent(mbrRow));
            }

            primitiveData.setPrimitiveInfo(VPFConstants.EDGE_PRIMITIVE_TABLE, edgeInfo);
            primitiveData.setPrimitiveCoords(VPFConstants.EDGE_PRIMITIVE_TABLE, coords);
        }
Пример #10
0
        /**
         * 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);
        }
Пример #11
0
 protected VPFFeatureClass doCreateFromSchema(VPFCoverage coverage, VPFFeatureClassSchema schema) throws IOException
Пример #12
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);
        }
Пример #13
0
        protected void buildFacePrimitives(VPFCoverage coverage, VPFTile tile, VPFPrimitiveData primitiveData)
        {
            VPFBufferedRecordData faceTable = this.createPrimitiveTable(coverage, tile, VPFConstants.FACE_PRIMITIVE_TABLE);

            if (faceTable == null)
            {
                return;
            }

            VPFBufferedRecordData mbrTable = this.createPrimitiveTable(coverage, tile,
                                                                       VPFConstants.FACE_BOUNDING_RECTANGLE_TABLE);

            if (mbrTable == null)
            {
                return;
            }

            VPFBufferedRecordData ringTable = this.createPrimitiveTable(coverage, tile, VPFConstants.RING_TABLE);

            if (ringTable == null)
            {
                return;
            }

            VPFPrimitiveData.PrimitiveInfo[] edgeInfo = primitiveData.getPrimitiveInfo(VPFConstants.EDGE_PRIMITIVE_TABLE);

            int numFaces = faceTable.getNumRecords();

            VPFPrimitiveData.FaceInfo[] faceInfo = new VPFPrimitiveData.FaceInfo[numFaces];

            foreach (VPFRecord faceRow in faceTable)
            {
                int       faceId = faceRow.getId();
                VPFRecord mbrRow = mbrTable.getRecord(faceId);

                // Face ID 1 is reserved for the "universe face", which does not have any associated geometry.
                if (faceId == 1)
                {
                    continue;
                }

                // The first ring primitive associated with the face primitive defines the outer ring. The face primitive must
                // at least contain coordinates for an outer ring.

                int                   ringId    = ((Number)faceRow.getValue("ring_ptr")).intValue();
                VPFRecord             ringRow   = ringTable.getRecord(ringId);
                VPFPrimitiveData.Ring outerRing = this.buildRing(ringRow, edgeInfo);

                // The ring table maintains an order relationship for its rows. The first record of a new face id will always
                // be defined as the outer ring. Any repeating records with an identical face value will define inner rings.

                ArrayList <VPFPrimitiveData.Ring> innerRingList = new ArrayList <VPFPrimitiveData.Ring>();

                for (ringId = ringId + 1; ringId <= ringTable.getNumRecords(); ringId++)
                {
                    ringRow = ringTable.getRecord(ringId);

                    // Break on the first ring primitive row which isn't associated with the face. Because the ring rows
                    // maintain an ordering with respect to face id, there will be no other ring rows corresponding to this
                    // face.
                    if (faceId != getId(ringRow.getValue("face_id")))
                    {
                        break;
                    }

                    VPFPrimitiveData.Ring innerRing = this.buildRing(ringRow, edgeInfo);
                    if (innerRing != null)
                    {
                        innerRingList.add(innerRing);
                    }
                }

                VPFPrimitiveData.Ring[] innerRings = new VPFPrimitiveData.Ring[innerRingList.size()];
                innerRingList.toArray(innerRings);

                faceInfo[VPFBufferedRecordData.indexFromId(faceId)] = new VPFPrimitiveData.FaceInfo(
                    outerRing, innerRings, VPFUtils.getExtent(mbrRow));
            }

            primitiveData.setPrimitiveInfo(VPFConstants.FACE_PRIMITIVE_TABLE, faceInfo);
        }