|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LaravelSpatial\Schema\Grammars; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Fluent; |
|
6
|
|
|
use LaravelSpatial\Schema\Blueprint; |
|
7
|
|
|
|
|
8
|
|
|
class PostgresGrammar extends \Illuminate\Database\Schema\Grammars\PostgresGrammar |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Adds a statement to add a point geometry column |
|
12
|
|
|
* |
|
13
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
14
|
|
|
* @return string |
|
15
|
|
|
*/ |
|
16
|
13 |
|
public function typePoint(Fluent $column) |
|
17
|
|
|
{ |
|
18
|
13 |
|
return 'GEOGRAPHY(POINT, 4326)'; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Adds a statement to add a point geometry column |
|
23
|
|
|
* |
|
24
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
25
|
|
|
* @return string |
|
26
|
|
|
*/ |
|
27
|
13 |
|
public function typeMultipoint(Fluent $column) |
|
28
|
|
|
{ |
|
29
|
13 |
|
return 'GEOGRAPHY(MULTIPOINT, 4326)'; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Adds a statement to add a polygon geometry column |
|
34
|
|
|
* |
|
35
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
13 |
|
public function typePolygon(Fluent $column) |
|
39
|
|
|
{ |
|
40
|
13 |
|
return 'GEOGRAPHY(POLYGON, 4326)'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Adds a statement to add a multipolygon geometry column |
|
45
|
|
|
* |
|
46
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
13 |
|
public function typeMultipolygon(Fluent $column) |
|
50
|
|
|
{ |
|
51
|
13 |
|
return 'GEOGRAPHY(MULTIPOLYGON, 4326)'; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Adds a statement to add a linestring geometry column |
|
56
|
|
|
* |
|
57
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
13 |
|
public function typeLinestring(Fluent $column) |
|
61
|
|
|
{ |
|
62
|
13 |
|
return 'GEOGRAPHY(LINESTRING, 4326)'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Adds a statement to add a multilinestring geometry column |
|
67
|
|
|
* |
|
68
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
13 |
|
public function typeMultilinestring(Fluent $column) |
|
72
|
|
|
{ |
|
73
|
13 |
|
return 'GEOGRAPHY(MULTILINESTRING, 4326)'; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Adds a statement to add a linestring geometry column |
|
78
|
|
|
* |
|
79
|
|
|
* @param \Illuminate\Support\Fluent $column |
|
80
|
|
|
* @return string |
|
81
|
|
|
*/ |
|
82
|
|
|
public function typeGeography(Fluent $column) |
|
83
|
|
|
{ |
|
84
|
|
|
return 'GEOGRAPHY'; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Adds a statement to add a geometry geometry column |
|
89
|
|
|
* |
|
90
|
|
|
* @param Fluent $column |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
13 |
|
public function typeGeometry(Fluent $column) |
|
94
|
|
|
{ |
|
95
|
13 |
|
return 'GEOGRAPHY(GEOMETRY, 4326)'; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Adds a statement to add a geometrycollection geometry column |
|
100
|
|
|
* |
|
101
|
|
|
* @param Fluent $column |
|
102
|
|
|
* @return string |
|
103
|
|
|
*/ |
|
104
|
13 |
|
public function typeGeometrycollection(Fluent $column) |
|
105
|
|
|
{ |
|
106
|
13 |
|
return 'GEOGRAPHY(GEOMETRYCOLLECTION, 4326)'; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Adds a statement to create the postgis extension |
|
111
|
|
|
* |
|
112
|
|
|
* @param Blueprint $blueprint |
|
113
|
|
|
* @param Fluent $command |
|
114
|
|
|
* @return string |
|
115
|
|
|
*/ |
|
116
|
1 |
|
public function compileEnablePostgis(Blueprint $blueprint, Fluent $command) |
|
117
|
|
|
{ |
|
118
|
1 |
|
return 'CREATE EXTENSION postgis'; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Adds a statement to drop the postgis extension |
|
123
|
|
|
* |
|
124
|
|
|
* @param Blueprint $blueprint |
|
125
|
|
|
* @param Fluent $command |
|
126
|
|
|
* @return string |
|
127
|
|
|
*/ |
|
128
|
1 |
|
public function compileDisablePostgis(Blueprint $blueprint, Fluent $command) |
|
129
|
|
|
{ |
|
130
|
1 |
|
return 'DROP EXTENSION postgis'; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|