diff --git a/composer.json b/composer.json index 3c22d1c2..6160bd17 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Types/Factory.php b/src/Types/Factory.php index 087348fa..7b95a8c5 100755 --- a/src/Types/Factory.php +++ b/src/Types/Factory.php @@ -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) diff --git a/src/Types/LineString.php b/src/Types/LineString.php index 02097edd..3b94f8ef 100644 --- a/src/Types/LineString.php +++ b/src/Types/LineString.php @@ -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); diff --git a/src/Types/MultiLineString.php b/src/Types/MultiLineString.php index dd3342fd..13166384 100644 --- a/src/Types/MultiLineString.php +++ b/src/Types/MultiLineString.php @@ -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); } diff --git a/src/Types/MultiPoint.php b/src/Types/MultiPoint.php index fb55f9e8..b4cf9a80 100644 --- a/src/Types/MultiPoint.php +++ b/src/Types/MultiPoint.php @@ -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); diff --git a/src/Types/MultiPolygon.php b/src/Types/MultiPolygon.php index aba2b6d1..9d97de9d 100644 --- a/src/Types/MultiPolygon.php +++ b/src/Types/MultiPolygon.php @@ -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); } diff --git a/src/Types/Point.php b/src/Types/Point.php index 40719af4..2ea1b614 100644 --- a/src/Types/Point.php +++ b/src/Types/Point.php @@ -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); } @@ -62,7 +62,7 @@ public static function fromString($wktArgument) public function __toString() { - return $this->getLng().' '.$this->getLat(); + return $this->getLat().' '.$this->getLng(); } /** @@ -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]); } /** @@ -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()]); } } diff --git a/src/Types/Polygon.php b/src/Types/Polygon.php index 9c10cecc..9860f6f9 100644 --- a/src/Types/Polygon.php +++ b/src/Types/Polygon.php @@ -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); }