-
Notifications
You must be signed in to change notification settings - Fork 7
/
islandora_simple_map.api.php
94 lines (87 loc) · 2.37 KB
/
islandora_simple_map.api.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @file
* Hook definition.
*/
/**
* Get coordinates from places other than MODS and return them.
*
* @param AbstractObject $object
* The Islandora object.
*
* @return array
* Array of coordinates.
*/
function hook_islandora_simple_map_get_coordinates(AbstractObject $object) {
if (isset($object['coordinates'])) {
$datastream_content = trim($object['coordinates']->content);
$coordinates = array();
$temporary_array = explode(';', $datastream_content);
foreach ($temporary_array as $coord) {
$coordinates[] = $coord;
}
return $coordinates;
}
}
/**
* Register a function to parse a type of coordinate.
*
* @return array
* Associative array with the format below.
* array(
* 'function_name' => 'name of function to call',
* 'file' => 'path to file to include for accessing above function.',
* 'weight' => 'positive integer for setting an order',
* );
*
* The callable 'function_name' takes an array of coordinates and returns an
* associative array where the key is the original coordinate and the value is
* the parsed version.
*/
function hook_islandora_simple_map_parse_coordinates_callback() {
return array(
'my_module_implementation' => array(
'function_name' => 'islandora_test_parse_coordinates',
'file' => drupal_get_path('module', 'islandora_simple_map') .
'includes/test_functions.inc',
'weight' => 100,
),
);
}
/**
* Get GeoJSON Feature objects for rendering on a map for the given object.
*
* @param AbstractObject $object
* The object for which to gather GeoJSON Features.
*
* @return array
* An array of GeoJSON Features.
*
* @see http://geojson.org/geojson-spec.html#feature-objects
*/
function hook_islandora_simple_map_get_geojson(AbstractObject $object) {
$geojson = array();
$geojson[] = array(
'type' => 'Feature',
'geometry' => array(
'type' => 'Point',
'coordinates' => array(
-63.1245071,
46.2350236,
),
),
);
return $geojson;
}
/**
* Permit altering of GeoJSON hook values.
*
* @param array $geojson
* A reference to the array of GeoJSON features gathered.
* @param AbstractObject $object
* The object for which GeoJSON is being gathered.
*
* @see hook_islandora_gmap_get_geojson()
*/
function hook_islandora_simple_map_get_geojson_alter(array &$geojson, AbstractObject $object) {
}