/*
Each record contains latitude and longitude fields
327149
function (record, index) {
		var getLocation = function (latitudeField, longitudeField) {
			var latitude = L.Util.getFieldValue(record, latitudeField);
			var longitude = L.Util.getFieldValue(record, longitudeField);
			var location = null;

			if (latitude && longitude) {
				var latlng = new L.LatLng(latitude, longitude);
				location = {
					location: latlng,
					text: [latlng.lat.toFixed(3),latlng.lng.toFixed(3)].join(', '),
					center: latlng
				};
			}

			return location;
		};

		var location = getLocation(this.options.latitudeField, this.options.longitudeField);

		if (!location && this.options.fallbackLocationFields) {
			var fallbackIndex = 0;
			var fallbackLocationFields;
			while (!location && fallbackIndex < this.options.fallbackLocationFields.length) {
				fallbackLocationFields = this.options.fallbackLocationFields[fallbackIndex];
				location = getLocation(fallbackLocationFields.latitudeField, fallbackLocationFields.longitudeField);
				fallbackIndex++;
			}
		}

		return location;
	}
1028775
public Iterable<DContact> queryByLatitude(Object parent, java.lang.Float latitude) {
    return queryByField(parent, DContactMapper.Field.LATITUDE.getFieldName(), latitude);
  }
802624
def min( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil )
      min = {}
      hasValues = false
      iterateRecords(dbid,fieldNames,query,qid,qname,clist,slist,fmt,options){|record|
         fieldNames.each{|field|
            value = record[field]
            if value
               baseFieldType = lookupBaseFieldTypeByName(field)
               case baseFieldType
                  when "int32","int64","bool" 
                     value = record[field].to_i
                  when "float"   
                     value = record[field].to_f
               end
            end
            if min[field].nil? or  (value and value < min[field])
               min[field] = value
               hasValues = true
            end
         }
      }
      min = nil if not hasValues
      min
   end
176556
function runListFeatures(callback) {
  var rectangle = {
    lo: {
      latitude: 400000000,
      longitude: -750000000
    },
    hi: {
      latitude: 420000000,
      longitude: -730000000
    }
  };
  console.log('Looking for features between 40, -75 and 42, -73');
  var call = client.listFeatures(rectangle);
  call.on('data', function(feature) {
      console.log('Found feature called "' + feature.name + '" at ' +
          feature.location.latitude/COORD_FACTOR + ', ' +
          feature.location.longitude/COORD_FACTOR);
  });
  call.on('end', callback);
}
161310
function prepareData() {
            updateModifiedOn.call(this);
            convertGeoPoints.call(this);

            return this.entityData;

            //--------------------------

            /**
             * If the schema has a "modifiedOn" property we automatically
             * update its value to the current dateTime
            */
            function updateModifiedOn() {
                if ({}.hasOwnProperty.call(this.schema.paths, 'modifiedOn')) {
                    this.entityData.modifiedOn = new Date();
                }
            }

            /**
             * If the entityData has some property of type 'geoPoint'
             * and its value is an js object with "latitude" and "longitude"
             * we convert it to a datastore GeoPoint.
            */
            function convertGeoPoints() {
                if (!{}.hasOwnProperty.call(this.schema.__meta, 'geoPointsProps')) {
                    return;
                }

                this.schema.__meta.geoPointsProps.forEach((property) => {
                    if ({}.hasOwnProperty.call(_this.entityData, property)
                        && _this.entityData[property] !== null
                        && _this.entityData[property].constructor.name !== 'GeoPoint') {
                        _this.entityData[property] = _this.gstore.ds.geoPoint(_this.entityData[property]);
                    }
                });
            }
        }
677216
function select_geo($table, $latitude, $longitude, $radius = 0, $results = 0, $miles = true, $additional_where = false) {
		if (!empty($this->prefix) && !(substr_count($table,$this->prefix) > 0)) {
			$table = $this->prefix."_".$table;
        }
		$coord_cols = $this->geo_detect_coord_cols($table);

		$q = "SELECT *, (".($miles ? "3959" : "6371")." * acos(cos(radians(".$latitude.")) * cos(radians(".$this->lat_col.")) * cos(radians(".$this->lon_col.") - radians(".$longitude.")) + sin(radians(".$latitude.")) * sin(radians(".$this->lat_col.")))) AS distance FROM ".$this->encapsulate_column_name($table);

		if ($radius > 0) { $q .= " HAVING distance < ".$radius; }
		if ($additional_where !== false) { $q.= "WHERE $additional_where"; }
		$q .= " ORDER BY distance";
		if ($results > 0) { $q .= " LIMIT $results;"; }

		return $this->query($q);
	}
