Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: Shapefile '...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 5546 of 6457
Post > Topic >>

Re: Shapefile 'parts' woes

by cgpadwick@[EMAIL PROTECTED] Mar 27, 2008 at 06:38 AM

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
 




 6 Posts in Topic:
Shapefile 'parts' woes
Gaurav <selfishgaurav@  2008-03-19 03:35:20 
Re: Shapefile 'parts' woes
David Fanning <news@[E  2008-03-19 06:33:46 
Re: Shapefile 'parts' woes
Gaurav <selfishgaurav@  2008-03-19 23:38:45 
Re: Shapefile 'parts' woes
David Fanning <news@[E  2008-03-20 08:01:13 
Re: Shapefile 'parts' woes
cgpadwick@[EMAIL PROTECTE  2008-03-27 06:38:45 
Re: Shapefile 'parts' woes
Gaurav <selfishgaurav@  2008-03-28 01:16:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 20:55:27 CST 2008.