// Unknown key-value pairs available in the input map are retained as-is.
abstract public function getGeocodedAddress(array $address);
+ // Cleans the address from its geocoded data
+ abstract public function stripGeocodingFromAddress(array $address);
+
// Updates geoloc_administrativeareas, geoloc_subadministrativeareas and
// geoloc_localities databases with new geocoded data and returns the
// corresponding id.
}
}
}
+
+ // Returns the part of the text preceeding the line with the postal code
+ // and the city name, within the limit of $limit number of lines.
+ static public function getFirstLines($text, $postalCode, $limit)
+ {
+ $textArray = explode("\n", $text);
+ for ($i = 0; $i < count($textArray); ++$i) {
+ if ($i > $limit || strpos($textLine, $postalCode) !== false) {
+ $limit = $i; break;
+ }
+ }
+ return implode("\n", array_slice($textArray, 0, $limit));
+ }
}
// Implementation of a Geocoder using the Google Maps API. Please refer to
return $address;
}
+ public function stripGeocodingFromAddress(array $address) {
+ unset($address['geoloc'], $address['geoloc_choice'], $address['countryId'],
+ $address['country'], $address['administrativeAreaName'],
+ $address['subAdministrativeAreaName'], $address['localityName'],
+ $address['thoroughfareName'], $address['postalCode']);
+ $address['accuracy'] = 0;
+ return $address;
+ }
+
// Updates the address with the geocoded information from Google Maps. Also
// cleans up the final informations.
private function getUpdatedAddress(array $address, array $geocodedData, $extraLines) {