[postgis-users] postgis with jdbc

Gilbert, Antoine AGilbert at korem.com
Mon Jan 30 11:48:55 PST 2006


Hi

Suppose you draw a polygon of 150000 nodes in a graphics to render a
640x480 image. It should be possible while reading one node at a time to
"on the fly" build a simplified polygon for the fill (ex: maybe 1000
node will be at the same pixel). 

I'm using MapXTreme java, which do not support PostgreSQL but it support
spatial data from Oracle Spatial. MapXTreme Java allows you to
implements interfaces designed to retrieve ranges of geom objects in
some kind of "iterator fashion". I implemented the stuff to support the
read of postgis geometries with the postgis.jar. I charged same tables
with very large polygon objects (>100000 nodes) in both database. In the
oracle implementation the memory never go up. On my PostGIS
implementation I load one geometry at a time but entirely in memory with
the classes from postgis.jar, the use of memory is was much more than
with Oracle (like 7-8 times more). All the filling stuff was going ok.

Another thing, why the coordinates of the PostGIS geometry objects are
always returned in the form of Point objects. I think it's more
effective to have a native array of 2x100000 (x,y,x,...) than 100000
point objects. I wonder if it would be less memory consuming in this
way.

Maybe I could use the WKB4J project (http://wkb4j.sourceforge.net/) to
read the geometries, but I'm not sure I will be able to do what I want.

-----Original Message-----
From: Markus Schaber [mailto:schabi at logix-tt.com] 
Sent: January 10, 2006 12:16 PM
To: PostGIS Users Discussion
Cc: Vachon, Patrick
Subject: Re: [postgis-users] postgis with jdbc

Hi, Gilbert,

Gilbert, Antoine wrote:

> I have a special question getting no answer. I would like to avoid
> charging all geometry in memory, i.e. having something to browse point
> with a special reader. With my understanding I can't achieve this with
> the PostGIS java object provided with PostGIS.jar. I would have to use
> myself the WKB (well-know binary) specification. Does I'm wrong? It's
> because I want to avoid to load the 100 000 points of a polygon in
> memory to draw them for example, could be nice to be able to read one,
> draw it, read another, draw it, etc... Usually in such produc it's the
> way to do.

Well, the PostGIS java classes just represent a single geometry via a
single object instance.

I don't think that there's an efficient drawing algorithm that gets a
single polygons vertices one-by-one, at least each polygon will have to
exist in Memory once for the filling algorithm to work. But it may help
to clip or simplify the polygon in the PostGIS query before fetching it
to the client.

It is easily possible to get the resultset row-by-row with pgjdbc, just
use statement.setAutoCommit(false) and statement.setFetchSize(1).
However, this is a pgjdbc subject and not postgis specific.

Btw, the CVS version of PostGIS (and AFAIR it was released with the 1.1
release) has experimental support for reading PostGIS data directly into
a Java2D Shape object, which should be the most efficient way to draw
PostGIS data in a java Graphics2D context.


HTH,
Schabi


-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org
www.nosoftwarepatents.org
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list