Esempio n. 1
0
        private void UpdateVectorPtrs(Feature feature)
        {
            if (feature.VectorPtrs != null)
            {
                foreach (var vectorPtr in feature.VectorPtrs)
                {
                    if (vectorPtr.Vector == null)
                    {
                        VectorName vectorName = vectorPtr.Name;
                        string     key        = string.Format("{0}-{1}", mapIndex, vectorName.ToString());

                        if (Vectors.ContainsKey(key))
                        {
                            var vector = Vectors[key];
                            vectorPtr.Vector = vector;
                        }
                        else
                        {
                            notFoundGeometries.Add(feature.lnam.ToString());
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 private string VectorKey(VectorName vectorName)
 {
     return(string.Format("{0}-{1}", mapIndex, vectorName.ToString()));
 }
Esempio n. 3
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
                }
            }
        }
Esempio n. 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)
                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
                }
            }
        }