def get_cad_locations(self): locations = [] misses = 0 for i, entry in enumerate(self.cad.values()): res = {} address = "%s"%(entry['inf_addr']) areaid = self.get_areaid(entry) if self.is_default: #if self.address_to_coordinates is None: # self.address_to_coordinates = (dict((x['address'], x) for x in # AddressLatLog.objects.values("address", "latitude", "longitude"))) #address_coordinates = self.address_to_coordinates.get(address) if self.propid_to_coordinates is None: self.propid_to_coordinates = dict((x['propid'], x) for x in PropIdLatLong.objects.values("propid", "latitude", "longitude")) address_coordinates = self.propid_to_coordinates.get(entry['propid']) res['address_latitude'] = float(address_coordinates['latitude']) if address_coordinates else None res['address_longitude'] = float(address_coordinates['longitude']) if address_coordinates else None if areaid: coordinates = self.blocks_to_coordinates.get(areaid) else: areaid = address coordinates = address_coordinates if coordinates: res['latitude'] = float(coordinates['latitude']) res['longitude'] = float(coordinates['longitude']) #print i else: misses += 1 continue res = utils.get_lat_long("%s, Boston MA"%address) print i, res if not res: continue item = PropIdLatLong(propid=entry['propid'], address=address, latitude=res['latitude'], longitude=res['longitude']) #item = AddressLatLog(address=address, latitude=res['latitude'], # longitude=res['longitude']) item.save() time.sleep(0.5) res['date'] = entry['close_dt'] res['bg_id'] = str(entry['bg_id']) res['areaid'] = str(areaid) res['address'] = address res['subject'] = "Subject" res['type'] = "%s"%entry['type_desc'] locations.append(res) locations = sorted(locations, key=lambda x: (x['address'], x['date'] or datetime.date.min)) #print "MISSES %s"%misses return locations
def get_cad_locations(self): locations = [] misses = 0 for i, entry in enumerate(self.cad.values()): res = {} address = "%s" % (entry['inf_addr']) areaid = self.get_areaid(entry) if self.is_default: #if self.address_to_coordinates is None: # self.address_to_coordinates = (dict((x['address'], x) for x in # AddressLatLog.objects.values("address", "latitude", "longitude"))) #address_coordinates = self.address_to_coordinates.get(address) if self.propid_to_coordinates is None: self.propid_to_coordinates = dict( (x['propid'], x) for x in PropIdLatLong.objects.values( "propid", "latitude", "longitude")) address_coordinates = self.propid_to_coordinates.get( entry['propid']) res['address_latitude'] = float( address_coordinates['latitude'] ) if address_coordinates else None res['address_longitude'] = float( address_coordinates['longitude'] ) if address_coordinates else None if areaid: coordinates = self.blocks_to_coordinates.get(areaid) else: areaid = address coordinates = address_coordinates if coordinates: res['latitude'] = float(coordinates['latitude']) res['longitude'] = float(coordinates['longitude']) #print i else: misses += 1 continue res = utils.get_lat_long("%s, Boston MA" % address) print i, res if not res: continue item = PropIdLatLong(propid=entry['propid'], address=address, latitude=res['latitude'], longitude=res['longitude']) #item = AddressLatLog(address=address, latitude=res['latitude'], # longitude=res['longitude']) item.save() time.sleep(0.5) res['date'] = entry['close_dt'] res['bg_id'] = str(entry['bg_id']) res['areaid'] = str(areaid) res['address'] = address res['subject'] = "Subject" res['type'] = "%s" % entry['type_desc'] locations.append(res) locations = sorted(locations, key=lambda x: (x['address'], x['date'] or datetime.date.min)) #print "MISSES %s"%misses return locations
def get_crm_data(self): locations = [] misses = 0 for i, entry in enumerate(self.crm): res = {} areaid = self.get_areaid(entry) address = entry['location'] address_coordinate = None if self.use_addresses and self.is_default or not areaid: #if self.address_to_coordinates is None: # self.address_to_coordinates = (dict((x['address'], x) for x in # AddressLatLog.objects.values("address", "latitude", "longitude"))) #address_coordinates = self.address_to_coordinates.get(address) if self.propid_to_coordinates is None: self.propid_to_coordinates = dict((x['propid'], x) for x in PropIdLatLong.objects.values("propid", "latitude", "longitude")) address_coordinates = self.propid_to_coordinates.get(entry['propid']) res['address_latitude'] = float(address_coordinates['latitude']) if address_coordinates else None res['address_longitude'] = float(address_coordinates['longitude']) if address_coordinates else None if areaid: coordinates = self.blocks_to_coordinates.get(areaid) else: areaid = address coordinates = address_coordinates if coordinates: res['latitude'] = float(coordinates['latitude']) res['longitude'] = float(coordinates['longitude']) #print "%s %s %s"%(i, res['latitude'], res['longitude']) elif address is None: #print "Bad %s"%i pass else: misses += 1 continue res = utils.get_lat_long(address) print i, res if not res: continue item = PropIdLatLong(propid=entry['propid'], address=address, latitude=res['latitude'], longitude=res['longitude']) #item = AddressLatLog(address=address, latitude=res['latitude'], # longitude=res['longitude']) item.save() time.sleep(.5) res['date'] = entry['open_dt'] res['bg_id'] = str(entry['bg_id']) res['areaid'] = str(areaid) res['address'] = address res['subject'] = "%s, %s"%(entry['subject'],entry['reason']) res['type'] = "%s"%entry['type'] locations.append(res) if self.use_addresses: locations = sorted(locations, key=lambda x: (x['date'])) else: locations = sorted(locations, key=lambda x: (x['address'], x['date'])) #print "MISSES %s"%misses return locations
def get_crm_data(self): locations = [] misses = 0 for i, entry in enumerate(self.crm): res = {} areaid = self.get_areaid(entry) address = entry['location'] address_coordinate = None if self.use_addresses and self.is_default or not areaid: #if self.address_to_coordinates is None: # self.address_to_coordinates = (dict((x['address'], x) for x in # AddressLatLog.objects.values("address", "latitude", "longitude"))) #address_coordinates = self.address_to_coordinates.get(address) if self.propid_to_coordinates is None: self.propid_to_coordinates = dict( (x['propid'], x) for x in PropIdLatLong.objects.values( "propid", "latitude", "longitude")) address_coordinates = self.propid_to_coordinates.get( entry['propid']) res['address_latitude'] = float( address_coordinates['latitude'] ) if address_coordinates else None res['address_longitude'] = float( address_coordinates['longitude'] ) if address_coordinates else None if areaid: coordinates = self.blocks_to_coordinates.get(areaid) else: areaid = address coordinates = address_coordinates if coordinates: res['latitude'] = float(coordinates['latitude']) res['longitude'] = float(coordinates['longitude']) #print "%s %s %s"%(i, res['latitude'], res['longitude']) elif address is None: #print "Bad %s"%i pass else: misses += 1 continue res = utils.get_lat_long(address) print i, res if not res: continue item = PropIdLatLong(propid=entry['propid'], address=address, latitude=res['latitude'], longitude=res['longitude']) #item = AddressLatLog(address=address, latitude=res['latitude'], # longitude=res['longitude']) item.save() time.sleep(.5) res['date'] = entry['open_dt'] res['bg_id'] = str(entry['bg_id']) res['areaid'] = str(areaid) res['address'] = address res['subject'] = "%s, %s" % (entry['subject'], entry['reason']) res['type'] = "%s" % entry['type'] locations.append(res) if self.use_addresses: locations = sorted(locations, key=lambda x: (x['date'])) else: locations = sorted(locations, key=lambda x: (x['address'], x['date'])) #print "MISSES %s"%misses return locations