[postgis] Drawing PostGIS MultiPolygon
James Macgill
J.Macgill at geography.leeds.ac.uk
Wed Feb 27 07:11:14 PST 2002
At 10:53 AM 2/27/02, you wrote:
>Hi,
>
>does anyone have any advice on drawing MultiPolygons using java...
>
>I can retieve them efficiently but I am unsure which approach to take
>to draw them onto a canvas.....
>
>I thought someone might have some experience in doing this...
>e.g what sort of data structures should I draw from....
>
>should I be retreiving the x and y coordinates of each polygon into
>separate vectors eg x[] and y[] and then use g.drawPolygon(x , y)
>
>Regards
>Ismail
The GeoTools library has code which will do this. It converts, flips and
scales the polygons so that they can be displayed using g.drawPolygon(x,y).
I have an experimental PostGIS viewer which works quite well but needs more
work to make it more generic, in particular it needs to be able to query
the database to see what is available, though we are collaborating with the
GeoServer project which may make that a little easier.
Try downloading the latest nightly build of the GeoTools utill package.
http://prdownloads.sourceforge.net/geotools/utils-nightly-build.html
This contains the PostGISViewer code and all the jar files you need. There
is a .bat file which sets up the classpath, though if you are on a unix box
it should be easy to turn it into a .sh file.
To run with the .bat file try
PostGISViewer -server foo.bar.com:database:user:password -bounds
x:y:width:height
or in full
java -Xmx128mb -cp
jars\geotools.jar;jars\collections.jar;jars\support.jar;jars\
postgis.jar;jars\postgresql.jar;. PostGISViewer -server
foo.bar.com:database:user:password -bounds x:y:width:height
It's not been tested on anything except our own install of PostGIS so
please let me know if it fails.
With any luck your map should be displayed, pan and zoom actions will
result in new requests to the database for any additional features.
Note, for now no shapes that are loaded get thrown away so eventually you
could run out of memory if you keep panning or zoom out too far.
If you want some advice/help with using the GeoTools library in your own
code to display PostGIS data then let me know and I'll talk you through it.
Cheers
James
James Macgill
Center for Computational Geography http://www.ccg.leeds.ac.uk
Spell Checker (c) Creative Spelling inc (aka my dyslexic brain)
http://www.geotools.org a client side java mapping toolkit.
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Tiny Wireless Camera under $80!
Order Now! FREE VCR Commander!
Click Here - Only 1 Day Left!
http://us.click.yahoo.com/nuyOHD/7.PDAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the postgis-users
mailing list