23 || !isset($input[
'type'])
24 || !is_string($input[
'type'])
30 $method =
'arrayTo' . $input[
'type'];
32 return method_exists($this, $method)
33 ? $this->$method($input[
'coordinates'])
42 return $this->getArray($geometry);
49 private function getArray($geometry): array
52 'type' => $geometry->getGeometryType(),
53 'coordinates' => $geometry->asArray(),
61 private function arrayToPoint(array $array): Point
63 return new Point($array[1], $array[0]);
70 private function arrayToLineString(array $array): LineString
74 foreach ($array as $item)
76 $points[] = $this->arrayToPoint($item);
79 return new LineString($points);
86 private function arrayToPolygon(array $array): Polygon
90 foreach ($array as $item)
92 $lines[] = $this->arrayToLineString($item);
95 return new Polygon($lines);
102 private function arrayToMultiPoint(array $array): MultiPoint
106 foreach ($array as $item)
108 $points[] = $this->arrayToPoint($item);
111 return new MultiPoint($points);
118 private function arrayToMultiLineString(array $array): MultiLineString
122 foreach ($array as $item)
124 $lines[] = $this->arrayToLineString($item);
127 return new MultiLineString($lines);
134 private function arrayToMultiPolygon(array $array): MultiPolygon
138 foreach ($array as $item)
140 $polys[] = $this->arrayToPolygon($item);
143 return new MultiPolygon($polys);