RedCorners.Components.CoordsWords 5.10.0

Convert map coordinates to a sequence of words and back.

Install-Package RedCorners.Components.CoordsWords -Version 5.10.0
dotnet add package RedCorners.Components.CoordsWords --version 5.10.0
<PackageReference Include="RedCorners.Components.CoordsWords" Version="5.10.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RedCorners.Components.CoordsWords --version 5.10.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Convert map coordinates to a sequence of words and back.

NuGet: https://www.nuget.org/packages/RedCorners.Components.CoordsWords

GitHub: https://github.com/samafshari/RedCorners.Components.CoordsWords

Getting Started

Install the NuGet and use the RedCorners.Components namespace:

using RedCorners.Components;
var coordsWords = new CoordsWords();

You can convert a pair of latitude and longitudes to a sequence of words like this:

coordsWords.Latitude = latitude;
coordsWords.Longitude = longitude;
string[] sequence = coordsWords.Words;

You can convert back the sequence of words to the coordinates like this:

coordsWords.Words = sequence;
var latitude = coordsWords.Latitude;
var longitude = coordsWords.Longitude;

By default, the library comes with a list of English words. You can use an arbitrary array of strings instead of the default index. There are no limitations to what you can use, other than having more than one entries, and no repetitions:

var lines = File.ReadAllLines("words.txt");
var coordsWords = new CoordsWords(lines);

The more words in your index file, the less words the output sequence will have. The default index results in sequences with four words.

It is strongly recommended to use a custom index file, as the default index may change between releases, resulting in changes in the outputted sequence for a given input.

Example

Input:  1, 1
Words:  canadian provides certification one
Back:   1.0000, 1.0000
---
Input:  0, 0
Words:  designing reached proposed one
Back:   0.0000, 0.0000
---
Input:  -90, -180
Words:  prefers envelope warranty more
Back:   -90.0000, -180.0000
---
Input:  90, 180
Words:  accessibility rays marketing use
Back:   90.0000, 180.0000
---
Input:  -90, 180
Words:  guarantee boulder warranty more
Back:   -90.0000, 180.0000
---
Input:  90, -180
Words:  archives giants marketing use
Back:   90.0000, -180.0000
---
Input:  59.3232, 18.0757
Words:  deaths firmware two which
Back:   59.3232, 18.0757
---
Input:  59.32323232, 18.0757757757
Words:  deaths firmware two which
Back:   59.3232, 18.0757
using RedCorners.Components;

static void Main(string[] args)
{
    var testPoints = new[]
    {
        (1.0, 1.0),
        (0.0, 0.0),
        (-90.0, -180.0),
        (90.0, 180.0),
        (-90.0, 180.0),
        (90.0, -180.0),
        (59.3232,18.0757),
        (59.32323232,18.0757757757)
    };

	foreach (var p in testPoints)
	{
		Console.WriteLine($"Input:\t{p.Item1}, {p.Item2}");
		var coordsWords = new CoordsWords();
		coordsWords.Latitude = p.Item1;
		coordsWords.Longitude = p.Item2;
		var words = coordsWords.Words;
		Console.WriteLine($"Words:\t{coordsWords}");

		
		var reverse = new CoordsWords();
		reverse.Words = words;
		Console.WriteLine($"Back:\t{reverse.Latitude:N4}, {reverse.Longitude:N4}");
		Console.WriteLine("---");
	}
}

Convert map coordinates to a sequence of words and back.

NuGet: https://www.nuget.org/packages/RedCorners.Components.CoordsWords

GitHub: https://github.com/samafshari/RedCorners.Components.CoordsWords

Getting Started

Install the NuGet and use the RedCorners.Components namespace:

using RedCorners.Components;
var coordsWords = new CoordsWords();

You can convert a pair of latitude and longitudes to a sequence of words like this:

coordsWords.Latitude = latitude;
coordsWords.Longitude = longitude;
string[] sequence = coordsWords.Words;

You can convert back the sequence of words to the coordinates like this:

coordsWords.Words = sequence;
var latitude = coordsWords.Latitude;
var longitude = coordsWords.Longitude;

By default, the library comes with a list of English words. You can use an arbitrary array of strings instead of the default index. There are no limitations to what you can use, other than having more than one entries, and no repetitions:

var lines = File.ReadAllLines("words.txt");
var coordsWords = new CoordsWords(lines);

The more words in your index file, the less words the output sequence will have. The default index results in sequences with four words.

It is strongly recommended to use a custom index file, as the default index may change between releases, resulting in changes in the outputted sequence for a given input.

Example

Input:  1, 1
Words:  canadian provides certification one
Back:   1.0000, 1.0000
---
Input:  0, 0
Words:  designing reached proposed one
Back:   0.0000, 0.0000
---
Input:  -90, -180
Words:  prefers envelope warranty more
Back:   -90.0000, -180.0000
---
Input:  90, 180
Words:  accessibility rays marketing use
Back:   90.0000, 180.0000
---
Input:  -90, 180
Words:  guarantee boulder warranty more
Back:   -90.0000, 180.0000
---
Input:  90, -180
Words:  archives giants marketing use
Back:   90.0000, -180.0000
---
Input:  59.3232, 18.0757
Words:  deaths firmware two which
Back:   59.3232, 18.0757
---
Input:  59.32323232, 18.0757757757
Words:  deaths firmware two which
Back:   59.3232, 18.0757
using RedCorners.Components;

static void Main(string[] args)
{
    var testPoints = new[]
    {
        (1.0, 1.0),
        (0.0, 0.0),
        (-90.0, -180.0),
        (90.0, 180.0),
        (-90.0, 180.0),
        (90.0, -180.0),
        (59.3232,18.0757),
        (59.32323232,18.0757757757)
    };

	foreach (var p in testPoints)
	{
		Console.WriteLine($"Input:\t{p.Item1}, {p.Item2}");
		var coordsWords = new CoordsWords();
		coordsWords.Latitude = p.Item1;
		coordsWords.Longitude = p.Item2;
		var words = coordsWords.Words;
		Console.WriteLine($"Words:\t{coordsWords}");

		
		var reverse = new CoordsWords();
		reverse.Words = words;
		Console.WriteLine($"Back:\t{reverse.Latitude:N4}, {reverse.Longitude:N4}");
		Console.WriteLine("---");
	}
}

Release Notes

Convert map coordinates to a sequence of words and back.

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
5.10.0 115 12/31/2019
5.9.0 54 12/18/2019
5.8.0 49 11/29/2019
5.7.0 48 11/29/2019
5.6.0 50 11/21/2019
5.5.0 49 11/20/2019
5.4.0 49 11/20/2019
5.3.0 46 11/20/2019
5.2.0 49 11/16/2019
5.1.0 47 11/16/2019