Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Myth of Cambodia Geography Identification Code

with one comment

How many of you are familiar with Cambodia Geography Identification code. Do you know the myth behind it code assignment? Well, it’s all started like this:

  • There are 4 levels of administration
    • Province
      • District
        • Commune
          • Village
  • Each level add up 2 digits begin with Province 2 digits
  • Identification code are stored in numberic form (Integer)

That mean valid village code length bewteen 7 and 8 for example code 24020406 would identified as:

  • Village Name = Ou Ressey Loeu (24020406)
  • In Commune  = Ou Andoung (240204)
  • In District = Sala Krau (2402)
  • In Province = Pailin (24)

Now suppose these Geography represent in 4 separate tables (SQL Server for ghost shack!) 

geography

By knowing a village code (eg:  24020406) I want to extract province code and I want the quickest way possible any thought? Oh ! there will be a reward for best answer.

Advertisements

Written by Chorn Sokun

April 28, 2009 at 5:27 pm

One Response

Subscribe to comments with RSS.

  1. // In C# you can do:
    int villageCode = 24020406 ;
    int provinceCode = villageCode / Math.Pow(10,6); // 24
    
    // In Ms. Excel:
    Cell A1 = 24020406 
    Cell A2 = "=INT(A1/10^6)
    
    // In Ms. Access:
    SELECT (vil.Id\10^6) as ProvinceId 
      FROM GISVillage vil WHERE vil.Id = 24020406 
    
    // SQL Server
    SELECT (vil.Id/POWER(10,6)) as ProvinceId 
      FROM GISVillage vil WHERE vil.Id = 24020406 
    
    // ... what else ?
    

    Chorn Sokun

    October 2, 2009 at 9:17 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: