コード例 #1
0
ファイル: models.py プロジェクト: xuan6/dg
 def clean(self):
     logger = logging.getLogger('dashboard')
     if(self.latitude is None or self.longitude is None):
         geocoder = Geocoder()
         address = u"%s,%s,%s" % (self.district_name, self.state.state_name, self.state.country.country_name)
         if (geocoder.convert(address)):
             try:
                 (self.latitude, self.longitude) = geocoder.getLatLng()
                 logger.info("%s: Lat Long Added" % self.district_name)
             except:
                 logger.error("Geocodes not found for %s, %s" % (self.district_name, self.state.state_name))
コード例 #2
0
 def clean(self):
     logger = logging.getLogger('dashboard')
     if (self.latitude is None or self.longitude is None):
         geocoder = Geocoder()
         address = u"%s,%s,%s" % (self.district_name, self.state.state_name,
                                  self.state.country.country_name)
         if (geocoder.convert(address)):
             try:
                 (self.latitude, self.longitude) = geocoder.getLatLng()
                 logger.info("%s: Lat Long Added" % self.district_name)
             except:
                 logger.error("Geocodes not found for %s, %s" %
                              (self.district_name, self.state.state_name))
コード例 #3
0
'''populate_district_lat_long.py: One time script to populate existing districts coordinates.
   To run this file type python -m feeds.populate_district_lat_long'''

__author__ = "Aadish Gupta"

from django.core.management import setup_environ
import dg.settings
setup_environ(dg.settings)

from geographies.models import District
from libs.geocoder import Geocoder

geocoder = Geocoder()
for d in District.objects.all():
    address = u"%s,%s,%s" % (d.district_name, d.state.state_name,
                             d.state.country.country_name)
    if (geocoder.convert(address)):
        try:
            (d.latitude, d.longitude) = geocoder.getLatLng()
            d.save()
        except:
            print "Geocodes not found for %s, %s" % (d.district_name,
                                                     d.state.state_name)
コード例 #4
0
'''populate_district_lat_long.py: One time script to populate existing districts coordinates.
   To run this file type python -m feeds.populate_district_lat_long'''

__author__ = "Aadish Gupta"

from django.core.management import setup_environ
import dg.settings
setup_environ(dg.settings)

from geographies.models import District
from libs.geocoder import Geocoder

geocoder = Geocoder()
for d in District.objects.all():
    address = u"%s,%s,%s" % (d.district_name, d.state.state_name, d.state.country.country_name)
    if (geocoder.convert(address)):
        try:
            (d.latitude, d.longitude) = geocoder.getLatLng()
            d.save()
        except:
            print "Geocodes not found for %s, %s" % (d.district_name, d.state.state_name)