Browse Source

fixup! Fall back to "null island" when no centerpoint is given in index.

feature/region-slug-gone
Bèr Kessels 5 months ago
parent
commit
0a8bb31c80
3 changed files with 142 additions and 1 deletions
  1. 6
    0
      lib/hours.rb
  2. 135
    0
      test/fixtures/address_sample.csv
  3. 1
    1
      test/support/location_helpers.rb

+ 6
- 0
lib/hours.rb View File

@@ -67,6 +67,12 @@ module Hours
EventSourcery::Postgres.config.projections_database
end

def self.address_database
# For now, we're lazy and stick the addresses in the same projections
# database. It could (and probably should) be a separate database.
EventSourcery::Postgres.config.projections_database
end

def self.repository
@repository ||= EventSourcery::Repository.new(
event_source: event_source,

+ 135
- 0
test/fixtures/address_sample.csv View File

@@ -0,0 +1,135 @@
hash,number,street,unit,city,district,region,postcode,location
4f51cd9959943379,1,Stationsplein,,Nijmegen,,Gelderland,6512AA,SRID=4326;POINT(5.8531012 51.8432072)
c251422e0a839ed6,2,Stationsplein,,Nijmegen,,Gelderland,6512AA,SRID=4326;POINT(5.8531021 51.8431853)
72e9b48bfa5d0fe7,3,Stationsplein,,Nijmegen,,Gelderland,6512AA,SRID=4326;POINT(5.8531012 51.8432072)
6acd89c350b12678,4,Stationsplein,,Nijmegen,,Gelderland,6512AA,SRID=4326;POINT(5.8531021 51.8431853)
ef65d50d55088d77,5,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8531012 51.8432072)
7bfd4ffb246dac49,6A,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
5460453af52d04c9,6B,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
4183f0828760f05a,6C,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
a51cb1b1ff847e6e,6D,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
a4f6b062fc6b6618,6E,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
09b012182bea9d04,6F,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
cdcac712ef4b9a3e,6G,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
bf2c3233331a7161,6H,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530907 51.8431625)
cc44d822987dffb2,6J,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530937 51.843142)
98b90479a1d78a28,6K,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530937 51.843142)
96a32ad7a9a66f23,6L,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530937 51.843142)
78165cfa2a48c3b1,6M,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853092 51.8431221)
9c69071c7e35432a,6N,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853092 51.8431221)
d9fd411a842dc32c,6P,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530919 51.843104)
e04b78380b77267a,6Q,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8530919 51.843104)
73bbf6cabc76da3d,6,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8531021 51.8431853)
21b90378c98ada6f,7,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8533866 51.8428513)
3af879e65f2c9c5f,8,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8525674 51.843689)
51957fdaf1001846,9K-1,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538009 51.8442869)
d949d08ff8d1c802,9K-10,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535038 51.8443288)
dd7debb04f353948,9K-11,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536123 51.8443035)
05dd78cc990409ef,9K-12,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536836 51.8442856)
3ad495bbd68c8c82,9K-13,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537581 51.8442959)
60b7f916f523966f,9K-14,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537865 51.8442763)
0805c3a34685590f,9K-15,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853555 51.8443038)
50b01dc182d9b503,9K-16,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535667 51.8443215)
063ce9413c0c410e,9K-17,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536836 51.8442856)
f6edc674881accd7,9K-18,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535836 51.8442966)
69ea91851509a6bd,9K-19,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538179 51.8442708)
7006261570217020,9K-2,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.85357 51.8443675)
afe6bd3a5b937ecd,9K-20,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538009 51.8442869)
fdf0afc5ddc3913d,9K-21,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537439 51.8443066)
c39ccc36dcf64098,9K-22,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538409 51.8442778)
8a5a059ddbed0725,9K-23,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538182 51.8442956)
02ff6d395c9705d3,9K-24,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8534836 51.8443147)
f8192b36ac197788,9K-25,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535207 51.8443039)
d632c385c4f16586,9K-26,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538295 51.8442832)
62ca38c51f95f17d,9K-27,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537008 51.844289)
7e296c463606021a,9K-28,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535377 51.8442826)
53d1cfb0cd431712,9K-29,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538436 51.8442707)
7c7b3eedb5513011,9K-3,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536123 51.8443035)
619fc98273cd0b2e,9K-30,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537238 51.8442996)
a488c5bcad4de6bb,9K-31,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535925 51.8443249)
aa5c67dee5ec6a9e,9K-32,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537896 51.8443028)
55384a29bdcfe3dc,9K-33,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537637 51.8442817)
c46f8ef627baf5bd,9K-34,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536351 51.8443035)
b6cacbbdf8e51682,9K-35,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536242 51.8443496)
92b48d37258e0aed,9K-36,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536155 51.8443443)
8f2b5412ae3a3634,9K-37,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538182 51.8442956)
facbd23fc8caffb4,9K-38,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536242 51.8443496)
bae92dfd81eb3d4b,9K-39,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536408 51.8442928)
d6891490fd92ae83,9K-4,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536179 51.8442929)
6374e218c5b4767b,9K-40,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537406 51.8442676)
0e97bc1abdc5b533,9K-41,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537778 51.8442657)
959203fd057874a5,9K-42,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536977 51.8442695)
b0466ba5b30842c1,9K-43,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853632 51.8442769)
fa1d3763c535cb18,9K-44,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535836 51.8442966)
e6f1d0484f6d901e,9K-45,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536781 51.8443068)
9ee9f445964d21f4,9K-46,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537351 51.8442871)
981299945cb2f94c,9K-47,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536381 51.8443141)
b96919d82b9eb1ec,9K-48,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853538 51.844318)
5ba8b3cd229c04d5,9K-49,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536953 51.8443068)
671470351b651c1d,9K-5,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536634 51.8442661)
9a8e285b521ebda3,9K-50,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536297 51.8443247)
338e90ce4b3682d4,9K-51,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853601 51.8443178)
94928916e34fbffa,9K-52,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536666 51.844298)
a5af9360c352e325,9K-53,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537463 51.8442587)
58c997ae56b5fdf3,9K-54,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537093 51.8442766)
f7890c6f4f36923d,9K-55,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536109 51.8442892)
9787abf7dcd3906a,9K-56,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535723 51.8443161)
05f9be2f967a7653,9K-57,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853661 51.8443104)
b99bb7b8b92404f8,9K-58,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535608 51.8443108)
468539c69c46d172,9K-59,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537262 51.844257)
7d096d8ff77a5ec3,9K-6,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537408 51.84428)
fbc88a7d57cbbc7e,9K-60,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853655 51.8442874)
7eedfa7ec1a9656a,9K-61,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537748 51.8442551)
da39ecfd70758847,9K-62,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537235 51.8442712)
e054f6ea80e22964,9K-63,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537037 51.8442943)
1b139a3ed1069d68,9K-64,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536124 51.8443142)
835066f8c31b8291,9K-65,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535659 51.8442909)
cdfa3e141e6eae86,9K-66,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535836 51.8442966)
49c9f859befbf655,9K-67,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536496 51.8443211)
944f91f034cb0bb8,9K-68,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853632 51.8442769)
e7ce9cdc8836221d,9K-69,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853555 51.8443038)
95b4b10c052130be,9K-7,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537865 51.8442763)
254a1a90f4d691a3,9K-70,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853755 51.8442764)
bfcfd7ad0b51e523,9K-71,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537865 51.8442763)
1144b9b208d58d4d,9K-72,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853598 51.8443089)
c23b6e31948685bd,9K-73,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536692 51.8442732)
880b20cfa6287dc0,9K-74,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536351 51.8443035)
34c0bbd7198918c7,9K-75,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537581 51.8442959)
2eaf2657a4eddeb1,9K-76,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853584 51.8443391)
dac310ec154861c5,9K-8,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853584 51.8443391)
a0e00274c01ca72a,9K-81,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535955 51.8443426)
d10608b051d8c1cf,9K-82,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537896 51.8443028)
8660377730b8cfe6,9K-83,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535297 51.8443411)
d48efad5fa782e4e,9K-84,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538436 51.8442707)
6edb6ad0ae566fe6,9K-85,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8538493 51.8442601)
f7b4f962ac1a0369,9K-86,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535526 51.8443392)
2636f161fd5ced45,9K-9,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537408 51.84428)
d7ea23630f58ddfa,9K-91,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537213 51.8443332)
228477bc6ac67140,9K-92,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.853481 51.8443324)
45ac0478e42acb38,9K-93,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537896 51.8443028)
fa7356bb1a0012d3,9K-94,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535094 51.8443111)
8cda14f46ec8992d,9K-95,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537896 51.8443028)
eddf48c0cd5f1db7,9K-96,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8537351 51.8442871)
fc12a8650b983f9f,9,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535561 51.8442924)
9df66d70faf83ff7,11A,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8534453 51.8443322)
1c3ad562bcf34bbe,11B,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8535435 51.8446206)
477f665e07280f71,11C,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8536823 51.8443356)
c364ea98a2080f25,11,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8541368 51.8442635)
1c03cd2fd8bd2c51,12,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
5bc3995e71924521,13,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
1e37f69e1f8b2ef8,14,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
80b29de86872282e,15,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
2bde8b2c3fc4848a,16,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
39accf64021ea328,17,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
aa828f7123b05f60,18,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
066c1380f4187f57,19,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
c5ee2e85114529b1,20,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
ced4139cb2617f5a,21,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
577e2c0befc61025,22,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544949 51.8430769)
2e300cee5970a2d7,23,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8544964 51.8430573)
b4b2a739fca5c00e,26,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8541473 51.842218)
7ca7589bb344c762,29,Stationsplein,,Nijmegen,,Gelderland,6512AB,SRID=4326;POINT(5.8529342 51.8420089)
2215e111e1ac5ce8,26,Vijzelstraat,,Arnhem,,Gelderland,6811ET,SRID=4326;POINT(5.9067795 51.9815167)
b4ac426074553d7c,2,Op het Toneel,,Arnhem,,Gelderland,6836ND,SRID=4326;POINT(5.8939416 51.9418593)
adb19e7d67038baa,3,Op het Toneel,,Arnhem,,Gelderland,6836ND,SRID=4326;POINT(5.8941034 51.9415266)
2b305bcfe358a429,4,Op het Toneel,,Arnhem,,Gelderland,6836ND,SRID=4326;POINT(5.8940051 51.9416768)

+ 1
- 1
test/support/location_helpers.rb View File

@@ -8,7 +8,7 @@ module LocationHelpers
DISTANCE_DELTA = 0.001 # Translates to 79-111 meter.

def null_island
GeoRuby::SimpleFeatures::Point.from_xy(0,0)
GeoRuby::SimpleFeatures::Point.from_xy(0, 0)
end

def assert_nearby(expected, actual, delta = DISTANCE_DELTA, message = nil)

Loading…
Cancel
Save