Index: src/Common/SharpMap/Layers/LayerAttribute.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/SharpMap/Layers/LayerAttribute.cs (.../LayerAttribute.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/SharpMap/Layers/LayerAttribute.cs (.../LayerAttribute.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -2,8 +2,8 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using DelftTools.Utils.Reflection; using DelftTools.Utils; +using DelftTools.Utils.Reflection; using GeoAPI.Extensions.Feature; using NetTopologySuite.Extensions.Features; using SharpMap.Api.Layers; @@ -17,14 +17,19 @@ private IComparable maxValue; private IComparable minValue; - public override string ToString() + public LayerAttribute(ILayer layer, string attributeName) { - return AttributeName; + this.layer = layer; + this.attributeName = attributeName; + //TODO : check the attribute name is ok...?> } public string AttributeName { - get { return attributeName; } + get + { + return attributeName; + } } public string DisplayName @@ -40,27 +45,18 @@ return FeatureAttributeAccessorHelper.GetPropertyDisplayName(layer.DataSource.FeatureType, attributeName); } } - - public LayerAttribute(ILayer layer, string attributeName) - { - this.layer = layer; - this.attributeName = attributeName; - //TODO : check the attribute name is ok...?> - } /// /// TODO: these are not attribute values but attribute values without NoDataValues /// public IEnumerable AttributeValues { - get { return GetAttributeValues(); } + get + { + return GetAttributeValues(); + } } - private IEnumerable GetAttributeValues() - { - return GetAttributeValuesFromFeatures(); - } - public IComparable MinValue { get @@ -99,15 +95,15 @@ IEnumerable values = null; - if(layer is VectorLayer) + if (layer is VectorLayer) { values = GetAttributeValuesFromFeatures(); } else { return new List(); } - + foreach (IComparable attributeValue in values) { uniqueValues.Add(attributeValue); @@ -141,10 +137,22 @@ } } + public override string ToString() + { + return AttributeName; + } + + private IEnumerable GetAttributeValues() + { + return GetAttributeValuesFromFeatures(); + } + private IEnumerable GetAttributeValuesFromFeatures() { if (layer == null || layer.DataSource == null) + { yield break; + } foreach (var feature in layer.DataSource.Features.Cast()) { @@ -179,7 +187,7 @@ var first = true; var minComparable = default(IComparable); var maxComparable = default(IComparable); - + foreach (var value in AttributeValues) { if (first) @@ -189,9 +197,13 @@ first = false; } if (value.IsSmaller(minComparable)) + { minComparable = value; + } if (value.IsBigger(maxComparable)) + { maxComparable = value; + } } if (first) //nothing found