/**
  * Checks the bound getter & setter
  */
 public function testBound()
 {
     $boundTest = new Bound();
     $boundTest->setSouthWest(new Coordinate(-1, -1, true));
     $boundTest->setNorthEast(new Coordinate(1, 1, true));
     self::$object->setBound($boundTest);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLatitude(), -1);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLongitude(), -1);
     $this->assertTrue(self::$object->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLatitude(), 1);
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLongitude(), 1);
     $this->assertTrue(self::$object->getBound()->getNorthEast()->isNoWrap());
     $southWestTest = new Coordinate(-2.1, -2.1, false);
     $northEastTest = new Coordinate(2.1, 2.1, false);
     self::$object->setBound($southWestTest, $northEastTest);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLatitude(), -2.1);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLongitude(), -2.1);
     $this->assertFalse(self::$object->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLatitude(), 2.1);
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLongitude(), 2.1);
     $this->assertFalse(self::$object->getBound()->getNorthEast()->isNoWrap());
     self::$object->setBound(-3.1, -3.1, 3.1, 3.1, true, false);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLatitude(), -3.1);
     $this->assertEquals(self::$object->getBound()->getSouthWest()->getLongitude(), -3.1);
     $this->assertTrue(self::$object->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLatitude(), 3.1);
     $this->assertEquals(self::$object->getBound()->getNorthEast()->getLongitude(), 3.1);
     $this->assertFalse(self::$object->getBound()->getNorthEast()->isNoWrap());
     $boundTest = new Bound();
     $this->setExpectedException('InvalidArgumentException');
     self::$object->setBound($boundTest);
     $this->setExpectedException('InvalidArgumentException');
     self::$object->setBound('foo');
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $boundTest = new Bound();
     $boundTest->setSouthWest(-1.1, -2.1, true);
     $boundTest->setNorthEast(1.1, 2.1, true);
     $overviewPolyline = new EncodedPolyline('value');
     self::$directionsRoute = new DirectionsRoute($boundTest, 'copyrights', array(), $overviewPolyline, 'summary', array(), array());
 }
 /**
  * Checks the render method
  */
 public function testRender()
 {
     $boundTest = new Bound();
     $this->assertEquals(self::$boundHelper->render($boundTest), 'var ' . $boundTest->getJavascriptVariable() . ' = new google.maps.LatLngBounds();' . PHP_EOL);
     $boundTest = new Bound();
     $boundTest->setSouthWest(new Coordinate(-1.1, -2.1, false));
     $boundTest->setNorthEast(new Coordinate(1.1, 2.1, true));
     $this->assertEquals(self::$boundHelper->render($boundTest), 'var ' . $boundTest->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, false), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL);
 }
 /**
  * Checks the routes getter & setter
  */
 public function testRoutes()
 {
     $this->assertEquals(count(self::$directionsResponse->getRoutes()), 0);
     $boundTest = new Bound();
     $boundTest->setSouthWest(-1.1, -2.1, true);
     $boundTest->setNorthEast(1.1, 2.1, true);
     $overviewPolyline = new EncodedPolyline('value');
     $directionsRouteTest = new DirectionsRoute($boundTest, 'copyrights', array(), $overviewPolyline, 'summary', array(), array());
     self::$directionsResponse->addRoute($directionsRouteTest);
     $this->assertEquals(count(self::$directionsResponse->getRoutes()), 1);
 }
 /**
  * Checks the render method
  */
 public function testRender()
 {
     $mapTest = new Map();
     $rectangleTest = new Rectangle();
     $boundTest = new Bound();
     $boundTest->setSouthWest(new Coordinate(-1.1, -2.1, true));
     $boundTest->setNorthEast(new Coordinate(1.1, 2.1, true));
     $rectangleTest->setBound($boundTest);
     $this->assertEquals(self::$rectangleHelper->render($rectangleTest, $mapTest), 'var ' . $rectangleTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . 'var ' . $rectangleTest->getJavascriptVariable() . ' = new google.maps.Rectangle({"map":' . $mapTest->getJavascriptVariable() . ',"bounds":' . $rectangleTest->getBound()->getJavascriptVariable() . '});' . PHP_EOL);
     $rectangleTest->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $this->assertEquals(self::$rectangleHelper->render($rectangleTest, $mapTest), 'var ' . $rectangleTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . 'var ' . $rectangleTest->getJavascriptVariable() . ' = new google.maps.Rectangle({"map":' . $mapTest->getJavascriptVariable() . ',"bounds":' . $rectangleTest->getBound()->getJavascriptVariable() . ',"option1":"value1","option2":"value2"});' . PHP_EOL);
 }
 /**
  * Checks the results getter & setter
  */
 public function testResults()
 {
     $addressComponentsTest = array(new GeocoderAddressComponent('long_name_1', 'short_name_1', array('type_1', 'type_2')), new GeocoderAddressComponent('long_name_2', 'short_name_2', array('type_3', 'type_4')));
     $viewportTest = new Bound();
     $viewportTest->setSouthWest(-1.1, -2.1, true);
     $viewportTest->setNorthEast(2.1, 1.1, true);
     $boundTest = new Bound();
     $boundTest->setSouthWest(-5.1, -4.1, true);
     $boundTest->setNorthEast(4.1, 5.1, true);
     $geometryTest = new GeocoderGeometry(new Coordinate(1.2, 2.1, true), GeocoderLocationType::APPROXIMATE, $viewportTest, $boundTest);
     self::$geocoderResponse->addResult(new GeocoderResult($addressComponentsTest, 'address', $geometryTest, array('type_1', 'type_2'), true));
     $this->assertEquals(count(self::$geocoderResponse->getResults()), 2);
 }
 /**
  * Checks the bound getter & setter
  */
 public function testBound()
 {
     $southWestCoordinateTest = new Coordinate(-1, -1, true);
     $northEastCoordinateTest = new Coordinate(1, 1, true);
     $boundTest = new Bound();
     $boundTest->setSouthWest($southWestCoordinateTest);
     $boundTest->setNorthEast($northEastCoordinateTest);
     self::$geocoderRequest->setBound($boundTest);
     $this->assertTrue(self::$geocoderRequest->hasBound());
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLatitude(), -1);
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLongitude(), -1);
     $this->assertTrue(self::$geocoderRequest->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLatitude(), 1);
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLongitude(), 1);
     $this->assertTrue(self::$geocoderRequest->getBound()->getNorthEast()->isNoWrap());
     self::$geocoderRequest->setBound($southWestCoordinateTest, $northEastCoordinateTest);
     $this->assertTrue(self::$geocoderRequest->hasBound());
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLatitude(), -1);
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLongitude(), -1);
     $this->assertTrue(self::$geocoderRequest->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLatitude(), 1);
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLongitude(), 1);
     $this->assertTrue(self::$geocoderRequest->getBound()->getNorthEast()->isNoWrap());
     self::$geocoderRequest->setBound(-2, -2, 2, 2, true, true);
     $this->assertTrue(self::$geocoderRequest->hasBound());
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLatitude(), -2);
     $this->assertEquals(self::$geocoderRequest->getBound()->getSouthWest()->getLongitude(), -2);
     $this->assertTrue(self::$geocoderRequest->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLatitude(), 2);
     $this->assertEquals(self::$geocoderRequest->getBound()->getNorthEast()->getLongitude(), 2);
     $this->assertTrue(self::$geocoderRequest->getBound()->getNorthEast()->isNoWrap());
     self::$geocoderRequest->setBound(null);
     $this->assertFalse(self::$geocoderRequest->hasBound());
     $this->setExpectedException('InvalidArgumentException');
     self::$geocoderRequest->setBound('foo');
 }
 /**
  * Checks the render bound method
  */
 public function testRenderBound()
 {
     $mapTest = new Model\Map();
     $boundTest = new Base\Bound();
     $boundTest->setSouthWest(-1.1, 2.1, true);
     $boundTest->setNorthEast(1.1, 2.1, true);
     $mapTest->setBound($boundTest);
     $this->assertEquals(self::$mapHelper->renderBound($mapTest), 'var ' . $mapTest->getBound()->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, 2.1, true), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL . $mapTest->getJavascriptVariable() . '.fitBounds(' . $mapTest->getBound()->getJavascriptVariable() . ');' . PHP_EOL);
 }
 /**
  * Build geocoder geometry with the given normalized geocoding geometry given
  *
  * @param \stdClass $geocoderGeometry
  * @return Ivory\GoogleMapBundle\Model\Services\Geocoding\Result\GeocoderGeometry 
  */
 protected function buildGeocoderGeometry(\stdClass $geocoderGeometry)
 {
     $location = new Coordinate($geocoderGeometry->location->lat, $geocoderGeometry->location->lng);
     $locationType = $geocoderGeometry->location_type;
     $viewport = new Bound();
     $viewport->setNorthEast($geocoderGeometry->viewport->northeast->lat, $geocoderGeometry->viewport->northeast->lng);
     $viewport->setSouthWest($geocoderGeometry->viewport->southwest->lat, $geocoderGeometry->viewport->southwest->lng);
     if (isset($geocoderGeometry->bounds)) {
         $bound = new Bound();
         $bound->setNorthEast($geocoderGeometry->bounds->northeast->lat, $geocoderGeometry->bounds->northeast->lng);
         $bound->setSouthWest($geocoderGeometry->bounds->southwest->lat, $geocoderGeometry->bounds->southwest->lng);
     } else {
         $bound = null;
     }
     return new Result\GeocoderGeometry($location, $locationType, $viewport, $bound);
 }
 /**
  * Checks the bound getter & setter
  */
 public function testBound()
 {
     $boundTest = new Bound();
     $boundTest->setSouthWest(-4.1, -8.1, false);
     $boundTest->setNorthEast(7.1, 3.1, true);
     self::$geocoderGeometry->setBound($boundTest);
     $this->assertEquals(self::$geocoderGeometry->getBound()->getSouthWest()->getLatitude(), -4.1);
     $this->assertEquals(self::$geocoderGeometry->getBound()->getSouthWest()->getLongitude(), -8.1);
     $this->assertFalse(self::$geocoderGeometry->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderGeometry->getBound()->getNorthEast()->getLatitude(), 7.1);
     $this->assertEquals(self::$geocoderGeometry->getBound()->getNorthEast()->getLongitude(), 3.1);
     $this->assertTrue(self::$geocoderGeometry->getBound()->getNorthEast()->isNoWrap());
 }
 /**
  * Checks the geometry getter & setter
  */
 public function testGeometry()
 {
     $viewportTest = new Bound();
     $viewportTest->setSouthWest(-1, -2, true);
     $viewportTest->setNorthEast(2, 1, true);
     $boundTest = new Bound();
     $boundTest->setSouthWest(-5, -4, true);
     $boundTest->setNorthEast(4, 5, true);
     self::$geocoderResult->setGeometry(new GeocoderGeometry(new Coordinate(1, 2, true), GeocoderLocationType::APPROXIMATE, $viewportTest, $boundTest));
     $this->assertEquals(self::$geocoderResult->getGeometry()->getLocation()->getLatitude(), 1);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getLocation()->getLongitude(), 2);
     $this->assertTrue(self::$geocoderResult->getGeometry()->getLocation()->isNoWrap());
     $this->assertEquals(self::$geocoderResult->getGeometry()->getLocationType(), GeocoderLocationType::APPROXIMATE);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getViewport()->getSouthWest()->getLatitude(), -1);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getViewport()->getSouthWest()->getLongitude(), -2);
     $this->assertTrue(self::$geocoderResult->getGeometry()->getViewport()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderResult->getGeometry()->getViewport()->getNorthEast()->getLatitude(), 2);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getViewport()->getNorthEast()->getLongitude(), 1);
     $this->assertTrue(self::$geocoderResult->getGeometry()->getViewport()->getNorthEast()->isNoWrap());
     $this->assertEquals(self::$geocoderResult->getGeometry()->getBound()->getSouthWest()->getLatitude(), -5);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getBound()->getSouthWest()->getLongitude(), -4);
     $this->assertTrue(self::$geocoderResult->getGeometry()->getBound()->getSouthWest()->isNoWrap());
     $this->assertEquals(self::$geocoderResult->getGeometry()->getBound()->getNorthEast()->getLatitude(), 4);
     $this->assertEquals(self::$geocoderResult->getGeometry()->getBound()->getNorthEast()->getLongitude(), 5);
     $this->assertTrue(self::$geocoderResult->getGeometry()->getBound()->getNorthEast()->isNoWrap());
 }
 /**
  * Build directions route with the normalized directions API route given
  *
  * @param stdClass $directionsRoute
  * @return Ivory\GoogleMapBundle\Model\Services\Directions\DirectionsRoute
  */
 protected function buildDirectionsRoute(\stdClass $directionsRoute)
 {
     $bound = new Bound();
     $bound->setNorthEast($directionsRoute->bounds->northeast->lat, $directionsRoute->bounds->northeast->lng);
     $bound->setSouthWest($directionsRoute->bounds->southwest->lat, $directionsRoute->bounds->southwest->lng);
     $copyrights = $directionsRoute->copyrights;
     $directionsLegs = $this->buildDirectionsLegs($directionsRoute->legs);
     $overviewPolyline = new EncodedPolyline($directionsRoute->overview_polyline->points);
     $summary = $directionsRoute->summary;
     $warnings = $directionsRoute->warnings;
     $waypointOrder = $directionsRoute->waypoint_order;
     return new DirectionsRoute($bound, $copyrights, $directionsLegs, $overviewPolyline, $summary, $warnings, $waypointOrder);
 }