CSC/ECE 517 Spring 2015/oss S1504 AAC: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "==About Sahana== ==Goals of the project== ==Implementation== ===Searching Internal database=== ===Searching geonames===")
 
Line 3: Line 3:
==Implementation==
==Implementation==
===Searching Internal database===
===Searching Internal database===
<pre>
    #Get vars from url
    user_str = get_vars["name_startsWith"]
    callback_func = request.vars["callback"]
    atable = db.gis_location
    query = atable.name.lower().like(user_str + '%')
    rows = db(query).select(atable.id,
                            atable.level,
                            atable.name,
                            atable.lat,
                          atable.lon
                            )
    results = []
    count = 0
    for row in rows:
        count += 1
        result = {}
       
        #Convert the level colum into the ADM codes geonames returns
        #fcode = row["gis_location.level"]
        level = row["gis_location.level"]
        if level=="L0": #Country
            fcode = "PCL" #Zoom 5
        elif level=="L1": #State/Province
            fcode = "ADM1"
        elif level=="L2": #County/District
            fcode = "ADM2"
        elif level=="L3": #Village/Suburb
            fcode = "ADM3"
        else: #City/Town/Village
            fcode = "ADM4"
           
        result = {"id" : row["gis_location.id"],
                  "fcode" : fcode,
                  "name" : row["gis_location.name"],
                  "lat" : row["gis_location.lat"],
                  "lng" : row["gis_location.lon"]}
        results.append(result)
</pre>
===Searching geonames===
===Searching geonames===

Revision as of 19:32, 21 March 2015

About Sahana

Goals of the project

Implementation

Searching Internal database

    #Get vars from url
    user_str = get_vars["name_startsWith"]
    callback_func = request.vars["callback"]
    atable = db.gis_location
    query = atable.name.lower().like(user_str + '%')
    rows = db(query).select(atable.id,
                            atable.level,
                            atable.name,
                            atable.lat,
                           atable.lon
                            )
    results = []
    count = 0
    for row in rows:
        count += 1
        result = {}
         
        #Convert the level colum into the ADM codes geonames returns
        #fcode = row["gis_location.level"]
        level = row["gis_location.level"]
        if level=="L0": #Country
            fcode = "PCL" #Zoom 5
        elif level=="L1": #State/Province
            fcode = "ADM1"
        elif level=="L2": #County/District
            fcode = "ADM2"
        elif level=="L3": #Village/Suburb
            fcode = "ADM3"
        else: #City/Town/Village
            fcode = "ADM4"
             
        result = {"id" : row["gis_location.id"],
                  "fcode" : fcode,
                  "name" : row["gis_location.name"],
                  "lat" : row["gis_location.lat"],
                  "lng" : row["gis_location.lon"]}
        results.append(result)

Searching geonames