Beispiel #1
0
        public void BuildFromDataRecord(S57Reader reader, DataRecord cr, CatalogueFile catalogueFile)
        {
            // Record Identifier Field
            var rcid = cr.Fields.GetFieldByTag("CATD");

            if (rcid != null)
            {
                RecordIdentificationNumber = (uint)rcid.GetInt32("RCID");
                fileName             = rcid.GetString("FILE");
                fileLongName         = rcid.GetString("LFIL");
                southernMostLatitude = rcid.GetDouble("SLAT");
                westernMostLongitude = rcid.GetDouble("WLON");
                northernMostLatitude = rcid.GetDouble("NLAT");
                easternMostLongitude = rcid.GetDouble("ELON");
            }
        }
Beispiel #2
0
        public void BuildFromDataRecord(S57Reader reader, DataRecord cr, CatalogueFile catalogueFile)
        {
            // Record Identifier Field
            var catd = cr.Fields.GetFieldByTag("CATD");

            if (catd != null)
            {
                subFieldRow = catd.subFields.Values[0];
                tagLookup   = catd.subFields.TagIndex;
                RecordIdentificationNumber = (uint)subFieldRow.GetInt32(tagLookup.IndexOf("RCID")); //this one ist stored as integer, so implementing GetUint32 to do merely a cast will fail
                fileName             = subFieldRow.GetString(tagLookup.IndexOf("FILE"));
                fileLongName         = subFieldRow.GetString(tagLookup.IndexOf("LFIL"));
                southernMostLatitude = subFieldRow.GetDouble(tagLookup.IndexOf("SLAT"));
                westernMostLongitude = subFieldRow.GetDouble(tagLookup.IndexOf("WLON"));
                northernMostLatitude = subFieldRow.GetDouble(tagLookup.IndexOf("NLAT"));
                easternMostLongitude = subFieldRow.GetDouble(tagLookup.IndexOf("ELON"));
            }
        }
Beispiel #3
0
 public Vector(S57Reader reader, DataRecord vr, BaseFile baseFile)
 {
     _vr = vr;
     BuildFromDataRecord(reader, vr, baseFile);
 }
