Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "grimzy/laravel-mysql-spatial",
"name": "vahidalvandi/laravel-mysql-spatial",
"description": "MySQL spatial data types extension for Laravel.",
"scripts": {
"test": "phpunit -c phpunit.xml.dist",
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Factory implements \GeoIO\Factory
{
public function createPoint($dimension, array $coordinates, $srid = null)
{
return new Point($coordinates['y'], $coordinates['x']);
return new Point($coordinates['x'], $coordinates['y']);
}

public function createLineString($dimension, array $points, $srid = null)
Expand Down
2 changes: 1 addition & 1 deletion src/Types/LineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function fromJson($geoJson)

$set = [];
foreach ($geoJson->getCoordinates() as $coordinate) {
$set[] = new Point($coordinate[1], $coordinate[0]);
$set[] = new Point($coordinate[0], $coordinate[1]);
}

return new self($set);
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function fromJson($geoJson)
foreach ($geoJson->getCoordinates() as $coordinates) {
$points = [];
foreach ($coordinates as $coordinate) {
$points[] = new Point($coordinate[1], $coordinate[0]);
$points[] = new Point($coordinate[0], $coordinate[1]);
}
$set[] = new LineString($points);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function fromJson($geoJson)

$set = [];
foreach ($geoJson->getCoordinates() as $coordinate) {
$set[] = new Point($coordinate[1], $coordinate[0]);
$set[] = new Point($coordinate[0], $coordinate[1]);
}

return new self($set);
Expand Down
2 changes: 1 addition & 1 deletion src/Types/MultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function fromJson($geoJson)
foreach ($polygonCoordinates as $lineStringCoordinates) {
$points = [];
foreach ($lineStringCoordinates as $lineStringCoordinate) {
$points[] = new Point($lineStringCoordinate[1], $lineStringCoordinate[0]);
$points[] = new Point($lineStringCoordinate[0], $lineStringCoordinate[1]);
}
$lineStrings[] = new LineString($points);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Types/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public function setLng($lng)

public function toPair()
{
return $this->getLng().' '.$this->getLat();
return $this->getLat().' '.$this->getLng();
}

public static function fromPair($pair)
{
list($lng, $lat) = explode(' ', trim($pair, "\t\n\r \x0B()"));
list($lat,$lng) = explode(' ', trim($pair, "\t\n\r \x0B()"));

return new static((float) $lat, (float) $lng);
}
Expand All @@ -62,7 +62,7 @@ public static function fromString($wktArgument)

public function __toString()
{
return $this->getLng().' '.$this->getLat();
return $this->getLat().' '.$this->getLng();
}

/**
Expand All @@ -82,7 +82,7 @@ public static function fromJson($geoJson)

$coordinates = $geoJson->getCoordinates();

return new self($coordinates[1], $coordinates[0]);
return new self($coordinates[0], $coordinates[1]);
}

/**
Expand All @@ -92,6 +92,6 @@ public static function fromJson($geoJson)
*/
public function jsonSerialize()
{
return new GeoJsonPoint([$this->getLng(), $this->getLat()]);
return new GeoJsonPoint([$this->getLat(), $this->getLng()]);
}
}
2 changes: 1 addition & 1 deletion src/Types/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function fromJson($geoJson)
foreach ($geoJson->getCoordinates() as $coordinates) {
$points = [];
foreach ($coordinates as $coordinate) {
$points[] = new Point($coordinate[1], $coordinate[0]);
$points[] = new Point($coordinate[0], $coordinate[1]);
}
$set[] = new LineString($points);
}
Expand Down