GisFactory.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. declare(strict_types=1);
  9. namespace PhpMyAdmin\Gis;
  10. /**
  11. * Factory class that handles the creation of geometric objects.
  12. *
  13. * @package PhpMyAdmin-GIS
  14. */
  15. class GisFactory
  16. {
  17. /**
  18. * Returns the singleton instance of geometric class of the given type.
  19. *
  20. * @param string $type type of the geometric object
  21. *
  22. * @return GisMultiPolygon|GisPolygon|GisMultiPoint|GisPoint|GisMultiLineString|GisLineString|GisGeometryCollection|false the singleton instance of geometric class 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. }