PHP Classes
elePHPant
Icontem

geozonedb: Get world geographic data from GeoNames into MySQL

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2011-06-14 (4 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 632 All time: 4,681 This week: 1,256Up
Version License PHP version Categories  
geozonedb 0.4GNU General Publi...5PHP 5, Databases, Web services, Geogr...
Description Author  

This class can get world geographic data from GeoNames into MySQL.

It can retrieve geographic data files about countries of the world from the GeoNames site and populates a MySQL database for easier lookup.

The class can create the necessary MySQL tables and fill them with country data elements like names, codes, capital names, location coordinates, city names, postal codes, etc..

Innovation Award  
PHP Programming Innovation award nominee
June 2011
Number 4


Prize: One subscription to the PDF edition of the PHP Architect magazine
GeoNames is site that aggregates information of all regions around the world. That information may be searched in the site or via a Web service.

However, if you need to perform intensive queries on the available information, it would be faster if you query it locally. The site also provides dumps of their database, so you can retrieve and use it locally in any other site.

This class can parse the Geonames database dump files and import it into a local MySQL database to make it easier to query the Geonames information in a much faster way.

Manuel Lemos
Picture of Virgilio lino
Name: Virgilio lino <contact>
Classes: 2 packages by
Country: Italy Italy
Age: 36
All time rank: 177571 in Italy Italy
Week rank: 883 Up46 in Italy Italy Up
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
Copyright Virgilio Lino 2011 Geozonedb. virgiliolino@gmail.com
Based on data taken from geonames.org
The framework and sql files are released under dual license,
Creative Commons Attribution 3.0 License and gpl license 2.

GeoZoneDB is an opensource project to load geozone data into sql
files, ready to download if you don't want to lose time. Database
has been conceived to be as fast as possible to retrieve data from
every Community, State, Country of the world, with population, postal
code, etc.


GeoZoneDB 0.5
geozonedb.php - world data extraction framework
geozonesearch.php - this is the only class you need if you plan to integrate geodata in your software or site.
                    An example of autosuggest is on file index.php please read comments on beginning of the file
                    I'm building a new dump in english, you'll just need to download it and include some files
                    to have all data in your software. I highly recommend to create a database just for geographical
                    data as it together with your database tables, it could slowdown everything. 
Read the instructions for GeoZoneDB0.4 as are ok for 0.5
Please let me know if you like it to virgiliolino@gmail.com send me suggestions, or if you want TO HELP ME!!!!
I'm searching for every skill, even if you are not a programmer i need someone to create a dump of every world language,
i need some one to put files on my site, etc

GeoZoneDB 0.4
What is GeoZoneDB 

--------------------------------------------------------------------------------------------------------------------
You may just download(its still not updated to version 0.4):
geozonedb_dump_data.tar.bz2 wich is an sql file, if you import it in your database you'll have
an optimized database with all the world zones, 2 country tables, and more than one hundred
zones comunity tables

To create a database with new 0.4 version do what follows:
0. Create a database with for example phpmyadmin or you may use an old database
To setup:
1. includes/configure.php
DB_SERVER                   :   the server name: usually it's fine to live "localhost"
DB_SERVER_USERNAME          :   the username      : the username to access the db
DB_SERVER_PASSWORD          :   the password of the user to access the db
DB_DATABASE                 :   the name of the database

There is no need to create the tables in the database, tables will be automatically generated
usage:
to populate the countries data:
$geo=new geoZoneDB();
$geo->setLocale('IT');  // if setted data will not be loaded in english but in the language indicated
$geo->loadCountries();

to populate the zones data:
$geo=new geoZoneDB();
$geo->loadZones();

************************************************************************

HELP WANTED

I need help to optimize the database, i plan to integrate the framework
with Sphinx indexes.
I need help to improve the php framework to import data.
I need help to build a multilevel set of combos to navigate throw
country-state-community.
I plan to build on next release an autosuggest system instead of
multilevel set of combos.
please contact me at virgiliolino@gmail.com

---------------------------------------------------------------------------------

Changes:
Version 0.4 ----------------------------------------------------------------------------------------------------
I've done some OO evolution of the code, on this version i'm gonna try MYsql fulltext search capabilities,
even if benchmarks around on the net tell mysql fullsearch is slow, i've done some tries and i think it's ok,
i get same benchmark as with innodb but without advanced capabilities on IR applied to index.
-result ordered by ranking!


Version 0.3 ----------------------------------------------------------------------------------------------------
I've changed the structure of the every zones table, i'ved removed the ISOnumeric field, it's the field to identify
the country, but, as the information is inserted on the table named by the country code, i think it could be enough
to take the table number, however I've created a ZoneToCountry table with two fields, it will be usefull to identify
the country a zone comes from.
The second most important change is that Zone_ID will be a unique ID among all the zone tables, so the extraction framework
must assing a unique id to every zone row, i mean unique not just inside the table on where it's but, unique among every
zone table, in these way we have a 32bit, the first target to apply the sphinx indexing capabilities. We plan to build
a view with all the zone tables and to index it with the open source indexing server. 


  Files folder image Files  
File Role Description
Accessible without login Plain text file geozonedb.php Class main class
Accessible without login Plain text file readme Doc. instructions
Accessible without login Plain text file engine.php Example library used by main class put in includes directory
Accessible without login Plain text file includes_configure.php Conf. put on includes directory
Accessible without login Plain text file includes_geozonedb.php Aux. put on includes directory
Accessible without login Plain text file geozonesearch.php Class class for interface to use on your application
Accessible without login Plain text file index.php Appl. example of usage

 Version Control Unique User Downloads Download Rankings  
 0%Total:632All time:4,681
 This week:0This week:1,256Up