Jump to content

a2bardeals

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Everything posted by a2bardeals

  1. ok well i figured out the error problem by deleting the APC folder, re-extracting it and starting over.... but running phpize from the php5 directory didn't work.. the extension still ended up in the usr/lib/php/extensions rather than usr/local/php5/lib/php/extensions... Any help would be amazing... P.S. (it did look like it was phpize-ing for the current version though, when it spits out the PHP API version and the Zend Module Api No at the start of phpize but after running ./configure, make and make install it ends up in a different extensions directory)
  2. i can't seem to get PECL to work and i can't find it anywhere in my PHP 5 installation. i am runing PHP 5 on Mac OS X. i tried running phpize from the usr/local/php5/bin path where the current version of PHP's phpize resides. after running phpize and ./configure everything seems to work ok... but when i try to "make" i get: make: *** [apc.la] Error 1 i didn't get that when i compiled for the old php. any ideas?
  3. i did something just like this not to long ago. i used Flash's media playback component to load and stream mp3 files on a my page. it's pretty easy and only takes a few lines of Actionscript. Basically i started with data from a MySQL table with ID, Title, Artist, & Path columns. for example, using php to retrive song ID: 393 it loads the artist, title, path variables for that track display the title and artist variables in PHP: <?php $result = mysql_query("SELECT artist, title, path FROM music WHERE ID = `393` LIMIT 1" while ($row = mysql_fetch_array($result)){ echo 'Artist: '.$row[0].'<br>'; echo 'Title: '.$row[1]; $file_path = $row[2]; } ?> then pass the $file_path variable into flash like this (notice you have to pass it twice) <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/" WIDTH="250" HEIGHT="300" id="player"> <PARAM NAME=movie VALUE="player.swf[b]?path=<?php echo $file_path; ?>[/b]"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="player.swf[b]?path=<?php echo $file_path; ?>[/b]" quality=high bgcolor=#FFFFFF WIDTH="250" HEIGHT="300" NAME="player" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </EMBED> </OBJECT> to create the empty player. you should add flash's media playback component to a new Flash project. Set the instance name to "media" in the properties window and set it's media type to mp3 in the component inspector. Select the first (and only) frame of the movie and open the actions window. Pass the variable like this: var passed:String = path; media.setMedia(path); export the flash movie as player.swf and save it in the same directory as the page retrieving the info from the database. you should be all set!
  4. i am trying to install the APC (http://pecl.php.net/package/APC) extension for PHP 5. i am trying to compile using phpize but when i do the make install it installs the extension to another version of php on my system.. i tried moving the apc.so file into the PHP5 extensions directory but when i do that Apache wont start. My question is, how do i get phpize and make install to compile the extension on PHP5 rather then the old PHP on my system?
  5. well i have just purchased the new OS X with Xcode for my server which should give me a compiler and allow me to use cURL and I will try that route and updating my PHP version should help as well
  6. ok well i do not have a windows version...I have a Mac OS X version (UNIX version) of PHP 4.1.2 should that matter?
  7. still nothing...im starting to think there is no workaround which is why cURL and file_get_contents were introduced maybe?
  8. returns nothing...am i calling the function right? <? function file_get_contents2($filename) { $fd = fopen("$filename", "rb"); $content = fread($fd, filesize($filename)); fclose($fd); return $content; } $string = file_get_contents2('http://maps.google.com/maps/geo?key=ABQIAAAAR0Cth1uWGX8aUnZOUNxxDRSTa-vPv41zs_3mMYBEENmT6-JqMxQvgmczA_f8sbJvBlQCW7hrjqwVQA&output=cvs&q=3060+Packard+Rd,+Ann+Arbor,+MI'); echo $string; ?>
  9. ok I love the help... however I have tried both...I cannot install cURL on the system and I'm only running PHP 4.1.2 which does not include the file_get_contents() function....are these the only ways of doing this?
  10. I am trying to create a PHP page with a variable's value being looked up from google's geocoding service. Basically I have a MySQL database table with customer names and addresses. On the page I am working on I want to do a quick lookup to: http://maps.google.com/maps/geo?q=Address+Info&key=abcdefg&output=csv when you type this in a browser in returns a small line of text that has the lat/long seperated by commas. How can I get that data from the HTTP request into a variable without leaving my site? I know you can use cURL but I cannot install it on my system (no compiler) so I am looking for an alternative... i was thinking i could use fopen() or fsockopen() but I have no idea how to set this up. Any ideas?
  11. my Apache did come with PHP (Mac OS X includes apache as "Web Sharing" as well as PHP) I have PHP Version 4.1.2 but no cURL installed i tried the code: <?php $ch = curl_init("http://www.example.com/"); $fp = fopen("example_homepage.txt", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); ?> and i get a call to unknown variable curl_init
  12. i am running my own server with whatever PHP libraries that come with standard Apache how do I know if I have cURL?
  13. is cURL the only way? it seems a bit hard to do and I don't know much about compiling PHP or anything related to installing things via command line.
  14. ok so I don't even know how to ask this question but i'll try anyways... Google has a geocoding system now and they have it setup so that you can send an HTTP request to find lat and long of an address. I want to be able to save the outputed info into PHP variables. On the documentation page from google it says this: how the #$@! do i send a HTTP request inside a page on my server. I want to quickly find the lat/long of a users address and calculate distance from a store. If i simply type the URL in http://maps.google.com/maps/geo?key=ABCDEFG&q=200+N+MAIN+ST,+NEW+YORK,+NY&output=csv i get a nice little text string with 4 comma seperated values two of which i want to store into variables (lat/long) then pass on to another page which will insert them into the users MySQL row. Seems pretty simple uh? But how do i create the HTTP request inside my document and use the outputed info from google?
  15. so I am using an earlier version of PHP that does not have the file_get_contents function. I am trying to request a URI from google's geocoding API. Is there a way to request (include) an external file within a page with out this function?
  16. dosen't google have fairly strict terms on using thier API for commercial purposes though? Plus...I would like to have this done all "in-house" so that I am not relying on anyone elses services or connections.
  17. basically I've loaded the data from 2 counties into a table using the method in the article posted above. Now I can not figure out how to: 1. Parse the user inputed address. e.g. 3004 N. Main St. would break up into 4 parts the street number (3004) the direction (N) the street (main) and the type (St.) 2. Then search the database for the lat-long of the address. Finally: 3. Calculate the distance from a set lat long (aka a store location).
  18. i have read the article yes. that is where i got the code from and how i got to step 2. the first file they give you had tons of errors but i hacked it a bit until i loaded the data in. the second script i cannot get to work which is the reason for my post in the first place
  19. the tutorial where i am getting this from is: http://blog.tooleshed.com/?page_id=18 **it's page 2 of the proccess
  20. i don't know if any of this is correct its a script from a tutorial. I get crazy parse errors on all of it...
  21. still get a parse error further down on Line 10
  22. i am posting a geocoding script that i found online that gives me parse errors like crazy. I need this to work. I can't figure out the problem. The first error i get is: Parse error: parse error in /Library/WebServer/Documents/bar/ver2/geocode/geo.php on line 3 I am also using PHP 4.1.2 if that makes a difference. When I fix the obvious one which i belive is the address input value: Address: <input type="text" size="40" name="address" value="<?=$_REQUEST[" />"> to Address: <input type=text" size="40" name="address" value="<? $_REQUEST["address] ?>"> I get a parse error on line 10 Here it is: <? define("DEBUG", false); // ===== Database parameters $db["user"] = "username"; $db["pass"] = "password"; $db["host"] = "localhost"; $db["database"] = "dbname"; ?> <h2>Geocode</h2> <form name="mainform" action="geocode.php" method="get"> Address: <input type="text" size="40" name="address" value="<?=$_REQUEST[" />"> <input type="submit" name="geo" value="Geocode" /> </form> <hr /> <? if ( array_key_exists("geo", $_REQUEST) ) { showresults(); } ?><?php// ==================================================================== // ==================================================================== PHP Functions // ==================================================================== // ==================================================================== show results // function showresults() { $address = $_REQUEST["address"]; // === Parse the address into it's various parts. $paddr = parse_address($address); // === Query the database for matching streets. $rsary = find_address($paddr); if ( !$rsary || count($rsary)> 1 ) { echo "No records found or more than one street segment matched. Be more specific. "; return; } // === Geocode the address. $latlon = geocode_address($rsary[0], $paddr); // === Display the lat/lon and a google maps link echo $latlon["lat"] . ", " . $latlon["lon"]; echo " <a href="http://blog.tooleshed.com/%5C%22http://maps.google.com/maps?f=q&hl=en&q=%22">Google Map</a>"; } // ==================================================================== geocode // function geocode_address($data, $addr) { $house_number = $addr["number"]; $from_number = $data["from_addr"]; $to_number = $data["to_addr"]; // === Convert the linedata string into an array of lat/lon pairs $chain = parse_linedata($data["linedata"]); // === Find the proportion between our house number and the fr/to numbers of the street segement $prop = ($house_number - $from_number) / ($to_number - $from_number); debug("house: $house_number fr: $from_number to: $to_number prop: $prop"); debug($chain); if ( count($chain) <2 ) { die("Error, linedata field bad: " . $data["linedata"] . " "); } if ( count($chain) == 2 ) { // === Using linear interpolation, we can calculate the lat/lon of our house on the street segment $house = lerp($chain[0], $chain[1], $prop); } else { // === The chain has more than two points, so a more complex calculation is required. $house = calc_position($chain, $prop); } return $house; } // ==================================================================== calc_position // function calc_position($chain, $prop) { $total_dist = 0; // First calculate the distance between each set of points // and the total distance of our entire street segment for ($i=0; $i $dist = calc_dist($chain[$i], $chain[$i+1]); $p2p_dist[$i] = $dist; $total_dist += $dist; debug("Distance from Point $i to " . ($i+1) . " = $dist ($total_dist)"); } // Now that we have the total distance we can figure out where // on the segment our address will be using the proportion. $house_dist = $total_dist * $prop; // Next we need to determine between which two set of points // our house_dist lies. $i=0; $part_dist = 0; while ($part_dist <$house_dist) { $part_dist += $p2p_dist[$i++]; } $i--; // Now we need to find the proportion at the partial distance level $part_from = $part_dist - $p2p_dist[$i]; $part_prop = ($house_dist - $part_from) / ($part_dist - $part_from); debug("i: $i house_dist: $house_dist part_dist: $part_dist, part_from: $part_from, part_prop: $part_prop"); // And with that we can now do the interpolation betwen the points at // that sub-part of the street segment. $house = lerp($chain[$i], $chain[$i+1], $part_prop); debug($house); return $house; } // ==================================================================== calc_dist // Calculates the distance between two lat/lon points // See: http://www.meridianworlddata.com/Distance-Calculation.asp function calc_dist($fr, $to) { $lat1 = deg2rad($fr["lat"]); $lon1 = deg2rad($fr["lon"]); $lat2 = deg2rad($to["lat"]); $lon2 = deg2rad($to["lon"]); $d = 3963 * acos( sin($lat1)*sin($lat2) + cos($lat1)*cos($lat2)*cos($lon2 - $lon1) ); return $d; } // ==================================================================== lerp // Performs linear interpolation on the lat and lon function lerp($fr, $to, $prop) { $frlat = $fr["lat"]; $frlon = $fr["lon"]; $tolat = $to["lat"]; $tolon = $to["lon"]; $point["lat"] = $frlat + ($prop * ($tolat - $frlat)); $point["lon"] = $frlon + ($prop * ($tolon - $frlon)); return $point; } // ==================================================================== parse_linedata // function parse_linedata($linedata) { // === Explode the linedata string of lat/lon's into an array: /* Example returned array: Array ( [0] => Array ( [lon] => -122.628906 [lat] => 45.53354 ) [1] => Array ( [lon] => -122.627906 [lat] => 45.53354 ) ) */ foreach ( explode(",", $linedata) as $latlon) { list($lon, $lat) = explode(" ", $latlon); $ll[] = array("lon" => ($lon/1000000), "lat" => ($lat/1000000)); } return $ll; } // ==================================================================== find_address // Build a query to find the street in the database // function find_address($addr) { global $db; require_once("adodb/adodb.inc.php"); $number = $addr["number"]; $dsn = "mysql://" . $db["user"] . ":" . $db["pass"] . "@" . $db["host"] . "/" . $db["database"]; $dbConn = ADONewConnection($dsn); $dbConn->debug = DEBUG; if (!$dbConn) { echo("Connection failed"); exit; } $q = " select cc_id, linedata, fedirp, fename, fetype, fedirs, if(fraddl % 2 = $number % 2, fraddl, fraddr) as from_addr, if(fraddl % 2 = $number % 2, toaddl, toaddr) as to_addr from completechain "; $q .= "where fename = " . $dbConn->qstr($addr["name"]) . " "; // === Build the Where clause $wh = ""; if ( array_key_exists("prefix", $addr) ) { $wh .= "and fedirp = " . $dbConn->qstr($addr["prefix"]) . " "; } if ( array_key_exists("type", $addr) ) { $wh .= "and fetype = " . $dbConn->qstr($addr["type"]) . " "; } if ( array_key_exists("suffix", $addr) ) { $wh .= "and fedirs = " . $dbConn->qstr($addr["suffix"]) . " "; } $wh .= "and ( (fraddr <= $number and toaddr>= $number) OR (fraddl <= $number and toaddl>= $number) )"; // === Add the where to the query $q .= $wh; debug($q); $rs = $dbConn->GetAll($q); $dbConn->Close(); return $rs; } // ==================================================================== parse_address // function parse_address($address="") { $dir=array( "N"=>"N","S"=>"S","E"=>"E","W"=>"W","NW"=>"NW","SW"=>"SW","NE"=>"NE","SE"=>"SE", "North"=>"N","South"=>"S","East"=>"E","West"=>"W","Northwest"=>"NW", "Southwest"=>"SW","Northeast"=>"NE","Southeast"=>"SE" ); $type=array( "ave"=>"Ave","blvd"=>"Blvd","st"=>"St","wy"=>"Wy","cir"=>"Cir","dr"=>"Dr", "ln"=>"Ln","Pl"=>"Pl","Rd"=>"Rd","Bvd"=>"Blvd","Avenue"=>"Ave","Boulevard"=>"Blvd", "Street"=>"St","Way"=>"Wy","Circle"=>"Cir","Drive"=>"Dr","Lane"=>"Ln","Place"=>"Pl", "Road"=>"Rd" ); $apts = "Apt|Apartment|Suite|Ste|Unit|Bldg|Building|Room|Rm|#"; $out["address_type"] = "Presumed Standard"; $address=trim($address); $out["raw_address"] = $address; $original = $address; //remove any unit or apt # from the end //a number alone at the end is not enough, we need at least # or one of the descriptors in () if( preg_match('/(\s+(' . $apts . ')\s*)+#?[-a-z0-9]+$/i', $address, $matches)){ $out["raw_unit"] = $matches[0]; $out["unit"] = preg_replace('/(\s+(' . $apts . ')\s*)+#?/i','',$matches[0]); //break raw unit down $address = substr($address, 0, strlen($address)-strlen($matches[0])); } //parse suffix direction (SW) $dirs = implode("|", array_keys($dir)); if(preg_match('/\s+(' . $dirs . ')$/i', $address, $matches)){ $out["raw_suffix"] = trim($matches[0]); $out["suffix"] = $dir[$out["raw_suffix"]]; $address=substr($address, 0, strlen($address)-strlen($matches[0])); } //remove type of street $types = implode("|", array_keys($type)); if(preg_match('/\s+(' . $types . ')$/i', $address, $matches)){ $out["raw_type"] = trim($matches[0]); strlen($out["raw_type"])> 3 || strtolower($out["raw_type"]) == 'way' || strtolower($out["raw_type"]) == 'bvd' ? $typeDefinite = false : $typeDefinite = true; $out[type] = $type[strtolower($out["raw_type"])]; $address = substr($address, 0, strlen($address)-strlen($matches[0])); } //remove number and fraction if(preg_match('/^[0-9]+(\s+[0-9]+\/[0-9]+)*/', $address, $matches)){ $address = substr($address, strlen($matches[0]), strlen($address)-strlen($matches[0])); if(preg_match('/\s+[0-9]+\/[0-9]+$/',$matches[0],$mmatch)){ $out["fraction"] = $mmatch[0]; $matches[0] = substr($matches[0], 0, strlen($matches[0])-strlen($mmatch[0])); } $out[number] = trim($matches[0]); $numberFormat = 'standard'; } else { $numberFormat = 'irregular'; //account for possible P.O. Boxes and Rural Routes if(preg_match('/^(POB\s+|P\s*O\s*Box|Post Office Box|Postal Box|Box|Boite Postal)\s*[0-9a-z]+(-[0-9a-z]+)*/i', $address, $matches)) { $out["raw_po_box"] = $matches[0]; preg_match('/[0-9a-z]+(-[0-9a-z]+)*$/i', $matches[0], $mmatch); $out["po_box"] = strtoupper($mmatch[0]); $out["address_type"] = "Post Office Box"; } if(preg_match('/(Rrte|RR|Rural Route|Rt|Rte|Route)\s+[0-9]+\s+(Box|Bx)\s+[0-9]+/i', $address, $matches)){ $out["raw_route"] = $matches[0]; $matches = explode('b',strtolower($matches[0])); $out["route_number"] = preg_replace('/[^0-9]+/', '', $matches[0]); $out["route_box_number"] = preg_replace('/[^0-9]+/', '', $matches[1]); $out["address_type"] = "Rural Route"; } //Account for HC nomenclature -- for drawmack if(preg_match('/(HC|Highway County|Hwy Cty|Hwy County)\s+[0-9]+\s+(Box|Bx)\s+[0-9]+/i',$address,$matches)){ $out["raw_hc"]=$matches[0]; $matches=explode('b', strtolower($matches[0])); $out["hc_number"] = preg_replace('/[^0-9]+/', '', $matches[0]); $out["hc_box_number"] = preg_replace('/[^0-9]+/', '',$matches[1]); $out["address_type"] = "Highway County Route"; } //Account for * | Star Route if(preg_match('/(\*\s+Rte|\*\s+Route|Star\s+Route|Star\s+Rte)\s+[0-9]+\s+(Box|Bx)\s+[0-9]+/i',$address,$matches)){ $out["raw_starrt"]=$matches[0]; $matches=explode('b',strtolower($matches[0])); $out["starrt_number"]=preg_replace('/[^0-9]+/','',$matches[0]); $out["starrt_box_number"]=preg_replace('/[^0-9]+/','',$matches[1]); $out["address_type"]="Star Route"; } /*** Note on the above 4 nodes: we don't check that an address only partially conforms, such as Rte 1 (no box number), and perhaps we should. Perhaps "Route 1" is even OK in some areas ***/ } //what remains is the prefix direction, and street, several analyses to make here /*** note that if there is still an address left over yet we pulled a PO Box above or a Rural Route, then either something is wrong or our code missed something, this should be flagged. ***/ $address = trim($address); if(preg_match('/^(' . $dirs . ')\s+/i', $address, $matches)){ $out["prefix"] = $dir[trim($matches[0])]; strlen($matches[0])> 2 ? $out["raw_prefix"] = $matches[0] : ''; $address = substr($address, strlen($matches[0]), strlen($address)-strlen($matches[0])); } //presume all else is the name $out["name"] = trim($address); //present the array visibly in a logical order -- not required for operation but nice $order=array( "type_definite", "address_type", "route_number", "route_box_number", "hc_number", "hc_box_number", "starrt_number", "starrt_box_number", "po_box", "number", "fraction", "prefix", "name", "type", "suffix", "unit", "raw_po_box", "raw_route", "raw_hc", "raw_starrt", "raw_prefix", "raw_suffix", "raw_type", "raw_unit", "raw_address" ); foreach($order as $v){ isset($out[$v]) ? $ret[$v] = $out[$v] : ''; } return $ret; } // =========================== Utility functions function debug($s) { if ( DEBUG ) { if ( is_array($s) || is_object($s) ) { view($s); } else { echo " $s "; } } } function view($obj) { echo " <pre>"; print_r($obj); echo "</pre> "; } ?>
  23. I don't know what GIS means... but I made a few hacks to the provided code on that article and loaded the data in. Now the second page to the article explains how to pull the data and calculate distance but when i try their geocode.php script i get all kinds of parse errors. Maybe because I'm using PHP 4.1.2 and they wrote it for 5 or something but now I am really stuck. I can post the code for anyone interested in helping a distraught student.
  24. now i am getting wrong parameter counts for fgets: Wrong parameter count for fgets() in /Library/WebServer/Documents/bar/secure/mrp/geocode/tigerload.php on line 27 Here is the whole script: <? require_once('adodb/adodb.inc.php'); set_time_limit(300); $dbConn = ADONewConnection("mysql://USER:PASSWORD@localhost/DATABASE"); if (!$dbConn) { echo("Connection failed"); exit; } complete_chain("41", "051"); // Process Multnomah County, Oregon // ================================================================================= complete_chain // Main function for processing a single county file // function complete_chain($state, $county) { $rt1path = "data/$state/$county/TGR${state}${county}.RT1"; $rt2path = "data/$state/$county/TGR${state}${county}.RT2"; $tFile_RT1 = @fopen($rt1path, "r"); $tFile_RT2 = @fopen($rt2path, "r"); if ( !$tFile_RT1 || !$tFile_RT2 ) { echo "Couldn't open a file: <br>"; echo "RT1: $rt1path RT2: $rt2path<br />"; return; } echo "Starting...<br />"; // === Load all RT2 records into an array with TLID as the Key echo "Loading Type2 Records...<br />"; $rt2def = datadict("RT2"); while ( ($line = fgets($tFile_RT2)) ) { $data = parseData($line, $rt2def); $rt2[$data["TLID"]][$data["RTSQ"]] = $data; $i++; } // === Read and process RT1 records, storing the combined data to the database $ttl=0; $cnt=0; $rt1def = datadict("RT1"); echo "Processing Type1 Records...<br />"; while ( ($line = fgets($tFile_RT1)) ) { $data = parseData($line, $rt1def); if ( $cnt++ % 1000 == 0 ) { echo " - $cnt records processed<br />"; flush(); } // === To limit the number of records added to the database, and to speed up the import // you can add a conditional here. This is quite useful when testing so you don't have // to load the entire county file. //if ( $data["zipl"] != "97232" || $data["zipr"] != "97232") continue; // === Process the Type1 record, also passing in any associated Type2 records if they exsist if ( array_key_exists($data["tlid"], $rt2) ) { $ttl += processData($data, $rt2[$data["tlid"]]); } else { $ttl += processData($data); } if ( $ttl % 500 == 0 ) { echo " -- $ttl records added<br />"; flush(); } } echo "Finished. Added $ttl completechain records<br />"; } // ================================================================================= processData // Returns field names and lengths for various TIGER/Line files // function processData($data, $rt2=null) { global $dbConn; // ====== Builds a linedata string similiar to: // -121952185 45642435,-121952674 45642755,-121953000 45642755,-121953072 45642719 // // It uses the fr/to lat/long of the type1 record ( = $data) for the start and end points // and if this TLID has a corresponding type2 record ($rt1 != null) then the intermediate // points in that type2 record are included. Once built, the string is added to the $data // array and stored in the database. // $linedata = $data["frlong"] . " " . substr($data["frlat"],1) . ","; if ( $rt2 != null ) { foreach($rt2 as $rtsq => $ll) { for($x=1; $x<11; $x++) { if ( $ll["Lng$x"] == "+000000000" ) break; $linedata .= $ll["Lng$x"] . " " . substr($ll["Lat$x"],'1') . ","; } } } $linedata .= $data["tolong"] . " " . substr($data["tolat"],1); $data["linedata"] = $linedata; // ==== Store all of the type1 record info and the new linedata to the completechain table // using the handy AutoExecute method in the ADODB library. return $dbConn->AutoExecute("completechain", $data, 1); } // ================================================================================= datadict // Returns field names and lengths for various TIGER/Line files // function datadict($rt) { switch ($rt) { case "RT1": $dd = array("rt" => 1, "version" => 4, "tlid" => 10, "side1" => 1, "source" => 1, "fedirp" => 2, "fename" => 30, "fetype" => 4, "fedirs" => 2,"cfcc" => 3, "fraddl" => 11, "toaddl" => 11, "fraddr" => 11, "toaddr" => 11, "friaddl" => 1, "toiaddl" => 1, "friaddr" => 1, "toiaddr" => 1, "zipl" => 5, "zipr" => 5, "aianhhfpl" => 5, "aianhhfpr" => 5, "aihhtlil" => 1, "aihhtlir" => 1, "census1" => 1, "census2" => 1, "statel" => 2, "stater" => 2, "countyl" => 3, "countyr" => 3, "cousubl" => 5, "cousubr" => 5, "submcdl" => 5, "submcdr" => 5, "placel" => 5, "placer" => 5, "tractl" => 6, "tractr" => 6, "blockl" => 4, "blockr" => 4, "frlong" => 10, "frlat" => 9, "tolong" => 10,"tolat" => 9); break; case "RT2": $dd = array("RT" => 1, "Version" => 4, "TLID" => 10, "RTSQ" => 3, "Lng1" => 10, "Lat1" => 9, "Lng2" => 10, "Lat2" => 9, "Lng3" => 10, "Lat3" => 9, "Lng4" => 10, "Lat4" => 9, "Lng5" => 10, "Lat5" => 9, "Lng6" => 10, "Lat6" => 9, "Lng7" => 10, "Lat7" => 9, "Lng8" => 10, "Lat8" => 9, "Lng9" => 10, "Lat9" => 9, "Lng10" => 10, "Lat10" => 9); break; } return $dd; } // ================================================================================= parseData // Returns an array of data from a string ($line) based on the fields in $def // function parseData($line, $def) { $start = 0; foreach($def as $name=>$len) { $ret[$name] = trim(substr($line, $start, $len)); $start += $len; } return $ret; } // ==== Helper/debug functions function view($obj) { echo "<pre>"; print_r($obj); echo "</pre>"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.