From: Andrea A. <and...@al...> - 2004-06-30 19:23:21
|
Alle 21:02, mercoled=EC 30 giugno 2004, Gayatri Ganpaa ha scritto: > Hi, > > Is anyone working on drawing a map by reading data from PostGIS? I have > been working on this from 20 days but I don't know i keep getting errors. > > I tried that but the setMapContext gives errors: > > See this is what I did: > actually did try connecting to postgis using PostgisConnectionPool and > then extracting the feature source from the database table, and then add > this to the layer and draw the map, but it didn't work. > > This is what i did: > > 1. Got a shapefile: "rails.shp" > 2. used the shp2pgsql to upload this to the database "raildb" and created > a table rail. > 3. Then connected to the database and got the feature source from the > table. 4. Then added this to layer and did the same set of steps, but > couldn't draw the map because of some errors in setMapContext(mapContext) > method. > > > PostgisConnectionFactory con =3D new > PostgisConnectionFactory("plundar.cs.uno.edu", 9011, "raildb"); > ConnectionPool cpl=3D con.getConnectionPool(); > Connection c=3D cpl.getConnection(); > PostgisDataStore ds =3D new PostgisDataStore(cpl); > System.out.println(ds.allowTable("rail")); > String str =3D ds.getTypeNames()[0]; > > FeatureSource fsRails =3D ds.getFeatureSource(str); > > StyleBuilder sb =3D new StyleBuilder(); > LineSymbolizer lsRail =3D sb.createLineSymbolizer(Color.BLUE, 3); > Style railsStyle =3D sb.createStyle(lsRail); > > MapContext map =3D new DefaultMapContext(); > map.addLayer(fsRails, railsStyle); > StyledMapPane mapPane =3D new StyledMapPane(); > mapPane.setMapContext(map); > mapPane.getRenderer().addLayer(new RenderedMapScale()); > JFrame frame =3D new JFrame(); > frame.setTitle("Rail map"); > frame.setContentPane(mapPane.createScrollPane()); > frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); > frame.setSize(640, 480); > frame.show(); > > > I tried to draw the map using shapefile, i could draw, but when i tried to > do it using postGIS it doesn't work. > > Could anyone hep me with this: > > These are the errors I get: > > Jun 1, 2004 10:49:21 PM org.geotools.data.jdbc.JDBCDataStore executeQuery > SEVERE: Error Performing SQL query > This method is not yet implemented. > at org.postgresql.Driver.notImplemented(Driver.java:388) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.setFetchSize(AbstractJdbc2Sta= te >ment.java:156) at You need the latest driver from jdbc.postgresql.org, the one you have is wa= y=20 too old. Go and download the latest, erase the old one and substitute... Best regards Andrea Aime |