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
|
|
|
public function typePoint(Fluent $column) |
17
|
|
|
{ |
18
|
|
|
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
|
|
|
public function typeMultipoint(Fluent $column) |
28
|
|
|
{ |
29
|
|
|
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
|
|
|
public function typePolygon(Fluent $column) |
39
|
|
|
{ |
40
|
|
|
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
|
|
|
public function typeMultipolygon(Fluent $column) |
50
|
|
|
{ |
51
|
|
|
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
|
|
|
public function typeLinestring(Fluent $column) |
61
|
|
|
{ |
62
|
|
|
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
|
|
|
public function typeMultilinestring(Fluent $column) |
72
|
|
|
{ |
73
|
|
|
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
|
|
|
public function typeGeometry(Fluent $column) |
94
|
|
|
{ |
95
|
|
|
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
|
|
|
public function typeGeometrycollection(Fluent $column) |
105
|
|
|
{ |
106
|
|
|
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
|
|
|
public function compileEnablePostgis(Blueprint $blueprint, Fluent $command) |
117
|
|
|
{ |
118
|
|
|
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
|
|
|
public function compileDisablePostgis(Blueprint $blueprint, Fluent $command) |
129
|
|
|
{ |
130
|
|
|
return 'DROP EXTENSION postgis'; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|