GIS_Factory.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Contains the factory class that handles the creation of geometric objects
  5. *
  6. * @package PhpMyAdmin-GIS
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Factory class that handles the creation of geometric objects.
  13. *
  14. * @package PhpMyAdmin-GIS
  15. */
  16. class PMA_GIS_Factory
  17. {
  18. /**
  19. * Returns the singleton instance of geometric class of the given type.
  20. *
  21. * @param string $type type of the geometric object
  22. *
  23. * @return PMA_GIS_Geometry the singleton instance of geometric class
  24. * of the given type
  25. *
  26. * @access public
  27. * @static
  28. */
  29. public static function factory($type)
  30. {
  31. include_once './libraries/gis/GIS_Geometry.class.php';
  32. $type_lower = strtolower($type);
  33. if (! file_exists('./libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php')) {
  34. return false;
  35. }
  36. if (include_once './libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php') {
  37. switch(strtoupper($type)) {
  38. case 'MULTIPOLYGON' :
  39. return PMA_GIS_Multipolygon::singleton();
  40. case 'POLYGON' :
  41. return PMA_GIS_Polygon::singleton();
  42. case 'MULTIPOINT' :
  43. return PMA_GIS_Multipoint::singleton();
  44. case 'POINT' :
  45. return PMA_GIS_Point::singleton();
  46. case 'MULTILINESTRING' :
  47. return PMA_GIS_Multilinestring::singleton();
  48. case 'LINESTRING' :
  49. return PMA_GIS_Linestring::singleton();
  50. case 'GEOMETRYCOLLECTION' :
  51. return PMA_GIS_Geometrycollection::singleton();
  52. default :
  53. return false;
  54. }
  55. } else {
  56. return false;
  57. }
  58. }
  59. }
  60. ?>