[postgis-users] Force_2d function does not exist
Hello All, I am trying to display a simple shape file from postgis database but error log keep giving me this. [Sat May 12 15:47:53 2012].968000 CGI Request 1 on process 4748 [Sat May 12 15:47:53 2012].968000 msDrawMap(): WMS/WFS set-up and query, 0.000s [Sat May 12 15:47:53 2012].995000 msPostGISLayerWhichShapes(): Query error. Error (ERROR: function force_2d(geometry) does not exist LINE 1: select encode(AsBinary(force_collection(force_2d("geom")),'N... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. ) executing query: select encode(AsBinary(force_collection(force_2d("geom")),'NDR'),'hex') as geom,"gid" from waterways where geom && GeomFromText('POLYGON((64.7695553856427 8.082365,64.7695553856427 34.585531,100.121858614357 34.585531,100.121858614357 8.082365,64.7695553856427 8.082365))',4326) [Sat May 12 15:47:53 2012].996000 msDrawMap(): Image handling error. Failed to draw layer named 'waterways'. [Sat May 12 15:47:53 2012].996000 msFreeMap(): freeing map at 01E5C1F8. my postgres version is 9.0, gdal 1.8, i am using MS4W on windows 7 This shape file was working perfectly on PostGIS 1.5 but now its not working on version 2. please help !! -- Thanks & Regards, Abhishek Bansal http://abhishekbansal.miyuri.com Jaypee Institute of Information Technology, Noida ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Force_2d function does not exist
On Sat, May 12, 2012 at 03:53:45PM +0530, abhishek bansal wrote: > Error (ERROR: function force_2d(geometry) does not exist > LINE 1: select encode(AsBinary(force_collection(force_2d("geom")),'N... > ^ Actually not even AsBinary and force_collection exist, all PostGIS functions got an ST_ prefix, so : encode(ST_AsBinary(ST_force_collection(ST_force_2d("geom")),'N... > my postgres version is 9.0, gdal 1.8, i am using MS4W on windows 7 It is PostGIS version that matters: select postgis_full_version(). You'd have a better experience if you stop using windows, btw. > This shape file was working perfectly on PostGIS 1.5 but now its not > working on version 2. Expected, due to the ST_ prefix. See the release notes in the manual page and the NEWS file in the source tree (I'm guessing you'll find info in there). There is a legacy.sql file you can load to add some obsoleted functions back for the sake of still supporting not-yet-ready users code, if you can't update it. --strk; ,--o-. | __/ |Delivering high quality PostGIS 2.0 ! | / 2.0 |http://strk.keybit.net - http://vizzuality.com `-o--' ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Force_2d function does not exist
Ohkay that worked!! Thanks On Sat, May 12, 2012 at 5:48 PM, Sandro Santilli wrote: > On Sat, May 12, 2012 at 03:53:45PM +0530, abhishek bansal wrote: > > > Error (ERROR: function force_2d(geometry) does not exist > > LINE 1: select encode(AsBinary(force_collection(force_2d("geom")),'N... > > ^ > > Actually not even AsBinary and force_collection exist, all PostGIS > functions got an ST_ prefix, so : > > encode(ST_AsBinary(ST_force_collection(ST_force_2d("geom")),'N... > > > my postgres version is 9.0, gdal 1.8, i am using MS4W on windows 7 > > It is PostGIS version that matters: select postgis_full_version(). > You'd have a better experience if you stop using windows, btw. > > > This shape file was working perfectly on PostGIS 1.5 but now its not > > working on version 2. > > Expected, due to the ST_ prefix. > See the release notes in the manual page and the NEWS file in the > source tree (I'm guessing you'll find info in there). > > There is a legacy.sql file you can load to add some obsoleted > functions back for the sake of still supporting not-yet-ready > users code, if you can't update it. > > --strk; > > ,--o-. > | __/ |Delivering high quality PostGIS 2.0 ! > | / 2.0 |http://strk.keybit.net - http://vizzuality.com > `-o--' > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > -- Thanks & Regards, Abhishek Bansal http://abhishekbansal.miyuri.com Jaypee Institute of Information Technology, Noida ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Closing polylines
On 12 May 2012 09:53, george wash wrote: > Hi, does anyone know of a function or algorithm which will help me in > closing open multilinestrings (contours) (I am using Postgis 2.0, Win 7 64). > My contours are made up of several segments, all multilinestrings, which > sometime are closed but often are open at several places along the same > contour height. > I can close them when the are open at the edge of the map by using a section > of the edge as the closing segment but the real problem is when the contours > are inside the map, e.g. when the several segments making up the contour do > not share common start or end points but have a gap between them. > Any suggestions would be most welcome. > Thank you I use a custom function ST_ForceClosed to close anything that is not closed, including LineStrings or MultiLineStrings. This function can be added to any version of PostGIS: CREATE OR REPLACE FUNCTION ST_ForceClosed(geom geometry) RETURNS geometry AS $BODY$BEGIN IF ST_IsClosed(geom) THEN RETURN geom; ELSIF GeometryType(geom) = 'LINESTRING' THEN SELECT ST_AddPoint(geom, ST_PointN(geom, 1)) INTO geom; ELSIF GeometryType(geom) ~ '(MULTI|COLLECTION)' THEN -- Deconstruct parts WITH parts AS ( SELECT CASE WHEN NOT ST_IsClosed(gd.geom) AND GeometryType(gd.geom) = 'LINESTRING' THEN ST_AddPoint(gd.geom, ST_PointN(gd.geom, 1)) ELSE gd.geom END AS closed_geom FROM ST_Dump(geom) AS gd ) -- Reconstitute parts SELECT ST_Collect(closed_geom) INTO geom FROM parts; END IF; IF NOT ST_IsClosed(geom) THEN RAISE EXCEPTION 'Could not close geometry'; END IF; RETURN geom; END;$BODY$ LANGUAGE plpgsql IMMUTABLE COST 100; -- And example use with a LineString: WITH data AS (SELECT 'LINESTRING (190 370, 130 280, 177 205, 330 250, 290 330)'::geometry as linestr) SELECT ST_IsClosed(linestr), ST_ForceClosed(linestr), ST_IsClosed(ST_ForceClosed(linestr)) FROM data; -- Similar with MultiLineString: WITH data AS (SELECT 'MULTILINESTRING ((190 280, 165 209, 205 186, 260 240, 220 280), (170 320, 118 225, 150 120, 280 130, 310 250, 230 340))'::geometry as linestr) SELECT GeometryType(linestr), ST_IsClosed(linestr), ST_ForceClosed(linestr), ST_IsClosed(ST_ForceClosed(linestr)) FROM data; -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users