<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Messages posted by "kbechtold"]]></title>
		<link>http://forum.geonames.org/gforum/posts/listByUser/352.page</link>
		<description><![CDATA[Messages posted by "kbechtold"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Aw:Importing *all* geonames tables to mysql</title>
				<description><![CDATA[ Hi folks, 

me again  :wink: 

I found out the problem with the uft8 problem (I had the same problem, see some posts above). You must add the "CHARACTER SET utf8" into the LOAD DATA command.

Here is my complete example (with a geo spatial search within a bounding box)

<blockquote>
# open mysql command line
mysql --default-character-set=utf8 -u root -p

# set character-set to utf8
SET NAMES 'utf8';

# create the database
CREATE DATABASE `geonames`;

# use the database
USE `geonames`;

# create the allCountries table for example
CREATE TABLE `geonames`.`allCountries` (
`geonameId` int(10) unsigned NOT NULL default '0',
`name` varchar(200) NOT NULL default '',
`ansiName` varchar(200) NOT NULL default '',
`alternateNames` varchar(2000) NOT NULL default '',
`latitude` double NOT NULL default '0',
`longitude` double NOT NULL default '0',
`featureClass` char(1) ,
`featureCode` varchar(10) ,
`countryCode` char(2),
`cc2` varchar(60),
`admin1Code` varchar(20) default '',
`admin2Code` varchar(80) default '',
`admin3Code` varchar(20) default '',
`admin4Code` varchar(20) default '',
`population` bigint(11) default '0',
`elevation` int(11) default '0',
`gtopo30` int(11) default '0',
`timezone` varchar(40),
`modificationDate` date default '0000-00-00',
PRIMARY KEY (`geonameid`)
) CHARACTER SET utf8 ;

# here I inserted the character-set property that works for me
LOAD DATA INFILE '/tmp/geonames/allCountries.txt' INTO TABLE `geonames`.`allCountries` CHARACTER SET utf8 (geonameId,name,ansiName,alternateNames,latitude,longitude,featureClass,featureCode,countryCode,cc2,admin1Code,admin2Code,admin3Code,admin4Code,population,elevation,gtopo30,timezone,modificationDate);

# shoud be over 7 million entries (2010, January)
SELECT count(*) FROM `geonames`.`allCountries`;

# now you could use the MySQL geo spatial extensions and add the new (geo) column "coordinate"
ALTER TABLE `geonames`.`allCountries` ADD COLUMN `coordinate` POINT NOT NULL AFTER `longitude`;

# fill the new column "coordinate" with data (lat, lon) from the allCountries table
UPDATE `geonames`.`allCountries` SET coordinate = PointFromText(CONCAT('POINT(',latitude,' ',longitude,')'));

# set an index to the new geo point "coordinate". It MUST be MyISAM, see MySQL documentation
ALTER TABLE `geonames`.`allCountries` ADD SPATIAL INDEX `coordinate`(`coordinate`), ENGINE = MyISAM;

# set some MySQL statement variables, e.g. a small bounding box of part of Berlin, Germany
SET @NE_Latitude=52.45904246505317, @NE_Longitude=13.354050815105438; # northEast coords Berlin-Stegitz, Germany
SET @SW_Latitude=52.44811060147279, @SW_Longitude=13.321183025836945; # southWest coords Berlin-Stegitz, Germany

select * from `geonames`.`allCountries` where
   MBRContains(
    GeomFromText(CONCAT('Polygon((',@SW_Latitude,' ',@SW_Longitude,', ',@NE_Latitude,' ',@SW_Longitude,', ',@NE_Latitude,' ',@NE_Longitude,', ',@SW_Latitude,' ',@NE_Longitude,', ',@SW_Latitude,' ',@SW_Longitude,'))')),
    coordinate
   );

# here is same example, if you're using it in your code
select * from `geonames`.`allCountries` where
   MBRContains(
    GeomFromText('Polygon((52.44811060147279 13.321183025836945, 52.45904246505317 13.321183025836945, 52.45904246505317 13.354050815105438, 52.44811060147279 13.354050815105438, 52.44811060147279 13.321183025836945))'),
    coordinate
   );
&nbsp;
		</blockquote>

I hope, that helps :)

So, I do have also a question. I want to get the closest/nearest point to a point in that table. Yes, I could build a bounding box with a rectangle of e.g. 1 mile. But, is there not an more easier way to find the closest point by a coordinate?

Thanks!

Best regards, Klaus
http://www.gpsies.com/]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/preList/732/7060.page#7060</guid>
				<link>http://forum.geonames.org/gforum/posts/preList/732/7060.page#7060</link>
				<pubDate><![CDATA[Tue, 26 Jan 2010 18:23:52]]> GMT</pubDate>
				<author><![CDATA[ kbechtold]]></author>
			</item>
			<item>
				<title>Aw:Importing *all* geonames tables to mysql</title>
				<description><![CDATA[ Hi folks,

does anyone has a new updated MySQL script to create the geonames database tables? Like an empty dump as written in the message from ajmas (see above, 09/02/2009)?

And :) - does anyone has also the updated load statements?

Thanks a lot!

Cheers, Klaus
http://www.gpsies.com/


]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/preList/732/7059.page#7059</guid>
				<link>http://forum.geonames.org/gforum/posts/preList/732/7059.page#7059</link>
				<pubDate><![CDATA[Mon, 25 Jan 2010 18:14:11]]> GMT</pubDate>
				<author><![CDATA[ kbechtold]]></author>
			</item>
			<item>
				<title>Aw:Service availability?</title>
				<description><![CDATA[ Hi Marc,

thank you very much! The new URL works very reliable and very fast again!

Cheers, 

Klaus]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/preList/1223/5237.page#5237</guid>
				<link>http://forum.geonames.org/gforum/posts/preList/1223/5237.page#5237</link>
				<pubDate><![CDATA[Wed, 21 Jan 2009 16:10:08]]> GMT</pubDate>
				<author><![CDATA[ kbechtold]]></author>
			</item>
			<item>
				<title>Aw:Service availability?</title>
				<description><![CDATA[ Hi Marc,

I'm (<a href="http://www.gpsies.com" target="_new" rel="nofollow">GPSies.com</a>) using the webservice of geonames.org about 500-1.000 times over the hole day by the service "findNearbyPostalCodes". I'm a heavy user by definition? Where is the limit? Should I better decide to download the database dumps?

Thank you for your fantastic service!

Best regards from Berlin,  Klaus]]></description>
				<guid isPermaLink="true">http://forum.geonames.org/gforum/posts/preList/1223/5220.page#5220</guid>
				<link>http://forum.geonames.org/gforum/posts/preList/1223/5220.page#5220</link>
				<pubDate><![CDATA[Tue, 20 Jan 2009 14:58:10]]> GMT</pubDate>
				<author><![CDATA[ kbechtold]]></author>
			</item>
	</channel>
</rss>