Skip to content

Commit

Permalink
Fixes #1242 Create Categories for symbology is inconsistent with larg…
Browse files Browse the repository at this point in the history
…e datasets
  • Loading branch information
danames authored and jany-tenaj committed Dec 18, 2018
1 parent 15ab645 commit 768af73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Expand Up @@ -148,4 +148,5 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati
- Error on OpenFile with special SPHEROID string (#1142)
- Shape File Saves with Wrong DataTypes (#1005)
- Calculation of translation param in InRamImageData.GetBitmap is defective (#1203)
- MapImageLayer not drawn correctly on print (#1137)
- MapImageLayer not drawn correctly on print (#1137)
- Create Categories for symbology is inconsistent with large datasets (#1242)
2 changes: 1 addition & 1 deletion Contributors
Expand Up @@ -16,7 +16,7 @@ Jany
Maxim Miroshnikov <mogikanin.tir@gmail.com>

Contributors:
Dan Ames
Dan Ames <dan.ames@byu.edu>
Darrel Brown
Yang Cao
Hugo Dejaune <hugo.dejaune@gmail.com>
Expand Down
12 changes: 9 additions & 3 deletions Source/DotSpatial.Symbology/FeatureScheme.cs
Expand Up @@ -301,7 +301,8 @@ public void GetValues(IAttributeSource source, ICancelProgressHandler progressHa
pageSize = 10000;
int count = EditorSettings.MaxSampleCount;

Random rnd = new Random();
// Specified seed is required for consistently recreating the break values
Random rnd = new Random(9999);
AttributePager ap = new AttributePager(source, pageSize);
int countPerPage = count / ap.NumPages();
ProgressMeter pm = new ProgressMeter(progressHandler, "Sampling " + count + " random values", count);
Expand Down Expand Up @@ -385,7 +386,10 @@ public void GetValues(DataTable table)
Dictionary<int, double> randomValues = new Dictionary<int, double>();
int count = EditorSettings.MaxSampleCount;
int max = rows.Length;
Random rnd = new Random();

// Specified seed is required for consistently recreating the break values
Random rnd = new Random(9999);

for (int i = 0; i < count; i++)
{
double val;
Expand Down Expand Up @@ -448,7 +452,9 @@ public void GetValues(DataTable table)
Dictionary<int, double> randomValues = new Dictionary<int, double>();
int count = EditorSettings.MaxSampleCount;
int max = table.Rows.Count;
Random rnd = new Random();

// Specified seed is required for consistently recreating the break values
Random rnd = new Random(9999);
for (int i = 0; i < count; i++)
{
double val;
Expand Down
2 changes: 1 addition & 1 deletion Source/DotSpatial.Symbology/NaturalBreaks.cs
Expand Up @@ -91,7 +91,7 @@ private void GetMatrices()
_lowerClassLimits[1, i] = 1;
_varianceCombinations[1, i] = 0;

// in the original implementation, 9999999 is used but since Javascript has `Infinity`, we use that.
// in the original implementation, 9999999 is used but since C# has `PositiveInfinity`, we use that.
for (j = 2; j < _values.Length + 1; j++)
{
_varianceCombinations[j, i] = double.PositiveInfinity;
Expand Down

0 comments on commit 768af73

Please sign in to comment.