Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates a Validator class to help validate various elements. Currently just a static class that better validates WKT geometry types fixes #314 and #288
- Loading branch information
Wayne Graham
authored and
Eric Rochester
committed
Jul 16, 2014
1 parent
cccdb8d
commit 81bf1eb
Showing
4 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Helper classes for validations | ||
* | ||
* @category Utilities | ||
* @package Omeka | ||
* @subpackage Neatline | ||
* @author Scholars' Lab <scholarslab@virginia.edu> | ||
* @copyright 2014 Rector and Board of Visitors, University of Virginia | ||
* @license http://www.apache.org/licenses/LICENSE-2.0.html Apache 2 | ||
*/ | ||
class Validator | ||
{ | ||
/** | ||
* Tests if a given string contains valid WKT | ||
* | ||
* @param string $coverage Coverage string to test | ||
* | ||
* @return boolean if the string is found | ||
*/ | ||
static function isValidWkt($coverage) | ||
{ | ||
return (bool) preg_match( | ||
'#(point|linestring|polygon|multipoint|multilinestring|multipolygon|geometrycollection)#', | ||
strtolower($coverage) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* @package omeka | ||
* @subpackage neatline | ||
* @copyright 2014 Rector and Board of Visitors, University of Virginia | ||
* @license http://www.apache.org/licenses/LICENSE-2.0.html | ||
*/ | ||
|
||
class HelpersTest_Coverage extends Neatline_Case_Default | ||
{ | ||
/** | ||
* `nl_explode` should split on ','. | ||
*/ | ||
public function testExtractValueWKT() | ||
{ | ||
$this->assertNotNull(nl_extractWkt('POINT (13 42)')); | ||
} | ||
|
||
public function testIgnoreNonWKT() | ||
{ | ||
$this->assertNull(nl_extractWkt('Paris')); | ||
} | ||
} |