Changeset 11642

Show
Ignore:
Timestamp:
08/20/07 21:01:18 (1 year ago)
Author:
bergie
Message:

Country information support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/org.routamc.positioning/config/mgdschema.xml

    r11248 r11642  
    22<Schema xmlns="http://www.midgard-project.org/repligard/1.4"> 
    33 
     4    <!-- Country --> 
     5    <type name="org_routamc_positioning_country" table="org_routamc_positioning_country"> 
     6        <property name="id" type="integer" primaryfield="id"/> 
     7        <!-- Country in ISO 3166-1 alpha-2 two letter format --> 
     8        <property name="code" type="string"/> 
     9        <!-- Country in ISO 3166-1 alpha-3 three letter format --> 
     10        <property name="code3" type="string"/>         
     11        <property name="codenumeric" type="string"/>           
     12        <!-- Country in FIPS two letter format --> 
     13        <property name="fips" type="string"/>         
     14         
     15        <property name="name" type="string"/> 
     16        <!-- TODO: Alternate names should probably be a MultiLang table --> 
     17        <property name="alternatenames" type="string"/> 
     18 
     19        <!-- Metadata -->         
     20        <property name="population" type="integer"/> 
     21        <!-- Area is in square km --> 
     22        <property name="area" type="float"/> 
     23        <property name="currency" type="string"/> 
     24        <property name="continent" type="string"/> 
     25        <property name="capital" type="integer" link="org_routamc_positioning_city:id" reverse="no"/> 
     26         
     27        <!-- Coordinates in decimal format --> 
     28        <property name="bboxwest" type="float"/> 
     29        <property name="bboxnorth" type="float"/> 
     30        <property name="bboxeast" type="float"/> 
     31        <property name="bboxsouth" type="float"/> 
     32    </type> 
     33 
    434    <!-- City is used for mapping log entries to "real-world places" --> 
    5     <type name="org_routamc_positioning_city" table="org_routamc_positioning_city"
     35    <type name="org_routamc_positioning_city" table="org_routamc_positioning_city" parentfield="country"
    636        <property name="id" type="integer" primaryfield="id"/> 
    737        <property name="city" type="string"/> 
    838        <!-- Country in ISO 3166-1 alpha-2 two letter format --> 
    9         <property name="country" type="string"/> 
     39        <property name="country" type="string" link="org_routamc_positioning_country:code" parentfield="country" reverse="no" /> 
    1040        <property name="region" type="string"/> 
    1141        <!-- TODO: Alternate names should probably be a MultiLang table --> 
  • trunk/midcom/org.routamc.positioning/config/midcom_dba_classes.inc

    r3630 r11642  
     1array( 
     2    'table' => 'org_routamc_positioning_country', 
     3    'old_class_name' => null, 
     4    'new_class_name' => 'org_routamc_positioning_country', 
     5    'midcom_class_name' => 'org_routamc_positioning_country_dba' 
     6), 
    17array( 
    28    'table' => 'org_routamc_positioning_city', 
  • trunk/midcom/org.routamc.positioning/documentation/CHANGES

    r11237 r11642  
    77  which might even break existing functionality. 
    88- All items marked with "+" represent completely new features. 
     9 
     102007-08-20 bergie 
     11  + Added country information to the database 
    912 
    10132007-07-16 bergie 
  • trunk/midcom/org.routamc.positioning/importer/manual.php

    r4795 r11642  
    3333     * - country 
    3434     * - aerodrome 
     35     * - timestamp 
    3536     * 
    3637     * @param Array $log Log entry in Array format specific to importer 
     
    5152            $this->log->person = $_MIDGARD['user']; 
    5253        } 
    53         $this->log->date = time(); 
     54         
     55        if (array_key_exists('timestamp', $log)) 
     56        { 
     57            $this->log->date = (int) $log['timestamp']; 
     58        } 
     59        else 
     60        { 
     61            $this->log->date = time(); 
     62        } 
    5463 
    5564        // Figure out which option we will use, starting from best option 
     
    119128            $qb = org_routamc_positioning_city_dba::new_query_builder(); 
    120129            $qb->add_constraint('city', '=', $log['city']); 
    121             $qb->add_constraint('country', '=', $log['country']); 
     130            $qb->add_constraint('country', '=', $country); 
    122131            $matches = $qb->execute(); 
    123132            if (count($matches) > 0) 
     
    131140                $qb = org_routamc_positioning_city_dba::new_query_builder(); 
    132141                $qb->add_constraint('alternatenames', 'LIKE', "%|{$log['city']}|%"); 
    133                 $qb->add_constraint('country', '=', $log['country']); 
     142                $qb->add_constraint('country', '=', $country); 
    134143                $matches = $qb->execute(); 
    135144                if (count($matches) > 0) 
     
    165174    } 
    166175 
     176    /** 
     177     * Modify country to conform to ISO standards 
     178     */ 
    167179    function normalize_country($country) 
    168180    { 
    169         // TODO: Modify country to conform to ISO standards 
    170         return $country; 
     181        if (strlen($country) == 2) 
     182        { 
     183            // Probably an ISO code 
     184            return $country; 
     185        } 
     186         
     187        $qb = org_routamc_positioning_country_dba::new_query_builder(); 
     188        $qb->add_constraint('name', '=', $country); 
     189        $countries = $qb->execute(); 
     190        if (count($countries) > 0) 
     191        { 
     192            return $countries[0]->code; 
     193        } 
     194         
     195        return ''; 
    171196    } 
    172197} 
  • trunk/midcom/org.routamc.positioning/midcom/interfaces.php

    r11237 r11642  
    3030            'utils.php', 
    3131            'aerodrome.php', 
     32            'country.php', 
    3233            'city.php', 
    3334            'location.php',