c# 4.0 - Find UK PostCodes closest to other UK Post Codes by matching the Post Code String -
here question has me awake number of days now. conclusion came far red bull not coders.
i have scenario in application have couple of jobs (1 50). job has address , have following properties of address: postcode, latitude, , longitude.
i have table of workers , have addresses. while jobs or workers created through screens, use google map queries make sure provided postcode valid , in uk addresses verified.
i using scheduler control display workers on y-axis , timeline on x-axis. every job has date , can move vertically on scheduler on job’s date. user selects number of jobs , displayed in basket close scheduler. user can drag , drop job against workers. manual works.
my task automate user not except verifying , allotting jobs. therefore, have automate process.
every worker has property called willingmaximumdistancetravel integer representing miles, worker willing travel job.
now here headache: have on 1500 workers. have utility function uses newtonsoft’s json convert de-serialize stream of response google maps. need feed postcode , b.
i plan introduce new table db store distance finds postcode a, postcode b, , distance. therefore, if find myself comparing same postcodes again, retrieve result db instead , , eventually, no longer require bothering google anymore table comprehensive.
i cannot use simple haversine formula, crow-fly path not requirement here. pain in takes lot of time calculate. workers can travel on 10 miles while vary 15 80. have take first job list , run every applicable worker o system! wondering uk postcode has pattern it. if sort list of uk postcodes, can rough-estimate, alphanumeric pattern, hit 100-mile mark, 200-mile mark , on?
if interested in code, please drop line , paste it.
(i work google, i'm not speaking on behalf of google. have nothing maps api.)
i suspect isn't great situation using google maps api, because you're pushing data through. don't want make many requests, if under directions limits.
when tackled similar in previous job, bought locally-hosted maps api - wasn't fast enough sort of work. ended precomputing time travel centroid of each postcode "area" (probably wrong name it, first part of postcode followed first digit of remainder, e.g. "sw1w 9" "sw1w 9tq") every other area, storing result in giant table. think did postcodes within 100 miles or similar, cut down on amount of preprocessing.
even then, simple db wasn't quite fast wanted - stored results in giant file, single byte per source/destination pair. (we had fixed sequence of source postcodes , target postcodes, didn't need specify those.) @ point, computing travel time consisted of:
- work out postcode areas (substring work)
- find index of each postcode area within sequence
- check if we'd loaded part of file (we lazy loaded startup speed)
- load row if necessary, , access otherwise
the bytes on sliding scale of accuracy, first 60 minutes on per-minute basis, each value meant 2 minutes, 5 etc. (those aren't exact values, that.)
when you've worked out "good candidates" can ask on-site api or google maps api more accurate directions exact postcodes, of course.
Comments
Post a Comment