Net_GeoIP
[ class tree: Net_GeoIP ] [ index: Net_GeoIP ] [ all elements ]

Source for file DMA.php

Documentation is available at DMA.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP version 5                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (C) 2004 MaxMind LLC                                       |
  6. // +----------------------------------------------------------------------+
  7. // | This library is free software; you can redistribute it and/or        |
  8. // | modify it under the terms of the GNU Lesser General Public           |
  9. // | License as published by the Free Software Foundation; either         |
  10. // | version 2.1 of the License, or (at your option) any later version.   |
  11. // |                                                                      |
  12. // | This library is distributed in the hope that it will be useful,      |
  13. // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  14. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
  15. // | Lesser General Public License for more details.                      |
  16. // |                                                                      |
  17. // | You should have received a copy of the GNU Lesser General Public     |
  18. // | License along with this library; if not, write to the Free Software  |
  19. // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
  20. // | USA, or view it online at http://www.gnu.org/licenses/lgpl.txt.      |
  21. // +----------------------------------------------------------------------+
  22. // | Authors: Jim Winstead <jimw@apache.org> (original Maxmind version)   |
  23. // |          Hans Lellelid <hans@xmpl.org>                               |
  24. // +----------------------------------------------------------------------+
  25. //
  26. // $Id: DMA.php,v 1.1 2004/07/01 12:51:13 hlellelid Exp $
  27.  
  28. /**
  29.  * Static class to handle mapping of DMA codes to metro regions.
  30.  * 
  31.  * Use this class with the dmaCode property of the Net_GeoIpLocation object.
  32.  * 
  33.  * <code>
  34.  * $region = Net_GeoIPDMA::getMetroRegion($record->dmaCode);
  35.  * </code>
  36.  * 
  37.  * 
  38.  * @author Hans Lellelid <hans@xmpl.org>
  39.  * @version $Revision: 1.1 $
  40.  * @package Net_GeoIP
  41.  */
  42. {
  43.     /**
  44.      * Holds DMA -> Metro mapping.
  45.      * @var array 
  46.      */
  47.     private static $dmaMap;
  48.     
  49.     public static function initialize()
  50.     {
  51.         self::$dmaMap = array(
  52.             500 => 'Portland-Auburn, ME',
  53.             501 => 'New York, NY',
  54.             502 => 'Binghamton, NY',
  55.             503 => 'Macon, GA',
  56.             504 => 'Philadelphia, PA',
  57.             505 => 'Detroit, MI',
  58.             506 => 'Boston, MA',
  59.             507 => 'Savannah, GA',
  60.             508 => 'Pittsburgh, PA',
  61.             509 => 'Ft Wayne, IN',
  62.             510 => 'Cleveland, OH',
  63.             511 => 'Washington, DC',
  64.             512 => 'Baltimore, MD',
  65.             513 => 'Flint, MI',
  66.             514 => 'Buffalo, NY',
  67.             515 => 'Cincinnati, OH',
  68.             516 => 'Erie, PA',
  69.             517 => 'Charlotte, NC',
  70.             518 => 'Greensboro, NC',
  71.             519 => 'Charleston, SC',
  72.             520 => 'Augusta, GA',
  73.             521 => 'Providence, RI',
  74.             522 => 'Columbus, GA',
  75.             523 => 'Burlington, VT',
  76.             524 => 'Atlanta, GA',
  77.             525 => 'Albany, GA',
  78.             526 => 'Utica-Rome, NY',
  79.             527 => 'Indianapolis, IN',
  80.             528 => 'Miami, FL',
  81.             529 => 'Louisville, KY',
  82.             530 => 'Tallahassee, FL',
  83.             531 => 'Tri-Cities, TN',
  84.             532 => 'Albany-Schenectady-Troy, NY',
  85.             533 => 'Hartford, CT',
  86.             534 => 'Orlando, FL',
  87.             535 => 'Columbus, OH',
  88.             536 => 'Youngstown-Warren, OH',
  89.             537 => 'Bangor, ME',
  90.             538 => 'Rochester, NY',
  91.             539 => 'Tampa, FL',
  92.             540 => 'Traverse City-Cadillac, MI',
  93.             541 => 'Lexington, KY',
  94.             542 => 'Dayton, OH',
  95.             543 => 'Springfield-Holyoke, MA',
  96.             544 => 'Norfolk-Portsmouth, VA',
  97.             545 => 'Greenville-New Bern-Washington, NC',
  98.             546 => 'Columbia, SC',
  99.             547 => 'Toledo, OH',
  100.             548 => 'West Palm Beach, FL',
  101.             549 => 'Watertown, NY',
  102.             550 => 'Wilmington, NC',
  103.             551 => 'Lansing, MI',
  104.             552 => 'Presque Isle, ME',
  105.             553 => 'Marquette, MI',
  106.             554 => 'Wheeling, WV',
  107.             555 => 'Syracuse, NY',
  108.             556 => 'Richmond-Petersburg, VA',
  109.             557 => 'Knoxville, TN',
  110.             558 => 'Lima, OH',
  111.             559 => 'Bluefield-Beckley-Oak Hill, WV',
  112.             560 => 'Raleigh-Durham, NC',
  113.             561 => 'Jacksonville, FL',
  114.             563 => 'Grand Rapids, MI',
  115.             564 => 'Charleston-Huntington, WV',
  116.             565 => 'Elmira, NY',
  117.             566 => 'Harrisburg-Lancaster-Lebanon-York, PA',
  118.             567 => 'Greenville-Spartenburg, SC',
  119.             569 => 'Harrisonburg, VA',
  120.             570 => 'Florence-Myrtle Beach, SC',
  121.             571 => 'Ft Myers, FL',
  122.             573 => 'Roanoke-Lynchburg, VA',
  123.             574 => 'Johnstown-Altoona, PA',
  124.             575 => 'Chattanooga, TN',
  125.             576 => 'Salisbury, MD',
  126.             577 => 'Wilkes Barre-Scranton, PA',
  127.             581 => 'Terre Haute, IN',
  128.             582 => 'Lafayette, IN',
  129.             583 => 'Alpena, MI',
  130.             584 => 'Charlottesville, VA',
  131.             588 => 'South Bend, IN',
  132.             592 => 'Gainesville, FL',
  133.             596 => 'Zanesville, OH',
  134.             597 => 'Parkersburg, WV',
  135.             598 => 'Clarksburg-Weston, WV',
  136.             600 => 'Corpus Christi, TX',
  137.             602 => 'Chicago, IL',
  138.             603 => 'Joplin-Pittsburg, MO',
  139.             604 => 'Columbia-Jefferson City, MO',
  140.             605 => 'Topeka, KS',
  141.             606 => 'Dothan, AL',
  142.             609 => 'St Louis, MO',
  143.             610 => 'Rockford, IL',
  144.             611 => 'Rochester-Mason City-Austin, MN',
  145.             612 => 'Shreveport, LA',
  146.             613 => 'Minneapolis-St Paul, MN',
  147.             616 => 'Kansas City, MO',
  148.             617 => 'Milwaukee, WI',
  149.             618 => 'Houston, TX',
  150.             619 => 'Springfield, MO',
  151.             620 => 'Tuscaloosa, AL',
  152.             622 => 'New Orleans, LA',
  153.             623 => 'Dallas-Fort Worth, TX',
  154.             624 => 'Sioux City, IA',
  155.             625 => 'Waco-Temple-Bryan, TX',
  156.             626 => 'Victoria, TX',
  157.             627 => 'Wichita Falls, TX',
  158.             628 => 'Monroe, LA',
  159.             630 => 'Birmingham, AL',
  160.             631 => 'Ottumwa-Kirksville, IA',
  161.             632 => 'Paducah, KY',
  162.             633 => 'Odessa-Midland, TX',
  163.             634 => 'Amarillo, TX',
  164.             635 => 'Austin, TX',
  165.             636 => 'Harlingen, TX',
  166.             637 => 'Cedar Rapids-Waterloo, IA',
  167.             638 => 'St Joseph, MO',
  168.             639 => 'Jackson, TN',
  169.             640 => 'Memphis, TN',
  170.             641 => 'San Antonio, TX',
  171.             642 => 'Lafayette, LA',
  172.             643 => 'Lake Charles, LA',
  173.             644 => 'Alexandria, LA',
  174.             646 => 'Anniston, AL',
  175.             647 => 'Greenwood-Greenville, MS',
  176.             648 => 'Champaign-Springfield-Decatur, IL',
  177.             649 => 'Evansville, IN',
  178.             650 => 'Oklahoma City, OK',
  179.             651 => 'Lubbock, TX',
  180.             652 => 'Omaha, NE',
  181.             656 => 'Panama City, FL',
  182.             657 => 'Sherman, TX',
  183.             658 => 'Green Bay-Appleton, WI',
  184.             659 => 'Nashville, TN',
  185.             661 => 'San Angelo, TX',
  186.             662 => 'Abilene-Sweetwater, TX',
  187.             669 => 'Madison, WI',
  188.             670 => 'Ft Smith-Fay-Springfield, AR',
  189.             671 => 'Tulsa, OK',
  190.             673 => 'Columbus-Tupelo-West Point, MS',
  191.             675 => 'Peoria-Bloomington, IL',
  192.             676 => 'Duluth, MN',
  193.             678 => 'Wichita, KS',
  194.             679 => 'Des Moines, IA',
  195.             682 => 'Davenport-Rock Island-Moline, IL',
  196.             686 => 'Mobile, AL',
  197.             687 => 'Minot-Bismarck-Dickinson, ND',
  198.             691 => 'Huntsville, AL',
  199.             692 => 'Beaumont-Port Author, TX',
  200.             693 => 'Little Rock-Pine Bluff, AR',
  201.             698 => 'Montgomery, AL',
  202.             702 => 'La Crosse-Eau Claire, WI',
  203.             705 => 'Wausau-Rhinelander, WI',
  204.             709 => 'Tyler-Longview, TX',
  205.             710 => 'Hattiesburg-Laurel, MS',
  206.             711 => 'Meridian, MS',
  207.             716 => 'Baton Rouge, LA',
  208.             717 => 'Quincy, IL',
  209.             718 => 'Jackson, MS',
  210.             722 => 'Lincoln-Hastings, NE',
  211.             724 => 'Fargo-Valley City, ND',
  212.             725 => 'Sioux Falls, SD',
  213.             734 => 'Jonesboro, AR',
  214.             736 => 'Bowling Green, KY',
  215.             737 => 'Mankato, MN',
  216.             740 => 'North Platte, NE',
  217.             743 => 'Anchorage, AK',
  218.             744 => 'Honolulu, HI',
  219.             745 => 'Fairbanks, AK',
  220.             746 => 'Biloxi-Gulfport, MS',
  221.             747 => 'Juneau, AK',
  222.             749 => 'Laredo, TX',
  223.             751 => 'Denver, CO',
  224.             752 => 'Colorado Springs, CO',
  225.             753 => 'Phoenix, AZ',
  226.             754 => 'Butte-Bozeman, MT',
  227.             755 => 'Great Falls, MT',
  228.             756 => 'Billings, MT',
  229.             757 => 'Boise, ID',
  230.             758 => 'Idaho Falls-Pocatello, ID',
  231.             759 => 'Cheyenne, WY',
  232.             760 => 'Twin Falls, ID',
  233.             762 => 'Missoula, MT',
  234.             764 => 'Rapid City, SD',
  235.             765 => 'El Paso, TX',
  236.             766 => 'Helena, MT',
  237.             767 => 'Casper-Riverton, WY',
  238.             770 => 'Salt Lake City, UT',
  239.             771 => 'Yuma, AZ',
  240.             773 => 'Grand Junction, CO',
  241.             789 => 'Tucson, AZ',
  242.             790 => 'Albuquerque, NM',
  243.             798 => 'Glendive, MT',
  244.             800 => 'Bakersfield, CA',
  245.             801 => 'Eugene, OR',
  246.             802 => 'Eureka, CA',
  247.             803 => 'Los Angeles, CA',
  248.             804 => 'Palm Springs, CA',
  249.             807 => 'San Francisco, CA',
  250.             810 => 'Yakima-Pasco, WA',
  251.             811 => 'Reno, NV',
  252.             813 => 'Medford-Klamath Falls, OR',
  253.             819 => 'Seattle-Tacoma, WA',
  254.             820 => 'Portland, OR',
  255.             821 => 'Bend, OR',
  256.             825 => 'San Diego, CA',
  257.             828 => 'Monterey-Salinas, CA',
  258.             839 => 'Las Vegas, NV',
  259.             855 => 'Santa Barbara, CA',
  260.             862 => 'Sacramento, CA',
  261.             866 => 'Fresno, CA',
  262.             868 => 'Chico-Redding, CA',
  263.             881 => 'Spokane, WA');
  264.     }
  265.     
  266.     /**
  267.      * Lookup the metro region based on the provided DMA code.
  268.      * @param int $dmaCode 
  269.      * @return string Metro region name.
  270.      */
  271.     public static function getMetroRegion($dmaCode)
  272.     {
  273.         if ($dmaCode === null{
  274.             return null;
  275.         }
  276.         if (self::$dmaMap === null{
  277.             self::initialize();
  278.         }
  279.         return self::$dmaMap[$dmaCode];
  280.     }
  281.  
  282.     /**
  283.      * Reverse lookup of DMA code if [exact] metro region name is known.
  284.      * @param string $metro Metro region name.
  285.      * @return int DMA code, or false if not found.
  286.      */
  287.     public static function getDMACode($metro)    
  288.     {
  289.         if (self::$dmaMap === null{
  290.             self::initialize();
  291.         }
  292.         return array_search($metroself::$dmaMap);
  293.     }
  294.  
  295. }

Documentation generated on Mon, 11 Mar 2019 14:20:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.