comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Bug in mapped polygon objects?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Bug in mapped polygon objects? [message #91905] Mon, 14 September 2015 18:52 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
Hello,

While developing a mapping application, I found what seems to be an odd bug with fill colors for polygon objects on maps. This happens both on imaps and on Function Graphics maps - due to both of them using ipolygon. The problem only happens on some polygons, apparently due to the way they are tessellated when placed on a map projection.

This shows an example where things work as expected:

lats2=[55d0,55d0,-45d0,-45d0,35d0,35d0,-15d0,-15d0]
lons2=[15d0,65d0,75d0,25d0,-15d0,-35d0,-35d0,-15d0]
colors2=[[255,0,0],[255,0,0],[255,0,0],[255,0,0],$
[0,0,255],[0,0,255],[0,0,255],[0,0,255]]
conn2=[4,0,1,2,3,4,4,5,6,7]

imap,map_projection='equirectangular',background='cyan'
ipolygon,transpose([[lons2],[lats2]]),vert_colors=colors2,$
connectivity=conn2,/data,/visualization

However, with some polygons (in this case, straddling the 0 longitude line), the problem shows up:

lats=[55d0,55d0,-45d0,-45d0,35d0,35d0,-15d0,-15d0]
lons=[-15d0,65d0,75d0,-25d0,-15d0,-35d0,-35d0,-15d0]
colors=[[255,0,0],[255,0,0],[255,0,0],[255,0,0],$
[0,0,255],[0,0,255],[0,0,255],[0,0,255]]
conn=[4,0,1,2,3,4,4,5,6,7]

imap,map_projection='equirectangular',background='cyan'
ipolygon,transpose([[lons],[lats]]),vert_colors=colors,$
connectivity=conn,/data,/visualization

The polygons are drawn with a white fill color, instead of the specified colors.

I tracked this down to the IDLitVisPolygon::_TessellateShapes method, which at lines 540-544 (in the IDL 8.5 version) resets the colors to zero when the tessellation changes the number of vertices, causing a mismatch with the number of colors.

To get around this and make my application work, I copied the source code of that method into my own file, where I edited those 5 lines of code. My programs then compile this edited version of that method before they try to draw the polygons. If anyone is interested in seeing the edit, it is lines 117-120 of http://www.ppenteado.net/idl/pp_lib/doc/tessellateshapes_pp. html
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: READ IMAGE
Next Topic: To reduce an n^2 problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:10:00 PDT 2025

Total time taken to generate the page: 0.00195 seconds