This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
/
simple_geo.install
87 lines (79 loc) · 1.9 KB
/
simple_geo.install
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
<?php
// $Id$
/**
* Install hook for simple geo
* We have to add our spatial columns manually in the install because the are unsupported by
* the schema api
*
* @return void
**/
function simple_geo_install() {
drupal_install_schema('simple_geo');
db_query("ALTER TABLE {simple_geo_area}
ADD COLUMN area POLYGON NOT NULL,
ADD SPATIAL INDEX area_index(area)");
db_query("ALTER TABLE {simple_geo_position}
ADD COLUMN position POINT NOT NULL,
ADD SPATIAL INDEX position_index(position)");
}
/**
* Uninstall hook for simple geo
*
* @return void
**/
function simple_geo_uninstall() {
drupal_uninstall_schema('simple_geo');
}
/**
* The base scheme for simple geo
* We have to add our spatial columns manually in the install because the are unsupported by
* the schema api
*
* @return array The database schema for simple_geo
**/
function simple_geo_schema() {
$schema['simple_geo_position'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['simple_geo_area'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['simple_geo_in_area'] = array(
'fields' => array(
'point_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'area_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'point' => array('point_nid'),
'area' => array('area_nid'),
),
'primary key' => array('point_nid', 'area_nid'),
);
return $schema;
}