Beispiel #4
0
        // Vector
        //  0001 ISO/IEC 8211 Record
        //      VRID Vector Record Identifier
        //      <R> ATTV Vector Record Attributes
        //      VRPC Vector Record Pointer Control
        //      <R> VRPT Vector Record Pointer
        //      SGCC Coordinate Control
        //      <R> SG2D 2D Coordinate
        //      <R> SG3D 3D Coordinate
        //      <R> ARCC Arc/Curve
        //          <R> AR2D
        //          <R> EL2D
        //          <R> CT2D

        public void BuildFromDataRecord(S57Reader reader, DataRecord vr, BaseFile baseFile)
        {
            // Record Identifier Field
            var vrid = vr.Fields.GetFieldByTag("VRID");

            if (vrid != null)
            {
                var rcnm = vrid.GetUInt32("RCNM");
                var rcid = vrid.GetUInt32("RCID");
                vectorName = new VectorName(rcnm, rcid);
                rver       = vrid.GetUInt32("RVER");
                ruin       = vrid.GetUInt32("RUIN");
            }

            // Attribute Field
            var attr = vr.Fields.GetFieldByTag("ATTV");

            if (attr != null)
            {
                Attributes = Feature.GetAttributes(attr, baseFile);
            }

            // VRPC Pointer Control Field
            var vrpc = vr.Fields.GetFieldByTag("VRPC");

            if (vrpc != null)
            {
                vectorPointerUpdateInstruction = vrpc.GetUInt32("VPUI");
                recordPointerIndex             = vrpc.GetUInt32("VPIX");
                nbVectorRecordPointers         = vrpc.GetUInt32("NVPT");
            }

            // <R> VRPT Pointer Field
            var vrpt = vr.Fields.GetFieldByTag("VRPT");

            if (vrpt != null)
            {
                VectorRecordPointers = GetVRPTs(vrpt);
            }

            // SGCC Coordinate Control Field
            var sgcc = vr.Fields.GetFieldByTag("SGCC");

            if (sgcc != null)
            {
                var coordinateUdpateInstruction = sgcc.GetUInt32("CCUI");
                var coordinateIndex             = sgcc.GetUInt32("CCIX");
                var numberOfCoordinates         = sgcc.GetUInt32("CCNC");
            }

            // Coordinate Fields
            var sg2d = vr.Fields.GetFieldByTag("SG2D");

            if (sg2d != null)
            {
                if (vectorName.Type == VectorType.connectedNode || vectorName.Type == VectorType.isolatedNode)
                {
                    var ycoo = sg2d.GetDouble("YCOO");
                    var xcoo = sg2d.GetDouble("XCOO");
                    geometry = new Point(xcoo, ycoo);
                }
                else
                {
                    var bytes        = sg2d.Bytes;
                    int currentIndex = 0;
                    int length       = bytes.Length - 1;
                    geometry = new Line();
                    var line = geometry as Line;
                    reader.BindVectorToVectorRecordPointsOf(this);
                    line.points.Add(VectorRecordPointers[0].Vector.geometry as Point);
                    while (currentIndex < length && bytes[currentIndex] != DataField.UnitTerminator)
                    {
                        var point = new Point();
                        for (int i = 0; i < 4; i++)
                        {
                            int tempVal = bytes[currentIndex++];
                            for (int j = 0; j < i; j++)
                            {
                                tempVal = tempVal << 8;
                            }
                            point.Y += tempVal;
                        }
                        point.Y /= baseFile.coordinateMultiplicationFactor;
                        for (int i = 0; i < 4; i++)
                        {
                            int tempVal = bytes[currentIndex++];
                            for (int j = 0; j < i; j++)
                            {
                                tempVal = tempVal << 8;
                            }
                            point.X += tempVal;
                        }
                        point.X /= baseFile.coordinateMultiplicationFactor;
                        line.points.Add(point);
                    }
                    line.points.Add(VectorRecordPointers[1].Vector.geometry as Point);
                }
            }
            else
            {
                var sg3d = vr.Fields.GetFieldByTag("SG3D");
                if (sg3d != null)
                {
                    var ycoo = sg3d.GetDouble("YCOO");
                    var xcoo = sg3d.GetDouble("XCOO");
                    geometry = new Point(xcoo, ycoo);
                }
                else
                {
                    var arcc = vr.Fields.GetFieldByTag("ARCC");
                    // Not managed
                }
            }
        }
Beispiel #5
0
 public Catalogue(S57Reader reader, DataRecord cr, CatalogueFile catalogueFile)
 {
     _cr = cr;
     BuildFromDataRecord(reader, cr, catalogueFile);
 }
