Changeset 12270

Show
Ignore:
Timestamp:
09/14/07 11:02:29 (1 year ago)
Author:
w_i
Message:

Updated to newest

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/org.routamc.positioning/aerodrome.php

    r3630 r12270  
    1919        return parent::__org_routamc_positioning_aerodrome_dba($id); 
    2020    } 
     21     
     22    /** 
     23     * @return org_routamc_positioning_city_dba City the airport caters for 
     24     */ 
     25    function get_parent_guid_uncached() 
     26    { 
     27        if ($this->city) 
     28        { 
     29            $parent = new org_routamc_positioning_city_dba($this->city); 
     30            if (! $parent) 
     31            { 
     32                debug_push_class(__CLASS__, __FUNCTION__); 
     33                debug_add("Could not load City ID {$this->city} from the database, aborting.", 
     34                    MIDCOM_LOG_INFO); 
     35                debug_pop(); 
     36                return null; 
     37            } 
     38            return $parent->guid; 
     39        } 
     40 
     41        return null; 
     42    } 
     43 
     44    /** 
     45     * Human-readable label for cases like Asgard navigation 
     46     */ 
     47    function get_label() 
     48    { 
     49        if (!empty($this->name)) 
     50        { 
     51            return "{$this->icao} ({$this->name})"; 
     52        } 
     53        return $this->icao; 
     54    } 
     55     
     56    /** 
     57     * Don't save aerodrome if another aerodrome is in same place or exists with same ICAO 
     58     */ 
     59    function _on_creating() 
     60    { 
     61        if (   $this->longitude 
     62            && $this->latitude) 
     63        { 
     64            $qb = org_routamc_positioning_aerodrome_dba::new_query_builder(); 
     65            $qb->add_constraint('longitude', '=', $this->longitude); 
     66            $qb->add_constraint('latitude', '=', $this->latitude); 
     67            $qb->set_limit(1); 
     68            $matches = $qb->execute_unchecked(); 
     69            if (count($matches) > 0) 
     70            { 
     71                // We don't need to save duplicate entries 
     72                return false; 
     73            } 
     74        } 
     75         
     76        $qb = org_routamc_positioning_aerodrome_dba::new_query_builder(); 
     77        $qb->add_constraint('icao', '=', $this->icao); 
     78        $qb->set_limit(1); 
     79        $matches = $qb->execute_unchecked(); 
     80        if (count($matches) > 0) 
     81        { 
     82            // We don't need to save duplicate entries 
     83            return false; 
     84        } 
     85        return parent::_on_creating(); 
     86    } 
    2187} 
    2288?> 
  • branches/MidCOM_2_8/org.routamc.positioning/city.php

    r4795 r12270  
    1919        return parent::__org_routamc_positioning_city_dba($id); 
    2020    } 
     21     
     22    /** 
     23     * Human-readable label for cases like Asgard navigation 
     24     */ 
     25    function get_label() 
     26    { 
     27        return $this->city; 
     28    } 
     29 
     30    /** 
     31     * @return org_routamc_positioning_country_dba Country the city is in 
     32     */ 
     33    function get_parent_guid_uncached() 
     34    { 
     35        if ($this->country) 
     36        { 
     37            $qb = org_routamc_positioning_country_dba::new_query_builder(); 
     38            $qb->add_constraint('code', '=', $this->country); 
     39            $countries = $qb->execute(); 
     40            if (count($countries) == 0) 
     41            { 
     42                debug_push_class(__CLASS__, __FUNCTION__); 
     43                debug_add("Could not load Country ID {$this->country} from the database, aborting.", 
     44                    MIDCOM_LOG_INFO); 
     45                debug_pop(); 
     46                return null; 
     47            } 
     48            return $countries[0]->guid; 
     49        } 
     50 
     51        return null; 
     52    } 
    2153 
    2254    /** 
     
    3769        return parent::_on_creating(); 
    3870    } 
     71     
     72    function get_by_name($name) 
     73    { 
     74        $qb = org_routamc_positioning_city_dba::new_query_builder(); 
     75        $qb->begin_group('OR'); 
     76        $qb->add_constraint('city', '=', $name); 
     77        $qb->add_constraint('alternatenames', 'LIKE', "%{$name}%"); 
     78        $qb->end_group(); 
     79         
     80        $qb->set_limit(1); 
     81         
     82        $matches = $qb->execute_unchecked(); 
     83        if (count($matches) > 0) 
     84        { 
     85            return $matches[0]; 
     86        } 
     87         
     88        return false; 
     89    } 
    3990} 
    4091?> 
  • branches/MidCOM_2_8/org.routamc.positioning/config/config.inc

    r4906 r12270  
    99 
    1010'plazes_developer_key' => '4c637b4469bc11d13e73aa18a55ff6e6', 
     11 
     12'map_provider' => 'google', 
     13'map_api_key'  => '', 
     14 
     15'yahoo_application_key' => '', 
  • branches/MidCOM_2_8/org.routamc.positioning/config/mgdschema.sql

    r3680 r12270  
    5353ALTER TABLE org_routamc_positioning_aerodrome ADD COLUMN revised datetime NOT NULL default '0000-00-00 00:00:00'; 
    5454ALTER TABLE org_routamc_positioning_aerodrome ADD COLUMN revision int(11) NOT NULL default '0'; 
     55ALTER TABLE org_routamc_positioning_aerodrome ADD COLUMN wmo varchar(255) NOT NULL default ''; 
     56ALTER TABLE org_routamc_positioning_aerodrome ADD COLUMN country varchar(2) NOT NULL default ''; 
    5557## 
    5658#Log 
  • branches/MidCOM_2_8/org.routamc.positioning/config/mgdschema.xml

    r5935 r12270  
    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"/> 
    7         <property name="city" type="text"/> 
     37        <property name="city" type="string"/> 
    838        <!-- Country in ISO 3166-1 alpha-2 two letter format --> 
    9         <property name="country" type="text"/> 
    10         <property name="region" type="text"/> 
     39        <property name="country" type="string" link="org_routamc_positioning_country:code" parentfield="country" reverse="no" /> 
     40        <property name="region" type="string"/> 
    1141        <!-- TODO: Alternate names should probably be a MultiLang table --> 
    12         <property name="alternatenames" type="text"/> 
     42        <property name="alternatenames" type="string"/> 
    1343        <property name="population" type="integer"/> 
    1444        <!-- Coordinates in decimal format --> 
    15         <property name="latitude" type="double"/> 
    16         <property name="longitude" type="double"/> 
     45        <property name="latitude" type="float"/> 
     46        <property name="longitude" type="float"/> 
    1747        <property name="altitude" type="integer"/> 
    18  
    19         <!-- required metadata --> 
    20         <property name="revised" type="string"/> 
    21         <property name="revision" type="integer"/> 
    22         <property name="created" type="string"/> 
    23         <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
    24         <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
    25         <!-- /required metadata --> 
    2648    </type> 
    2749 
     
    2951    <type name="org_routamc_positioning_aerodrome" table="org_routamc_positioning_aerodrome" parent="org_routamc_positioning_city" parentfield="city"> 
    3052        <property name="id" type="integer" primaryfield="id"/> 
    31         <property name="icao" type="text"/> 
    32         <property name="iata" type="text"/> 
    33         <property name="name" type="text"/> 
     53        <property name="icao" type="string"/> 
     54        <property name="iata" type="string"/> 
     55        <property name="wmo" type="string"/>         
     56        <property name="name" type="string"/> 
    3457        <property name="city" link="org_routamc_positioning_city:id" reverse="no" type="integer" parentfield="city"/> 
     58        <property name="country" link="org_routamc_positioning_country:code" reverse="no" type="string"/> 
    3559        <!-- Coordinates in decimal format --> 
    3660        <property name="latitude" type="float"/> 
     
    3963        <!-- Runway altitude in meters --> 
    4064        <property name="altitude" type="float"/> 
    41  
    42         <!-- required metadata --> 
    43         <property name="revised" type="string"/> 
    44         <property name="revision" type="integer"/> 
    45         <property name="created" type="string"/> 
    46         <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
    47         <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
    48         <!-- /required metadata --> 
    4965    </type> 
    5066 
     
    6379            objectlocation: Location acquired through an object's location 
    6480        --> 
    65         <property name="importer" type="text"/> 
     81        <property name="importer" type="string"/> 
    6682 
    6783        <!-- 
     
    8298        <!-- Bearing in degrees --> 
    8399        <property name="bearing" type="integer"/> 
    84  
    85         <!-- required metadata --> 
    86         <property name="revised" type="string"/> 
    87         <property name="revision" type="integer"/> 
    88         <property name="created" type="string"/> 
    89         <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
    90         <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
    91         <!-- /required metadata --> 
    92100    </type> 
    93101 
    94102    <!-- Locations are used for connecting any Midgard object into real-world positions --> 
    95     <type name="org_routamc_positioning_location" table="org_routamc_positioning_location"
     103    <type name="org_routamc_positioning_location" table="org_routamc_positioning_location" parentfield="log"
    96104        <property name="id" type="integer" primaryfield="id"/> 
    97105 
    98106        <!-- Parent object GUID --> 
    99         <property name="parent" type="text"/> 
     107        <property name="parent" type="string"/> 
    100108        <!-- Parent object class --> 
    101         <property name="parentclass" type="text"/> 
     109        <property name="parentclass" type="string"/> 
    102110        <!-- Parent component --> 
    103         <property name="parentcomponent" type="text"/> 
     111        <property name="parentcomponent" type="string"/> 
    104112 
    105113        <!-- Log entry this position information is based on if type is set to "10" --> 
    106         <property name="log" link="org_routamc_positioning_log:id" reverse="no" type="integer"/> 
     114        <property name="log" link="org_routamc_positioning_log:id" parentfield="log" reverse="no" type="integer"/> 
     115        <!-- Date maps to XEP-0080 timestamp --> 
    107116        <property name="date" type="integer"/> 
    108117 
     
    115124        <property name="relation" type="integer"/> 
    116125 
    117         <!-- Coordinates in decimal format --> 
     126        <!-- Coordinates in decimal format, mapping to XEP-0080 lat and lon --> 
    118127        <property name="latitude" type="float"/> 
    119128        <property name="longitude" type="float"/> 
    120129 
    121         <!-- Altitude in meters --> 
     130        <!-- Altitude in meters, mapping to XEP-0080 alt --> 
    122131        <property name="altitude" type="float"/> 
    123  
    124         <!-- required metadata --> 
    125         <property name="revised" type="string"/> 
    126         <property name="revision" type="integer"/> 
    127         <property name="created" type="string"/> 
    128         <property name="creator" link="midgard_person:id" reverse="no" type="integer"/> 
    129         <property name="revisor" link="midgard_person:id" reverse="no" type="integer"/> 
    130         <!-- /required metadata --> 
     132         
     133        <!-- XEP-0080 compatible civic location elements from http://www.xmpp.org/extensions/xep-0080.html#format --> 
     134        <property name="area" type="string"/> 
     135        <property name="building" type="string"/> 
     136        <property name="country" link="org_routamc_positioning_country:code" reverse="no" type="string"/> 
     137        <property name="description" type="string"/> 
     138        <property name="floor" type="string"/> 
     139        <property name="city" link="org_routamc_positioning_city:id" reverse="no" type="integer"/> 
     140        <property name="postalcode" type="string"/> 
     141        <property name="region" type="string"/> 
     142        <property name="room" type="string"/> 
     143        <property name="street" type="string"/> 
     144        <property name="text" type="string"/> 
     145        <property name="uri" type="string"/> 
    131146    </type> 
    132147</Schema> 
  • branches/MidCOM_2_8/org.routamc.positioning/config/midcom_dba_classes.inc

    r3630 r12270  
     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', 
  • branches/MidCOM_2_8/org.routamc.positioning/location.php

    r5420 r12270  
    1919        return parent::__org_routamc_positioning_location_dba($id); 
    2020    } 
     21     
     22    /** 
     23     * Human-readable label for cases like Asgard navigation 
     24     */ 
     25    function get_label() 
     26    { 
     27        if ($this->parent) 
     28        { 
     29            $parent = $this->get_parent(); 
     30            if ($parent) 
     31            { 
     32                $label = $parent->guid; 
     33                if (isset($parent->title)) 
     34                { 
     35                    $label = $parent->title; 
     36                } 
     37                elseif (method_exists($parent, 'get_label')) 
     38                { 
     39                    $label = $parent->get_label(); 
     40                } 
     41                return "{$this->parentclass} {$label}"; 
     42            } 
     43        } 
     44        return "{$this->parentclass} #{$this->id}"; 
     45    } 
    2146 
    2247    /** 
     
    3055            && $this->parentclass) 
    3156        { 
     57            if (!class_exists($this->parentclass)) 
     58            { 
     59                if (empty($this->parentcomponent)) 
     60                { 
     61                    return null; 
     62                } 
     63                $_MIDCOM->componentloader->load_graceful($this->parentcomponent); 
     64            } 
    3265            $classname = $this->parentclass; 
    3366            $parent = new $classname($this->parent); 
  • branches/MidCOM_2_8/org.routamc.positioning/utils.php

    r5022 r12270  
    267267            case 'org_routamc_positioning_log_dba': 
    268268            case 'org_routamc_positioning_city_dba': 
    269             case 'org_routamc_positioning_aerodrom_dba': 
     269            case 'org_routamc_positioning_aerodrome_dba': 
    270270                // Real position entry, query it directly 
    271271                $classname = $class; 
     
    287287     * @return Array Array of MidCOM DBA objects sorted by proximity 
    288288     */ 
    289     function get_closest($class, $center, $limit, $modifier = 0.05) 
     289    function get_closest($class, $center, $limit, $modifier = 0.15) 
    290290    { 
    291291        $classname = org_routamc_positioning_utils::get_positioning_class($class); 
     
    298298            $direct = true; 
    299299        } 
    300  
    301300        $qb =  $_MIDCOM->dbfactory->new_query_builder($classname); 
    302301 
     
    335334 
    336335 
     336                if (!isset($current_locale)) 
     337                { 
     338                        $current_locale = setlocale(LC_NUMERIC,"0"); 
     339                        setlocale(LC_NUMERIC,"C"); 
     340                } 
     341 
    337342        $qb->begin_group('AND'); 
    338         $qb->add_constraint('latitude', '<', $from['latitude']); 
     343        $qb->add_constraint('latitude', '<', (float) $from['latitude']); 
    339344        $qb->add_constraint('latitude', '>', (float) $to['latitude']); 
    340345        $qb->end_group(); 
     
    381386 
    382387            $modifier = $modifier * 1.05; 
     388                        setlocale(LC_NUMERIC,$current_locale); 
    383389            return org_routamc_positioning_utils::get_closest($class, $center, $limit, $modifier); 
    384390        } 
     
    411417            array_pop($closest); 
    412418        } 
    413  
     419                setlocale(LC_NUMERIC,$current_locale); 
    414420        return $closest; 
    415421    }