Opened 15 years ago

Closed 15 years ago

#3053 closed defect (fixed)

Label polygon takes excessive time

Reported by: woodbri Owned by: sdlime
Priority: normal Milestone: 5.4.2 release
Component: MapServer C Library Version: 5.4
Severity: normal Keywords:
Cc: dmorissette, jmckenna

Description

I have a world countries polygon shapefile and it displays in about 1 second using AGG renderer. If I add a label, then the render time for the layer increases to about 50 seconds. This is the time to render the layer only not process the label cache.

I have attached a tarball with the data and the mapfile. Here is a url on my server with the labels turned on: http://mt2.imaptools.com/cgi-bin/mapserv-5.4?map=%2Fu%2Fdata%2Fworld%2Fworld.map&layers=all&map_imagetype=agg&mode=map&mapext=-35997355.21934356+-19473536.007671427+18792705.280656442+23575797.242328573&imgext=-35997355.21934356+-19473536.007671427+18792705.280656442+23575797.242328573&map_size=700+550&imgx=350&imgy=275&imgxy=700+550

I loaded the data into postGIS and ran isvalid() which reports a lot of self-intersections on about half the objects. This has never been a problem for mapserver in the past and may not be the issue with this, but I seem to remember that we recently change the polygon label point generation scheme and this may be problematic with this shapefile.

Attachments (1)

isouterring.patch (612 bytes ) - added by pramsey 15 years ago.
Remove isOuterRing patch from getPolygonCenterOfGravity

Download all attachments as: .zip

Change History (13)

comment:1 by woodbri, 15 years ago

Argh, The file (43MB is to large to upload) so you can get it from: http://imaptools.com/downloads/world.tbz

All you need to do in the mapfile is re-point the paths to the directory you untar it into, and to see the speed difference just comment out LABELITEM "NAME" and it will render fast.

comment:2 by dmorissette, 15 years ago

Cc: dmorissette added

comment:3 by jmckenna, 15 years ago

Cc: jmckenna added

by pramsey, 15 years ago

Attachment: isouterring.patch added

Remove isOuterRing patch from getPolygonCenterOfGravity

comment:4 by pramsey, 15 years ago

The problem is too many calls to msPointInPolygon, driven by the isOuterRing test in getPolygonCenterOfGravity. And it looks like those can be avoided by simply not doing them: getPolygonCenterOfGravity says it only uses the biggest ring, and the biggest ring will always be larger than the interior rings. Running the calculation on all the rings is cheaper than figuring out which rings not to run the calculation on.

comment:5 by pramsey, 15 years ago

And, and that file is *way* too detailed for that scale. :)

comment:6 by jmckenna, 15 years ago

wow i agree, no wonder it's choking on this file.

comment:7 by pramsey, 15 years ago

Nothing like a degenerate case to expose an issue though. That 30:1 time difference makes me sit up and take notice.

comment:8 by sdlime, 15 years ago

Status: newassigned

There was a reason that test was there I thought, perhaps dealing with holes? Simpler is better though.

Steve

comment:9 by sdlime, 15 years ago

Milestone: 5.4.2 release

comment:10 by pramsey, 15 years ago

I can easily see you thinking "I only want outer rings, so I'll test away the inner ones". It's not immediately obvious that testing away the inner ones is far more expensive that running the calculation on them.

comment:11 by sdlime, 15 years ago

For some reason I recall Thomas running into a problem where coordinate order flipped the sign of the area computation and this worked around that. I'll dig into my mail archive to make sure...

Steve

comment:12 by sdlime, 15 years ago

Resolution: fixed
Status: assignedclosed

Fixed in 5.4 (r9131) and trunk (r9132). Closing...

Steve

Note: See TracTickets for help on using tickets.