Subject: [Thuban-list] LINESTRING and PostGIS

From: Stephan Holl <[email-masked]>
Date: Wed, 17 Mar 2004 20:39:19 +0100

Dear developers,

I am trying to access a dataset stored in Postgis which has the GEOMETRY
of LINESTRING.
I have the same geometries stored in another table with MUTLILINESTRING,
which works perfect.

The following output of thuban appears:
An unhandled exception occurred:
'LINESTRING'
(please report to http://thuban.intevation.org/bugtracker.html)

Traceback (most recent call last):
  File "/home/steph/cvs/thuban/Thuban/UI/legend.py", line 489, in
_OnItemActivated
    self.parent.DoOnProperties()
  File "/home/steph/cvs/thuban/Thuban/UI/legend.py", line 171, in
DoOnProperties
    self.mainWindow.OpenLayerProperties(list[0], list[1])
  File "/home/steph/cvs/thuban/Thuban/UI/mainwindow.py", line 690, in
OpenLayerProperties
    dialog = Classifier(self, name, self.Map(), layer, group)
  File "/home/steph/cvs/thuban/Thuban/UI/classifier.py", line 769, in
__init__
    self.__SelectField(self.__cur_field, group = group)
  File "/home/steph/cvs/thuban/Thuban/UI/classifier.py", line 996, in
__SelectField
    self.__SetGridTable(newIndex, group)
  File "/home/steph/cvs/thuban/Thuban/UI/classifier.py", line 970, in
__SetGridTable
    self.layer.ShapeType(), group)
  File "/home/steph/cvs/thuban/Thuban/Model/layer.py", line 216, in
ShapeType
    return self.store.ShapeType()
  File "/home/steph/cvs/thuban/Thuban/Model/postgisdb.py", line 471, in
ShapeType
    return shapetype_map[result]
KeyError: 'LINESTRING'

Does that mean, that thuban can not handle dataset in LINESTRING
notation?!
I am using thuban from CVS
Thuban Release Version 1.0.0
Currently using:
	wxPython 2.4.2.4
	Python 2.3.2
	PySQLite 0.4.3
	SQLite 2.8.9
	GDAL 1.2.0.0
	psycopg 1.1.10

thanks for your help

cheers
	Stephan Holl

-- 
Stephan Holl

Check headers for GnuPG Key!
http://www.gdf-hannover.de

 20:33:27 up  4:21,  1 user,  load average: 0.35, 0.41, 0.38

---

From: [email-masked] (Luiko Czub)
Date: Thu, 18 Mar 2004 05:02:17 +0100

Moin Stephan,

> I have the same geometries stored in another table with MUTLILINESTRING,

With following modification in thuban/Thuban/Model/postgisdb.py , you should
work with LINESTRINGS. 

shapetype_map = {"POLYGON": SHAPETYPE_POLYGON,
                 "MULTIPOLYGON": SHAPETYPE_POLYGON,
                 "MULTILINESTRING": SHAPETYPE_ARC,
## NEW LC 250104 ADD geomtype LINESTRING
                 "LINESTRING": SHAPETYPE_ARC,
## END LC 250104 ADD geomtype LINESTRING
                 "POINT": SHAPETYPE_POINT}

-- 

Gruß Luiko Czub

---

From: Stephan Holl <[email-masked]>
Date: Thu, 18 Mar 2004 18:07:22 +0100

Hello Luiko,

At Thu, 18 Mar 2004 05:02:17 +0100 Luiko Czub wrote:

> > I am trying to access a dataset stored in Postgis which has the
> > GEOMETRY of LINESTRING.
> > I have the same geometries stored in another table with
> > MUTLILINESTRING, which works perfect.
> > 
> 
> With following modification in thuban/Thuban/Model/postgisdb.py , you
> should work with LINESTRINGS. 
> 

