Beispiel #1
0
$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];
            }
            if (empty($rec['kivapin'])) {
Beispiel #2
0
        }
    } else {
        $ret = array('code' => 404, 'status' => 'error', 'message' => 'City ID was not valid..', 'data' => array());
    }
    $app->response->setStatus($ret['code']);
    echo json_encode($ret);
});
$app->get('/address-attributes-city-id/V0/:id/', function ($id) use($app) {
    list($city_id, $x) = explode("?", $id);
    $in_city = strtoupper($app->request()->params('city'));
    $in_state = strtoupper($app->request()->params('state'));
    $city_id = intval($city_id);
    if ($city_id) {
        if (city_state_valid($in_city, $in_state)) {
            if ($dbh = connect_to_address_database()) {
                $address_keys = new \Code4KC\Address\AddressKeys($dbh, true);
                if ($exisiting_address_alias_rec = $address_keys->find_by_city_address_id($city_id)) {
                    $address_id = $exisiting_address_alias_rec['address_id'];
                    $ret = get_address_attributes($dbh, $address_id);
                } else {
                    $ret = array('code' => 404, 'status' => 'error', 'message' => 'Address not found', 'data' => array());
                }
            } else {
                $ret = array('code' => 404, 'status' => 'error', 'message' => 'State or City was not valid.', 'data' => array());
            }
        } else {
            $ret = array('code' => 500, 'status' => 'failed', 'message' => 'Unable to connect to database.', 'data' => array());
        }
    } else {
        $ret = array('code' => 404, 'status' => 'error', 'message' => 'City ID was not valid..', 'data' => array());
    }
Beispiel #3
0
$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)) {
                print "EROOR: empty city id on line {$row}\n";