GisFactory.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. namespace PhpMyAdmin\Gis;
  9. /**
  10. * Factory class that handles the creation of geometric objects.
  11. *
  12. * @package PhpMyAdmin-GIS
  13. */
  14. class GisFactory
  15. {
  16. /**
  17. * Returns the singleton instance of geometric class of the given type.
  18. *
  19. * @param string $type type of the geometric object
  20. *
  21. * @return GisGeometry the singleton instance of geometric class
  22. * of the given type
  23. *
  24. * @access public
  25. * @static
  26. */
  27. public static function factory($type)
  28. {
  29. switch (strtoupper($type)) {
  30. case 'MULTIPOLYGON' :
  31. return GisMultiPolygon::singleton();
  32. case 'POLYGON' :
  33. return GisPolygon::singleton();
  34. case 'MULTIPOINT' :
  35. return GisMultiPoint::singleton();
  36. case 'POINT' :
  37. return GisPoint::singleton();
  38. case 'MULTILINESTRING' :
  39. return GisMultiLineString::singleton();
  40. case 'LINESTRING' :
  41. return GisLineString::singleton();
  42. case 'GEOMETRYCOLLECTION' :
  43. return GisGeometryCollection::singleton();
  44. default :
  45. return false;
  46. }
  47. }
  48. }