示例#1
0
 /// <summary>
 ///     Test if organism as substrate is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with substrate information.</param>
 /// <returns>True if organism as substrate is specified.</returns>
 public static bool IsOrganismAsSubstrateSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.HasHost && (speciesFact.Host.Id != (int)TaxonId.Life) &&
            speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            (speciesFact.MainField.EnumValue.KeyInt >= (int)OrganismAsSubstrateImportanceEnum.HasImportance) &&
            (speciesFact.MainField.EnumValue.KeyInt <= (int)OrganismAsSubstrateImportanceEnum.VeryImportant));
 }
示例#2
0
 /// <summary>
 ///     Test if redlist criteria is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with redlist criteria information.</param>
 /// <param name="period">Redlisting period.</param>
 /// <returns>True if redlist criteria is specified.</returns>
 public static bool IsSmallPopulationOrDistributionSpecified(this ISpeciesFact speciesFact, IPeriod period)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            (speciesFact.MainField.StringValue.Contains("B") ||
             speciesFact.MainField.StringValue.Contains("C") ||
             speciesFact.MainField.StringValue.Contains("D")) && speciesFact.HasPeriod &&
            speciesFact.Period.Year == period.Year);
 }
示例#3
0
 /// <summary>
 ///     Test if continuous decline is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with continuous decline information.</param>
 /// <param name="period">Redlisting period.</param>
 /// <returns>True if continuous decline is specified.</returns>
 public static bool IsContinuousDeclineSpecified(this ISpeciesFact speciesFact, IPeriod period)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            speciesFact.MainField.EnumValue.IsNotNull() &&
            (speciesFact.MainField.EnumValue.KeyInt >= (int)ContinuousDeclineEnum.GoesOn) &&
            (speciesFact.MainField.EnumValue.KeyInt <= (int)ContinuousDeclineEnum.DeclinesMoreThan25) &&
            speciesFact.HasPeriod && speciesFact.Period.Year == period.Year);
 }
示例#4
0
 public static bool IsGlobalRedlistCategorySpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#5
0
 /// <summary>
 ///     Test if county occurrence is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with county occurrence information.</param>
 /// <returns>True if county occurrence is specified.</returns>
 public static bool IsCountyOccurrenceSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.Field1.IsNotNull() && speciesFact.Field1.HasValue);
 }
示例#6
0
 /// <summary>
 ///     Test if extreme fluctuations is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with extreme fluctuations information.</param>
 /// <param name="period">Redlisting period.</param>
 /// <returns>True if extreme fluctuations is specified.</returns>
 public static bool IsExtremeFluctuationsSpecified(this ISpeciesFact speciesFact, IPeriod period)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            speciesFact.MainField.EnumValue.KeyInt >= (int)ExtremeFluctuationsEnum.CanOccur &&
            speciesFact.HasPeriod && speciesFact.Period.Year == period.Year);
 }
示例#7
0
 /// <summary>
 ///     Test if swedish occurence is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with swedish occurence information.</param>
 /// <returns>True if swedish occurrence is specified.</returns>
 public static bool IsSwedishOccurrenceSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#8
0
 /// <summary>
 ///     Test if swedish occurence is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with swedish occurence information.</param>
 /// <returns>True if swedish occurence is specified.</returns>
 public static bool IsOldRedlistCategorySpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.Field1.IsNotNull() && speciesFact.Field1.HasValue &&
            RedListedHelper.IsRedListedDdToNe(speciesFact.Field1.EnumValue.KeyInt) &&
            speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#9
0
 /// <summary>
 ///     Test if species information document threats is specified.
 /// </summary>
 /// <param name="speciesFact">Species fact with species information document threats information.</param>
 /// <returns>True if species information document threats is specified.</returns>
 public static bool IsSpeciesInformationDocumentThreatsSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#10
0
 /// <summary>
 ///     Test if substrate is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with substrate information.</param>
 /// <returns>True if substrate is specified.</returns>
 public static bool IsSubstrateSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            (speciesFact.MainField.EnumValue.KeyInt >= (int)SubstrateImportanceEnum.HasImportance) &&
            (speciesFact.MainField.EnumValue.KeyInt <= (int)SubstrateImportanceEnum.VeryImportant));
 }
示例#11
0
 /// <summary>
 ///     Test if impact is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with impact information.</param>
 /// <returns>True if impact is specified.</returns>
 public static bool IsImpactSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#12
0
 /// <summary>
 ///     Test if landscape type occurrence is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with landscape type occurrence information.</param>
 /// <returns>True if landscape type occurrence is specified.</returns>
 public static bool IsLandscapeTypeOccurrenceSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            (speciesFact.MainField.EnumValue.KeyInt >= (int)LandscapeTypeImportanceEnum.HasImportance) &&
            (speciesFact.MainField.EnumValue.KeyInt <= (int)LandscapeTypeImportanceEnum.VeryImportant));
 }
