# HG changeset patch
# User casties
# Date 1330028946 -3600
# Node ID 55bc9972fb1bf4c124d820f04cc780a35b19cbaf
# Parent eb8a18f94d2ddd097dc8f9cbec78556bfe68a0e7# Parent d1b43624cc63b829f64cc952540748e15272e389
Merge with d1b43624cc63b829f64cc952540748e15272e389
diff -r eb8a18f94d2d -r 55bc9972fb1b RestDbGisApi.py
--- a/RestDbGisApi.py Thu Feb 23 21:13:21 2012 +0100
+++ b/RestDbGisApi.py Thu Feb 23 21:29:06 2012 +0100
@@ -237,7 +237,7 @@
def getLiveKmlUrl(self,schema,table,useTimestamp=True,REQUEST=None):
return self.getLiveUrl(schema,table,useTimestamp,REQUEST)
- def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red_big"):
+ def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geomField="point", colorField="red_big",from_year_name='from_year',until_year_name=''):
"""returns data structure for KML template"""
logging.debug("getKMLdata gid=%s lat=%s lon=%s sortBy=%s geom=%s color=%s"%(gisIdField,latField,lonField,sortBy,geomField,colorField))
if geomField is None:
@@ -411,18 +411,24 @@
sql = "SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s"
# from_year and until_year in metadata first
try:
- res = self.executeSQL(sql, (table,'from_year'))
+ res = self.executeSQL(sql, (table,from_year_name))
if len(res['rows']) > 0:
from_year = res['rows'][0][0]
except:
from_year = "from_year_dummy"
try:
- res = self.executeSQL(sql, (table,'until_year'))
+ res = self.executeSQL(sql, (table,until_year_name))
if len(res['rows']) > 0:
until_year = res['rows'][0][0]
except:
until_year = "until_year_dummy"
-
+
+ #DW added for testing E4D with names
+ from_year=from_year_name
+ until_year=until_year_name
+
+ logging.debug("from_year:"+from_year)
+ logging.debug("until_year:"+until_year)
for i in range (len(dataset)):
value = dataset[i]
@@ -438,6 +444,7 @@
# continue
val = "%s: %s"%(name, value)
+ logging.debug(name)
value=unicode(value)
if name == from_year:
beg_yr= value
@@ -705,6 +712,7 @@
return kmlFileName
def trydatahas_key(self,data,index,key_string):
+ logging.debug("trying:"+key_string)
try:
return data[index].has_key(key_string)
except:
diff -r eb8a18f94d2d -r 55bc9972fb1b RestDbInterface.py
--- a/RestDbInterface.py Thu Feb 23 21:13:21 2012 +0100
+++ b/RestDbInterface.py Thu Feb 23 21:29:06 2012 +0100
@@ -123,9 +123,10 @@
def JSON_schema_table(self,schema,table):
"""JSON index function"""
+ logging.debug("start: json_schema")
self.REQUEST.RESPONSE.setHeader("Content-Type", "application/json")
json.dump(self.getTable(schema, table), self.REQUEST.RESPONSE)
-
+ logging.debug("end: json_schema")
def __init__(self, id, title, connection_id=None):
"""init"""
@@ -185,6 +186,16 @@
return map
+ def getFieldNames(self,fields):
+ """returns a dict mapping field names to row indexes"""
+ map = []
+ i = 0
+ for f in fields:
+ map.append(f[0])
+
+
+ return map
+
def executeSQL(self, query, args=None, hasResult=True, autocommit=True):
"""execute query with args on database and return all results.
result format: {"fields":fields, "rows":data}"""
@@ -260,6 +271,8 @@
# type and format are real parameter
resultFormat = REQUEST.get('format','HTML').upper()
queryType = REQUEST.get('type',None)
+ from_year_name = REQUEST.get('from_year_name',None)
+ until_year_name = REQUEST.get('until_year_name',None)
logging.debug("index_html path=%s resultFormat=%s queryType=%s"%(path,resultFormat,queryType))
@@ -267,7 +280,7 @@
# non-empty queryType -- look for template
pt = getattr(self.template, "%s_%s"%(resultFormat,queryType), None)
if pt is not None:
- return pt(format=resultFormat,type=queryType,path=path)
+ return pt(format=resultFormat,type=queryType,path=path,from_year_name=from_year_name,until_year_name=until_year_name)
if len(path) == 1:
# list of schemas
@@ -281,8 +294,10 @@
# POST to table to check
return self.checkTable(format=resultFormat,schema=path[1],table=path[2])
# else show table
- return self.showTable(format=resultFormat,schema=path[1],table=path[2],REQUEST=REQUEST, RESPONSE=RESPONSE)
-
+ logging.debug("index_html:will showTable")
+ x= self.showTable(format=resultFormat,schema=path[1],table=path[2],REQUEST=REQUEST, RESPONSE=RESPONSE)
+ logging.debug("index_html:have done showTable")
+ return x
# don't know what to do
return str(REQUEST)
@@ -351,10 +366,15 @@
# everything else has its own template
pt = getattr(self.template, '%s_schema_table'%format, REQUEST)
+ logging.debug("showtable: gottemplate")
if pt is None:
return "ERROR!! template %s_schema_table not found at %s"%(format, self.template )
#data = self.getTable(schema,table)
- return pt(schema=schema,table=table,args=queryArgs)
+ logging.debug("table:"+repr(table))
+ #x = pt(schema=schema,table=table,args={})
+ x = pt(schema=schema,table=table,args=queryArgs)
+ logging.debug("showtable: executed Table")
+ return x
def getLiveUrl(self,schema,table,useTimestamp=True,REQUEST=None):
if REQUEST is None:
@@ -381,7 +401,7 @@
attrString=""
# try:
for name in attrNames['rows']:
- logging.debug("name: ", name[0])
+ logging.debug("name: "+repr( name[0]))
not_added=True
if name[0] == "the_geom": #FJK: the table column is "the_geom"
attrString=attrString+"ST_AsText("+name[0]+"),"
@@ -389,9 +409,9 @@
break
for a_iter in attrTypes['rows']:
not_added = True
- logging.debug("attrTypes.field_name: ", a_iter[0])
+ logging.debug("attrTypes.field_name: "+ repr(a_iter[0]))
if a_iter[0]==name[0]:
- logging.debug("attrTypes.gis_type: ", a_iter[1])
+ logging.debug("attrTypes.gis_type: "+ repr(a_iter[1]))
if a_iter[1] == "the_geom": #FJK: the table column is registered in gis_table_meta_rows as type "the_geom"
attrString=attrString+"ST_AsText("+name[0]+"),"
not_added=False
@@ -407,6 +427,7 @@
""" table does not exist """
# fields=self.get
# self.createEmptyTable(schema, table, fields)
+ logging.debug("getTable: done")
return data
def hasTable(self,schema='public',table=None,username='guest'):
diff -r eb8a18f94d2d -r 55bc9972fb1b gis_gui/blocks/table.html.pt
--- a/gis_gui/blocks/table.html.pt Thu Feb 23 21:13:21 2012 +0100
+++ b/gis_gui/blocks/table.html.pt Thu Feb 23 21:29:06 2012 +0100
@@ -28,7 +28,11 @@
-
+
+ from data (or date):
+ to date (if existing):
+
+
diff -r eb8a18f94d2d -r 55bc9972fb1b gis_gui/lib/blocks.js
--- a/gis_gui/lib/blocks.js Thu Feb 23 21:13:21 2012 +0100
+++ b/gis_gui/lib/blocks.js Thu Feb 23 21:29:06 2012 +0100
@@ -109,15 +109,29 @@
jQuery.getJSON(url,callback);
};
-guiBlocks.prototype.e4DOpen = function(titel,tables){
+guiBlocks.prototype.e4DOpen = function(titel,tablesParam,from_year_name,until_year_name){
var e4D_URL="http://mappit.mpiwg-berlin.mpg.de:8080/e4D?";
- var paramstr = "format=KML";
+ var paramstr;
+ if (until_year_name!='') {
+ paramstr = "format=KML&from_year_name="+from_year_name+"&until_year_name="+until_year_name;
+ }else{
+ paramstr = "format=KML&from_year_name="+from_year_name
+ }
+
// var layer_URL = "http://chinagis-develop.mpiwg-berlin.mpg.de:9080/db/RESTdb/db/public/" + escape(table) + "?" + paramstr;
var layer_URL = "";
+ var tables;
+
+ if (tablesParam instanceof Array) {
+ tables=tablesParam;
+ } else {
+ tables=new Array(tablesParam);
+ }
for (var i=0;iThe title
+
table
-
+
+ -
+