Source for file openstreetmap.php

Documentation is available at openstreetmap.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Openstreetmap
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die();
  11.  
  12. /**
  13.  * Joomla Platform class for interact with Openstreetmap API.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Openstreetmap
  17.  * @since       13.1
  18.  */
  19. {
  20.     /**
  21.      * Options for the Openstreetmap object.
  22.      *
  23.      * @var    JRegistry 
  24.      * @since  13.1
  25.      */
  26.     protected $options;
  27.  
  28.     /**
  29.      * The HTTP client object to use in sending HTTP requests.
  30.      *
  31.      * @var    JHttp 
  32.      * @since  13.1
  33.      */
  34.     protected $client;
  35.  
  36.     /**
  37.      * The OAuth client.
  38.      *
  39.      * @var   JOpenstreetmapOauth 
  40.      * @since 13.1
  41.      */
  42.     protected $oauth;
  43.  
  44.     /**
  45.      * Openstreetmap API object for changesets.
  46.      *
  47.      * @var    JOpenstreetmapChangesets 
  48.      * @since  13.1
  49.      */
  50.     protected $changesets;
  51.  
  52.     /**
  53.      * Openstreetmap API object for elements.
  54.      *
  55.      * @var    JOpenstreetmapElements 
  56.      * @since  13.1
  57.      */
  58.     protected $elements;
  59.  
  60.     /**
  61.      * Openstreetmap API object for GPS.
  62.      *
  63.      * @var   JOpenstreetmapGps 
  64.      * @since  13.1
  65.      */
  66.     protected $gps;
  67.  
  68.     /**
  69.      * Openstreetmap API object for info.
  70.      *
  71.      * @var    JOpenstreetmapInfo 
  72.      * @since  13.1
  73.      */
  74.     protected $info;
  75.  
  76.     /**
  77.      * Openstreetmap API object for user.
  78.      *
  79.      * @var    JOpenstreetmapUser 
  80.      * @since  13.1
  81.      */
  82.     protected $user;
  83.  
  84.     /**
  85.      * Constructor.
  86.      *
  87.      * @param   JOpenstreetmapOauth  $oauth    Openstreetmap oauth client
  88.      * @param   JRegistry            $options  Openstreetmap options object
  89.      * @param   JHttp                $client   The HTTP client object
  90.      *
  91.      * @since   13.1
  92.      */
  93.     public function __construct(JOpenstreetmapOauth $oauth nullJRegistry $options nullJHttp $client null)
  94.     {
  95.         $this->oauth = $oauth;
  96.         $this->options = isset($options$options new JRegistry;
  97.         $this->client  = isset($client$client new JHttp($this->options);
  98.  
  99.         // Setup the default API url if not already set.
  100.         $this->options->def('api.url''http://api.openstreetmap.org/api/0.6/');
  101.  
  102.         // $this->options->def('api.url', 'http://api06.dev.openstreetmap.org/api/0.6/');
  103.     }
  104.  
  105.     /**
  106.      * Method to get object instances
  107.      *
  108.      * @param   string  $name  Name of property to retrieve
  109.      *
  110.      * @return  JOpenstreetmapObject  Openstreetmap API object
  111.      *
  112.      * @since   13.1
  113.      * @throws  InvalidArgumentException
  114.      */
  115.     public function __get($name)
  116.     {
  117.         $class 'JOpenstreetmap' ucfirst($name);
  118.  
  119.         if (class_exists($class))
  120.         {
  121.             if (false == isset($this->$name))
  122.             {
  123.                 $this->$name new $class($this->options$this->client$this->oauth);
  124.             }
  125.  
  126.             return $this->$name;
  127.         }
  128.  
  129.         throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s'$name$class));
  130.     }
  131.  
  132.     /**
  133.      * Get an option from the JOpenstreetmap instance.
  134.      *
  135.      * @param   string  $key  The name of the option to get.
  136.      *
  137.      * @return  mixed  The option value.
  138.      *
  139.      * @since   13.1
  140.      */
  141.     public function getOption($key)
  142.     {
  143.         return $this->options->get($key);
  144.     }
  145.  
  146.     /**
  147.      * Set an option for the Openstreetmap instance.
  148.      *
  149.      * @param   string  $key    The name of the option to set.
  150.      * @param   mixed   $value  The option value to set.
  151.      *
  152.      * @return  JOpenstreetmap  This object for method chaining.
  153.      *
  154.      * @since   13.1
  155.      */
  156.     public function setOption($key$value)
  157.     {
  158.         $this->options->set($key$value);
  159.  
  160.         return $this;
  161.     }
  162. }

Documentation generated on Tue, 19 Nov 2013 15:09:49 +0100 by phpDocumentor 1.4.3