import geopy
from geopy import distance
import json

from django.contrib.gis import geos


def getNextPoint(point, offset, bearing):
    lat = point.y
    lon = point.x
    pnt = geopy.Point(latitude=lat, longitude=lon)
    d = distance.VincentyDistance(kilometers=offset)
    newPnt = d.destination(point=pnt, bearing=bearing)
    return geos.Point(newPnt.longitude, newPnt.latitude)


def generateGeoJson(geometry):
    if type(geometry) != list:
        geometry = [geometry]
    features = []
    for geom in geometry:
        if isinstance(geom, geos.GEOSGeometry):
            geom_json = json.loads(geom.json)
            feature = {
                'type': 'Feature',
                'geometry': geom_json,
                'properties': {
                    'name': geom_json['type']
                }
            }
            features.append(feature)
        else:
            raise TypeError("Can't generate GeoJSON. " +
                            str(geom) + 'is not geometry.')

    return {"type": "FeatureCollection", "features": features}

@@ -40,20 +40,20 @@
 %0Aimport 
-json
+yaml
 %0A%0Afrom d
@@ -592,18 +592,22 @@
 n = 
-json.
+yaml.safe_
 load
-s
 (geo
@@ -658,25 +658,25 @@
     
-'
+%22
 type
-': '
+%22: %22
 Feature
-'
+%22
 ,%0A  
@@ -693,17 +693,17 @@
     
-'
+%22
 geometry
 ': g
@@ -698,17 +698,17 @@
 geometry
-'
+%22
 : geom_j
@@ -728,17 +728,17 @@
         
-'
+%22
 properti
@@ -739,17 +739,17 @@
 operties
-'
+%22
 : %7B%0A    
@@ -768,14 +768,14 @@
     
-'
+%22
 name
-'
+%22
 : ge

use yaml to load json to avoid unicode