示例#13
0
 /// <summary>
 ///     Test if severely fragmented is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with severely fragmented information.</param>
 /// <param name="period">Redlisting period.</param>
 /// <returns>True if severely fragmented is specified.</returns>
 public static bool IsSeverelyFragmentedSpecified(this ISpeciesFact speciesFact, IPeriod period)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            speciesFact.MainField.EnumValue.KeyInt >= (int)SeverelyFragementedEnum.CanBeFragmented &&
            speciesFact.HasPeriod && speciesFact.Period.Year == period.Year);
 }
示例#14
0
 /// <summary>
 ///     Test if reduction A4 is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with reduction A4 information.</param>
 /// <param name="period">Redlisting period.</param>
 /// <returns>True if reduction A4 is specified.</returns>
 public static bool IsReductionA4Specified(this ISpeciesFact speciesFact, IPeriod period)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue &&
            speciesFact.MainField.DoubleValue > 0 && speciesFact.HasPeriod &&
            speciesFact.Period.Year == period.Year);
 }
示例#15
0
 /// <summary>
 ///     Test if redlist taxon type is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with redlist taxon type information.</param>
 /// <returns>True if redlist taxon type is specified.</returns>
 public static bool IsRedListTaxonTypeSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#16
0
 /// <summary>
 ///     Test if redlist documentation is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with redlist documentation information.</param>
 /// <returns>True if redlist documentation is specified.</returns>
 public static bool IsRedlistDocumentationSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#17
0
 /// <summary>
 ///     Test if protected by law is specified in species fact.
 /// </summary>
 /// <param name="speciesFact">Species fact with protected by law information.</param>
 /// <returns>True if protected by law is specified.</returns>
 public static bool IsProtectedByLawSpecified(this ISpeciesFact speciesFact)
 {
     return(speciesFact.IsNotNull() && speciesFact.MainField.IsNotNull() && speciesFact.MainField.HasValue);
 }
