<commit_before><?php
function modify_headers(&$headers) {
  $headers[] = array("LAT", "real");
  $headers[] = array("LON", "real");
}

function modify_data(&$data) {
  preg_match("/POINT \(([0-9\.]+) ([0-9\.]+)\)/", $data[2], $m);
  $data[] = $m[2];
  $data[] = $m[1];
}

$form_search_def = array(
  'OBJECTID' => array(
    'type' => 'hidden',
    'name' => 'OBJECTID',
    'filter_function' => <<<EOT
function(data, filter_value) {
  return (data == filter_value);
}
EOT
  ),
  'BAUMNUMMER' => array(
    'type' => 'text',
    'name' => 'Baumnummer',
    'sql_function' => function($v) {
      global $db;

      if(preg_match("/^([0-9]+)([0-9]{1})$/", $v, $m)) {
	return "BAUMNUMMER in (". $db->quote($m[1]." ".$m[2]). ", ". $db->quote("{$m[1]}{$m[2]}  ").")";
      }

      if(preg_match("/^([0-9]+) ?([0-9A-Za-z]+)?$/", $v, $m)) {
	if(!$m[2])
	  $m[2] = " ";
	$m[2] = strtoupper($m[2]);

	return "BAUMNUMMER=". $db->quote("{$m[1]} {$m[2]}");
      }

      return "BAUMNUMMER=". $db->quote($v);
    },
    'filter_function' => <<<EOT
function(data, filter_value) {
  if(!filter_value)
    return true;

  if(data == filter_value)
    return true;

  if(data == filter_value + "  ")
    return true;

  var m;
  if(m = filter_value.match(/^([0-9]+)([0-9]{1})$/))
    if(data == m[1] + " " + m[2])
      return true;

  return false;
}
EOT
  ),
  'location' => array(
    'type' => 'geolocation',
    'name' => "In der Umgebung von",
    'desc' => "Nur Bäume im Umkreis von max. 1km",
    'options' => array(
      'enableHighAccuracy' => true,
    ),
    'sql_function' => function($v) {
      global $db;

      // 0.0090 resp 0.0135 is approx. 1.5km at the center of Vienna, Austria
      $bbox = array(
	(float)$v['latitude'] - 0.0090,
	(float)$v['longitude'] - 0.0135,
	(float)$v['latitude'] + 0.0090,
	(float)$v['longitude'] + 0.0135
      );

      return array(
        'add_columns' => "distance(lat, lon, ". $db->quote($v['latitude']) .", ". $db->quote($v['longitude']) .") as distance",
	'order' => "distance asc",
	'where' => "distance <= 1000 and lat >= {$bbox[0]} and lon >= {$bbox[1]} and lat <= {$bbox[2]} and lon <= {$bbox[3]}",
      );
    },
  ),
);

