Permalink
Browse files

Use projection title (if exists, else EPSG code) in Map CRS combobox

  • Loading branch information...
uprel committed Feb 2, 2019
1 parent f3a1926 commit d9a31b03907b5c0aa386bc577d97caf170eb9dff
Showing with 101 additions and 3 deletions.
  1. +2 −2 client/site/js/GUI.js
  2. +3 −1 client/site/js/LoadAppProjectData.js
  3. +96 −0 client/wsgi/data.wsgi
@@ -357,9 +357,9 @@ MyViewportUi = Ext.extend(Ext.Viewport, {
editable: false,
mode: 'local',
triggerAction: 'all',
width: 90,
width: 160,
store: projectData.crsComboStore(),
value: projectData.crsComboStore()[0],
value: projectData.crsComboStore()[0][1],
listeners: {
"select": function(combo, record, index) {
Eqwc.currentMapProjection = projectData.getProjectionsList().filter(function (val) {
@@ -228,7 +228,9 @@ projectData.crsComboStore = function() {

projectData.getProjectionsList().map(function(currentValue, index, arr) {
var code = currentValue[0];
ret.push(code);
var title = currentValue[1];
title = title ? title : code;
ret.push([code,title]);
}, ret);

return ret;
@@ -0,0 +1,96 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#sample queries
#http://localhost/wsgi/data.wsgi?table=lookup.temakode&filter=SOSI%20kode&gtype=2&cb=bla

import re #regular expression support
import string #string manipulation support
from webob import Request
from webob import Response
import psycopg2 #PostgreSQL DB Connection
import psycopg2.extras #z.b. für named column indexes
import json
import sys
import os

# append the Python path with the wsgi-directory
qwcPath = os.path.dirname(__file__)
if not qwcPath in sys.path:
sys.path.append(qwcPath)

import qwc_connect

def application(environ, start_response):
request = Request(environ)
filt = [];

table = request.params["table"]
gtype = request.params["gtype"]

filterString = request.params["filter"]

sql = ""
errorText = ''
data = ()

#todo params check and sanitize
#if "filter" in request.params:
# filterString = request.params["filter"]
# if len(filterString) > 0:
# #sanitize
# if re.search(r"[^A-Za-z,._]", filterString):
# print >> environ['wsgi.errors'], "wrong input: %s" % filterString
# filt = [] # set empty to have no search table error returned
# else:
# filt.extend(filterString.split(','))

filt.extend(filterString.split(','))
filtLength = len(filt)

#add single quotes
for i in range(filtLength):
filt[i] = "'"+filt[i]+"'"

sql += "SELECT code, description FROM " + table + " WHERE category IN("+','.join(filt)+") AND geom_type="+gtype+";"

#sql += "SELECT * FROM " + table + ";"

conn = qwc_connect.getConnection(environ, start_response)

if conn == None:
return [""]

cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)

try:
cur.execute(sql, data)
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
conn.close()
errorText += 'error: could not execute query'
# write the error message to the error.log
print >> environ['wsgi.errors'], "%s" % errorText+": "+str(exceptionValue)
response_headers = [('Content-type', 'text/plain; charset=utf-8'),
('Content-Length', str(len(errorText)))]
start_response('500 INTERNAL SERVER ERROR', response_headers)

return [errorText]

rowData = [];
rows = cur.fetchall()

resultString = '{"results": '+json.dumps(rows)+'}'
#resultString = string.replace(resultString,'"bbox": "[','"bbox": [')
#resultString = string.replace(resultString,']",','],')

#we need to add the name of the callback function if the parameter was specified
if "cb" in request.params:
resultString = request.params["cb"] + '(' + resultString + ')'

response = Response(resultString,"200 OK",[("Content-type","text/plain; charset=utf-8"),("Content-length", str(len(resultString)) )])

conn.close()

return response(environ, start_response)


1 comment on commit d9a31b0

@uprel

This comment has been minimized.

Copy link
Owner Author

uprel commented on d9a31b0 Feb 2, 2019

Addinig missing commit message for data.wsgi - new WSGI script to get data in json from database

Please sign in to comment.