src/External/Bag/Api/BagClient.php
public function geo($type, $id)
    {
      // Concat url
      $url = self::API_URL . '/' . $type . '/' . $id;

      // Create a REST request
      $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET);

      // Create a REST response
      $response = new \LibX\Net\Rest\Response();

      // Make the call
      $data = $this->call($request, $response);

      // Init
      $coordinates = null;

      // Get geo data
      if(isset($data->_embedded->geometrie))
      {
        $geo = $data->_embedded->geometrie;

        if($geo->type === 'Point')
        {
          $longitude = $geo->coordinates[0];
          $latitude = $geo->coordinates[1];

          $coordinates = new Coordinates($latitude, $longitude);
        }
        elseif($geo->type === 'Polygon')
        {
          $points = new PointStack();

          foreach($geo->coordinates[0] as $coordinates)
          {
            $longitude = $coordinates[0];
            $latitude = $coordinates[1];

            $points->push(new Coordinates($latitude, $longitude));
          }

          $coordinates = new Polygon($points);
        }
      }

      return $coordinates;
    }
public function geo($type, $id)
    {
      // Concat url
      $url = self::API_URL . '/' . $type . '/' . $id;

      // Create a REST request
      $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET);

      // Create a REST response
      $response = new \LibX\Net\Rest\Response();

      // Make the call
      $data = $this->call($request, $response);

      // Init
      $coordinates = null;

      // Get geo data
      if(isset($data->_embedded->geometrie))
      {
        $geo = $data->_embedded->geometrie;

        if($geo->type === 'Point')
        {
          $longitude = $geo->coordinates[0];
          $latitude = $geo->coordinates[1];

          $coordinates = new Coordinates($latitude, $longitude);
        }
        elseif($geo->type === 'Polygon')
        {
          $points = new PointStack();

          foreach($geo->coordinates[0] as $coordinates)
          {
            $longitude = $coordinates[0];
            $latitude = $coordinates[1];

            $points->push(new Coordinates($latitude, $longitude));
          }

          $coordinates = new Polygon($points);
        }
      }

      return $coordinates;
    }
public function geo ( $ type , $ id ) { // Concat url $ url = self :: API_URL . '/' . $ type . '/' . $ id ; // Create a REST request $ request = new \ LibX \ Net \ Rest \ Request ( $ url , \ LibX \ Net \ Rest \ Request :: REQUEST_METHOD_GET ) ; // Create a REST response $ response = new \ LibX \ Net \ Rest \ Response ( ) ; // Make the call $ data = $ this -> call ( $ request , $ response ) ; // Init $ coordinates = null ; // Get geo data if ( isset ( $ data -> _embedded -> geometrie ) ) { $ geo = $ data -> _embedded -> geometrie ; if ( $ geo -> type === 'Point' ) { $ longitude = $ geo -> coordinates [ 0 ] ; $ latitude = $ geo -> coordinates [ 1 ] ; $ coordinates = new Coordinates ( $ latitude , $ longitude ) ; } elseif ( $ geo -> type === 'Polygon' ) { $ points = new PointStack ( ) ; foreach ( $ geo -> coordinates [ 0 ] as $ coordinates ) { $ longitude = $ coordinates [ 0 ] ; $ latitude = $ coordinates [ 1 ] ; $ points -> push ( new Coordinates ( $ latitude , $ longitude ) ) ; } $ coordinates = new Polygon ( $ points ) ; } } return $ coordinates ; }
Retrieve BAG geo data

@param string $type
@param string $id
@return NULL|\LibX\Util\Coordinates
Retrieve BAG geo data