$table_def = array(
  'BAUMNUMMER' => array(
    'name' => "Baum&shy;num&shy;mer",
    'link' => "?OBJECTID={{ OBJECTID }}",
  ),
  'GEBIET' => array(
    'name' => "Ge&shy;biet",
  ),
  'STRASSE' => array(
    'name' => "Straße / Park",
  ),
  'ART' => array(
    'name' => "Art",
  ),
  'PFLANZJAHR' => array(
    'name' => "Pflanz&shy;jahr",
    'format' => "{% if PFLANZJAHR %} {{ PFLANZJAHR }} {% endif %}",
  ),
  'STAMMUMFANG' => array(
    'name' => "Stamm&shy;um&shy;fang",
    'format' => "{{ STAMMUMFANG }} cm",
  ),
  'KRONENDURCHMESSER' => array(
    'name' => "Kro&shy;nen&shy;durch&shy;mes&shy;ser",
    'format' => "{{ KRONENDURCHMESSER }} m",
  ),
  'BAUMHOEHE' => array(
    'name' => "Baum&shy;höhe",
    'format' => "{{ BAUMHOEHE }} m",
  ),
  'geo' => array(
    'name' => "Koor&shy;dina&shy;ten",
    'format' => "<a target='_blank' href='http://www.openstreetmap.org/?mlat={{ LAT }}&amp;mlon={{ LON }}&zoom=18'>{{ LAT|number_format(5) }} {{ LON|number_format(5) }}</a>",
  ),
  'distance' => array(<commit_msg>Baum: changes to new OGD layout<commit_after><?php
function modify_headers(&$headers) {
  $headers[] = array("LAT", "real");
  $headers[] = array("LON", "real");
}

function modify_data(&$data) {
  preg_match("/POINT \(([0-9\.]+) ([0-9\.]+)\)/", $data[2], $m);
  $data[] = $m[2];
  $data[] = $m[1];
}

$form_search_def = array(
  'OBJECTID' => array(
    'type' => 'hidden',
    'name' => 'OBJECTID',
    'filter_function' => <<<EOT
function(data, filter_value) {
  return (data == filter_value);
}
EOT
  ),
  'BAUMNUMMER' => array(
    'type' => 'text',
    'name' => 'Baumnummer',
    'sql_function' => function($v) {
      global $db;

      return "BAUMNUMMER=". $db->quote($v);
    },
    'filter_function' => <<<EOT
function(data, filter_value) {
  if(!filter_value)
    return true;

  if(data == filter_value)
    return true;

  return false;
}
EOT
  ),
  'location' => array(
    'type' => 'geolocation',
    'name' => "In der Umgebung von",
    'desc' => "Nur Bäume im Umkreis von max. 1km",
    'options' => array(
      'enableHighAccuracy' => true,
    ),
    'sql_function' => function($v) {
      global $db;

      // 0.0090 resp 0.0135 is approx. 1.5km at the center of Vienna, Austria
      $bbox = array(
	(float)$v['latitude'] - 0.0090,
	(float)$v['longitude'] - 0.0135,
	(float)$v['latitude'] + 0.0090,
	(float)$v['longitude'] + 0.0135
      );

      return array(
        'add_columns' => "distance(lat, lon, ". $db->quote($v['latitude']) .", ". $db->quote($v['longitude']) .") as distance",
	'order' => "distance asc",
	'where' => "distance <= 1000 and lat >= {$bbox[0]} and lon >= {$bbox[1]} and lat <= {$bbox[2]} and lon <= {$bbox[3]}",
      );
    },
  ),
);

$table_def = array(
  'BAUMNUMMER' => array(
    'name' => "Baum&shy;num&shy;mer",
    'link' => "?OBJECTID={{ OBJECTID }}",
  ),
  'GEBIETSGRUPPE' => array(
    'name' => "Ge&shy;biet",
  ),
  'OBJEKT_STRASSE' => array(
    'name' => "Straße / Park",
  ),
  'GATTUNG_ART' => array(
    'name' => "Art",
  ),
  'PFLANZJAHR' => array(
    'name' => "Pflanz&shy;jahr",
    'format' => "{% if PFLANZJAHR != 0 %} {{ PFLANZJAHR }} {% endif %}",
  ),
  'STAMMUMFANG' => array(
    'name' => "Stamm&shy;um&shy;fang",
    'format' => "{% if STAMMUMFANG != 0 %}{{ STAMMUMFANG }} cm{% endif %}",
  ),
  'KRONENDURCHMESSER' => array(
    'name' => "Kro&shy;nen&shy;durch&shy;mes&shy;ser",
    'format' => "{% if KRONENDURCHMESSER == 0 %}{% elseif KRONENDURCHMESSER == 1 %}0-3 m{% elseif KRONENDURCHMESSER == 8 %}> 21 m{% else %}{{ KRONENDURCHMESSER * 3 - 2 }}-{{ KRONENDURCHMESSER * 3 }} m{% endif %}",
  ),
  'BAUMHOEHE' => array(
    'name' => "Baum&shy;höhe",
    'format' => "{% if BAUMHOEHE == 0 %}{% elseif BAUMHOEHE == 1 %}0-5 m{% elseif BAUMHOEHE == 8 %}> 35 m{% else %}{{ BAUMHOEHE * 5 - 4 }}-{{ BAUMHOEHE * 5 }} m{% endif %}",
  ),
  'geo' => array(
    'name' => "Koor&shy;dina&shy;ten",
    'format' => "<a target='_blank' href='http://www.openstreetmap.org/?mlat={{ LAT }}&amp;mlon={{ LON }}&zoom=18'>{{ LAT|number_format(5) }} {{ LON|number_format(5) }}</a>",
  ),
  'distance' => array(
{'fraction_non_alphanumeric': 0.2576745665659297, 'fraction_numerical': 0.024176872912358836, 'mean_word_length': 3.2717391304347827, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 110, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1941627', 'n_tokens_mistral': 2797, 'n_tokens_neox': 2656, 'n_words': 493}