hjongsma avatar hjongsma committed 94110c7

Fixed misspelling of longitude, fixed display of string with comma-delimited float locale

Comments (0)

Files changed (7)

 
 * address - the requested address
 * computed_address - address returned by geocoder
-* longtitude
+* longitude
 * latitude
 * geocode_error - True if geocoder wasn't able to handle the address
 

easy_maps/admin.py

 from django.contrib import admin
 
 class AddressAdmin(admin.ModelAdmin):
-    list_display = ['address', 'computed_address', 'latitude', 'longtitude', 'geocode_error']
+    list_display = ['address', 'computed_address', 'latitude', 'longitude', 'geocode_error']
     list_filter = ['geocode_error']
     search_fields = ['address']

easy_maps/migrations/0002_auto__add_field_address_longitude.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'Address.longitude'
+        db.add_column('easy_maps_address', 'longitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Address.longitude'
+        db.delete_column('easy_maps_address', 'longitude')
+
+
+    models = {
+        'easy_maps.address': {
+            'Meta': {'object_name': 'Address'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'computed_address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'geocode_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longtitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['easy_maps']

easy_maps/migrations/0003_move_longitude_data.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+class Migration(DataMigration):
+
+    def forwards(self, orm):
+		# Migrate longtitude data to longitude
+		for address in orm.Address.objects.all():
+			address.longitude = address.longtitude
+			address.save()
+
+
+    def backwards(self, orm):
+		# Migrate longitude data to longtitude
+        for address in orm.Address.objects.all():
+			address.longtitude = address.longitude
+			address.save()
+
+
+    models = {
+        'easy_maps.address': {
+            'Meta': {'object_name': 'Address'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'computed_address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'geocode_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longtitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['easy_maps']

easy_maps/migrations/0004_auto__del_field_address_longtitude.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Deleting field 'Address.longtitude'
+        db.delete_column('easy_maps_address', 'longtitude')
+
+    def backwards(self, orm):
+        
+        # Adding field 'Address.longtitude'
+        db.add_column('easy_maps_address', 'longtitude', self.gf('django.db.models.fields.FloatField')(null=True, blank=True), keep_default=False)
+
+
+    models = {
+        'easy_maps.address': {
+            'Meta': {'object_name': 'Address'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
+            'computed_address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+            'geocode_error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+            'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['easy_maps']

easy_maps/models.py

     computed_address = models.CharField(max_length=255, null=True, blank=True)
     latitude = models.FloatField(null=True, blank=True)
     longtitude = models.FloatField(null=True, blank=True)
+    longitude = models.FloatField(null=True, blank=True)
     geocode_error = models.BooleanField(default=False)
 
     def fill_geocode_data(self):
         try:
             g = geocoders.Google(resource='maps')
             address = smart_str(self.address)
-            self.computed_address, (self.latitude, self.longtitude,) = g.geocode(address)
+            self.computed_address, (self.latitude, self.longitude,) = g.geocode(address)
             self.geocode_error = False
         except (UnboundLocalError, ValueError,):
             self.geocode_error = True
 
     def save(self, *args, **kwargs):
         # fill geocode data if it is unknown
-        if (self.longtitude is None) or (self.latitude is None):
+        if (self.longitude is None) or (self.latitude is None):
             self.fill_geocode_data()
         super(Address, self).save(*args, **kwargs)
 

easy_maps/templates/easy_maps/map.html

     <!-- Map creation script -->
     <script type="text/javascript">
         function initialize_map_{{ map.pk }}() {
-            var latlng = new google.maps.LatLng({{ map.latitude }}, {{ map.longtitude }});
+            var latlng = new google.maps.LatLng({{ map.latitude|stringformat:"f" }}, {{ map.longitude|stringformat:"f" }});
             var mapElem = document.getElementById("map-canvas-{{ map.pk }}");
 
             {% block map_options_js %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.