Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Added support for separation between geometry and geography types #30545

Merged
merged 7 commits into from
Nov 14, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ protected function typeMacAddress(Fluent $column)
*/
protected function typeGeometry(Fluent $column)
{
return $this->formatPostGisType('geometry');
return $this->formatPostGisType('geometry', $column);
}

/**
Expand All @@ -799,7 +799,7 @@ protected function typeGeometry(Fluent $column)
*/
protected function typePoint(Fluent $column)
{
return $this->formatPostGisType('point');
return $this->formatPostGisType('point', $column);
}

/**
Expand All @@ -810,7 +810,7 @@ protected function typePoint(Fluent $column)
*/
protected function typeLineString(Fluent $column)
{
return $this->formatPostGisType('linestring');
return $this->formatPostGisType('linestring', $column);
}

/**
Expand All @@ -821,7 +821,7 @@ protected function typeLineString(Fluent $column)
*/
protected function typePolygon(Fluent $column)
{
return $this->formatPostGisType('polygon');
return $this->formatPostGisType('polygon', $column);
}

/**
Expand All @@ -832,7 +832,7 @@ protected function typePolygon(Fluent $column)
*/
protected function typeGeometryCollection(Fluent $column)
{
return $this->formatPostGisType('geometrycollection');
return $this->formatPostGisType('geometrycollection', $column);
}

/**
Expand All @@ -843,7 +843,7 @@ protected function typeGeometryCollection(Fluent $column)
*/
protected function typeMultiPoint(Fluent $column)
{
return $this->formatPostGisType('multipoint');
return $this->formatPostGisType('multipoint', $column);
}

/**
Expand All @@ -854,7 +854,7 @@ protected function typeMultiPoint(Fluent $column)
*/
public function typeMultiLineString(Fluent $column)
{
return $this->formatPostGisType('multilinestring');
return $this->formatPostGisType('multilinestring', $column);
}

/**
Expand All @@ -865,7 +865,7 @@ public function typeMultiLineString(Fluent $column)
*/
protected function typeMultiPolygon(Fluent $column)
{
return $this->formatPostGisType('multipolygon');
return $this->formatPostGisType('multipolygon', $column);
}

/**
Expand All @@ -876,18 +876,27 @@ protected function typeMultiPolygon(Fluent $column)
*/
protected function typeMultiPolygonZ(Fluent $column)
{
return $this->formatPostGisType('multipolygonz');
return $this->formatPostGisType('multipolygonz', $column);
}

/**
* Format the column definition for a PostGIS spatial type.
*
* @param string $type
* @param Fluent $column
* @return string
*/
private function formatPostGisType(string $type)
private function formatPostGisType(string $type, Fluent $column)
{
return "geography($type, 4326)";
if (is_null($column->geography)) {
raymondtri marked this conversation as resolved.
Show resolved Hide resolved
if (is_null($column->projection)) {
return "geometry($type)";
} else {
return "geometry($type, $projection)";
}
} else {
return "geography($type, ".(is_null($column->projection) ? '4326' : $column->projection).')';
}
}

/**
Expand Down