THanks for this hint. This nearly solves my problem...but now its partly
my fault.
Here is the given output:
Traceback (most recent call last):
  File "/home/steph/cvs/thuban/Thuban/UI/view.py", line 206, in
_do_redraw
    if self.render_iter.next():
  File "/home/steph/cvs/thuban/Thuban/UI/view.py", line 255, in
_render_iterator
    for cont in renderer.RenderMapIncrementally():
  File "/home/steph/cvs/thuban/Thuban/UI/baserenderer.py", line 202, in
render_map_incrementally
    for i in self.draw_shape_layer_incrementally(layer):
  File "/home/steph/cvs/thuban/Thuban/UI/baserenderer.py", line 270, in
draw_shape_layer_incrementally
    for shape in self.layer_shapes(layer):
  File "/home/steph/cvs/thuban/Thuban/Model/postgisdb.py", line 534, in
ShapesInRegion
    cursor.execute("SELECT gid, AsText(%s) FROM %s"
ProgrammingError: ERROR:  Attribut »gid« nicht gefunden

SELECT gid, AsText("wkb_geometry") FROM "roads" WHERE "wkb_geometry" &&
GeometryFromText('POLYGON((3427000.290000 5787098.271461, 3427000.290000
5801372.438539, 3444004.000000 5801372.438539, 3444004.000000
5787098.271461, 3427000.290000 5787098.271461))', 104306) ORDER BY gid

My dataset does not have the "gid"-column, it is named ogc_fid (by
v.out.ogr).
After copying this column to "gid" everything is fine.

I am not quite sure why v.out.ogr does not name a gid-column...

But thanks so far.

Gruß
  Stephan

-- 
Stephan Holl

 18:00:40 up 54 min,  1 user,  load average: 0.25, 0.16, 0.11

---

From: Bernhard Herzog <[email-masked]>
Date: Thu, 18 Mar 2004 18:50:00 +0100

> ProgrammingError: ERROR:  Attribut »gid« nicht gefunden

The code in Thuban 1.0.0 only works with tables that have a column
called "gid".  This has been fixed in CVS last week.  You might want to
try that.

> I am not quite sure why v.out.ogr does not name a gid-column...

It doesn't have to.  The requirement for the gid-column is (or was now)
really a bug in Thuban.  All that's required now is that it has an
integer column with ids.  The dialog lets you choose which one to use.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/

---

From: Stephan Holl <[email-masked]>
Date: Thu, 18 Mar 2004 19:28:53 +0100

: 
Content-Type: multipart/signed; protocol="application/pgp-signature";
 micalg="pgp-sha1";
 boundary="Signature=_Thu__18_Mar_2004_19_28_53_+0100_Yrejsc.MMNJVIpiO"

--Signature=_Thu__18_Mar_2004_19_28_53_+0100_Yrejsc.MMNJVIpiO
Content-Type: text/plain; charset=ISO-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello Bernhard,

At Thu, 18 Mar 2004 18:50:00 +0100 Bernhard Herzog wrote:

>=20
> > ProgrammingError: ERROR:  Attribut =BBgid=AB nicht gefunden
>=20
> called "gid".  This has been fixed in CVS last week.  You might want
> to try that.
>=20
>=20
> It doesn't have to.  The requirement for the gid-column is (or was
> now) really a bug in Thuban.  All that's required now is that it has
> an integer column with ids.  The dialog lets you choose which one to
> use.

THanks for pointing this out. I did a CVS-update and voila,  the dialog
is present and I can choose the ID-column.

Good job folks!

Gru=DF
  Stephan

--=20
Stephan Holl

 19:27:20 up  2:21,  1 user,  load average: 0.34, 0.17, 0.09

--Signature=_Thu__18_Mar_2004_19_28_53_+0100_Yrejsc.MMNJVIpiO
Content-Type: application/pgp-signature

--Signature=_Thu__18_Mar_2004_19_28_53_+0100_Yrejsc.MMNJVIpiO--