Beispiel #6
0
        // Vector
        //  0001 ISO/IEC 8211 Record
        //      VRID Vector Record Identifier
        //      <R> ATTV Vector Record Attributes
        //      VRPC Vector Record Pointer Control
        //      <R> VRPT Vector Record Pointer
        //      SGCC Coordinate Control
        //      <R> SG2D 2D Coordinate
        //      <R> SG3D 3D Coordinate
        //      <R> ARCC Arc/Curve
        //          <R> AR2D
        //          <R> EL2D
        //          <R> CT2D

        public void BuildFromDataRecord(S57Reader reader, DataRecord vr, BaseFile baseFile)
        {
            // Record Identifier Field
            var vrid = vr.Fields.GetFieldByTag("VRID");

            if (vrid != null)
            {
                var rcnm = vrid.GetUInt32("RCNM");
                var rcid = vrid.GetUInt32("RCID");
                vectorName = new VectorName(rcnm, rcid);
                rver       = vrid.GetUInt32("RVER");
                ruin       = vrid.GetUInt32("RUIN");
            }

            // Attribute Field
            var attr = vr.Fields.GetFieldByTag("ATTV");

            if (attr != null)
            {
                Attributes = Feature.GetAttributes(attr, baseFile);
            }

            // VRPC Pointer Control Field
            var vrpc = vr.Fields.GetFieldByTag("VRPC");

            if (vrpc != null)
            {
                vectorPointerUpdateInstruction = vrpc.GetUInt32("VPUI");
                recordPointerIndex             = vrpc.GetUInt32("VPIX");
                nbVectorRecordPointers         = vrpc.GetUInt32("NVPT");
            }

            // <R> VRPT Pointer Field
            var vrpt = vr.Fields.GetFieldByTag("VRPT");

            if (vrpt != null)
            {
                VectorRecordPointers = GetVRPTs(vrpt);
            }

            // SGCC Coordinate Control Field
            var sgcc = vr.Fields.GetFieldByTag("SGCC");

            if (sgcc != null)
            {
                var coordinateUdpateInstruction = sgcc.GetUInt32("CCUI");
                var coordinateIndex             = sgcc.GetUInt32("CCIX");
                var numberOfCoordinates         = sgcc.GetUInt32("CCNC");
            }

            // Coordinate Fields
            var sg2d = vr.Fields.GetFieldByTag("SG2D");

            if (sg2d != null)
            {
                //if (vectorName.Type == VectorType.connectedNode || vectorName.Type == VectorType.isolatedNode)
                if (vectorName.Type == (uint)VectorType.connectedNode || vectorName.Type == (uint)VectorType.isolatedNode)
                {
                    var ycoo = sg2d.GetDouble("YCOO");
                    var xcoo = sg2d.GetDouble("XCOO");
                    geometry = new Point(xcoo, ycoo);
                    //Debug.WriteLine($"{ycoo:0.0#####}");
                }
                else
                {
                    var bytes        = sg2d.Bytes;
                    int currentIndex = 0;
                    int length       = bytes.Length - 1;
                    geometry = new Line();
                    var line = geometry as Line;
                    reader.BindVectorToVectorRecordPointsOf(this);
                    line.points.Add(VectorRecordPointers[0].Vector.geometry as Point);
                    //to stop at DataField.UnitTerminator while reading coordinates is a bug: "31" can occur like any other byte to encode the XCOO or YCOO coordinates
                    //e.g. it is the first byte of latitude 34.6188063 (31+26880+10616832+335544320)
                    //while (currentIndex < length && bytes[currentIndex] != DataField.UnitTerminator) //this is a bug: unit terminator causes premature termination
                    while (currentIndex < length)
                    {
                        var point = new Point();
                        for (int i = 0; i < 4; i++)
                        {
                            int tempVal = bytes[currentIndex++];
                            for (int j = 0; j < i; j++)
                            {
                                tempVal = tempVal << 8;
                            }
                            point.Y += tempVal;
                        }
                        var b = point.Y;
                        //Debug.WriteLine($"{b:0.0#####}");
                        point.Y /= baseFile.coordinateMultiplicationFactor;
                        for (int i = 0; i < 4; i++)
                        {
                            int tempVal = bytes[currentIndex++];
                            for (int j = 0; j < i; j++)
                            {
                                tempVal = tempVal << 8;
                            }
                            point.X += tempVal;
                        }
                        point.X /= baseFile.coordinateMultiplicationFactor;
                        line.points.Add(point);
                    }
                    line.points.Add(VectorRecordPointers[1].Vector.geometry as Point);
                }
            }
            else
            {
                var sg3d = vr.Fields.GetFieldByTag("SG3D");
                if (sg3d != null)
                {
                    //does this make sense here? Are there 3D points where only 2D is of interest? Alternative proposal:
                    //put entire method "ExtractSoundings()" here, store List under new Vector member variable "private List<SoundingData> soundingMultipoint"
                    //would make MultiPoint directly accessible under the respective Soundingfeature without need to call additional method.
                    var ycoo = sg3d.GetDouble("YCOO");
                    var xcoo = sg3d.GetDouble("XCOO");
                    geometry = new Point(xcoo, ycoo);
                    //Debug.WriteLine($"{ycoo:0.0#####}");
                }
                else
                {
                    var arcc = vr.Fields.GetFieldByTag("ARCC");
                    // Not managed
                }
            }
        }