1095413
function mapRecord (type, record) {
  const keys = this.keys
  const uriTemplate = this.uriTemplate
  const recordTypes = this.recordTypes
  const fields = recordTypes[type]
  const options = this.options
  const prefix = options.prefix
  const inflectType = options.inflectType
  const inflectKeys = options.inflectKeys
  const clone = {}

  const id = record[keys.primary]

  clone[reservedKeys.type] = inflectType[type] ?
    inflection.transform(type, typeInflections[1]) : type
  clone[reservedKeys.id] = id.toString()
  clone[reservedKeys.meta] = {}
  clone[reservedKeys.attributes] = {}
  clone[reservedKeys.relationships] = {}
  clone[reservedKeys.links] = {
    [reservedKeys.self]: prefix + uriTemplate.fillFromObject({
      type: inflectType[type] ?
        inflection.transform(type, typeInflections[1]) : type,
      ids: id
    })
  }

  const unionFields = union(Object.keys(fields), Object.keys(record))

  for (let i = 0, j = unionFields.length; i < j; i++) {
    let field = unionFields[i]

    if (field === keys.primary) continue

    const fieldDefinition = fields[field]
    const hasField = field in record

    if (!hasField && !fieldDefinition[keys.link]) continue

    const originalField = field

    // Per the recommendation, dasherize keys.
    if (inflectKeys)
      field = inflection.transform(field,
        [ 'underscore', 'dasherize' ])

    // Handle meta/attributes.
    if (!fieldDefinition || fieldDefinition[keys.type]) {
      const value = record[originalField]

      if (!fieldDefinition) clone[reservedKeys.meta][field] = value
      else clone[reservedKeys.attributes][field] = value

      continue
    }

    // Handle link fields.
    const ids = record[originalField]

    const linkedType = inflectType[fieldDefinition[keys.link]] ?
      inflection.transform(fieldDefinition[keys.link], typeInflections[1]) :
      fieldDefinition[keys.link]

    clone[reservedKeys.relationships][field] = {
      [reservedKeys.links]: {
        [reservedKeys.self]: prefix + uriTemplate.fillFromObject({
          type: inflectType[type] ?
            inflection.transform(type, typeInflections[1]) : type,
          ids: id,
          relatedField: reservedKeys.relationships,
          relationship: inflectKeys ? inflection.transform(field,
            [ 'underscore', 'dasherize' ]) : field
        }),
        [reservedKeys.related]: prefix + uriTemplate.fillFromObject({
          type: inflectType[type] ?
            inflection.transform(type, typeInflections[1]) : type,
          ids: id,
          relatedField: inflectKeys ? inflection.transform(field,
            [ 'underscore', 'dasherize' ]) : field
        })
      }
    }

    if (hasField)
      clone[reservedKeys.relationships][field][reservedKeys.primary] =
        fieldDefinition[keys.isArray] ?
          ids.map(toIdentifier.bind(null, linkedType)) :
          (ids ? toIdentifier(linkedType, ids) : null)
  }

  if (!Object.keys(clone[reservedKeys.attributes]).length)
    delete clone[reservedKeys.attributes]

  if (!Object.keys(clone[reservedKeys.meta]).length)
    delete clone[reservedKeys.meta]

  if (!Object.keys(clone[reservedKeys.relationships]).length)
    delete clone[reservedKeys.relationships]

  return clone
}
1353846
public function getGeoSelectableFields() {
		$all = $this->owner->getSelectableFields(null, false);
		$listTypes = $this->owner->searchableTypes('Page');
		$geoFields = array();
		
		foreach ($listTypes as $classType) {
			$db = Config::inst()->get($classType, 'db');
			foreach ($db as $name => $type) {
				if (is_subclass_of($type, 'SolrGeoPoint') || $type == 'SolrGeoPoint') {
					$geoFields[$name] = $name;
				}
			}
		}

		ksort($geoFields);
		return $geoFields;
	}
1165962
function generateRecordElements(recordElements)
        {
            var elements = '';
            for(var key in recordElements){
                var recordElement = recordElements[key];
                if(recordElement.hasOwnProperty('value'))
                {
                    elements += format('<q1:{0}>{1}</q1:{0}>', key, recordElement.value);
                }
                else if(recordElement.hasOwnProperty('node'))
                {
                    elements += recordElement.node;
                }
            };

            return elements;
        }
932208
function (record) {
      var recordToSend = { object: record };

      recordToSend.columnValues = this.getRecordColumnValues(record);
      recordToSend.searchKeywords = this.getRecordKeywords(record);
      recordToSend.filterValues = this.getRecordFilterValues(record);
      recordToSend.color = this.getRecordColor(record);

      return recordToSend;
    }
1227521
public void setupSFields()
    {
        Record query = this.getMainRecord();
        for (int fieldSeq = query.getFieldSeq(FileHdr.FILE_NAME); fieldSeq < query.getFieldSeq(FileHdr.FILE_NOTES); fieldSeq++)
            query.getField(fieldSeq).setupFieldView(this);  // Add this view to the list
        for (int fieldSeq = query.getFieldSeq(FileHdr.FILE_NOTES)+1; fieldSeq < query.getFieldCount(); fieldSeq++)
            query.getField(fieldSeq).setupFieldView(this);  // Add this view to the list
        query.getField(FileHdr.FILE_NOTES).setupFieldView(this);    // Add this view to the list
    }
