-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgeofield.schemaorg.inc
More file actions
66 lines (60 loc) · 1.74 KB
/
geofield.schemaorg.inc
File metadata and controls
66 lines (60 loc) · 1.74 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
<?php
/**
* @file
* Provides hooks for integration with Schemaorg (https://www.drupal.org/project/schemaorg)
*/
/**
* Schema.org format.
*
* Formats shapes for output in metadata using Schema.org format. This is
* different from the WKT format provided by GeoGenerator, so just use a one
* off function.
*/
function geofield_schemaorg_shape($item) {
$output = '';
$bottom = $item['bottom'];
$left = $item['left'];
$right = $item['right'];
$top = $item['top'];
switch ($item['geo_type']) {
case 'polygon':
$output = $bottom . ',' . $left . ' ';
$output .= $bottom . ',' . $right . ' ';
$output .= $top . ',' . $right . ' ';
$output .= $top . ',' . $left . ' ';
$output .= $bottom . ',' . $left;
break;
case 'linestring':
$output = $bottom . ',' . $left . ' ';
$output .= $bottom . ',' . $right . ' ';
$output .= $top . ',' . $right . ' ';
$output .= $top . ',' . $left;
break;
}
return $output;
}
function _geofield_geo_types_options_callback() {
module_load_include('inc', 'geofield', 'libraries/geophp/geoPHP');
if (!class_exists('geoPHP')) {
return;
}
return geoPHP::geometryList();
}
/**
* Gets the a latlong property.
*/
function geofield_return_latlon($data, array $options, $name) {
if ((is_array($data) || (is_object($data) && $data instanceof ArrayAccess)) && !is_null($data['lat']) && !is_null($data['lon'])) {
return $data['lat'] . ',' . $data['lon'];
}
return NULL;
}
/**
* Gets the Schema.org formatted shape value.
*/
function geofield_return_schemaorg_shape($data, array $options, $name) {
if ((is_array($data) || (is_object($data) && $data instanceof ArrayAccess))) {
return geofield_schemaorg_shape($data);
}
return NULL;
}