Skip to content

Commit 90b5569

Browse files
committed
Merge pull request #8 from amenadiel/feature/multipolygon_merge
Feature/multipolygon merge
2 parents 50e0a12 + 4aed301 commit 90b5569

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2012 Derek J. Lambert
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
namespace CrEOF\Spatial\DBAL\Types\Geometry;
25+
26+
use CrEOF\Spatial\DBAL\Types\GeometryType;
27+
use CrEOF\Spatial\PHP\Types\Geometry\GeometryInterface;
28+
29+
/**
30+
* Doctrine MULTIPOLYGON type
31+
*
32+
* @author Derek J. Lambert <dlambert@dereklambert.com>
33+
* @license http://dlambert.mit-license.org MIT
34+
*/
35+
class MultiPolygonType extends GeometryType
36+
{
37+
/**
38+
* {@inheritdoc}
39+
*/
40+
public function getSQLType()
41+
{
42+
return GeometryInterface::MULTIPOLYGON;
43+
}
44+
}

lib/CrEOF/Spatial/PHP/Types/AbstractGeometry.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,22 @@ private function toStringMultiPolygon(array $multiPolygon)
284284

285285
return implode(',', $strings);
286286
}
287+
288+
/**
289+
* @param array[] $multipolygon
290+
*
291+
* @return string
292+
*/
293+
private function toStringMultiPolygon(array $polygons)
294+
{
295+
// return $this->toStringMultiLineString($polygon);
296+
297+
$strings = null;
298+
299+
foreach ($polygons as $polygon) {
300+
$strings[] = '(' . $this->toStringPolygon($polygon) . ')';
301+
}
302+
303+
return implode(',', $strings);
304+
}
287305
}

lib/CrEOF/Spatial/PHP/Types/AbstractMultiPolygon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
abstract class AbstractMultiPolygon extends AbstractGeometry
3636
{
3737
/**
38-
* @var array[] $polygons
38+
* @var AbstractPolygon[]
3939
*/
4040
protected $polygons = array();
4141

lib/CrEOF/Spatial/PHP/Types/Geometry/MultiPolygon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use CrEOF\Spatial\PHP\Types\AbstractMultiPolygon;
2727

2828
/**
29-
* Polygon object for POLYGON geometry type
29+
* Polygon object for MULTIPOLYGON geometry type
3030
*
3131
* @author Derek J. Lambert <dlambert@dereklambert.com>
3232
* @license http://dlambert.mit-license.org MIT

0 commit comments

Comments
 (0)