Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bridging GIS and 3D Animation with Python

Chad Cooper
September 10, 2013

Bridging GIS and 3D Animation with Python

Presented at the AR GIS User's Forum 2013 meeting in Rogers, AR, Sept 2013

Python is becoming deeply embedded in both GIS and 3D animation and modeling packages. In the GIS realm, Python is becoming the de facto standard language for automation and data processing in both the commercial and open-source arenas. As for the 3D animation and modeling industry, the same holds true; Python is emerging as the language of choice for APIs to allow developers to automate repetitive tasks and extend the core functionality of the software packages. So what do you do when you have a project where your GIS package needs to communicate with and pass data to your 3D package? You use Python, of course. These packages all have Python support, so getting them to talk should be easy, right? Not so much. This talk will be a highly technical case study on how we used Python to convince ArcGIS 10.0 and Vue Infinite 10.5 to be friends.

Chad Cooper

September 10, 2013
Tweet

More Decks by Chad Cooper

Other Decks in Programming

Transcript

  1. Credits / disclaimer Funded by Bureau of Ocean Energy Management

    (BOEM) On-going study Not meant to represent BOEM policy
  2. File > Import object > elevation.dem e l e v

    _ o b j = I m p o r t O b j e c t ( " e l e v a t i o n . d e m " , 0 , t r u e , - 1 )
  3. d e f r a s t e r _

    t o _ t e x t ( i n _ r a s t e r ) : " " " W r i t e o u t a r a s t e r t o t e x t f i l e f o r V u e " " " . . . f o = o p e n ( o u t _ t e x t , " w " ) p t _ a r r a y = a r c p y . R a s t e r T o N u m P y A r r a y ( i n _ r a s t e r ) p = p t _ a r r a y . t o l i s t ( ) # R e v e r s e t h e l i s t p . r e v e r s e ( ) # G e t p r o p e r t i e s o f t h e r a s t e r t o u s e b e l o w r p = g e t _ r a s t e r _ p r o p s ( s t r ( i n _ r a s t e r ) ) n e w _ l i s t = [ ] f o r e a c h i n p : n e w _ i n n e r _ l i s t = [ ] f o r e v e r y i n e a c h : n e w _ i n n e r _ l i s t . a p p e n d ( t r a n s l a t e _ z ( e v e r y , r p [ " N o D a t a " ] , r p [ " M a x E l e v a t i o n " ] , r p [ " M i n E l e v a t i o n " ] ) ) f o . w r i t e ( s t r ( n e w _ i n n e r _ l i s t ) . s t r i p ( ' [ ] ' ) + " \ n " ) f o . c l o s e ( ) r e t u r n o u t _ t e x t _ n a m e
  4. d e f t r a n s l a

    t e _ z ( i n _ v a l , n o _ d a t a , m a x _ e l e v , m i n _ e l e v ) : " " " T a k e e l e v a t i o n Z v a l u e f r o m r a s t e r a n d c o n v e r t t o e q u i v a l e n t v a l u e o n a s c a l e o f 0 t o 1 , w h e r e 0 i s t h e m i n i m u m e l e v a t i o n v a l u e o f t h e r a s t e r d a t a s e t a n d 1 i s t h e m a x i m u m . " " " i f i n _ v a l = = n o _ d a t a : n e w _ v a l = 0 e l s e : n e w _ v a l = ( ( i n _ v a l - m i n _ e l e v ) / ( m a x _ e l e v - m i n _ e l e v ) ) r e t u r n n e w _ v a l Vue elev value = ( ) cell input value J raster min elev raster max elev J raster min elev Vue elev value = ( ) = 0.5 64 J 0 128 J 0
  5. 0 , 0 , 0 , 0 , 0 ,

    0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 0 . 8 0 7 5 6 3 2 7 8 2 3 0 6 0 4 7 , 0 . 8 0 7 5 8 4 2 3 5 8 4 3 6 8 9 8 8 , 0 . 8 0 7 2 4 4 7 5 8 1 3 3 7 1 3 9 9 , 0 . 8 0 7 0 1 2 9 1 8 2 4 9 5 8 3 8 8 , 0 . 8 0 7 2 4 9 0 . 8 0 7 4 6 4 0 1 1 5 7 5 9 9 1 2 4 , 0 . 8 0 7 5 2 6 2 9 0 7 1 5 1 5 9 5 8 , 0 . 8 0 7 2 3 5 3 1 8 3 0 2 3 2 4 3 1 , 0 . 8 0 7 0 2 4 0 2 0 4 4 1 2 1 8 3 5 , 0 . 8 0 7 3 7 0 . 8 0 7 2 3 9 6 5 2 3 1 2 9 6 2 3 5 , 0 . 8 0 7 1 8 4 1 4 1 3 5 4 7 9 0 3 3 , 0 . 8 0 6 7 5 6 4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 , 0 . 8 0 6 8 0 0 3 7 3 6 1 8 2 9 4 3 8 , 0 . 8 0 6 5 2 5 2 5 2 9 9 7 7 9 2 7 6 , 0 . 8 0 6 4 8 9 2 1 5 4 0 2 4 8 7 5 2 , 0 . 8 0 6 5 8 0 . 8 0 6 9 4 4 8 2 0 8 4 9 5 5 8 9 9 , 0 . 8 0 7 1 0 0 0 7 3 4 2 2 4 1 4 4 1 , 0 . 8 0 6 7 8 6 7 7 7 8 8 6 2 9 2 8 3 , 0 . 8 0 6 4 2 6 7 5 8 1 5 3 2 9 2 9 , 0 . 8 0 6 2 8 4
  6. t e r r a i n _ o b

    j . S e t T e r r a i n R e s o l u t i o n ( t e r r _ w i d t h , t e r r _ h e i g h t ) e l e v _ f i l e = o p e n ( e l e v _ f i l e , " r " ) a l t i t u d e s = [ ] w i t h o p e n ( e l e v _ f i l e , " r " ) a s e l e v _ f i l e : l i n e = e l e v _ f i l e . r e a d l i n e ( ) b i t s = l i n e . s p l i t ( " , " ) a l t = [ ] f o r x i n b i t s : a l t . a p p e n d ( f l o a t ( x ) ) a l t i t u d e s . a p p e n d ( a l t ) t e r r a i n _ o b j . S e t T e r r a i n A l t i t u d e s ( a l t i t u d e s ) x _ s c a l e = y _ s c a l e = t e r r _ c e l l _ r e s # G e t z - s i z e o f t e r r a i n b e f o r e s c a l i n g t e r r _ b b o x = t e r r a i n _ o b j . G e t B o u n d i n g B o x ( ) t e r r _ z _ s i z e = t e r r _ b b o x . G e t M a x ( ) [ 2 ] - t e r r _ b b o x . G e t M i n ( ) [ 2 ] a c t u a l _ t e r r _ z _ s i z e = a b s ( t e r r _ m a x _ e l e v - t e r r _ m i n _ e l e v ) z _ s c a l e = a c t u a l _ t e r r _ z _ s i z e / t e r r _ z _ s i z e # R e s i z e t e r r a i n b a s e d o n c a l c ' d s c a l e f a c t o r s b _ o b j e c t . R e s i z e A x i s ( x _ s c a l e , y _ s c a l e , z _ s c a l e , T r u e ) t e r r _ b b o x = t e r r a i n _ o b j . G e t B o u n d i n g B o x ( ) t e r r _ z _ s i z e = t e r r _ b b o x . G e t M a x ( ) [ 2 ] - t e r r _ b b o x . G e t M i n ( ) [ 2 ] b _ o b j e c t . S e t P o s i t i o n ( 0 , 0 , t e r r _ z _ e l e v )
  7. d e f h a v e r s i

    n e ( l o n 2 , l a t 2 ) : l o n 1 = r a s t e r _ c e n t e r _ x l a t 1 = r a s t e r _ c e n t e r _ y l o n 1 , l a t 1 , l o n 2 , l a t 2 = m a p ( m a t h . r a d i a n s , [ l o n 1 , l a t 1 , l o n 2 , l a t 2 ] ) d l o n = l o n 2 - l o n 1 d l a t = l a t 2 - l a t 1 a = m a t h . s i n ( d l a t / 2 ) * * 2 + m a t h . c o s ( l a t 1 ) \ * m a t h . c o s ( l a t 2 ) * m a t h . s i n ( d l o n / 2 ) * * 2 c = 2 * m a t h . a s i n ( m a t h . s q r t ( a ) ) d = 6 2 7 8 * c r e t u r n d
  8. = z ′ z J d 2 2r o u

    t _ r a s t e r = a r c p y . R a s t e r ( o r i g _ r a s t e r ) - ( ( a r c p y . R a s t e r ( h a v _ r a s t e r ) \ * a r c p y . R a s t e r ( h a v _ r a s t e r ) ) / ( 2 * 6 2 7 8 ) ) o u t _ r a s t e r . s a v e ( o u t _ h a v e r s i n e _ r a s t e r )
  9. a r c p y . R a s t

    e r ( i n _ e l e v _ d s ) * 0 . 3 0 4 8 a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( i n _ r a s t e r , o u t _ r a s t e r + " _ P C S " , t a r g e t _ s r , " B I L I N E A R " , " # " , g e o _ t r a n s _ p c s ) i n _ r a s t e r _ p r o p s = v _ u t i l s . g e t _ r a s t e r _ p r o p s ( i n _ r a s t e r ) i n _ r a s t e r _ o b j = a r c p y . R a s t e r ( i n _ r a s t e r ) a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( i n _ r a s t e r _ o b j , o u t _ r a s t e r , h a v _ o u t p u t _ s r , " B I L I N E A R " , " # " , g e o _ t r a n s _ w g s 8 4 ) a r c p y . R a s t e r T o P o i n t _ c o n v e r s i o n ( i n _ e l e v _ d s , r a s _ t o _ p t s , " V A L U E " ) a r c p y . C a l c u l a t e F i e l d _ m a n a g e m e n t ( r a s _ t o _ p t s , " H a v _ D i s t a n c e " , e x p r e s s i o n , " P Y T H O N " , c o d e b l o c k ) a r c p y . P o i n t T o R a s t e r _ c o n v e r s i o n ( r a s _ t o _ p t s , " H a v _ D i s t a n c e " , h a v _ d i s t _ r a s t e r , " M O S T _ F R E Q U E N T " , " H a v _ D i s t a n c e " , i n _ r a s t e r ) o u t _ r a s t e r = a r c p y . R a s t e r ( o r i g _ r a s t e r ) - ( ( a r c p y . R a s t e r ( h a v _ r a s t e r ) * a r c p y . R a s t e r ( h a v _ r a s t e r ) ) / ( 2 * 6 2 7 8 ) ) o u t _ r a s t e r . s a v e ( o u t _ h a v e r s i n e _ r a s t e r ) a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( o u t _ h a v e r s i n e _ r a s t e r , o u t _ h a v e r s i n e _ r a s t e r _ p c s , c u s t o m _ s r , " B I L I N E A R " )
  10. n e g _ 1 0 0 = a r

    c p y . s a . C o n ( i n _ r a s t e r _ o b j , - 1 0 0 , i n _ r a s t e r , " V A L U E = 0 " )
  11. i n _ r a s t e r _

    p r o p s = v _ u t i l s . g e t _ r a s t e r _ p r o p s ( i n _ r a s t e r ) # G e t s t r i n g e x t e n t o f i n _ r a s t e r a s " X M i n , Y M i n , X M a x , Y M a x " s t r _ e x t e n t = " " . j o i n ( [ s t r ( v ) f o r v i n i n _ r a s t e r _ p r o p s [ " E x t e n t " ] ] ) i n _ r a s t e r _ o b j = a r c p y . R a s t e r ( i n _ r a s t e r ) a r c p y . e n v . e x t e n t = s t r _ e x t e n t a r c p y . e n v . c e l l S i z e = i n _ r a s t e r _ p r o p s [ " T e r r a i n C e l l R e s o l u t i o n " ]
  12. d e f g e t _ r a s

    t e r _ p r o p s ( i n _ r a s t e r ) : " " " G e t p r o p e r t i e s o f a r a s t e r , r e t u r n a s d i c t " " " r = a r c p y . R a s t e r ( i n _ r a s t e r ) r a s t e r _ p r o p s = { } x _ c e n t e r = r . e x t e n t . X M i n + ( r . e x t e n t . X M a x - r . e x t e n t . X M i n ) / 2 y _ c e n t e r = r . e x t e n t . Y M i n + ( r . e x t e n t . Y M a x - r . e x t e n t . Y M i n ) / 2 r a s t e r _ p r o p s [ " X C e n t e r " ] = x _ c e n t e r r a s t e r _ p r o p s [ " Y C e n t e r " ] = y _ c e n t e r r a s t e r _ p r o p s [ " M a x E l e v a t i o n " ] = r . m a x i m u m r a s t e r _ p r o p s [ " M i n E l e v a t i o n " ] = r . m i n i m u m r a s t e r _ p r o p s [ " N o D a t a " ] = r . n o D a t a V a l u e r a s t e r _ p r o p s [ " T e r r a i n W i d t h " ] = r . w i d t h r a s t e r _ p r o p s [ " T e r r a i n H e i g h t " ] = r . h e i g h t r a s t e r _ p r o p s [ " T e r r a i n C e l l R e s o l u t i o n " ] = r . m e a n C e l l H e i g h t r a s t e r _ p r o p s [ " E x t e n t " ] = [ r . e x t e n t . X M i n , r . e x t e n t . Y M i n , r . e x t e n t . X M a x , r . e x t e n t . Y M a x ] r e t u r n r a s t e r _ p r o p s
  13. o n e s _ z e r o s

    = a r c p y . s a . C o n ( i n _ r a s t e r _ o b j , 1 , 0 , " V A L U E > 0 " )
  14. e x t r a c t e d _

    o n e s = a r c p y . s a . E x t r a c t B y A t t r i b u t e s ( o n e s _ z e r o s , " V A L U E = 1 " )
  15. e u c _ d i s t = a

    r c p y . s a . E u c D i s t a n c e ( e x t r a c t e d _ o n e s )
  16. c o n v _ t o _ h u

    n d r e d = a r c p y . s a . C o n ( e u c _ d i s t , ( e u c _ d i s t * ( 1 0 0 / - m a x _ e l e v ) ) , e u c _ d i s t , " V A L U E > 0 " )
  17. c o n _ r e v e r s

    e _ s l o p e = a r c p y . s a . C o n ( c o n v _ t o _ h u n d r e d _ c o n , c o n v _ t o _ h u n d r e d _ c o n + 1 0 0 , c o n v _ t o _ h u n d r e d _ c o n , " V A L U E < 1 0 0 " )
  18. b e a c h = a r c p

    y . s a . C o n ( c o n _ r e v e r s e _ s l o p e , c o n _ r e v e r s e _ s l o p e + \ i n _ r a s t e r _ o b j , c o n _ r e v e r s e _ s l o p e , " V A L U E = 1 0 0 " )
  19. # R a s t e r p r e

    p a r c p y . R a s t e r ( i n _ e l e v _ d s ) * 0 . 3 0 4 8 a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( i n _ r a s t e r , o u t _ r a s t e r + " _ P C S " , t a r g e t _ s r , " B I L I N E A R " , " # " , g e o _ t r a n s _ p c s ) i n _ r a s t e r _ p r o p s = v _ u t i l s . g e t _ r a s t e r _ p r o p s ( i n _ r a s t e r ) i n _ r a s t e r _ o b j = a r c p y . R a s t e r ( i n _ r a s t e r ) # S e t e n v i r o n m e n t a l p r o p e r t i e s . . . a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( i n _ r a s t e r _ o b j , o u t _ r a s t e r , h a v _ o u t p u t _ s r , " B I L I N E A R " , " # " , g e o _ t r a n s _ w g s 8 4 ) # S h o r e l i n e s l o p e c a l c s o n e s _ z e r o s = a r c p y . s a . C o n ( i n _ r a s t e r _ o b j , 1 , 0 , " V A L U E > 0 " ) e x t r a c t e d _ o n e s = a r c p y . s a . E x t r a c t B y A t t r i b u t e s ( o n e s _ z e r o s , " V A L U E = 1 " ) e u c _ d i s t = a r c p y . s a . E u c D i s t a n c e ( e x t r a c t e d _ o n e s ) c o n v _ t o _ h u n d r e d = a r c p y . s a . C o n ( e u c _ d i s t , ( e u c _ d i s t * ( 1 0 0 / - m a x _ e l e v ) ) , e u c _ d i s t , " V A L U E > 0 " ) c o n _ r e v e r s e _ s l o p e = a r c p y . s a . C o n ( c o n v _ t o _ h u n d r e d _ c o n , c o n v _ t o _ h u n d r e d _ c o n + 1 0 0 , c o n v _ t o _ h u n d r e d _ c o n , " V A L U E < 1 0 0 " ) b e a c h = a r c p y . s a . C o n ( c o n _ r e v e r s e _ s l o p e , c o n _ r e v e r s e _ s l o p e + \ i n _ r a s t e r _ o b j , c o n _ r e v e r s e _ s l o p e , " V A L U E = 1 0 0 " ) # H a v e r s i n e c o n v e r s i o n s a r c p y . R a s t e r T o P o i n t _ c o n v e r s i o n ( i n _ e l e v _ d s , r a s _ t o _ p t s , " V A L U E " ) a r c p y . C a l c u l a t e F i e l d _ m a n a g e m e n t ( r a s _ t o _ p t s , " H a v _ D i s t a n c e " , e x p r e s s i o n , " P Y T H O N " , c o d e b l o c k ) a r c p y . P o i n t T o R a s t e r _ c o n v e r s i o n ( r a s _ t o _ p t s , " H a v _ D i s t a n c e " , h a v _ d i s t _ r a s t e r , " M O S T _ F R E Q U E N T " , " H a v _ D i s t a n c e " , i n _ r a s t e r ) o u t _ r a s t e r = a r c p y . R a s t e r ( o r i g _ r a s t e r ) - ( ( a r c p y . R a s t e r ( h a v _ r a s t e r ) * a r c p y . R a s t e r ( h a v _ r a s t e r ) ) / ( 2 * 6 2 7 8 ) ) o u t _ r a s t e r . s a v e ( o u t _ h a v e r s i n e _ r a s t e r ) a r c p y . P r o j e c t R a s t e r _ m a n a g e m e n t ( o u t _ h a v e r s i n e _ r a s t e r , o u t _ h a v e r s i n e _ r a s t e r _ p c s , c u s t o m _ s r , " B I L I N E A R " )
  20. S e a r c h C u r s

    o r ( d a t a s e t , { w h e r e _ c l a u s e } , { s p a t i a l _ r e f e r e n c e } , { f i e l d s } , { s o r t _ f i e l d s } ) spatial_reference: When specified, features will be projected on the fly using the spatial_reference provided. Type: Object
  21. s r = ' P R O J C S

    [ " V u e G n o m o n i c " , G E O G C S [ " < c u s t o m > " , D A T U M [ " < c u s t o m > " , \ S P H E R O I D [ " < c u s t o m > " , 6 2 7 8 0 0 0 . 0 , 0 . 0 ] ] , \ P R I M E M [ " < c u s t o m > " , 0 . 0 ] , U N I T [ " D e g r e e " , 0 . 0 1 7 4 5 3 2 9 2 5 1 9 9 4 3 3 ] ] , \ P R O J E C T I O N [ " G n o m o n i c " ] , P A R A M E T E R [ " F a l s e _ E a s t i n g " , 0 . 0 ] , \ P A R A M E T E R [ " F a l s e _ N o r t h i n g " , 0 . 0 ] , \ P A R A M E T E R [ " L o n g i t u d e _ O f _ C e n t e r " , { 0 } ] , \ P A R A M E T E R [ " L a t i t u d e _ O f _ C e n t e r " , { 1 } ] , \ U N I T [ " M e t e r " , 1 . 0 ] ] ' . f o r m a t ( g c s _ x _ c e n t e r , g c s _ y _ c e n t e r )
  22. d e f g e t _ w t g

    _ l o c a t i o n s ( p r o j e c t _ p a t h , p r o j e c t _ n a m e ) : " " " I n t e r a t e t h r u W T G f e a t u r e c l a s s a n d g a t h e r W T G a r r a y i n f o " " " g d b = o s . p a t h . j o i n ( p r o j e c t _ p a t h , p r o j e c t _ n a m e + " . g d b " ) s r = a r c p y . D e s c r i b e ( o s . p a t h . j o i n ( g d b , p r o j e c t _ n a m e + " _ H a v C u r v e d P C S " ) ) . s p a t i a l R e f e r e n c e r o w s = a r c p y . S e a r c h C u r s o r ( o s . p a t h . j o i n ( g d b , " W T G s " ) , " " , s r ) w i n d f a r m _ a r r a y = [ ] d i c t _ a r r a y = [ ] f o r r o w i n r o w s : w i n d f a r m _ d i c t = { } g e o m = r o w . s h a p e p o i n t = g e o m . g e t P a r t ( ) w t g _ i d = r o w . g e t V a l u e ( " O B J E C T I D " ) w i n d f a r m _ d i c t [ " I D " ] = w t g _ i d w i n d f a r m _ d i c t [ " W t g V u e N o r t h i n g " ] = p o i n t . Y w i n d f a r m _ d i c t [ " W t g V u e E a s t i n g " ] = p o i n t . X w i n d f a r m _ a r r a y . a p p e n d ( [ w t g _ i d , p o i n t . Y , p o i n t . X ] ) d i c t _ a r r a y . a p p e n d ( w i n d f a r m _ d i c t ) r e t u r n d i c t _ a r r a y
  23. [ { " I D " : 1 , "

    W t g N o r t h i n g " : 4 2 8 0 , " W t g E a s t i n g " : 1 5 6 9 2 } , . . . ]
  24. < w t g i d = " 6 0

    " > < w t g v u e n o r t h i n g > 4 2 8 0 . 9 7 2 0 8 7 6 1 < / w t g v u e n o r t h i n g > < w t g v u e e a s t i n g > 1 5 6 9 2 . 4 5 1 4 4 4 2 < / w t g v u e e a s t i n g > < n a c e l l e y a w > 0 < / n a c e l l e y a w > < / w t g >
  25. d e f g e t _ k o p

    _ l o c a t i o n s ( s e l f , p r o j e c t _ p a t h , p r o j e c t _ n a m e , r e n d e r _ d a t e , s i m u l a t i o n _ t i m e , c a m e r a _ p o s i t i o n , c a m e r a _ b e a r i n g s ) : " " " I n t e r a t e t h r u K O P f e a t u r e c l a s s a n d g a t h e r K O P a r r a y i n f o " " " s r = a r c p y . D e s c r i b e ( o s . p a t h . j o i n ( g d b , p r o j e c t _ n a m e + " _ H a v C u r v e d P C S " ) ) . s p a t i a l R e f e r e n c e r o w s = a r c p y . S e a r c h C u r s o r ( o s . p a t h . j o i n ( g d b , " K O P s " ) , " " , s r ) k o p _ d i c t = { } f o r r o w i n r o w s : g e o m = r o w . s h a p e p o i n t = g e o m . g e t P a r t ( ) k o p _ i d = r o w . g e t V a l u e ( " O B J E C T I D " ) # G e t t i m e z o n e i n f o # G e t s u n p o s i t i o n s u n _ p i t c h , s u n _ y a w , u t c _ t i m e = s u n _ p o s i t i o n s . g e t ( k o p _ i d ) # G e t c a m e r a p r o p s k o p _ d i c t [ k o p _ i d ] = { " K o p V u e E a s t i n g " : p o i n t . X , " K o p V u e N o r t h i n g " : p o i n t . Y , " S u n P i t c h " : s u n _ p i t c h , " S u n Y a w " : s u n _ y a w , " S i m u l a t i o n T i m e U T C " : u t c _ t i m e , " C a m e r a Y a w " : c a m e r a _ y a w , " C a m e r a Z P o s i t i o n " : c a m e r a _ e l e v _ m e t e r s } r e t u r n k o p _ d i c t
  26. d e f u p d a t e M

    e s s a g e s ( s e l f ) : i m p o r t r e i f s e l f . p _ p r o j e c t _ s r . v a l u e : i f s e l f . p _ p r o j e c t _ s r . v a l u e . l i n e a r U n i t N a m e ! = " M e t e r " : s e l f . p _ p r o j e c t _ s r . s e t E r r o r M e s s a g e ( " T h e l i n e a r u n i t s o f " \ " y o u r p r o j e c t e d c o o r d i n a t e s y s t e m m u s t b e m e t e r s , " \ " n o t " + s t r ( s e l f . p _ p r o j e c t _ s r . v a l u e . l i n e a r U n i t N a m e ) ) i f s e l f . p _ p r o j e c t _ s r . v a l u e . t y p e = = " G e o g r a p h i c " : s e l f . p _ p r o j e c t _ s r . s e t E r r o r M e s s a g e ( " Y o u m u s t u s e a " " p r o j e c t e d c o o r d i n a t e s y s t e m . " ) i f s e l f . p _ p r o j e c t _ n a m e . v a l u e : p a t t = r e . c o m p i l e ( r " ( ^ \ d ) | ( \ s ) | [ \ W . - ] " ) i f p a t t . s e a r c h ( s t r ( s e l f . p _ p r o j e c t _ n a m e . v a l u e ) ) : s e l f . p _ p r o j e c t _ n a m e . s e t E r r o r M e s s a g e ( " Y o u r p r o j e c t n a m e " \ " c o n t a i n s i n v a l i d c h a r a c t e r s . " ) i f s e l f . p _ i n p u t _ r a s t e r . v a l u e : d a t u m = s e l f . g e t _ d a t u m ( s e l f . p _ i n p u t _ r a s t e r . v a l u e ) i f d a t u m n o t i n s e l f . a c c e p t a b l e _ d a t u m s : s e l f . p _ i n p u t _ r a s t e r . s e t E r r o r M e s s a g e ( " Y o u r d a t u m " \ + d a t u m + " i s u n a c c e p t a b l e " ) r e t u r n
  27. r a w _ k o p _ l i

    s t = s e l f . g e t _ k o p s _ f o r _ l i s t b o x ( e n v . v _ r o o t _ d i r , e n v . p r o j e c t _ n a m e ) k o p _ l i s t = [ s t r ( e ) f o r e i n r a w _ k o p _ l i s t ] s e l f . k o p s = w x . L i s t B o x ( p a r e n t = s e l f , i d = 0 , p o s = ( 2 0 , 2 0 ) , s i z e = ( 1 4 0 , 1 2 0 ) , c h o i c e s = k o p _ l i s t , s t y l e = w x . L B _ M U L T I P L E ) s e l f . k o p s . S e t T o o l T i p ( w x . T o o l T i p ( " K O P l i s t f o r c u r r e n t p r o j e c t . " \ " S e l e c t \ n o n e o r m o r e t o c o n f i g u r e " \ " a n d q u e u e u p " ) )
  28. s e l f . d a t e _

    c t r l = w x . D a t e P i c k e r C t r l ( s e l f , - 1 , s i z e = ( 1 1 0 , - 1 ) , s t y l e = w x . D P _ D R O P D O W N | w x . D P _ S H O W C E N T U R Y ) s e l f . d a t e _ c t r l . S e t T o o l T i p ( w x . T o o l T i p ( " D a t e t h a t t h e s i m u l a t i o n " \ " r e n d e r s h o u l d r e p r e s e n t . " ) ) s e l f . t i m e _ c t r l = T i m e C t r l ( s e l f , d i s p l a y _ s e c o n d s = F a l s e , f m t 2 4 h r = F a l s e , i d = - 1 , n a m e = ' t i m e C t r l ' , s t y l e = 0 , u s e F i x e d W i d t h F o n t = F a l s e , v a l u e = d a t e t i m e . n o w ( ) . s t r f t i m e ( ' % X ' ) ) s e l f . t i m e _ c t r l . S e t T o o l T i p ( w x . T o o l T i p ( " T i m e o f d a y o n s i m u l a t i o n " \ " d a t e t h a t t h e s i m u l a t i o n " \ " s h o u l d r e p r e s e n t . " ) )
  29. s e l f . l o a d _

    c o n f i g _ b t n = w x . B u t t o n ( s e l f , l a b e l = " L o a d C o n f i g " , s i z e = ( 9 0 , - 1 ) ) s e l f . l o a d _ c o n f i g _ b t n . B i n d ( w x . E V T _ B U T T O N , s e l f . o n _ o p e n _ f i l e , s e l f . l o a d _ c o n f i g _ b t n ) d e f o n _ o p e n _ f i l e ( s e l f , e v e n t ) : " " " O p e n u p e x i s t i n g X M L c o n f i g f i l e " " " d l g = w x . F i l e D i a l o g ( s e l f , m e s s a g e = " C h o o s e a f i l e " , d e f a u l t F i l e = " " , w i l d c a r d = " X M L f i l e s ( * . x m l ) | * . x m l " , s t y l e = w x . O P E N | w x . C H A N G E _ D I R ) i f d l g . S h o w M o d a l ( ) = = w x . I D _ O K : f = d l g . G e t P a t h ( ) s e l f . p a r s e _ p o p u l a t e _ x m l ( f ) d l g . D e s t r o y ( )
  30. s e l f . h e l p _

    b t n _ b e a c h = w x . B i t m a p B u t t o n ( s e l f , - 1 , h e l p _ i c o n , s t y l e = 0 ) s e l f . h e l p _ b t n _ b e a c h . B i n d ( w x . E V T _ M O T I O N , s e l f . o n _ m o u s e o v e r _ h e l p ) d e f o n _ m o u s e o v e r _ h e l p ( s e l f , e v e n t ) : " " " C h a n g e c u r s o r t o h a n d w h e n h o v e r o v e r h e l p i c o n s " " " w x . S e t C u r s o r ( w x . S t o c k C u r s o r ( w x . C U R S O R _ H A N D ) ) d e f o n _ e d i t _ s c e n e ( s e l f , e v e n t ) : . . . i f s e l f . e d i t _ s e s s i o n _ k o p . g e t ( " N a c e l l e O r i e n t a t i o n " ) = = " R a n d o m " : s e l f . w t g _ d i r _ s l i d e r . S e t V a l u e ( i n t ( s e l f . e d i t _ s e s s i o n _ k o p . g e t ( \ " R a n d o m N a c e l l e C o u n t " ) ) ) s e l f . w t g _ d i r _ r a n d _ d e g r e e s _ s l i d e r . S e t V a l u e ( i n t ( \ s e l f . e d i t _ s e s s i o n _ k o p . g e t ( " N a c e l l e O r i e n t R a n d o m n e s s " ) ) ) s e l f . w t g _ d i r _ r a n d o m _ s l i d e r . E n a b l e ( ) s e l f . w t g _ d i r _ r a n d _ d e g r e e s _ s l i d e r . E n a b l e ( ) i f s e l f . e d i t _ s e s s i o n _ k o p . g e t ( " W i n d S p e e d " ) ! = " C a l m " : s e l f . w i n d _ d i r e c t i o n s _ r a d i o b o x . E n a b l e ( ) s e l f . c l o u d s _ r a d i o b o x . E n a b l e ( )
  31. XML

  32. v i e s o r e _ e l

    e m = E l e m e n t T r e e . E l e m e n t ( " V I E S O R E . C o n f i g u r a t i o n " ) t e r r _ d i c t = p a r a m s [ " T e r r a i n " ] t e r r _ e l e m = E l e m e n t T r e e . S u b E l e m e n t ( v i e s o r e _ e l e m , " T e r r a i n " ) t e r r _ f i l e _ e l e m = E l e m e n t T r e e . S u b E l e m e n t ( t e r r _ e l e m , " T e r r a i n F i l e " ) k o p s = p a r a m s [ " K o p A r r a y " ] f o r k o p i n k o p s : k o p _ e l e m = E l e m e n t T r e e . S u b E l e m e n t ( v i e s o r e _ e l e m , " K o p A r r a y " , { " I D " : s t r ( k o p . g e t ( " I D " ) ) } ) b e a c h _ c o l o r = E l e m e n t T r e e . S u b E l e m e n t ( k o p _ e l e m , " B e a c h C o l o r " ) b e a c h _ c o l o r . t e x t = s t r ( k o p . g e t ( " B e a c h C o l o r " ) ) . . . w t g s = k o p . g e t ( " W T G " ) f o r w t g i n w t g s : w t g _ e l e m = E l e m e n t T r e e . S u b E l e m e n t ( k o p _ e l e m , " W T G " , { " I D " : s t r ( w t g [ " I D " ] ) } ) w t g _ n _ e l e m = E l e m e n t T r e e . S u b E l e m e n t ( w t g _ e l e m , " W t g V u e N o r t h i n g " ) w t g _ n _ e l e m . t e x t = s t r ( w t g [ " W t g V u e N o r t h i n g " ] ) f = o p e n ( o s . p a t h . j o i n ( p a t h , n a m e + " . x m l " ) , " w " ) f . w r i t e ( v i e s o r e _ e l e m e n t ) f . c l o s e ( )
  33. < v i e s o r e . c

    o n f i g u r a t i o n > < t e r r a i n > < t e r r a i n f i l e > T e s t 1 _ H a v C u r v e d P C S . t x t < / t e r r a i n f i l e > < t e r r a i n w i d t h > 5 8 3 < / t e r r a i n w i d t h > < t e r r a i n h e i g h t > 5 4 8 < / t e r r a i n h e i g h t > < t e r r a i n x c e n t e r > 0 . 3 2 0 6 8 8 9 0 3 4 3 6 < / t e r r a i n x c e n t e r > < t e r r a i n y c e n t e r > - 1 . 4 4 6 3 1 3 8 5 8 0 3 < / t e r r a i n y c e n t e r > < t e r r a i n m i n e l e v a t i o n > - 5 . 0 8 7 8 8 2 5 1 8 7 7 < / t e r r a i n m i n e l e v a t i o n > < t e r r a i n m a x e l e v a t i o n > 2 8 . 3 8 6 7 5 6 8 9 7 < / t e r r a i n m a x e l e v a t i o n > . . . < / t e r r a i n > < k o p a r r a y i d = " 1 " > < k o p n a m e > K O P # 1 < / k o p n a m e > < b e a c h c o l o r > D a r k b e i g e < / b e a c h c o l o r > < r o c k s i z e > 1 - 2 i n c h e s < / r o c k s i z e > < w i n d s p e e d > C a l m < / w i n d s p e e d > < w i n d d i r e c t i o n > N o r t h < / w i n d d i r e c t i o n > < c l o u d c o v e r > C l o u d y 6 0 % c l o u d s < / c l o u d c o v e r > < n a c e l l e o r i e n t a t i o n > R a n d o m < / n a c e l l e o r i e n t a t i o n > < n a c e l l e o r i e n t a t i o n r a n d o m n e s s > 1 0 < / n a c e l l e o r i e n t a t i o n r a n d o m n e s s > < r a n d o m n a c e l l e c o u n t > 1 0 < / r a n d o m n a c e l l e c o u n t > < s i m u l a t i o n d a t e > 1 2 / 9 / 2 0 1 9 < / s i m u l a t i o n d a t e > < s i m u l a t i o n t i m e > 0 3 : 1 5 P M < / s i m u l a t i o n t i m e > < r e n d e r q u a l i t y > F i n a l < / r e n d e r q u a l i t y > < f o v p o s i t i o n > B y b e a r i n g < / f o v p o s i t i o n > < k o p v u e n o r t h i n g > 1 2 5 . 8 8 3 7 2 2 8 7 9 < / k o p v u e n o r t h i n g > < k o p v u e e a s t i n g > - 9 5 . 6 0 4 3 7 5 9 1 6 6 < / k o p v u e e a s t i n g > < s u n p i t c h > 1 0 4 . 5 7 8 9 6 8 7 7 4 < / s u n p i t c h > < s u n y a w > 1 3 3 . 1 7 0 9 0 6 6 4 5 < / s u n y a w > < s i m u l a t i o n t i m e u t c > 2 0 1 9 / 1 2 / 0 9 2 0 : 1 5 : 0 0 < / s i m u l a t i o n t i m e u t c > < c a m e r a z p o s i t i o n > 1 6 < / c a m e r a z p o s i t i o n > < c a m e r a y a w > 2 0 5 < / c a m e r a y a w > < c a m e r a p i t c h > 9 3 < / c a m e r a p i t c h > < b e a r i n g d i r > N W < / b e a r i n g d i r > < b e a r i n g d i g i t s > 6 5 < / b e a r i n g d i g i t s > . . . < w t g i d = " 1 " > < w t g v u e n o r t h i n g > 1 7 7 2 . 2 7 5 0 0 9 7 5 < / w t g v u e n o r t h i n g >
  34. c o n f i g = C o n

    v e r t X m l T o D i c t ( f ) r o o t = c o n f i g [ " V I E S O R E . C o n f i g u r a t i o n " ] p r o j e c t = r o o t [ " P r o j e c t " ] t e r r a i n = r o o t [ " T e r r a i n " ] k o p s = r o o t [ " K o p A r r a y " ] t e r r = S e l e c t B y N a m e ( " T e m p l a t e T e r r a i n " ) b _ o b j e c t = G e t S e l e c t e d O b j e c t B y I n d e x ( 0 ) b _ o b j e c t . R e s i z e A x i s ( 0 , 0 , 0 , T r u e ) t e r r a i n _ o b j = b _ o b j e c t . T o T e r r a i n ( ) t e r r a i n _ o b j . S e t T e r r a i n R e s o l u t i o n ( t e r r _ w i d t h , t e r r _ h e i g h t ) a l t i t u d e s = [ ] w i t h o p e n ( e l e v _ f i l e , " r " ) a s e l e v _ f i l e : l i n e = e l e v _ f i l e . r e a d l i n e ( ) i f n o t l i n e : b r e a k b i t s = l i n e . s p l i t ( " , " ) a l t = [ ] f o r x i n b i t s : a l t . a p p e n d ( f l o a t ( x ) ) a l t i t u d e s . a p p e n d ( a l t ) # D o s o m e s c a l i n g t o t e r r a i n # P u s h o u r e l e v a t i o n d a t a i n t o t h e t e r r a i n o b j e c t t e r r a i n _ o b j . S e t T e r r a i n A l t i t u d e s ( a l t i t u d e s )
  35. c a m e r a _ n o r

    t h i n g = f l o a t ( k o p . g e t ( " K o p V u e N o r t h i n g " ) ) c a m e r a _ e a s t i n g = f l o a t ( k o p . g e t ( " K o p V u e E a s t i n g " ) ) c a m e r a _ z p o s = f l o a t ( k o p . g e t ( " C a m e r a Z P o s i t i o n " ) ) c a m e r a _ y a w = f l o a t ( k o p . g e t ( " C a m e r a Y a w " ) ) c a m e r a _ p i t c h = f l o a t ( k o p . g e t ( " C a m e r a P i t c h " ) ) s e l e c t _ c a m e r a = S e l e c t B y N a m e ( " M a i n c a m e r a " ) c a m e r a = G e t S e l e c t e d O b j e c t B y I n d e x ( 0 ) c a m e r a . S e t P o s i t i o n ( c a m e r a _ e a s t i n g , c a m e r a _ n o r t h i n g , c a m e r a _ z p o s ) R e f r e s h ( ) c a m e r a . S e t R o t a t i o n A n g l e s ( c a m e r a _ p i t c h , 0 , c a m e r a _ y a w , t r u e )
  36. i m p o r t _ w t g

    = I m p o r t O b j e c t ( w t g , 0 , T r u e , - 1 ) S e l e c t ( i m p o r t _ w t g ) w t g _ h e i g h t = i n t ( g e t _ o b j e c t _ s i z e ( i m p o r t _ w t g ) [ 2 ] ) c = C o p y ( ) d = D e l e t e ( ) w t g s = k o p [ " W T G " ] f o r w t g i n w t g s : w t g _ n o r t h i n g = f l o a t ( w t g . g e t ( " W t g V u e N o r t h i n g " ) ) w t g _ e a s t i n g = f l o a t ( w t g . g e t ( " W t g V u e E a s t i n g " ) ) w t g _ y a w = f l o a t ( w t g . g e t ( " N a c e l l e Y a w " ) ) w t g _ n a m e = s t r ( w t g . g e t ( " I D " ) ) # P a s t e t h e W T G p = P a s t e ( ) # P o s i t i o n ( m o v e / r o t a t e ) t h e p a s t e d W T G c u r r _ w t g = G e t S e l e c t e d O b j e c t B y I n d e x ( 0 ) c u r r _ w t g . M o v e ( w t g _ e a s t i n g , w t g _ n o r t h i n g , ( w t g _ h e i g h t / 2 ) + 1 0 0 ) c u r r _ w t g . S e t R o t a t i o n A n g l e s V ( ( 0 , 0 , w t g _ y a w ) , T r u e ) c u r r _ w t g . S e t N a m e ( w t g _ n a m e )
  37. d e f r e n d e r _

    i m a g e ( o u t _ f i l e ) : " " " R e n d e r s m a i n v i e w o u t t o j p e g " " " S e t R e n d e r O u t p u t ( V u e P y t h o n . R O _ D i s k , o u t _ f i l e ) S e t R e n d e r Q u a l i t y ( V u e P y t h o n . P R S _ F i n a l ) S e t P i c t u r e W i d t h ( 1 9 2 0 ) R e n d e r ( T r u e )