From d406a815617566931403e65ca273f19e9ab115b3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 25 Jul 2012 01:38:36 +0530 Subject: [PATCH] fix editstops js --- chaloBEST/static/js/editstops.js | 14 +++++++++++--- patches/postgis-adapter-2.patch | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 patches/postgis-adapter-2.patch diff --git a/chaloBEST/static/js/editstops.js b/chaloBEST/static/js/editstops.js index b6c440b..c8c75d3 100644 --- a/chaloBEST/static/js/editstops.js +++ b/chaloBEST/static/js/editstops.js @@ -39,6 +39,7 @@ var API_BASE = "/1.0/", $('.list').click(function(e) { var name = $(this).attr("id").replace("sList", ""); //FIXME: stick name in a data attr or so? var $target = $(e.target).parent(); + //console.log($target); if (!$target.hasClass('listItem')) { return; } @@ -75,10 +76,12 @@ var API_BASE = "/1.0/", $('#stopForm').remove(); $('#formCol').empty(); $.getJSON(url, {'srid': 3857}, function(obj) { + //console.log("here", $target); $loading.remove(); var stopsGeojson = obj.stops; var stops = stopsGeojson.features; var $stopsList = getStopsList(stops); + //console.log($stopsList); var stopsWithGeom = []; $.each(stops, function(i,v) { if (!$.isEmptyObject(v.geometry)) { @@ -89,11 +92,16 @@ var API_BASE = "/1.0/", stopsGeojson.features = stopsWithGeom; var currFeatures = jsonLayer.features; jsonLayer.removeFeatures(currFeatures); + console.log(stopsWithGeom); if (stopsWithGeom.length !== 0) { jsonLayer.addFeatures(geojson_format.read(stopsGeojson)); var maxExtent = jsonLayer.getDataExtent(); - map.zoomToExtent(maxExtent); - } + //What you see here with the setTimeout is a sign of having given up - PLEASE PLEASE make this go away - you should not need to do this - but apparently there is some error being raised by map.zoomToExtent() ALTHOUGH it seems to be doing the right thing and calling it in a setTimeout makes the other code work alright. But it causes me to sleep a little less soundly at night. Please HELP. + setTimeout(function() { + map.zoomToExtent(maxExtent); + }, 50); + } + //console.log("whoosh", $target); $target.append($stopsList); // $target.data("hasList", true); $target.data("loading", false); @@ -315,7 +323,7 @@ var API_BASE = "/1.0/", var permalink = new OpenLayers.Control.Permalink({base: "http://www.openstreetmap.org/"}); map.addControl(permalink); $(".olControlPermalink a").attr("target","_blank").html("View in OSM"); - alert('Not here'); + //alert('Not here'); } function onFeatureSelect(e) { diff --git a/patches/postgis-adapter-2.patch b/patches/postgis-adapter-2.patch new file mode 100644 index 0000000..2bc9552 --- /dev/null +++ b/patches/postgis-adapter-2.patch @@ -0,0 +1,28 @@ +--- django/contrib/gis/db/backends/postgis/adapter.py.orig 2011-09-09 11:51:27.769648151 +0100 ++++ django/contrib/gis/db/backends/postgis/adapter.py 2011-09-12 14:09:51.733962708 +0100 +@@ -12,6 +12,7 @@ + # the adaptor) and the SRID from the geometry. + self.ewkb = str(geom.ewkb) + self.srid = geom.srid ++ self._adapter = Binary(self.ewkb) + + def __conform__(self, proto): + # Does the given protocol conform to what Psycopg2 expects? +@@ -26,10 +27,15 @@ + def __str__(self): + return self.getquoted() + ++ def prepare(self, conn): ++ # Pass the connection to the adapter: this allows escaping the binary ++ # in the style required by the server's standard_conforming_string setting. ++ self._adapter.prepare(conn) ++ + def getquoted(self): + "Returns a properly quoted string for use in PostgreSQL/PostGIS." +- # Want to use WKB, so wrap with psycopg2 Binary() to quote properly. +- return 'ST_GeomFromEWKB(E%s)' % Binary(self.ewkb) ++ # psycopg will figure out whether to use E'\\000' or '\000' ++ return 'ST_GeomFromEWKB(%s)' % self._adapter.getquoted() + + def prepare_database_save(self, unused): + return self