forked from derickr/3angle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.php
More file actions
70 lines (66 loc) · 2.1 KB
/
Copy pathdisplay.php
File metadata and controls
70 lines (66 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
function format_response( $s, $showCheckIn )
{
$rets = array();
foreach( $s as $o )
{
$ret = array(
'type' => 'Feature',
'properties' => array( 'popupContent' => '', 'changed' => false ),
);
if ( isset( $o['possible'] ) )
{
$ret['properties']['changed'] = true;
}
if ( isset( $o[TAGS] ) ) {
$name = $content = ''; $image = false;
$classes = array();
foreach ( $o[TAGS] as $tagName => $value ) {
list( $tagName, $value ) = explode( '=', $value, 2 );
if ( $tagName == 'name' ) {
$name = $value;
} else if ( $tagName == 'title' ) {
$name = $value;
} else if ( $tagName == 'thumb_url' ) {
$ret['properties']['thumbUrl'] = preg_replace( '/_q\.jpg$/', '_s.jpg', $value );
$image = preg_replace( '/_q\.jpg$/', '_m.jpg', $value );
} else {
$content .= "<br/>{$tagName}: {$value}\n";
}
if ( in_array( $tagName, array( 'amenity', 'leisure', 'real_ale', 'real_cider' ) ) )
{
$classes[] = preg_replace( '/[^a-z0-9]/', '', $tagName . $value );
}
}
if ($image) {
$content = "<br/><div style='width: 240px'><img src='{$image}'/></div>";
}
else if ( $showCheckIn )
{
$content .= "<br/><form action='maps-3angle/checkin.php' method='post'><input type='hidden' name='object' value='{$o['_id']}'/><input type='submit' value='check in'/></form>";
}
$ret['properties']['name'] = $name;
if ( isset( $o['distance'] ) )
{
$ret['properties']['name'] .= "<br/>\n(". sprintf('%d m', $o['distance']) . ')';
}
if ( isset( $o['direction'] ) )
{
$ret['properties']['name'] .= sprintf("<br/> <small>%d°</small>", ( $o['direction'] + 360 ) % 360);
}
if ( isset( $o['dirLabel'] ) )
{
$ret['properties']['name'] .= sprintf(" <small>%s</small>", $o['dirLabel']);
}
$ret['properties']['classes'] = join( ' ', $classes );
$ret['properties']['popupContent'] = "<b>{$name}</b>" . $content;
if ( array_key_exists( 'score', $o ) )
{
$ret['properties']['score'] = $o['score'];
}
}
$ret['geometry'] = $o[LOC];
$rets[] = $ret;
}
return $rets;
}