Exemple de scripts en PHP 5

Géocodage

<h1>Geocoding service</h1>

<?php
// Display all errors:
error_reporting(E_ALL);
ini_set('display_errors', '1');

///////////////////////////////////////////////////////////////////////
///////////////////////////  CREATE REQUEST ///////////////////////////
///////////////////////////////////////////////////////////////////////

class AddressType{

   function __construct($countryCode,$city,$postalCode,$addressLine,$srs="epsg:4326",$maxResponses=2)  {
     $this->countryCode=$countryCode;
     $this->city=$city;
     $this->postalCode=$postalCode;
     $this->addressLine=$addressLine;
     $this->srs=$srs;
     $this->maxResponses=$maxResponses;
   }
};


$addressType=new AddressType("fr","Paris","75013","25 rue de Toldiac","wgs84");
$request=array(
  "geocode" => $addressType
);

///////////////////////////////////////////////////////////////////////
/////////////////////////////  CALL SOAP  /////////////////////////////
///////////////////////////////////////////////////////////////////////

try{
  $clientOptions=array(
    'trace'=>true,
    'exceptions'=>true,
    'encoding'=>'utf-8'
  );

  $client = new SoapClient('http://gcweb.geoconcept.com/gws/api/ws/geocodeService?wsdl', $clientOptions);


  echo "<h2>Request</h2>";
  echo "<pre>";
  var_dump($request);
  echo "</pre>";

  $response = $client->__soapCall("geocode",$request);


  echo "<h2>Response (initialAddress)</h2>";
  echo "<pre>";
  var_dump($response->GeocodeResult->initialAddress);
  echo "</pre>";

  echo "<h2>Response (geocodedAddress)</h2>";
  echo "<pre>";
  var_dump($response->GeocodeResult->geocodedAddress);
  echo "</pre>";
}
catch (SoapFault $e) {
  echo $e;
}
?>

Calcul d’itinéraire

<h1>Route service</h1>

<?php
// Display all errors:
error_reporting(E_ALL);
ini_set('display_errors', '1');

///////////////////////////////////////////////////////////////////////
///////////////////////////  CREATE REQUEST ///////////////////////////
///////////////////////////////////////////////////////////////////////

class RoutePointType {

  function __construct($x,$y)  {
    $this->x=$x;
    $this->y=$y;
  }
}

$step1=new RoutePointType(0.691012,47.384813);
$step2=new RoutePointType(0.693012,47.385813);

$route=array(
  "request" => array(
     "origin" => $step1,
     "destination" => $step2,
     "srs" => "epsg:4326",
     "method" => "time",
     "format" => "STANDARD",
     "rejectFlags" => array("Toll"),
     "tolerance" => array()
    )

);

$request=array(
   "route" => $route
);

///////////////////////////////////////////////////////////////////////
/////////////////////////////  CALL SOAP  /////////////////////////////
///////////////////////////////////////////////////////////////////////

try{
  $clientOptions=array(
    'trace'=>true,
    'exceptions'=>true,
    'encoding'=>'utf-8'
  );

  $client = new SoapClient('http://pouget/geoconcept-web/api/ws/routeService?wsdl', $clientOptions);


  echo "<h2>Request</h2>";
  echo "<pre>";
  var_dump($request);
  echo "</pre>";

  $response = $client->__soapCall("route",$request);

  echo "<h2>Response</h2>";
  echo "<pre>";
  var_dump($response);
  echo "</pre>";
}
catch (SoapFault $e) {
  echo $e;
}
?>

Search Around

<h1>SearchAround service</h1>

<?php
// Display all errors:
error_reporting(E_ALL);
ini_set('display_errors', '1');

///////////////////////////////////////////////////////////////////////
///////////////////////////  CREATE REQUEST ///////////////////////////
///////////////////////////////////////////////////////////////////////

class SearchAroundTargetType {

  function __construct($x,$y)  {
    $this->x=$x;
    $this->y=$y;
  }
}

class SearchAroundPointType {

  function __construct($x,$y,$id="",$priority1="",$priority2="")  {
    $this->x=$x;
    $this->y=$y;
    $this->id=$id;
    $this->priority1=$priority1;
    $this->priority2=$priority2;
  }
}

$target=new SearchAroundTargetType(-1.593927,47.218580);
$resource1=new SearchAroundPointType(-1.593927,47.188580,2,1,1);
$resource2=new SearchAroundPointType(-1.556927,47.188580,3,1,2);
$resource3=new SearchAroundPointType(-1.557927,47.189580,4,1,1);

$searchAround=array(
       "request" => array (
                "target" => $target,
                "method" => "time",
                "reverse"   => "",
                "srs" => "epsg:4326",
                 "exclusions" => array(),
                "resources" => array($resource1,$resource2,$resource3),
       )

);

$request = array("searchAround" => $searchAround);


///////////////////////////////////////////////////////////////////////
/////////////////////////////  CALL SOAP  /////////////////////////////
///////////////////////////////////////////////////////////////////////

try{
  $clientOptions=array(
    'trace'=>true,
    'exceptions'=>true,
    'encoding'=>'utf-8'
  );

  $client = new SoapClient('http://pouget/geoconcept-web/api/ws/searchAroundService?wsdl', $clientOptions);

  echo "<h2>Request</h2>";
  echo "<pre>";
  var_dump($request);
  echo "</pre>";

  $response = $client->__soapCall("searchAround",$request);

  echo "<h2>Response</h2>";
  echo "<pre>";
  var_dump($response);
  echo "</pre>";
}
catch (SoapFault $e) {
  echo $e;
}
?>