Changeset 11642
- Timestamp:
- 08/20/07 21:01:18 (1 year ago)
- Files:
-
- trunk/midcom/org.routamc.positioning/config/mgdschema.xml (modified) (1 diff)
- trunk/midcom/org.routamc.positioning/config/midcom_dba_classes.inc (modified) (1 diff)
- trunk/midcom/org.routamc.positioning/country.php (added)
- trunk/midcom/org.routamc.positioning/documentation/CHANGES (modified) (1 diff)
- trunk/midcom/org.routamc.positioning/exec/import-countries.php (added)
- trunk/midcom/org.routamc.positioning/importer/manual.php (modified) (5 diffs)
- trunk/midcom/org.routamc.positioning/midcom/interfaces.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/org.routamc.positioning/config/mgdschema.xml
r11248 r11642 2 2 <Schema xmlns="http://www.midgard-project.org/repligard/1.4"> 3 3 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 4 34 <!-- 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"> 6 36 <property name="id" type="integer" primaryfield="id"/> 7 37 <property name="city" type="string"/> 8 38 <!-- 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" /> 10 40 <property name="region" type="string"/> 11 41 <!-- TODO: Alternate names should probably be a MultiLang table --> trunk/midcom/org.routamc.positioning/config/midcom_dba_classes.inc
r3630 r11642 1 array( 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 ), 1 7 array( 2 8 'table' => 'org_routamc_positioning_city', trunk/midcom/org.routamc.positioning/documentation/CHANGES
r11237 r11642 7 7 which might even break existing functionality. 8 8 - All items marked with "+" represent completely new features. 9 10 2007-08-20 bergie 11 + Added country information to the database 9 12 10 13 2007-07-16 bergie trunk/midcom/org.routamc.positioning/importer/manual.php
r4795 r11642 33 33 * - country 34 34 * - aerodrome 35 * - timestamp 35 36 * 36 37 * @param Array $log Log entry in Array format specific to importer … … 51 52 $this->log->person = $_MIDGARD['user']; 52 53 } 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 } 54 63 55 64 // Figure out which option we will use, starting from best option … … 119 128 $qb = org_routamc_positioning_city_dba::new_query_builder(); 120 129 $qb->add_constraint('city', '=', $log['city']); 121 $qb->add_constraint('country', '=', $ log['country']);130 $qb->add_constraint('country', '=', $country); 122 131 $matches = $qb->execute(); 123 132 if (count($matches) > 0) … … 131 140 $qb = org_routamc_positioning_city_dba::new_query_builder(); 132 141 $qb->add_constraint('alternatenames', 'LIKE', "%|{$log['city']}|%"); 133 $qb->add_constraint('country', '=', $ log['country']);142 $qb->add_constraint('country', '=', $country); 134 143 $matches = $qb->execute(); 135 144 if (count($matches) > 0) … … 165 174 } 166 175 176 /** 177 * Modify country to conform to ISO standards 178 */ 167 179 function normalize_country($country) 168 180 { 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 ''; 171 196 } 172 197 } trunk/midcom/org.routamc.positioning/midcom/interfaces.php
r11237 r11642 30 30 'utils.php', 31 31 'aerodrome.php', 32 'country.php', 32 33 'city.php', 33 34 'location.php',
