예제 #1
0
    def test_geocode(self):
        
        import dstk
        
        p = self.partitions.find(table='addresses')
    
        dstk = dstk.DSTK({'apiBase':'http://ec2-54-235-229-124.compute-1.amazonaws.com/'})
        
        c = []
        
        lr = self.init_log_rate(300)
        
        o = {}
        
        for row in p.rows:
           
            c.append(str(row.text))

            if len(c) > 10:
           
                try:
                    r = dstk.street2coordinates(c)
                    o.update(r)
                except UnicodeDecodeError:
                    # The unicode errors occur for strings that don't appear to have unicode,
                    # so I don't know how to fix it. 
                    for x in c:
                        try:
                            dstk.street2coordinates(x)
                            o.update(r)
                        except UnicodeDecodeError:
                            self.error("Failed for '{}'".format(x))  
                        
                c = []
            
            lr()
                
                
        self.log("Done. {} records".format(len(o)))
예제 #2
0
파일: bug_0004.py 프로젝트: zslayton/dstk
#!/usr/bin/env python
#
# A test case to reproduce https://github.com/petewarden/dstk/issues/4
#
# Calls the street2coordinates API repeatedly until it fails

import dstk

dstk = dstk.DSTK()

counter = 0
while True:

    test_input = '2543 Graystone Place, Simi Valley, CA 93065'

    result = dstk.street2coordinates(test_input)

    counter += 1
    print str(counter)
예제 #3
0
  "5 Arbury Court, Cambridge. CB4 2JQ": {"confidence": 9, "street_number": None, "locality": "King's Hedges", "street_name": None, "longitude": "0.129886208578", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.2241815277", "region": "Cambridge", "street_address": None}, 
  "363 Sharrow Vale Road, Sheffield. S11 8ZG": {"confidence": 9, "street_number": "363", "locality": "Nether Edge", "street_name": "Sharrow Vale Road", "longitude": "-1.49839785957369", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "53.367555815374", "region": "Sheffield", "street_address": "363 Sharrow Vale Road"}, 
  "59 Ebury Street, London. SW1W 0NZ": {"confidence": 9, "street_number": "59", "locality": "Warwick", "street_name": "Ebury Street", "longitude": "-0.147190779445509", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "51.4959945275595", "region": "Westminster", "street_address": "59 Ebury Street"}, 
  "70 Division Street, Sheffield. S1 4GF": {"confidence": 9, "street_number": "70", "locality": "Central", "street_name": "Division Street", "longitude": "-1.47302453068155", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "53.3801969393084", "region": "Sheffield", "street_address": "70 Division Street"}, 
  "Addenbrookes Hosp, Hills Rd, Cambridge. CB2 2QQ": {"confidence": 8, "street_number": None, "locality": "Cambridge", "street_name": "Hills Road", "longitude": "0.1273966", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.199353", "region": None, "street_address": None}, 
  "Victoria Station, London. SW1V 1JY": {"confidence": 9, "street_number": None, "locality": "Warwick", "street_name": "Victoria Street", "longitude": "-0.143065416450093", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "51.4965774374698", "region": "Westminster", "street_address": None}, 
  "Hardwick Street, Cambridge. CB3 9JA": {"confidence": 9, "street_number": None, "locality": "Newnham", "street_name": "Hardwick Street", "longitude": "0.1088908", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.1950862", "region": "Cambridge", "street_address": None}, 
  "Victoria Station, London. SW1V 1JT": {"confidence": 9, "street_number": None, "locality": "Warwick", "street_name": "Victoria Street", "longitude": "-0.142632392027176", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "51.4965537502431", "region": "Westminster", "street_address": None}, 
  "6 Cathedral Walk Cardinal Place, London. SW1E 5JH": {"confidence": 9, "street_number": "6", "locality": "St James's", "street_name": "Cardinal Place", "longitude": "-0.2177927", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "51.4645664", "region": "Westminster", "street_address": "6 Cardinal Place"}, 
  "269 Fulwood Rd, S10. S10 3BD": {"confidence": 9, "street_number": "269", "locality": "Broomhill", "street_name": "Fulwood Road", "longitude": "-1.50146255148811", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "53.3773528827613", "region": "Sheffield", "street_address": "269 Fulwood Road"}, 
  "139-143 Milton Road, Cambridge. CB4 1XE": {"confidence": 9, "street_number": "139", "locality": "West Chesterton", "street_name": "Milton Road", "longitude": "0.133951984546466", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.220486593745", "region": "Cambridge", "street_address": "139 Milton Road"}, 
  "11 MEADOW LN, OVER, CAMBRIDGE CB24 5NF": {"confidence": 9, "street_number": "11", "locality": "Willingham and Over", "street_name": "Meadow Lane", "longitude": "0.0202307", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.3168159", "region": "South Cambridgeshire", "street_address": "11 Meadow Lane"},
  "261-263 Newmarket Road, Cambridge. CB5 8JE": {"confidence": 9, "street_number": "261", "locality": "Abbey", "street_name": "Newmarket Road", "longitude": "0.146200079031848", "country_code3": "GBR", "country_name": "United Kingdom", "fips_county": None, "country_code": "UK", "latitude": "52.2106264426397", "region": "Cambridge", "street_address": "261 Newmarket Road"}
}

actual_output = dstk.street2coordinates(test_input)

#print json.dumps(actual_output)

if len(expected_output) != len(actual_output):
  print json.dumps(actual_output)
  print('Expected '+str(len(expected_output))+' items, found '+str(len(actual_output)))
  exit(1)

for key, expected_values in expected_output.items():

  if key not in actual_output:
    print json.dumps(actual_output)
    print('Expected key "'+key+'" not found')
    exit(1)
예제 #4
0
#!/usr/bin/env python
#
# A test case to reproduce https://github.com/petewarden/dstk/issues/4
#
# Calls the street2coordinates API repeatedly until it fails

import dstk

dstk = dstk.DSTK()

counter = 0
while True:

  test_input = '2543 Graystone Place, Simi Valley, CA 93065'

  result = dstk.street2coordinates(test_input)
  
  counter += 1
  print str(counter)
예제 #5
0
import dstk

dstk = dstk.DSTK({'checkVersion': False})

print dstk.street2coordinates('2543 Graystone Place, Simi Valley, CA 93065')import dstk

dstk = dstk.DSTK({'checkVersion': False})

print dstk.street2coordinates('2543 Graystone Place, Simi Valley, CA 93065')
예제 #6
0
        "confidence": 9,
        "street_number": "261",
        "locality": "Abbey",
        "street_name": "Newmarket Road",
        "longitude": "0.146200079031848",
        "country_code3": "GBR",
        "country_name": "United Kingdom",
        "fips_county": None,
        "country_code": "UK",
        "latitude": "52.2106264426397",
        "region": "Cambridge",
        "street_address": "261 Newmarket Road",
    },
}

actual_output = dstk.street2coordinates(test_input)

# print json.dumps(actual_output)

if len(expected_output) != len(actual_output):
    print json.dumps(actual_output)
    print ("Expected " + str(len(expected_output)) + " items, found " + str(len(actual_output)))
    exit(1)

for key, expected_values in expected_output.items():

    if key not in actual_output:
        print json.dumps(actual_output)
        print ('Expected key "' + key + '" not found')
        exit(1)