This project is read-only.
Geotron can help you to resolve addresses into co-ordinates. To use it, download the source-code and add a reference to Geotron and ICSharpCode.SharpZLib. From then on, you will be able to access Geotron's functions.

In order to resolve an address, Geotron must be initialized. To do this, call Geotron.GeoResolve.Initialize (assuming that you have not imported the Geotron namespace) - this will read its' configuration file. Next call Geotron.GeoResolve.Resolve, passing in a comma-seperated address as its' singular argument. The object returned is a LocationResult. If the resolution has been unsuccessful, its' Result variable with be equal to Result.CannotResolve, and its' Certainty attribute will be 0. Otherwise, Geotron will give the co-ordinates in the Coordinates variable, and its' certainty will be set to 100 (postcode resolution is very accurate.)

Example program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example
{
    class Program
    {
        static void Main(string{} args)
        {
            Console.WriteLine("Please enter a postcode:");
            string input = Console.ReadLine();

            // Initializing the library
            Console.WriteLine("Initializing library...");
            Geotron.GeoResolve.Initialize(Geotron.ResolutionInstruction.OnlyPostcode); // Geotron only supports postcodes at present

            // Resolve the postcode
            Console.WriteLine("Attempting to resolve...");
            var result = Geotron.GeoResolve.Resolve(input);

            if (result.Result == Geotron.Result.CannotResolve) Console.WriteLine("Sorry! Couldn't resolve your postcode");
            else
            {
                // If you don't pass this in, Geotron will output in unfriendly radians
                result.Coordinates.Mode = Geotron.AngleType.Degrees;
                Console.WriteLine("Latitude: " + result.Coordinates.Latitude);
                Console.WriteLine("Longitude: " + result.Coordinates.Longitude);
            }
            input = Console.ReadLine();

        }
    }
}

Last edited Apr 12, 2010 at 12:02 AM by acornalert, version 2

Comments

No comments yet.