[postgis-users] PostGIS 1.3.3 on Windows XP Unstable

Obe, Regina robe.dnd at cityofboston.gov
Mon Aug 18 05:15:04 PDT 2008


Mike,

I could very well be an idiot or at least as far as using ArcMap is
concerned.  I tested union out in ArcMap - not knowing anything of
course.  I figured I have it installed might as well see the slickness
of ArcGIS with mine own eys. I'm using ArcGIS 9.2 - I've been too lazy
to install ArcGIS 9.3.

First it took me a while to figure out where the Union tool is.  It
wasn't intuitively obvious like it is in OpenJump.

Then finally after fumbling in the help - I saw a button in the help
that says "Open Tool".  attached is what my options look like and what I
had set.

Then I ran it - took about 2.5 secs on my pc and to my shock - it did a
stupid collect which PostGIS can do in 1.5 seconds or less.

How the hell do you get it to do a real union?

By the way Martin - I've got my timings down to 8.5 seconds with the
st99_00 dataset using the  envelop trick - but I'm sure I still have a
lot of inefficiencies I'm missing.

Thanks,
Regina

 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Bresnahan, Mike
Sent: Thursday, August 14, 2008 7:45 PM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] PostGIS 1.3.3 on Windows XP Unstable

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

> FWIW:  The unioning operations currently in PostGIS are very
inefficient.

Do I guess right that PostGIS iterates over each geometry and unions it
with the result of all previous geometries, something like this:

            java.awt.geom.Area area = null;
            for (Geometry geom : geomList) {
                if (area == null) {
                    area = ConvertToArea(geom);
                }
                else {
                    path = area.add(ConvertToArea(geom)); // union
                }
            }

AFAIK, that is what Oracle does and it is quite slow.

> We are working on improving the union operation in PostGIS and
hopefully
> will have at least a first draft to show in the next release.  Most
> notably
> porting the JTS logic for doing Cascaded Unions to PostGIS.

By Cascaded Unions do you mean a routine that works something like this:

            java.awt.geom.Area subArea = null; 
            int rowCount = 0;
            while (result.next()) {
                JGeometry geom = JGeometry.load(result.getBytes(1));
                java.awt.Shape shape =
Java2DClipper.geometryToShape(geom);
                if (shape != null) {
                    if (subArea == null) {
                        subArea = new java.awt.geom.Area(shape);
                    }
                    else {
                        subArea.add(new java.awt.geom.Area(shape));
                    }
                    ++rowCount;
                    if (rowCount % 10 == 0) {
                         if (area == null) {
                            area = subArea;
                        }
                        else {
                            area.add(subArea);
                        }
                        subArea = null;
                    }
                }
                System.out.println(rowCount);
            }

I have found that this is indeed faster that the first approach, but
what I have found that is even faster is to create one large geometry
collection and union it with itself like this:

            java.awt.geom.GeneralPath path = null;
            for (Geometry geom : geomList) {
                if (path == null) {
                    path = ConvertToPath(geom);
                }
                else {
                    path = AppendToPath(path, geom);
                }
            }
            java.awt.geom.Area area = new java.awt.geom.Area(path);
            area.add(area); // self-union

I think the gain here is that you only build the temp data structures
for each polygon once. I'm guessing that this is what ArcMap does.

-----BEGIN PGP SIGNATURE-----
Version: PGP Universal 2.8.3
Charset: us-ascii

wsBVAwUBSKTDPR6WPRoYuvd0AQjlRwf/Rci7f0R8jm/deW5Q7kA1tBwXRFSdd3S9
dQwp/Sl/5wTcQc/NbV8kRM5MHeDRPzL2XBUY7zp/ypdLYv5RDi0+niJSmLWiYg5T
vu4ot5Z4de1PjWncSmHNQqqVcNrxy4oxwLtrULgEZ3yMPcW3ffxwHFZzxNBULNCi
VjWISI670HOb/7vmzjgsWrBgPgXl5gMRsDp6eiR+L+SDBBqZJTwHaR6WV86hGsYw
t92QkvKUYNq0DOSmcjnNgIE2xxDuCAABed5ZwLiCF34hP3bN5nnfOs29Fd+yTP/V
pEKxZYrPn/v6RNUNPuw9MhjGEvGA4YkcL6y/Bbf1nnvaK0EseOzwow==
=Y1Pu
-----END PGP SIGNATURE-----
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arcgisunion.png
Type: image/png
Size: 37960 bytes
Desc: arcgisunion.png
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080818/ec907beb/attachment.png>


More information about the postgis-users mailing list