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

Home » Public Forums » archive » Re: Shapefile 'parts' woes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Shapefile 'parts' woes [message #59433 is a reply to message #59372] Thu, 27 March 2008 06:38 Go to previous messageGo to previous message
cgpadwick is currently offline  cgpadwick
Messages: 7
Registered: December 2007
Junior Member
Here's a routine that might help you understand how to do what you
want. IDLffShape has a nasty gotcha that can trip people up : it only
defines the parts pointer if the polygon contains multiple contours.
So I usually handle that by checking the n_parts and if it is zero
then I set parts = [0]. That way I don't have to have a bunch of
nasty if (nparts eq 0) logic in my code.

pro printPoly, verts, partsPtr

nParts = N_Elements(partsPtr)
nVerts = N_Elements(verts[0,*])

for ndx=0L, nParts-1L do begin
sIdx = partsPtr[ndx]
eIdx = ( (ndx+1) gt nParts-1L) ? nVerts - 1L : partsPtr[ndx+1L]-1L

Print, '==============================='
Print, 'NDX: ', String(StrTrim(ndx, 2))
Print, 'VERTICES: ', verts[*,sIdx:eIdx]

endfor

end

pro testShape

filename = Dialog_Pickfile(TITLE='Pick the shapefile...')

oShape = Obj_New('IDLffShape', filename)
oShape->GetProperty, N_ENTITIES=nEnt

window, 1

for ndx=0L, nEnt-1L do begin
ent = oShape->GetEntity(ndx)

verts = *ent.vertices
parts = *ent.parts
nParts = ent.n_parts
if (nParts eq 0) then parts = [0]

printPoly, verts, parts
oShape->DestroyEntity, ent


endfor

Obj_Destroy, oShape

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Locked-up workbench: ctrl-C doesnt work
Next Topic: Re: concatenate arrays of different sizes

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

Current Time: Sun Oct 12 03:31:00 PDT 2025

Total time taken to generate the page: 0.01066 seconds