Mercurial > hg > ChinaGisRestApi
changeset 117:3369c21b66e0
polygon-Layers
author | fknauft |
---|---|
date | Wed, 02 Feb 2011 13:42:45 +0100 |
parents | a7087ee57d09 |
children | 2795bb8fbcbc |
files | RestDbGisApi.py gis_gui/blocks/layer.html.pt gis_gui/blocks/layer.js gis_gui/head.pt gis_gui/icons/mappit_stand.png zpt/KML_schema_table.zpt |
diffstat | 6 files changed, 36 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/RestDbGisApi.py Wed Feb 02 13:19:50 2011 +0100 +++ b/RestDbGisApi.py Wed Feb 02 13:42:45 2011 +0100 @@ -161,7 +161,7 @@ paramstr = urllib.urlencode(params) return "%s/db/%s/%s?%s"%(baseUrl,schema,table,paramstr) - def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None): + def getKmlData(self, schema, table, ids=None, sortBy=1, gisIdField=None, latField=None, lonField=None, geometry="point"): """returns data structure for KML template""" logging.debug("getKMLdata gid=%s lat=%s lon=%s"%(gisIdField,latField,lonField)) # Mapping a set of points from table-based SQL-query: @@ -189,7 +189,12 @@ data = self.executeSQL(qstr,idList) fieldMap = self.getFieldNameMap(data['fields']) - + try: + geomstr='select astext(st_simplify(transform(the_geom,4326),0.02)) from "%s"."%s"'%(schema,table) + geomdata=self.executeSQL(geomstr) + except: + geomdata=None + if (gisIdField is None) and (latField is None or lonField is None): # no fields given - choose automagically sql = 'SELECT field_name FROM public.gis_table_meta_rows WHERE table_name = %s and gis_type = %s' @@ -225,6 +230,7 @@ gisIdIdx = fieldMap.get(gisIdField,None) latIdx = fieldMap.get(latField,None) lonIdx = fieldMap.get(lonField,None) + the_geom=fieldMap.get("the_geom",None) logging.debug("gisidfield=%s idx=%s"%(gisIdField,gisIdIdx)) # convert data @@ -280,10 +286,13 @@ #kmlPlace['description'] = "<![CDATA[%s]]>"%desc kmlPlace['description'] = desc - kmlPlace['icon'] = '#marker_icon' - kmlPlace['coord_x'] = str(xCoord) - kmlPlace['coord_y'] = str(yCoord) - kmlPlace['coord_z'] = '0' + if geometry=='point': + kmlPlace['icon'] = '#marker_icon' + kmlPlace['coord_x'] = str(xCoord) + kmlPlace['coord_y'] = str(yCoord) + kmlPlace['coord_z'] = '0' + if geomtry=='poly': + kmlPlace['LinearRing']=geomdata.split('(')[4] kmlData.append(kmlPlace) #logging.debug("kmlData=%s"%(repr(kmlData))) @@ -405,7 +414,7 @@ kml4Marker=kml4Marker+attribute_string+"</a><br>\n" kml4Marker=kml4Marker+"]]></description>\n" - kml4Marker=kml4Marker+"<styleURL>#marker_icon</styleURL>\n" + kml4Marker=kml4Marker+"<styleURL>#marker_icon_red</styleURL>\n" kml4Marker=kml4Marker+"<Point>" kml4Marker=kml4Marker+"<coordinates>"+str(xCoord)+","+str(yCoord)+",0</coordinates>\n"
--- a/gis_gui/blocks/layer.html.pt Wed Feb 02 13:19:50 2011 +0100 +++ b/gis_gui/blocks/layer.html.pt Wed Feb 02 13:42:45 2011 +0100 @@ -40,6 +40,7 @@ <tr> <th> Label </th> <td> <select class="layer_label_select"><option>None</option></select> </td> </tr> <tr> <th> Size </th> <td> <select class="layer_size_select"><option>None</option></select></td> </tr> <tr> <th> Color </th> <td> <select class="layer_color_select"><option>None</option><option>blue</option><option>green</option><option>black</option><option>violett</option><option>red</option></select></td> </tr> + <tr> <th> Geometry </th> <td> <select class="layer_geom_select"><option>point</option><option>poly</option><option>line</option></select></td> </tr> <tr> <th> Shape </th> <td> <select class="layer_shape_select"><option>None</option></select> </td> </tr> <tr> <td colspan="2"> <input class="layer_line_checkbox" type="checkbox"/> connect markers with a line </td></tr> </table>
--- a/gis_gui/blocks/layer.js Wed Feb 02 13:19:50 2011 +0100 +++ b/gis_gui/blocks/layer.js Wed Feb 02 13:42:45 2011 +0100 @@ -36,6 +36,7 @@ } $(this).find("option").filter(function(){return $(this).text() == params.size_field;}).attr("selected","true"); }); + $(be).find(".layer_geom_select"); $(be).find(".layer_color_select"); // $(be).find(".layer_color_select").load("../db/RESTdb/db/public/"+tablename+"?format=HTML&type=schema_table_rows&layout=select&element_id=rows #rows *", // function() { @@ -102,6 +103,7 @@ params.label_field = $(elem).find(".layer_label_select").val(); params.size_field = $(elem).find(".layer_size_select").val(); params.color_field = $(elem).find(".layer_color_select").val(); + params.geom_field = $(elem).find(".layer_geom_select").val(); params.shape_field = $(elem).find(".layer_shape_select").val(); params.connect_line = $(elem).find(".layer_line_checkbox").attr("checked"); return params; @@ -114,9 +116,12 @@ if (params.position_field && params.position_field != "Default") { paramstr += "&gis_id_field="+params.position_field; } - if (params.color_field!="red"){ + if (params.color_field!="None"){ paramstr += "&color_field="+params.color_field; } + if (params.geometry_field!="point"){ + paramstr += "&geometry_field="+params.geometry_field; + } if (params.connect_line) { paramstr += "&connect_line="+params.connect_line; }
--- a/gis_gui/head.pt Wed Feb 02 13:19:50 2011 +0100 +++ b/gis_gui/head.pt Wed Feb 02 13:42:45 2011 +0100 @@ -1,4 +1,6 @@ <div class="head"> <span style="float:right" tal:content="python:'logged in as %s'%request.get('AUTHENTICATED_USER','')"/> -<h1><b>map P</b>laces <b>I</b>n <b>T</b>ime</h1> +<span style="float: left; width: 250px;" ><img align="left" width="100%" src="http://www.mpiwg-berlin.mpg.de/en/images/title.png" /><br/> + <img align="left" width="50%" src="http://mappit.mpiwg-berlin.mpg.de/mappit/icons/mpdl_logo.png" /></span> +<font size=5 style="margin-left:-120px;"><b>map P</b>laces <b>I</b>n <b>T</b>ime</font> </div> \ No newline at end of file
--- a/zpt/KML_schema_table.zpt Wed Feb 02 13:19:50 2011 +0100 +++ b/zpt/KML_schema_table.zpt Wed Feb 02 13:42:45 2011 +0100 @@ -61,7 +61,7 @@ <color>ff0000ff</color> </PolyStyle> </Style> - <Placemark tal:repeat="place data"> + <Placemark tal:repeat="place data" tal:condition="place/geometry=='point'"> <description tal:content="place/description"> ERD-0815: ERD-0815 </description> @@ -71,6 +71,15 @@ <coordinates tal:content="string:${place/coord_x},${place/coord_y},${place/coord_z}">116.38,39.92,0</coordinates> </Point> </Placemark> + <Placemark tal:repeat="place data" tal:condition="place/geometry=='poly'"> + <description tal:content="place/description"> + ERD-0815: ERD-0815 + </description> +# <styleUrl tal:content="place/icon">#marker_icon</styleUrl> + <Style><PolyStyle><color>#80800000</color><fill>1</fill><outline>1</outline></PolyStyle></Style> + <MultiGeometry><Polygon><outerBoundaryIs><LinearRing><coordinates> tal:content="string:${place/LinearRing}">116.38,39.92,0</coordinates> + </LinearRing></outerBoundaryIs></Polygon></MultiGeometry> + </Placemark> <Placemark tal:condition="withLine"> <name>Path</name> <description>Red line visualizes path between locations</description>