Exemplo n.º 1
0
/**
 * @param $dbh
 * @param $address_id
 * @return array
 */
function get_address_attributes(&$dbh, $address_id)
{
    $address = new \Code4KC\Address\Address($dbh, true);
    if ($address_rec = $address->find_by_id($address_id)) {
        if ($attributes = $address->get_attributes($address_id)) {
            $data = array_merge($address_rec, $attributes);
            $ret = array('code' => 200, 'status' => 'success', 'message' => '', 'data' => $data);
        } else {
            $data = $address_rec;
            $ret = array('code' => 200, 'status' => 'success', 'message' => 'Unable to provide address attributes', 'data' => $data);
        }
    } else {
        $data = $address_rec;
        $ret = array('code' => 402, 'status' => 'error', 'message' => 'Internal error, address alias found, but address record is missing', 'data' => $data);
    }
    return $ret;
}
Exemplo n.º 2
0
$rustart = getrusage();
// Lest see wall clock time on this run
$start_time = time();
$census = new \Code4KC\Address\Census();
$row = 0;
$out = array();
$names = array();
global $dbh;
$totals = array('input' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'census_attributes' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0));
try {
    $dbh = new PDO("pgsql:dbname={$DB_NAME}", $DB_USER, $DB_PASS);
} catch (PDOException $e) {
    error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
    throw new Exception('Unable to connect to database');
}
$address = new \Code4KC\Address\Address($dbh, true);
$census_attributes = new \Code4KC\Address\CensusAttributes($dbh, true);
$sql = 'SELECT a.id, a.street_number, a.pre_direction, a.street_name, a.street_type, a.post_direction, a.internal, a.city, a.state, a.zip, k.city_address_id, k.county_address_id, c.city_address_id AS census_city_address_id FROM address a 
LEFT JOIN address_keys k ON ( k.address_id = a.id) 
LEFT JOIN census_attributes c ON ( k.city_address_id = c.city_address_id) ';
$query = $dbh->prepare("{$sql}  -- " . __FILE__ . ' ' . __LINE__);
try {
    $query->execute();
} catch (PDOException $e) {
    error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
    //throw new Exception('Unable to query database');
    return false;
}
$row = 0;
$count = 0;
while ($address_rec = $query->fetch(PDO::FETCH_ASSOC)) {
Exemplo n.º 3
0
// Lest see wall clock time on this run
$start_time = time();
$census = new \Code4KC\Address\Census();
$row = 0;
$out = array();
$names = array();
global $dbh;
$totals = array('input' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address_keys' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'city_address_attributes' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0));
if (($handle = fopen("KCMO_06152015_Parcel_PTs_Zoning.csv", "r")) !== FALSE) {
    try {
        $dbh = new PDO("pgsql:dbname={$DB_NAME}", $DB_USER, $DB_PASS);
    } catch (PDOException $e) {
        error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
        throw new Exception('Unable to connect to database');
    }
    $address = new \Code4KC\Address\Address($dbh, true);
    $address_keys = new \Code4KC\Address\AddressKeys($dbh, true);
    $city_address_attributes = new \Code4KC\Address\CityAddressAttributes($dbh, true);
    $names = array('id', 'longitude', 'latitude', 'land_use_code', 'classification', 'land_use', 'sub_class');
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        $row++;
        print "{$row}\n";
        if ($row == 1) {
        } else {
            $rec = array();
            for ($c = 0; $c < $num; $c++) {
                $rec[$names[$c]] = $data[$c];
            }
            $city_address_id = $rec['id'];
            if (empty($city_address_id)) {
Exemplo n.º 4
0
require '../../vendor/Convissor/address/AddressStandardizationSolution.php';
$census = new \Code4KC\Address\Census();
$row = 0;
$out = array();
$names = array();
global $dbh;
$totals = array('input' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address_alias' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'address_keys' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0), 'city_address_attributes' => array('insert' => 0, 'update' => 0, 'N/A' => 0, 'error' => 0));
if (($handle = fopen("kcmo_addresses_kiva_nbrhd_06_18_2015.csv", "r")) !== FALSE) {
    try {
        $dbh = new PDO("pgsql:dbname={$DB_NAME}", $DB_USER, $DB_PASS);
    } catch (PDOException $e) {
        error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
        throw new Exception('Unable to connect to database');
    }
    $address_converter = new Convissor\address\AddressStandardizationSolution();
    $address = new \Code4KC\Address\Address($dbh, true);
    $address_alias = new \Code4KC\Address\AddressAlias($dbh, true);
    $address_keys = new \Code4KC\Address\AddressKeys($dbh, true);
    $city_address_attributes = new \Code4KC\Address\CityAddressAttributes($dbh, true);
    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
        $num = count($data);
        $row++;
        print "{$row}\n";
        if ($row == 1) {
            for ($c = 0; $c < $num; $c++) {
                $names[$c] = $data[$c];
            }
        } else {
            $rec = array();
            for ($c = 0; $c < $num; $c++) {
                $rec[$names[$c]] = $data[$c];
Exemplo n.º 5
0
<?php

require '../../vendor/autoload.php';
require '../../config/config.php';
try {
    $dbh = new PDO("pgsql:dbname={$DB_NAME}", $DB_USER, $DB_PASS);
} catch (PDOException $e) {
    error_log($e->getMessage() . ' ' . __FILE__ . ' ' . __LINE__);
    throw new Exception('Unable to connect to database');
}
$address_alias = new \Code4KC\Address\AddressAlias($dbh, true);
$address = new \Code4KC\Address\Address($dbh, true);
$single_line_address = '523 GRAND BLVD, KANSAS CITY, MO';
$exisiting_address_alias_rec = $address_alias->find_by_single_line_address($single_line_address);
var_dump($exisiting_address_alias_rec);
$address_id = $exisiting_address_alias_rec['address_id'];
$exisiting_address_rec = $address->find_by_id($address_id);
print_r($exisiting_address_rec);