2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Contains the factory class that handles the creation of geometric objects
6 * @package PhpMyAdmin-GIS
9 if (! defined('PHPMYADMIN')) {
14 * Factory class that handles the creation of geometric objects.
16 * @package PhpMyAdmin-GIS
21 * Returns the singleton instance of geometric class of the given type.
23 * @param string $type type of the geometric object
25 * @return PMA_GIS_Geometry the singleton instance of geometric class
31 public static function factory($type)
33 include_once './libraries/gis/GIS_Geometry.class.php';
35 $type_lower = strtolower($type);
36 $file = './libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php';
37 if (! PMA_isValid($type_lower, PMA_Util
::getGISDatatypes())
38 ||
! file_exists($file)
42 if (include_once $file) {
43 switch(strtoupper($type)) {
45 return PMA_GIS_Multipolygon
::singleton();
47 return PMA_GIS_Polygon
::singleton();
49 return PMA_GIS_Multipoint
::singleton();
51 return PMA_GIS_Point
::singleton();
52 case 'MULTILINESTRING' :
53 return PMA_GIS_Multilinestring
::singleton();
55 return PMA_GIS_Linestring
::singleton();
56 case 'GEOMETRYCOLLECTION' :
57 return PMA_GIS_Geometrycollection
::singleton();