miami_dade_geo 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +44 -4
- data/Rakefile +2 -0
- data/lib/miami_dade_geo.rb +1 -1
- data/lib/miami_dade_geo/addr_xy_client.rb +21 -1
- data/lib/miami_dade_geo/address.rb +54 -36
- data/lib/miami_dade_geo/coordinate.rb +101 -0
- data/lib/miami_dade_geo/errors/base.rb +1 -0
- data/lib/miami_dade_geo/errors/invalid_address_error.rb +1 -0
- data/lib/miami_dade_geo/geo_attribute_client.rb +16 -1
- data/lib/miami_dade_geo/get_closest_feature_client.rb +45 -1
- data/lib/miami_dade_geo/latlong_client.rb +10 -1
- data/lib/miami_dade_geo/municipality.rb +49 -15
- data/lib/miami_dade_geo/version.rb +2 -1
- data/miami_dade_geo.gemspec +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a277a7b75e101dc40eb9f482a18e1707ddcbe0a9
|
|
4
|
+
data.tar.gz: bcc7ed55b71bf645472550ef5da262df6290a0df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d9d4718cac3630a5ac9f54caa40e4a977fc07b64924f6a15810eef7722846f079ad06e85edca2dfa36928e1f0dbb739d10fa6753745e7a983e960f039aeace7
|
|
7
|
+
data.tar.gz: d07dfb923f7f5122dbc3260fd1c3e04969590762c08f029de60d989b7200999243f8cdc0dc165c825f165284e402d743a887802271a4c195664579cba2cce1b4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -5,13 +5,13 @@ This library wraps some of the Miami-Dade County geospatial services, including:
|
|
|
5
5
|
* Address to NAD 83 State Plane X and Y coordinate
|
|
6
6
|
* NAD 83 State Plane X and Y coordinate to latitude and longitude
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Installation #
|
|
9
9
|
|
|
10
10
|
Add this line to your application's Gemfile:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
~~~ruby
|
|
13
13
|
gem 'miami_dade_geo'
|
|
14
|
-
|
|
14
|
+
~~~
|
|
15
15
|
|
|
16
16
|
And then execute:
|
|
17
17
|
|
|
@@ -23,7 +23,47 @@ Or install it yourself as:
|
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
### Coordinate to Address
|
|
27
|
+
|
|
28
|
+
~~~ruby
|
|
29
|
+
coordinate = MiamiDadeGeo::Coordinate.new(long: -80.199245566240819,
|
|
30
|
+
lat: 25.7999410593211)
|
|
31
|
+
addr = coordinate.address
|
|
32
|
+
addr.address #=> "2390 NW 2ND AVE"
|
|
33
|
+
addr.zip #=> 33127
|
|
34
|
+
~~~
|
|
35
|
+
|
|
36
|
+
### Address to Coordinate
|
|
37
|
+
|
|
38
|
+
~~~ruby
|
|
39
|
+
addr = MiamiDadeGeo::Address.new '2390 NW 2nd Ave'
|
|
40
|
+
addr.zip #=> 33127
|
|
41
|
+
addr.lat #=> 25.7999410593211
|
|
42
|
+
addr.long #=> -80.199245566240819
|
|
43
|
+
addr.municipality.name #=> "MIAMI"
|
|
44
|
+
~~~
|
|
45
|
+
|
|
46
|
+
### Coordinate to Municipality
|
|
47
|
+
|
|
48
|
+
~~~ruby
|
|
49
|
+
muni = MiamiDadeGeo::Municipality.new_with_latlong(
|
|
50
|
+
long: -80.199245566240819,
|
|
51
|
+
lat: 25.7999410593211)
|
|
52
|
+
|
|
53
|
+
muni.name #=> "MIAMI"
|
|
54
|
+
~~~
|
|
55
|
+
|
|
56
|
+
## Links
|
|
57
|
+
|
|
58
|
+
* <https://rubygems.org/gems/miami_dade_geo>
|
|
59
|
+
|
|
60
|
+
* <https://github.com/jdiago/miami_dade_geo_api>
|
|
61
|
+
|
|
62
|
+
* <https://github.com/bkerley/what_municipality>
|
|
63
|
+
|
|
64
|
+
* <https://radiant-taiga-73968.herokuapp.com/address-meta?address=2390%20NW%202nd%20Ave>
|
|
65
|
+
|
|
66
|
+
* <https://what-mdc-muni.herokuapp.com>
|
|
27
67
|
|
|
28
68
|
## Development
|
|
29
69
|
|
data/Rakefile
CHANGED
data/lib/miami_dade_geo.rb
CHANGED
|
@@ -2,11 +2,31 @@ require 'singleton'
|
|
|
2
2
|
require 'savon'
|
|
3
3
|
|
|
4
4
|
module MiamiDadeGeo
|
|
5
|
+
# Singleton SOAP client for converting an address to NAD 83 x-y coordinates.
|
|
6
|
+
# Makes one SOAP request for WSDL on first instantiation.
|
|
7
|
+
#
|
|
8
|
+
# @api private
|
|
5
9
|
class AddrXyClient
|
|
6
10
|
include Singleton
|
|
7
11
|
|
|
12
|
+
# URL to AddrXy service WSDL
|
|
8
13
|
WSDL_URL = "http://gisws.miamidade.gov/gisaddress/addrxy.asmx?wsdl"
|
|
9
|
-
|
|
14
|
+
|
|
15
|
+
def xy_for_address(address)
|
|
16
|
+
body = savon.
|
|
17
|
+
call(:xy_address, message: { myAddress: address}).
|
|
18
|
+
body
|
|
19
|
+
|
|
20
|
+
if body[:xy_address_response][:xy_address_result][:count] == '0'
|
|
21
|
+
raise MiamiDadeGeo::InvalidAddressError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
body[:xy_address_response][:xy_address_result][:xy][:arr_xy]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Returns a Savon SOAP client instance
|
|
28
|
+
#
|
|
29
|
+
# @return [Savon::Client]
|
|
10
30
|
def savon
|
|
11
31
|
@savon ||= Savon.client(wsdl: WSDL_URL)
|
|
12
32
|
end
|
|
@@ -1,83 +1,101 @@
|
|
|
1
1
|
require 'miami_dade_geo/addr_xy_client'
|
|
2
|
-
require 'miami_dade_geo/
|
|
2
|
+
require 'miami_dade_geo/coordinate'
|
|
3
3
|
require 'miami_dade_geo/municipality'
|
|
4
4
|
require 'miami_dade_geo/errors/invalid_address_error'
|
|
5
5
|
|
|
6
6
|
module MiamiDadeGeo
|
|
7
|
+
# A street address in Miami-Dade County.
|
|
8
|
+
# Lazily makes up to two SOAP requests:
|
|
9
|
+
# one to get the X and Y coordinates, and one to convert them to standard
|
|
10
|
+
# latitude and longitude.
|
|
11
|
+
#
|
|
12
|
+
# Can raise an [InvalidAddressError] when lazily making the initial SOAP
|
|
13
|
+
# request if the given address does not exist.
|
|
14
|
+
#
|
|
15
|
+
# @raise [InvalidAddressError]
|
|
7
16
|
class Address
|
|
17
|
+
attr_reader :feature
|
|
18
|
+
|
|
19
|
+
# @!attribute [r] address
|
|
20
|
+
# @return [String] the street address
|
|
8
21
|
attr_reader :address
|
|
9
22
|
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
# @!attribute [rw] zip
|
|
24
|
+
# @return [String] the ZIP code
|
|
25
|
+
attr_accessor :zip
|
|
26
|
+
|
|
27
|
+
# Construct the address object
|
|
28
|
+
# @param address [String] the street address
|
|
29
|
+
def self.new_from_address(address)
|
|
30
|
+
xy = AddrXyClient.instance.xy_for_address(address)
|
|
31
|
+
|
|
32
|
+
Coordinate.new(xy).address
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.new_from_feature(feature)
|
|
36
|
+
new feature
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @return [Coordinate] a coordinate object representing where this address
|
|
40
|
+
# even is
|
|
41
|
+
def coordinate
|
|
42
|
+
@coordinate ||= Coordinate.new xy_addr
|
|
12
43
|
end
|
|
13
44
|
|
|
45
|
+
# @return [Float] the x-coordinate of the address
|
|
14
46
|
def x
|
|
15
|
-
|
|
47
|
+
coordinate.x
|
|
16
48
|
end
|
|
17
49
|
|
|
50
|
+
# @return [Float] the y-coordinate of the address
|
|
18
51
|
def y
|
|
19
|
-
|
|
52
|
+
coordinate.y
|
|
20
53
|
end
|
|
21
54
|
|
|
55
|
+
# @return [Integer] the ZIP code of the address
|
|
22
56
|
def zip
|
|
23
57
|
@zip ||= xy_addr[:zip_code].to_i
|
|
24
58
|
end
|
|
25
59
|
|
|
60
|
+
# @return [Integer] the municipality code of the address
|
|
26
61
|
def munic_code
|
|
27
62
|
@munic_code ||= xy_addr[:munic_code].to_i
|
|
28
63
|
end
|
|
29
64
|
|
|
65
|
+
# @return [Float] the latitude of the address
|
|
30
66
|
def lat
|
|
31
|
-
|
|
67
|
+
coordinate.lat
|
|
32
68
|
end
|
|
33
69
|
|
|
70
|
+
# @return [Float] the longitude of the address
|
|
34
71
|
def long
|
|
35
|
-
|
|
72
|
+
coordinate.long
|
|
36
73
|
end
|
|
37
74
|
|
|
75
|
+
# Constructs and returns a {Municipality} object. Makes one SOAP request.
|
|
76
|
+
# @return [Municipality]
|
|
38
77
|
def municipality
|
|
39
78
|
@municipality ||= Municipality.new_with_code(munic_code)
|
|
40
79
|
end
|
|
41
80
|
|
|
81
|
+
def address
|
|
82
|
+
@address ||= [feature[:hse_num], feature[:sname]].join ' '
|
|
83
|
+
end
|
|
84
|
+
|
|
42
85
|
private
|
|
43
86
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
body = latlong_client.
|
|
47
|
-
call(:get_lat_long_dec_from_xy,
|
|
48
|
-
message: { 'X' => x.to_s, 'Y' => y.to_s} ).
|
|
49
|
-
body
|
|
50
|
-
|
|
51
|
-
resp = body[:get_lat_long_dec_from_xy_response]
|
|
52
|
-
result = resp[:get_lat_long_dec_from_xy_result]
|
|
53
|
-
double = result[:double]
|
|
54
|
-
|
|
55
|
-
@latlong = {
|
|
56
|
-
long: double[0].to_f,
|
|
57
|
-
lat: double[1].to_f
|
|
58
|
-
}
|
|
87
|
+
def initialize(feature)
|
|
88
|
+
@feature = feature
|
|
59
89
|
end
|
|
60
90
|
|
|
61
91
|
def xy_addr
|
|
62
92
|
return @xy_addr if defined? @xy_addr
|
|
63
93
|
|
|
64
|
-
|
|
65
|
-
call(:xy_address, message: { myAddress: address}).
|
|
66
|
-
body
|
|
67
|
-
|
|
68
|
-
if body[:xy_address_response][:xy_address_result][:count] == '0'
|
|
69
|
-
raise MiamiDadeGeo::InvalidAddressError
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
@xy_addr = body[:xy_address_response][:xy_address_result][:xy][:arr_xy]
|
|
94
|
+
@xy_addr = addr_xy_client.xy_for_address(address)
|
|
73
95
|
end
|
|
74
96
|
|
|
75
97
|
def addr_xy_client
|
|
76
|
-
AddrXyClient.instance
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def latlong_client
|
|
80
|
-
LatlongClient.instance.savon
|
|
98
|
+
AddrXyClient.instance
|
|
81
99
|
end
|
|
82
100
|
end
|
|
83
101
|
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'miami_dade_geo/latlong_client'
|
|
2
|
+
require 'miami_dade_geo/get_closest_feature_client'
|
|
3
|
+
|
|
4
|
+
module MiamiDadeGeo
|
|
5
|
+
class Coordinate
|
|
6
|
+
def initialize(opts)
|
|
7
|
+
if opts[:x] && opts[:y]
|
|
8
|
+
initialize_from_xy opts
|
|
9
|
+
elsif
|
|
10
|
+
opts[:lat] && opts[:long]
|
|
11
|
+
initialize_from_latlong opts
|
|
12
|
+
else
|
|
13
|
+
fail ArgumentError "Can't initialize without x & y or lat & long"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize_from_xy(opts)
|
|
18
|
+
@x = opts[:x].to_f
|
|
19
|
+
@y = opts[:y].to_f
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize_from_latlong(opts)
|
|
23
|
+
@lat = opts[:lat].to_f
|
|
24
|
+
@long = opts[:long].to_f
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def x
|
|
28
|
+
return @x if @x
|
|
29
|
+
load_xy_from_latlong
|
|
30
|
+
@x
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def y
|
|
34
|
+
return @y if @y
|
|
35
|
+
load_xy_from_latlong
|
|
36
|
+
@y
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def lat
|
|
40
|
+
return @lat if @lat
|
|
41
|
+
load_latlong_from_xy
|
|
42
|
+
@lat
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def long
|
|
46
|
+
return @long if @long
|
|
47
|
+
load_latlong_from_xy
|
|
48
|
+
@long
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def xy
|
|
52
|
+
{ x: x, y: y }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def latlong
|
|
56
|
+
{ lat: lat, long: long }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def address
|
|
60
|
+
return @address if defined? @address
|
|
61
|
+
feature = get_closest_feature_client.find_feature(xy, 'GeoAddress')
|
|
62
|
+
|
|
63
|
+
@address = Address.new_from_feature feature
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
def load_xy_from_latlong
|
|
68
|
+
body = latlong_client.
|
|
69
|
+
call(:get_x_yfrom_lat_long_dec,
|
|
70
|
+
message: { 'LNG' => long.to_s, 'LAT' => lat.to_s}).
|
|
71
|
+
body
|
|
72
|
+
|
|
73
|
+
resp = body[:get_x_yfrom_lat_long_dec_response]
|
|
74
|
+
result = resp[:get_x_yfrom_lat_long_dec_result]
|
|
75
|
+
|
|
76
|
+
@x = result[:double][0].to_f
|
|
77
|
+
@y = result[:double][1].to_f
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def load_latlong_from_xy
|
|
81
|
+
body = latlong_client.
|
|
82
|
+
call(:get_lat_long_dec_from_xy,
|
|
83
|
+
message: { 'X' => x.to_s, 'Y' => y.to_s} ).
|
|
84
|
+
body
|
|
85
|
+
|
|
86
|
+
resp = body[:get_lat_long_dec_from_xy_response]
|
|
87
|
+
result = resp[:get_lat_long_dec_from_xy_result]
|
|
88
|
+
|
|
89
|
+
@lat = result[:double][1].to_f
|
|
90
|
+
@long = result[:double][0].to_f
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_closest_feature_client
|
|
94
|
+
GetClosestFeatureClient.instance
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def latlong_client
|
|
98
|
+
LatlongClient.instance.savon
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -2,11 +2,23 @@ require 'singleton'
|
|
|
2
2
|
require 'savon'
|
|
3
3
|
|
|
4
4
|
module MiamiDadeGeo
|
|
5
|
+
# Singleton SOAP client for searching geographic attributes. Used to search
|
|
6
|
+
# for municipalities by name or `munic_code`. Makes one SOAP request for WSDL
|
|
7
|
+
# on first instantiation.
|
|
8
|
+
#
|
|
9
|
+
# @api private
|
|
5
10
|
class GeoAttributeClient
|
|
6
11
|
include Singleton
|
|
7
12
|
|
|
13
|
+
# URL to GeoAttribute service WSDL
|
|
8
14
|
WSDL_URL = "http://gisws.miamidade.gov/gisdata/GeoAttribute.asmx?wsdl"
|
|
9
15
|
|
|
16
|
+
# Performs a search for geo-attributes.
|
|
17
|
+
#
|
|
18
|
+
# @param [String] table the table to search
|
|
19
|
+
# @param [String] field_name the field/column to search in the given table
|
|
20
|
+
# @param [String] value string value to search in the given field and table
|
|
21
|
+
# @return [Hash] search results
|
|
10
22
|
def all_fields(table, field_name, value)
|
|
11
23
|
body = savon.
|
|
12
24
|
call(:get_all_fields_records_given_a_field_name_and_value,
|
|
@@ -29,7 +41,10 @@ module MiamiDadeGeo
|
|
|
29
41
|
fail "Unexpected polys #{polys.class.name}, wanted Array or Hash"
|
|
30
42
|
end
|
|
31
43
|
end
|
|
32
|
-
|
|
44
|
+
|
|
45
|
+
# Returns a Savon SOAP client instance
|
|
46
|
+
#
|
|
47
|
+
# @return [Savon::Client]
|
|
33
48
|
def savon
|
|
34
49
|
@savon ||= Savon.client(wsdl: WSDL_URL)
|
|
35
50
|
end
|
|
@@ -2,11 +2,55 @@ require 'singleton'
|
|
|
2
2
|
require 'savon'
|
|
3
3
|
|
|
4
4
|
module MiamiDadeGeo
|
|
5
|
+
# Singleton SOAP client for finding features close to a given point.
|
|
6
|
+
# Makes one SOAP request for WSDL on first instantiation.
|
|
7
|
+
#
|
|
8
|
+
# @api private
|
|
5
9
|
class GetClosestFeatureClient
|
|
6
10
|
include Singleton
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
# URL to GetClosestFeature service WSDL
|
|
13
|
+
WSDL_URL =
|
|
14
|
+
"http://gisws.miamidade.gov/gisxyservices/GetClosestFeature.asmx?wsdl"
|
|
9
15
|
|
|
16
|
+
FIND_RADIUSES = [0, 10, 100, 1000, 5280, (20 * 5280)]
|
|
17
|
+
|
|
18
|
+
def find_feature(xy_hash, feature_class)
|
|
19
|
+
FIND_RADIUSES.each do |radius|
|
|
20
|
+
result = get_closest_feature(feature_class,
|
|
21
|
+
xy_hash[:x].to_s,
|
|
22
|
+
xy_hash[:y].to_s,
|
|
23
|
+
radius.to_s)
|
|
24
|
+
|
|
25
|
+
return result unless result.nil?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_closest_feature(feature_class, x, y, buffer)
|
|
32
|
+
body = savon.
|
|
33
|
+
call(:get_closest_feature_from_xy_all_atrbts,
|
|
34
|
+
message: {
|
|
35
|
+
'X' => x,
|
|
36
|
+
'Y' => y,
|
|
37
|
+
'Buffer' => buffer,
|
|
38
|
+
'NameOfFeatureClass' => feature_class
|
|
39
|
+
}).
|
|
40
|
+
body
|
|
41
|
+
|
|
42
|
+
begin
|
|
43
|
+
resp = body[:get_closest_feature_from_xy_all_atrbts_response]
|
|
44
|
+
rslt = resp[:get_closest_feature_from_xy_all_atrbts_result]
|
|
45
|
+
poly = rslt[:diffgram][:document_element][:results]
|
|
46
|
+
rescue
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns a Savon SOAP client instance
|
|
52
|
+
#
|
|
53
|
+
# @return [Savon::Client]
|
|
10
54
|
def savon
|
|
11
55
|
@savon ||= Savon.client(wsdl: WSDL_URL)
|
|
12
56
|
end
|
|
@@ -2,12 +2,21 @@ require 'singleton'
|
|
|
2
2
|
require 'savon'
|
|
3
3
|
|
|
4
4
|
module MiamiDadeGeo
|
|
5
|
+
# Singleton SOAP client for converting NAD 83 x-y coordinates to latitude and
|
|
6
|
+
# longitude, and back again. Makes one SOAP request for WSDL on first
|
|
7
|
+
# instantiation.
|
|
8
|
+
#
|
|
9
|
+
# @api private
|
|
5
10
|
class LatlongClient
|
|
6
11
|
include Singleton
|
|
7
12
|
|
|
13
|
+
# URL to XyLatLongConversions SOAP service WSDL
|
|
8
14
|
WSDL_URL =
|
|
9
15
|
"http://gisws.miamidade.gov/gisxyservices/XYLatLongConversions.asmx?wsdl"
|
|
10
|
-
|
|
16
|
+
|
|
17
|
+
# Returns a Savon SOAP client instance
|
|
18
|
+
#
|
|
19
|
+
# @return [Savon::Client]
|
|
11
20
|
def savon
|
|
12
21
|
@savon ||= Savon.client(wsdl: WSDL_URL)
|
|
13
22
|
end
|
|
@@ -3,9 +3,30 @@ require 'miami_dade_geo/get_closest_feature_client'
|
|
|
3
3
|
require 'miami_dade_geo/latlong_client'
|
|
4
4
|
|
|
5
5
|
module MiamiDadeGeo
|
|
6
|
+
# Represents one of the municipalities in Miami-Dade County, and
|
|
7
|
+
# unincorporated Miami-Dade County as well.
|
|
8
|
+
#
|
|
9
|
+
# Makes one or two SOAP requests on construction.
|
|
10
|
+
#
|
|
11
|
+
# Doesn't have a `new` method for construction, since there are a few
|
|
12
|
+
# different ways to construct it.
|
|
6
13
|
class Municipality
|
|
7
|
-
|
|
14
|
+
# @!attribute [r] name
|
|
15
|
+
# @return [String] the name of the municipality, or
|
|
16
|
+
# unincorporated MDC.
|
|
17
|
+
attr_reader :name
|
|
8
18
|
|
|
19
|
+
# @!attribute [r] munic_code
|
|
20
|
+
# @return [Integer] the numeric code of the municipality
|
|
21
|
+
attr_reader :munic_code
|
|
22
|
+
|
|
23
|
+
# Constructs a {Municipality} object for a given municipality name. The
|
|
24
|
+
# SOAP method called is case-sensitive, and we believe all municipalities
|
|
25
|
+
# to be ALL-CAPS, so this constructor capitalizes the name before searching.
|
|
26
|
+
#
|
|
27
|
+
# Useful to get the `munic_code` for a given municipality name.
|
|
28
|
+
#
|
|
29
|
+
# @param [String] name case-insensitive name of the municipality
|
|
9
30
|
def self.new_with_name(name)
|
|
10
31
|
canonicalized_name = name.upcase
|
|
11
32
|
|
|
@@ -17,6 +38,13 @@ module MiamiDadeGeo
|
|
|
17
38
|
new poly
|
|
18
39
|
end
|
|
19
40
|
|
|
41
|
+
# Constructs a {Municipality} object for a given `munic_code`. The SOAP
|
|
42
|
+
# method called zero-pads single-digit municipality codes, so this
|
|
43
|
+
# constructor converts the code to an `Integer` and formats it.
|
|
44
|
+
#
|
|
45
|
+
# Used by the {Address#municipality} method.
|
|
46
|
+
#
|
|
47
|
+
# @param [Integer] munic_code numeric code for the municipality
|
|
20
48
|
def self.new_with_code(munic_code)
|
|
21
49
|
canonicalized_munic_code = "%02d" % [munic_code.to_i]
|
|
22
50
|
|
|
@@ -28,23 +56,29 @@ module MiamiDadeGeo
|
|
|
28
56
|
new poly
|
|
29
57
|
end
|
|
30
58
|
|
|
59
|
+
# Constructs a {Municipality} object for a given x-y coordinate in
|
|
60
|
+
# the NAD 83 Florida state coordinate system. Calls one SOAP method.
|
|
61
|
+
#
|
|
62
|
+
# @param [Hash] xy_hash NAD 83 coordinates of a location inside a
|
|
63
|
+
# municipality
|
|
64
|
+
# @option xy_hash [Float] :x x-coordinate
|
|
65
|
+
# @option xy_hash [Float] :y y-coordinate
|
|
31
66
|
def self.new_with_xy(xy_hash)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'Buffer' => 0,
|
|
38
|
-
'NameOfFeatureClass' => 'municipality_poly'
|
|
39
|
-
}).
|
|
40
|
-
body
|
|
41
|
-
resp = body[:get_closest_feature_from_xy_all_atrbts_response]
|
|
42
|
-
rslt = resp[:get_closest_feature_from_xy_all_atrbts_result]
|
|
43
|
-
poly = rslt[:diffgram][:document_element][:results]
|
|
44
|
-
|
|
45
|
-
new poly
|
|
67
|
+
new GetClosestFeatureClient.instance.
|
|
68
|
+
get_closest_feature('municipality_poly',
|
|
69
|
+
xy_hash[:x],
|
|
70
|
+
xy_hash[:y],
|
|
71
|
+
0)
|
|
46
72
|
end
|
|
47
73
|
|
|
74
|
+
# Constructs a {Municipality} object for a given latitude and longitude.
|
|
75
|
+
# Makes two SOAP requests: one to convert from lat-long to x-y in NAD 83,
|
|
76
|
+
# and one to load the municipality for the NAD 83 coordinate.
|
|
77
|
+
#
|
|
78
|
+
# @param [Hash] latlong_hash latitude and longitude hash of a locatio inside
|
|
79
|
+
# a municipality
|
|
80
|
+
# @option latlong_hash [Float] :lat latitude coordinate
|
|
81
|
+
# @option latlong_hash [Float] :long longitude coordinate
|
|
48
82
|
def self.new_with_latlong(latlong_hash)
|
|
49
83
|
body = LatlongClient.instance.savon.
|
|
50
84
|
call(:get_x_yfrom_lat_long_dec,
|
data/miami_dade_geo.gemspec
CHANGED
|
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_development_dependency "vcr", "~> 3.0"
|
|
26
26
|
spec.add_development_dependency 'webmock', "~> 2.1"
|
|
27
27
|
spec.add_development_dependency 'guard-rspec', "~> 4.7"
|
|
28
|
+
spec.add_development_dependency 'yard', "~> 0.8"
|
|
29
|
+
spec.add_development_dependency 'kramdown', "~> 1.11"
|
|
28
30
|
|
|
29
31
|
spec.add_dependency 'savon', '~> 2.11.1'
|
|
30
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: miami_dade_geo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryce Kerley
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-
|
|
12
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -95,6 +95,34 @@ dependencies:
|
|
|
95
95
|
- - "~>"
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '4.7'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: yard
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0.8'
|
|
105
|
+
type: :development
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0.8'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: kramdown
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - "~>"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '1.11'
|
|
119
|
+
type: :development
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - "~>"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '1.11'
|
|
98
126
|
- !ruby/object:Gem::Dependency
|
|
99
127
|
name: savon
|
|
100
128
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,6 +159,7 @@ files:
|
|
|
131
159
|
- lib/miami_dade_geo.rb
|
|
132
160
|
- lib/miami_dade_geo/addr_xy_client.rb
|
|
133
161
|
- lib/miami_dade_geo/address.rb
|
|
162
|
+
- lib/miami_dade_geo/coordinate.rb
|
|
134
163
|
- lib/miami_dade_geo/errors/base.rb
|
|
135
164
|
- lib/miami_dade_geo/errors/invalid_address_error.rb
|
|
136
165
|
- lib/miami_dade_geo/geo_attribute_client.rb
|