1172115
private void scanRecordsFields(String[] strClassNames)
    {
        for (int i = 1; i < strClassNames.length; i++)
        {
            this.scanRecordFields(strClassNames, i, markUnusedFields); // Keep unused base fields.
        }
//x        this.scanRecordFields(strClassNames[strClassNames.length -1], recClassInfo, recFieldData, true);
    }
463227
function display_add_field($recordid = 0, $formdata = null) {
        global $CFG, $DB, $OUTPUT;

        $lat = '';
        $long = '';
        if ($formdata) {
            $fieldname = 'field_' . $this->field->id . '_0';
            $lat = $formdata->$fieldname;
            $fieldname = 'field_' . $this->field->id . '_1';
            $long = $formdata->$fieldname;
        } else if ($recordid) {
            if ($content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) {
                $lat  = $content->content;
                $long = $content->content1;
            }
        }
        $str = '<div title="'.s($this->field->description).'">';
        $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
        $str .= '<table class="form-inline"><tr><td align="right">';
        $classes = 'mod-data-input form-control-static';
        $str .= '<label for="field_'.$this->field->id.'_0" class="' . $classes . '">' . get_string('latitude', 'data');
        if ($this->field->required) {
            $str .= $OUTPUT->pix_icon('req', get_string('requiredelement', 'form'));
        }
        $classes = 'form-control mx-1';
        $str .= '</label></td><td>';
        $str .= '<input class="' . $classes . '" type="text" name="field_'.$this->field->id.'_0" ';
        $str .= ' id="field_'.$this->field->id.'_0" value="';
        $str .= s($lat).'" size="10" />°N</td></tr>';
        $classes = 'mod-data-input form-control-static';
        $str .= '<tr><td align="right"><label for="field_'.$this->field->id.'_1" class="' . $classes . '">';
        $str .= get_string('longitude', 'data');
        if ($this->field->required) {
            $str .= $OUTPUT->pix_icon('req', get_string('requiredelement', 'form'));
        }
        $classes = 'form-control mx-1';
        $str .= '</label></td><td><input class="' . $classes . '" type="text" ';
        $str .= 'name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="';
        $str .= s($long).'" size="10" />°E</td>';
        $str .= '</tr>';
        $str .= '</table>';
        $str .= '</fieldset>';
        $str .= '</div>';
        return $str;
    }
542626
function (record, index) {
		var code = this.options.codeField ? L.Util.getFieldValue(record, this.options.codeField) : index;

		this._lookupIndex = this._lookupIndex || L.GeometryUtils.indexFeatureCollection(this.options.locationLookup, this.options.locationIndexField || this.options.codeField);

		var geoJSON = this._lookupIndex[code];
		var location = null;

		if (!geoJSON && code.indexOf('0') === 0) {
			geoJSON = this._lookupIndex[code.substring(1)];
		}

		if (geoJSON) {
			var me = this;
			var recordToLayer = function (location, record) {
				return me.recordToLayer(location, record);
			};

			location = L.GeometryUtils.getGeoJSONLocation(geoJSON, record, this.options.locationTextField, recordToLayer);
		}

		return location;
	}
915193
def ensureGeoIndex(self, fields) :
        """"""
        data = {
            "type" : "geo",
            "fields" : fields,
        }
        ind = Index(self, creationData = data)
        self.indexes["geo"][ind.infos["id"]] = ind
        return ind
475779
public Map<String,Object> getFieldData(Map<String,Object> properties)
    {
        Map<String, Object> propReturn = null;
        if (properties != null)
        {
            propReturn = new Hashtable<String, Object>();
            for (int i = 1; ; i++)
            {
                String strFieldNumber = DBParams.FIELD + Integer.toString(i);
                String strFieldName = (String)properties.get(strFieldNumber);
                if (strFieldName == null)
                    break;  // Done.
                Record record = this.getMainRecord();
                if (strFieldName.indexOf('.') != -1)
                {
                    record = this.getRecord(strFieldName.substring(0, strFieldName.indexOf('.')));
                    strFieldName = strFieldName.substring(strFieldName.indexOf('.') + 1);
                }
                BaseField field = null;
                if (record != null)
                    field = record.getField(strFieldName);
                if (field != null)
                    propReturn.put(strFieldNumber, field.getData());
            }
        }
        return propReturn;
    }
106769
def serialize_field_value_geolocalization
      return unless value
      value_object = eval(value)
      serialized = {}

      # add basic info
      serialized[:latitude] = value_object[:lat]
      serialized[:longitude] = value_object[:lng]
      serialized[:address] = value_object[:address]

      # return serialized data
      serialized
    end