Beispiel #1
0
def get_products():
    conf = ut.getConfig()
    da = DataAccess(conf)

    query = "select * from products"
    result = da.select_row(query)
    return result
Beispiel #2
0
    def render(self):
        env = Environment(loader=FileSystemLoader('templates'),
                          autoescape=select_autoescape(['html', 'xml']),
                          trim_blocks=True,
                          lstrip_blocks=True)
        dataAccess = DataAccess()
        data = dataAccess.get_formatted_location_data()

        template = env.get_template('template.html')
        rendered_output = template.render(locations=data)
        return rendered_output
Beispiel #3
0
def move_time():
    da = DataAccess()
    name_1 = input("距離計算の場所を一つ入力してください")
    name_2 = input("距離計算の場所を、もう一つ入力してください")
    spot_list = da.get_latitude_longitude(name_1)
    x = da.get_latitude_longitude(name_2)
    a = np.array([])
    b = np.array([])
    for spot, i in zip(spot_list, x):
        a = np.append(a, spot, axis=0)
        b = np.append(b, i, axis=0)

    move_time = space_calc(a[1], a[0], b[1], b[0])
    print(move_time / 4.0)
def proc(raw):
    dataaccess = DataAccess(raw)

    elements = dataaccess.get_level_data()
    evals = dataaccess.get_evals()
    classes = dataaccess.get_classes()
    relative_weights = dataaccess.get_weight_result()

    mem_grades = calculate_membership_grade(evals, classes)
    tree = ElementTree(elements)
    tree.set_membership_grade(mem_grades)
    weights = calculate_weight(relative_weights, tree.get_pids(), tree.get_nodes())
    tree.set_weight(weights)
    final_weight = tree.fuzzy_synthetic_evaluation()
    final_score = calculate_final_score(final_weight, classes)
    res = {}
    res["_result"] = final_score
    res["_errorno"] = 0

    return res
Beispiel #5
0
def createProduct():
    try:
        p_name = request.json['name']
        p_desc = request.json['description']
        p_price = request.json['price']

        p_int_price = float(p_price)

        conf = ut.getConfig()
        da = DataAccess(conf)

        query = "INSERT INTO products (`name`, `description`, `price`) VALUES ('{0}', '{1}', {2})".format(
            p_name, p_desc, str(p_price))
        print query
        da.execute_query(query)

        p_obj = dict(success=True, error="")
    except Exception as ex:
        p_obj = dict(success=False, error=str(ex))

    return json.dumps(p_obj)
Beispiel #6
0
from dataaccess import DataAccess
import numpy as np

da = DataAccess()

#時間的計算(内積)
name = input("調べたい場所を入力してください")
time = da.get_spots_by_time(name)
time = np.array(time)
spot_list = da.get_time()
a = np.array([])
for spot in spot_list:
    a = np.append(a, spot, axis=0)
a = a.reshape(5, 3)
kekka = []
for item in a:
    kekka.append(
        [item[0],
         np.sum(item[1:].astype(np.float) * time.astype(np.float))])
print(kekka)
Beispiel #7
0
from dataaccess import DataAccess
import itertools
import math

hoge = DataAccess()
count = 0
list_latitude = {}
list_longitude = {}
#赤道、極半径
red_rad = 6378.137
pol_rad = 6356.752
name = {}
name_ex = {}
name_box = []
time_box = []

#化成緯度、経度それぞれ辞書型に格納
for id_n in range(1, 11):
    x = list(itertools.chain.from_iterable(hoge.get_spots(id_n)))
    #化成緯度のリスト
    list_latitude[count] = x[2]
    list_longitude[count] = x[3]
    name[count] = x[0]
    name_ex[count] = x[0]
    name_box.append(x[0])
    count += 1


def make_dist(point_A, point_B):
    #print(point_A + "から" + point_B + "までの時間")
    #適当なidを取得
Beispiel #8
0
 def __init__(self):
     self.data = DataAccess()
     self.location_data = None