示例#18
0
        private Bitmap getBitmap()
        {
            Bitmap bitmap;
            float  xScale = 1.0F * _bitmapWidth / _width;
            float  yScale = 1.0F * _bitmapHeight / _height;

            if (xScale < yScale)
            {
                _scale = xScale;
            }
            else
            {
                _scale = yScale;
            }

            //_shapeTransform = new TransformGroup();
            bitmap = new Bitmap(_bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight + 2, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (Graphics canvas = Graphics.FromImage(bitmap))
            {
                using (Pen pen = new Pen(Color.Black, 1))
                {
                    using (Brush backgroundBrush = new SolidBrush(_colorBackground))
                    {
                        String countyCode         = "";
                        int    countyOccurenceKey = 0;

                        canvas.FillRectangle(backgroundBrush, 0, 0, _bitmapWidth + _legendBoxWidth - _legendBoxOffsetX, _bitmapHeight + 2);

                        for (int recordIndex = 0; recordIndex < _shapeFile.Records.Count; recordIndex++)
                        {
                            try
                            {
                                ShapeFileRecord record = _shapeFile.Records[recordIndex];

                                if (_countyInformation.IsNotEmpty())
                                {
                                    countyCode = record.Attributes[2].ToString();
                                    int countyId = getCountyId(countyCode);
                                    if (countyId > 0)
                                    {
                                        ISpeciesFact    fact  = null;
                                        SpeciesFactList facts = null;
                                        if (_counties.Exists(countyId))
                                        {
                                            try
                                            {
                                                facts = _countyInformation.GetSpeciesFacts(_counties.Get(countyId));
                                                if (facts.IsNotEmpty())
                                                {
                                                    fact = facts[0];
                                                }
                                            }
                                            catch (Exception)
                                            {
                                                throw;
                                            }

                                            if (fact.IsNotNull())
                                            {
                                                countyOccurenceKey = fact.MainField.EnumValue.KeyInt.GetValueOrDefault(0);
                                            }
                                            else
                                            {
                                                countyOccurenceKey = 0;
                                            }
                                        }
                                        else
                                        {
                                            countyOccurenceKey = 0;
                                        }
                                    }
                                }
                                else
                                {
                                    countyOccurenceKey = -1;
                                }

                                for (int i = 0; i < record.NumberOfParts; i++)
                                {
                                    List <Point> points = new List <Point>();

                                    // Determine the starting index and the end index
                                    // into the points array that defines the figure.
                                    int start = record.Parts[i];
                                    int end;
                                    if (record.NumberOfParts > 1 && i != (record.NumberOfParts - 1))
                                    {
                                        end = record.Parts[i + 1];
                                    }
                                    else
                                    {
                                        end = record.NumberOfPoints;
                                    }


                                    for (int j = start; j < end; j++)
                                    {
                                        System.Windows.Point pt = record.Points[j];

                                        // Transform from lon/lat to canvas coordinates.
                                        //pt = this._shapeTransform.Transform(pt);

                                        Point point = new Point(_legendBoxWidth - _legendBoxOffsetX + (int)((pt.X - _xMin) * _scale), _bitmapHeight - (int)((pt.Y - _yMin) * _scale));
                                        points.Add(point);
                                    }

                                    using (Brush countyOccurrenceBrush = getBrush(countyOccurenceKey))
                                    {
                                        canvas.FillPolygon(countyOccurrenceBrush, points.ToArray());
                                    }

                                    canvas.DrawPolygon(pen, points.ToArray());
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }

                        if (_countyInformation.IsEmpty())
                        {
                            using (Font font = new Font("Arial", 24 * _bitmapHeight / 708))
                            {
                                using (Brush brush = new SolidBrush(Color.Red))
                                {
                                    canvas.DrawString("Information saknas", font, brush, _legendBoxWidth, _bitmapHeight / 2);
                                }
                            }
                        }

                        if (UpdateInformation.IsNotEmpty())
                        {
                            canvas.DrawImage(GetUpdateInformationBox(),
                                             0,
                                             0);
                            canvas.DrawImage(getLegendBox(), 0, _updateInformationBoxHeight);
                        }
                        else
                        {
                            canvas.DrawImage(getLegendBox(), 0, 0);
                        }
                    }
                }
            }

            return(bitmap);
        }
示例#19
0
        /// <summary>
        /// Get string with taxonomic information.
        /// </summary>
        /// <returns>String with taxonomic information.</returns>
        private String GetAutomaticTaxonomicString()
        {
            StringBuilder text;

            if (_taxonomicParagraphSpeciesFact.IsNotNull() &&
                (_taxonomicParagraphSpeciesFact.Quality.Id == (Int32)SpeciesFactQualityId.VeryGood) &&
                _taxonomicParagraphSpeciesFact.Field5.HasValue)
            {
                return(_taxonomicParagraphSpeciesFact.Field5.StringValue);
            }

            text = new StringBuilder();
            if (_taxon.IsNotNull())
            {
                _italicStringsInAutomaticTaxonomicParagraph.Clear();


                Int32 startFromIndex = ParentTaxa.Count - 3;
                if (startFromIndex < 0)
                {
                    startFromIndex = 0;
                }
                for (Int32 index = startFromIndex; index < ParentTaxa.Count; index++)
                {
                    if (text.ToString() != String.Empty)
                    {
                        text.Append(", ");
                    }
                    text.Append(ParentTaxa[index].Category.Name + " ");
                    text.Append(ParentTaxa[index].ScientificName);

                    //Eventuellt ska denna kodrad tas bort (förslag från Tomas Hallingbäck): Överordnade taxa bör ej vara kursiverade
                    //Enligt artexperternas diskussion 2010-03-04 ska överordnade vetenskapliga taxonnamn ej kursiveras!
                    //_italicStringsInAutomaticTaxonomicParagraph.Add(suitableParents[index].ScientificName);

                    if (ParentTaxa[index].CommonName.IsNotEmpty())
                    {
                        text.Append(" (" + ParentTaxa[index].CommonName + ")");
                    }
                }

                if (text.ToString() != String.Empty)
                {
                    text.Append(", ");
                }

                text.Append(_taxon.GetScientificNameAndAuthor());
                _italicStringsInAutomaticTaxonomicParagraph.Add(_taxon.ScientificName);



                if (Synonyms.Count > 0)
                {
                    text.Append(". Syn. ");
                    for (Int32 itemIndex = 0; itemIndex < Synonyms.Count; itemIndex++)
                    {
                        if (itemIndex > 0)
                        {
                            if (itemIndex == Synonyms.Count - 1)
                            {
                                text.Append(" och ");
                            }
                            else
                            {
                                text.Append(", ");
                            }
                        }

                        text.Append(Synonyms[itemIndex].Name);
                        if (Synonyms[itemIndex].Author.IsNotEmpty())
                        {
                            text.Append(" " + Synonyms[itemIndex].Author);
                        }
                    }
                }
                if (text.ToString() != String.Empty)
                {
                    text.Append(". ");
                }
            }
            String cleanText = text.ToString().Replace("..", ".");

            return(cleanText);
        }