Ejemplo n.º 1
0
        public List <Feature> GetFeaturesOfClasses(string[] acronyms)
        {
            List <uint> codes = new List <uint>();

            foreach (var acronym in acronyms)
            {
                uint code = S57Objects.Get(acronym).Code;
                codes.Add(code);
            }
            return(GetFeaturesOfClasses(codes.ToArray()));
        }
Ejemplo n.º 2
0
        public int Filter(string filter)
        {
            if (string.IsNullOrEmpty(filter))
            {
                return(0);
            }
            string[] codes = filter.Split(new char[] { ' ' });
            for (int i = 0; i < codes.Length; i++)
            {
                codes[i] = codes[i].Trim();
                var isNumeric = int.TryParse(codes[i], out int n);
                if (!isNumeric)
                {
                    codes[i] = S57Objects.Get(codes[i]).Code.ToString();
                }
            }
            List <string> lCodes           = codes.ToList();
            var           features         = Features.Values.ToList();
            var           filteredFeatures = features.Where(f => lCodes.Contains(f.Code.ToString()));

            Features = filteredFeatures.ToDictionary(f => f.lnam.ToString(), f => f);
            return(features.Count);
        }
Ejemplo n.º 3
0
        public int Filter(string filter)
        {
            if (string.IsNullOrEmpty(filter))
            {
                return(0);
            }
            string[] codes = filter.Split(new char[] { ' ' });
            for (int i = 0; i < codes.Length; i++)
            {
                codes[i] = codes[i].Trim();
                var isNumeric = int.TryParse(codes[i], out int n);
                if (!isNumeric)
                {
                    codes[i] = S57Objects.Get(codes[i]).Code.ToString(); //performance-killer: convert uint to string, to later compare strings. Better: compare uints
                }
            }
            List <string> lCodes = new List <string>();

            lCodes.AddRange(codes);
            List <Feature> features = new List <Feature>();

            features.AddRange(Features.Values);
            Features = new Dictionary <LongName, Feature>();
            foreach (var feature in features)
            {
                foreach (var code in lCodes)
                {
                    if (code == feature.Code.ToString())
                    {
                    }
                    Features.Add(feature.lnam, feature);
                }
            }

            return(features.Count);
        }
Ejemplo n.º 4
0
 public List <Feature> GetFeaturesOfClass(string acronym)
 {
     return(GetFeaturesOfClass(S57Objects.Get(acronym).Code));
 }
Ejemplo n.º 5
0
        public PurgeResults PurgeBasedOnS57KnownObjects()
        {
            PurgeResults result = new PurgeResults();

            result.NbFeaturesBefore = Features.Count;
            result.NbVectorsBefore  = Vectors.Count;
            List <VectorName> usedVectors = new List <VectorName>();
            List <LongName>   unusedLnams = new List <LongName>();

            foreach (Feature feature in newFeatures.Values)
            {
                var featureInfo = S57Objects.Get(feature.Code);
                if (featureInfo != null && feature.Code < 300)
                {
                    if (feature.VectorPtrs != null && feature.VectorPtrs.Count > 0)
                    {
                        foreach (var vectorPtr in feature.VectorPtrs)
                        {
                            var vector = vectorPtr.Vector;
                            if (vector == null)
                            {
                                UpdateVectorPtrs(feature);
                            }
                            if (!usedVectors.Contains(vectorPtr.Vector.vectorName))
                            {
                                usedVectors.Add(vectorPtr.Vector.vectorName);
                            }
                        }
                    }
                }
                else
                {
                    unusedLnams.Add(feature.lnam);
                }
            }
            result.NbRemovedFeatures = unusedLnams.Count;
            result.NbRemovedVectors  = 0;
            foreach (var lnam in unusedLnams)
            {
                Features.Remove(lnam);
            }
            int           index   = Vectors.Count - 1;
            List <Vector> vectors = new List <Vector>();

            vectors.AddRange(Vectors.Values);
            while (index >= 0)
            {
                if (!usedVectors.Contains(vectors[index].vectorName))
                {
                    if (Vectors.Remove(vectors[index].vectorName))
                    {
                        result.NbRemovedVectors++;
                    }
                }
                index--;
            }
            baseFile.FeatureRecords.Clear();
            baseFile.VectorRecords.Clear();
            GC.Collect();
            result.NbFeatures = Features.Count;
            result.NbVectors  = Vectors.Count;
            return(result);
        }