Module: UkCountyLocator

Defined in:
lib/uk_county_locator.rb,
lib/uk_county_locator/locator.rb,
lib/uk_county_locator/version.rb,
lib/uk_county_locator/polygon_fetcher.rb,
lib/uk_county_locator/argument_validator.rb,
lib/uk_county_locator/aliases/historic_county_aliases.rb,
lib/uk_county_locator/aliases/ceremonial_county_aliases.rb,
lib/uk_county_locator/polygons/historic_county_polygons.rb,
lib/uk_county_locator/polygons/ceremonial_county_polygons.rb,
lib/uk_county_locator/aliases/current_county_and_unitary_authority_aliases.rb,
lib/uk_county_locator/polygons/current_county_and_unitary_authority_polygons.rb

Overview

UkCountyLocator module provides functionality for locating counties in the UK based on latitude and longitude coordinates. It supports different types of county information, including historical, ceremonial, and current county/ Unitary Authority data. The main method, ‘find_county`, returns the relevant county data for the provided coordinates and type. The method `find_polygon` will return the polygon for the requested county and type.

Defined Under Namespace

Modules: Aliases, Polygons Classes: ArgumentValidator, Error, InvalidArgumentError, Locator, PolygonFetcher

Constant Summary collapse

VERSION =
'0.1.4'

Class Method Summary collapse

Class Method Details

.county_list(type: :ceremonial) ⇒ Object



30
31
32
33
34
# File 'lib/uk_county_locator.rb', line 30

def self.county_list(type: :ceremonial)
  validated_params = ArgumentValidator.new(request: :list, type: type)

  PolygonFetcher.new(type: validated_params.type).county_list
end

.find_county(lat:, lng:, type: :ceremonial) ⇒ Object



18
19
20
21
22
# File 'lib/uk_county_locator.rb', line 18

def self.find_county(lat:, lng:, type: :ceremonial)
  validated_params = ArgumentValidator.new(request: :county, type: type, lat: lat, lng: lng)

  Locator.new(validated_params.lat, validated_params.lng, type: validated_params.type).county_data
end

.find_polygon(county:, type: :ceremonial) ⇒ Object



24
25
26
27
28
# File 'lib/uk_county_locator.rb', line 24

def self.find_polygon(county:, type: :ceremonial)
  validated_params = ArgumentValidator.new(request: :polygon, type: type, county: county)

  PolygonFetcher.new(type: validated_params.type).county_polygon(county)
end