parameters: (entity, geo_attr)
docstring: Fix location with empty geo:json, seting it to 0,0
  
      :param entity: entity to fix
      :param geo_attr: name of the geo:json attribute
      :return: "OK" if update when ok, "FAIL xxxx" otherwise
docstring_summary: Fix location with empty geo:json, seting it to 0,0
docstring_tokens: Fix location with empty geo : json seting it to 0 0
function: def fix_empty_geojson(entity, geo_attr):
      """
      Fix location with empty geo:json, seting it to 0,0
  
      :param entity: entity to fix
      :param geo_attr: name of the geo:json attribute
      :return: "OK" if update when ok, "FAIL xxxx" otherwise
      """
  
      # Location example for reference:
      # { "attrName" : "position", "coords" : { "type" : "Point", "coordinates" : [ -1.52363, 42.9113 ] } }
  
      entity[ATTRS][geo_attr]['value'] = {
          'type': 'Point',
          'coordinates': [0, 0]
      }
  
      location = {
          'attrName': geo_attr,
          'coords': {
              'type': 'Point',
              'coordinates': [0, 0]
          }
      }
  
      try:
          # Update document with the new attribute fields
          db[COL].update(flatten(entity['_id']), {'$set': {ATTRS: entity[ATTRS], 'location': location}})
  
          # Check update was ok (this is not an exhaustive checking that is better than nothing :)
          check_doc = db[COL].find_one(flatten(entity['_id']))
  
          if update_ok(check_doc, entity[ATTRS]):
              return 'OK'
          else:
              return 'FAIL attrs check after update in DB'
  
      except pymongo.errors.WriteError as e:
          return 'FAIL mongo error %d - location was %s' % (e.code, json.dumps(location))
function_tokens: def fix_empty_geojson ( entity , geo_attr ) : # Location example for reference: # { "attrName" : "position", "coords" : { "type" : "Point", "coordinates" : [ -1.52363, 42.9113 ] } } entity [ ATTRS ] [ geo_attr ] [ 'value' ] = { 'type' : 'Point' , 'coordinates' : [ 0 , 0 ] } location = { 'attrName' : geo_attr , 'coords' : { 'type' : 'Point' , 'coordinates' : [ 0 , 0 ] } } try : # Update document with the new attribute fields db [ COL ] . update ( flatten ( entity [ '_id' ] ) , { '$set' : { ATTRS : entity [ ATTRS ] , 'location' : location } } ) # Check update was ok (this is not an exhaustive checking that is better than nothing :) check_doc = db [ COL ] . find_one ( flatten ( entity [ '_id' ] ) ) if update_ok ( check_doc , entity [ ATTRS ] ) : return 'OK' else : return 'FAIL attrs check after update in DB' except pymongo . errors . WriteError as e : return 'FAIL mongo error %d - location was %s' % ( e . code , json . dumps ( location ) )