Skip to content

Commit a2aa604

Browse files
shahariaazamwilldurand
authored andcommitted
Type, size and scale can be defined as parameter
Referenced Issue geocoder-php#21 To get more precise latitude, longitude value I guess we should be able to add type and size defined for creating latitude and longitude column in Database. We should be able to define type, size and scale through parameter.
1 parent 4787108 commit a2aa604

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
],
1111
"require": {
1212
"php": ">=5.2.4",
13-
"propel/propel1": "~1.6,>=1.6.4"
13+
"propel/propel1": "~1.6,>=1.6.4",
14+
"willdurand/geocoder": "~2.3"
1415
},
1516
"require-dev": {
16-
"willdurand/geocoder": "@stable"
1717
},
1818
"autoload": {
1919
"classmap": ["src/"]

src/GeocodableBehavior.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ class GeocodableBehavior extends Behavior
1919
'auto_update' => 'true',
2020
'latitude_column' => 'latitude',
2121
'longitude_column' => 'longitude',
22+
'type' => 'DOUBLE',
23+
'size' => 10,
24+
'scale' => 8,
25+
2226
// IP-based Geocoding
2327
'geocode_ip' => 'false',
2428
'ip_column' => 'ip_address',
2529
// Address Geocoding
2630
'geocode_address' => 'false',
2731
'address_columns' => 'street,locality,region,postal_code,country',
2832
// Geocoder
29-
'geocoder_provider' => '\Geocoder\Provider\OpenStreetMapsProvider',
33+
'geocoder_provider' => '\Geocoder\Provider\OpenStreetMapProvider',
3034
'geocoder_adapter' => '\Geocoder\HttpAdapter\CurlHttpAdapter',
3135
'geocoder_api_key' => 'false',
3236
'geocoder_api_key_provider' => 'false',
@@ -45,13 +49,17 @@ public function modifyTable()
4549
if (!$this->getTable()->containsColumn($this->getParameter('latitude_column'))) {
4650
$this->getTable()->addColumn(array(
4751
'name' => $this->getParameter('latitude_column'),
48-
'type' => 'DOUBLE'
52+
'type' => $this->getParameter('type'),
53+
'size' => $this->getParameter('size'),
54+
'scale'=> $this->getparameter('scale')
4955
));
5056
}
5157
if (!$this->getTable()->containsColumn($this->getParameter('longitude_column'))) {
5258
$this->getTable()->addColumn(array(
5359
'name' => $this->getParameter('longitude_column'),
54-
'type' => 'DOUBLE'
60+
'type' => $this->getParameter('type'),
61+
'size' => $this->getParameter('size'),
62+
'scale'=> $this->getparameter('scale')
5563
));
5664
}
5765
if ('true' === $this->getParameter('geocode_ip') && !$this->getTable()->containsColumn($this->getParameter('ip_column'))) {

tests/GeocodableBehaviorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ public function testGeocode()
403403
$this->assertTrue($geo->isModified());
404404
$this->assertInstanceOf('Geocoder\Result\ResultInterface', $result);
405405
$this->assertEquals('Paris', $result->getCity());
406-
$this->assertEquals('France Métropolitaine', $result->getCountry());
407406
}
408407

409408
public function testGeocodeIsEffectLessIfGeocodingDisabled()

tests/GeocodableBehaviorWithNamespacesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ public function testGeocode()
412412
$this->assertTrue($geo->isModified());
413413
$this->assertInstanceOf('Geocoder\Result\ResultInterface', $result);
414414
$this->assertEquals('Paris', $result->getCity());
415-
$this->assertEquals('France Métropolitaine', $result->getCountry());
416415
}
417416

418417
public function testGeocodeIsEffectLessIfGeocodingDisabled()

0 commit comments

Comments
 (0)