Advertisement
Guest User

SigTill_FME_Workspace

a guest
Dec 7th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.94 KB | None | 0 0
  1. DEFAULT_MACRO WB_CURRENT_CONTEXT
  2.  
  3. # -------------------------------------------------------------------------
  4.  
  5.  
  6. Tcl2 proc Creator_CoordSysRemover {} { \
  7. global FME_CoordSys; \
  8. set FME_CoordSys {}; \
  9. }
  10.  
  11. MACRO Creator_XML NOT_ACTIVATED
  12.  
  13. MACRO Creator_CLASSIC NOT_ACTIVATED
  14.  
  15. MACRO Creator_2D3D 2D_GEOMETRY
  16.  
  17. MACRO Creator_COORDS <Unused>
  18.  
  19. INCLUDE [ if { {Geometry Object} == {Geometry Object} } { \
  20. puts {MACRO Creator_XML *} } ]
  21.  
  22. INCLUDE [ if { {Geometry Object} == {2D Coordinate List} } { \
  23. puts {MACRO Creator_2D3D 2D_GEOMETRY}; \
  24. puts {MACRO Creator_CLASSIC *} } ]
  25.  
  26. INCLUDE [ if { {Geometry Object} == {3D Coordinate List} } { \
  27. puts {MACRO Creator_2D3D 3D_GEOMETRY}; \
  28. puts {MACRO Creator_CLASSIC *} } ]
  29.  
  30. INCLUDE [ if { {Geometry Object} == {2D Min/Max Box} } { \
  31. set comment { \
  32. We need to turn the COORDS which are \
  33. minX minY maxX maxY \
  34. into a full polygon list of coordinates \
  35. }; \
  36. set splitCoords [split [string trim {<Unused>}]]; \
  37. if { [llength $splitCoords] != 4 } { \
  38. error {Creator: Coordinate List MUST have four numbers - `<Unused>' is invalid}; \
  39. }; \
  40. set minX [lindex $splitCoords 0]; \
  41. set minY [lindex $splitCoords 1]; \
  42. set maxX [lindex $splitCoords 2]; \
  43. set maxY [lindex $splitCoords 3]; \
  44. puts "MACRO Creator_COORDS $minX $minY $minX $maxY $maxX $maxY $maxX $minY $minX $minY"; \
  45. puts {MACRO Creator_2D3D 2D_GEOMETRY}; \
  46. puts {MACRO Creator_CLASSIC *} } ]
  47.  
  48. FACTORY_DEF $(Creator_XML) CreationFactory \
  49. FACTORY_NAME Creator_XML_Creator \
  50. CREATE_AT_END no \
  51. OUTPUT FEATURE_TYPE _____CREATED______ \
  52. @Geometry(FROM_ENCODED_STRING,<lt>?xml<space>version=<quote>1.0<quote><space>encoding=<quote>US_ASCII<quote><space>standalone=<quote>no<quote><space>?<gt><lt>geometry<space>dimension=<quote>2<quote><gt><lt>null<solidus><gt><lt><solidus>geometry<gt>)
  53.  
  54. FACTORY_DEF $(Creator_CLASSIC) CreationFactory \
  55. FACTORY_NAME Creator_CLASSIC_Creator \
  56. $(Creator_2D3D) $(Creator_COORDS) \
  57. CREATE_AT_END no \
  58. OUTPUT FEATURE_TYPE _____CREATED______
  59.  
  60. FACTORY_DEF * TeeFactory \
  61. FACTORY_NAME Creator_Cloner \
  62. INPUT FEATURE_TYPE _____CREATED______ \
  63. NUMBER_OF_COPIES 1 \
  64. COPY_NUMBER_ATTRIBUTE "_creation_instance" \
  65. OUTPUT FEATURE_TYPE Creator_CREATED \
  66. @Tcl2(Creator_CoordSysRemover) \
  67. @CoordSys()
  68.  
  69.  
  70. # -------------------------------------------------------------------------
  71.  
  72.  
  73. FACTORY_DEF * TeeFactory \
  74. FACTORY_NAME AttributeRenamer \
  75. INPUT FEATURE_TYPE Creator_CREATED \
  76. OUTPUT FEATURE_TYPE AttributeRenamer_OUTPUT \
  77. @RenameAttributes(ATTR_LIST_DEF_VAL, "",$(Date__FMEENCODED__),$(Date__FMEENCODED__))
  78.  
  79.  
  80.  
  81. # -------------------------------------------------------------------------
  82.  
  83.  
  84. # Set the directive to add all the meta-attributes to the features.
  85.  
  86. # We do this so users see all possible information in the viewed
  87.  
  88. # features.
  89.  
  90.  
  91. READER_META_ATTRIBUTES fme_feature_type fme_dataset fme_basename
  92.  
  93. # Assumption is that the workspace temp dir has been already set and created. See controldefs.cpp - ControlDefs::writeVisualizerTempDir
  94.  
  95. DEFAULT_MACRO WORKSPACE_TEMP_DIR
  96.  
  97. INCLUDE [ \
  98. if { [string length {}] > 0 } { \
  99. set catter "" ; \
  100. set comma "" ; \
  101. foreach attr {} { \
  102. set catter "$catter$comma@Value(\"$attr\")" ; \
  103. set comma ",_," ; \
  104. } ; \
  105. puts "MACRO CATMAC _@Concatenate($catter)" ; \
  106. } \
  107. else { \
  108. puts "MACRO CATMAC " ; \
  109. }; \
  110. set safeName "[regsub -all {[^a-zA-Z0-9]} {AttributeCreator_OUTPUT} _]_[expr round(rand() * 1000000)]_[clock clicks -milliseconds]"; \
  111. puts "MACRO SAFE_FFS_NAME $safeName"; \
  112. ]
  113.  
  114. # Make the temporary directory that the FFS files will live in.
  115.  
  116. FACTORY_DEF * CreationFactory \
  117. FACTORY_NAME AttributeCreator_OUTPUT_DirCreator \
  118. OUTPUT FEATURE_TYPE __nukeme__ \
  119. @Tcl2("catch {file mkdir {$(WORKSPACE_TEMP_DIR)}}")
  120.  
  121. FACTORY_DEF * TeeFactory \
  122. FACTORY_NAME AttributeCreator_OUTPUT_DirCreatorCleanerUpper \
  123. INPUT FEATURE_TYPE __nukeme__
  124.  
  125. # Send raster, point cloud and vector features down different paths to prepare
  126.  
  127. # them for viewing
  128.  
  129.  
  130. FACTORY_DEF * TestFactory \
  131. FACTORY_NAME AttributeCreator_OUTPUT_FeatureDirector \
  132. INPUT FEATURE_TYPE AttributeRenamer_OUTPUT \
  133. TEST &fme_type == "fme_raster" \
  134. OUTPUT FAILED FEATURE_TYPE AttributeCreator_OUTPUT___NotRasterFeatures___ \
  135. OUTPUT PASSED FEATURE_TYPE AttributeCreator_OUTPUT___RasterFeatures___
  136.  
  137. FACTORY_DEF * TestFactory \
  138. FACTORY_NAME AttributeCreator_OUTPUT___FeatureDirector1 \
  139. INPUT FEATURE_TYPE AttributeCreator_OUTPUT___NotRasterFeatures___ \
  140. TEST &fme_type == "fme_point_cloud" \
  141. OUTPUT FAILED FEATURE_TYPE AttributeCreator_OUTPUT___VectorFeatures___ \
  142. OUTPUT PASSED FEATURE_TYPE AttributeCreator_OUTPUT___PointCloudFeatures___
  143.  
  144. # Vector features simply may get their colors overridden
  145.  
  146.  
  147. FACTORY_DEF * TeeFactory \
  148. FACTORY_NAME AttributeCreator_OUTPUT_VectorSetterUpper \
  149. INPUT FEATURE_TYPE AttributeCreator_OUTPUT___VectorFeatures___ \
  150. OUTPUT FEATURE_TYPE __viewme__
  151.  
  152. # Point Cloud Features Might Need to be thinned
  153.  
  154.  
  155. # Note that we don't call the ThinPointCloud function directly, but rather
  156.  
  157. # do it through TCL. This should allow this transformer to be used with a
  158.  
  159. # Desktop license, even though ThinPointCloud requires Professional.
  160.  
  161.  
  162. Tcl2 proc AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_thinPointCloud {} { \
  163. FME_Execute ThinPointCloud NO_THINNING 1; \
  164. }
  165.  
  166. FACTORY_DEF * TeeFactory \
  167. FACTORY_NAME AttributeCreator_OUTPUT___PointCloudThinner \
  168. INPUT FEATURE_TYPE AttributeCreator_OUTPUT___PointCloudFeatures___ \
  169. OUTPUT FEATURE_TYPE __viewme__ \
  170. @Tcl2("AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_thinPointCloud")
  171.  
  172. Tcl2 proc AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_prepareRaster {subsetStartRow subsetNumRows subsetStartCol subsetNumCols} { \
  173. set useDI [string equal -nocase {$(FME_VIEWER_APP)} {fmedatainspector}]; \
  174. if {!$useDI} { \
  175. FME_Execute ApplyRasterRotation BILINEAR; \
  176. }; \
  177. set doResample [string equal {NoReduction} {Resample}]; \
  178. set doSubset [string equal {NoReduction} {Subset}]; \
  179. set doBounds [string equal {NoReduction} {BoundingBoxOnly}]; \
  180. if {$doBounds} { \
  181. FME_Execute GeometryType fme_polygon; \
  182. } \
  183. elseif {$doResample || $doSubset} { \
  184. set comment { \
  185. First, we need to prefix all the attributes. This is done because \
  186. we are going to call @RasterProperties, and we want to make sure \
  187. it doesn't overwrite any existing attributes. \
  188. }; \
  189. set kAttrPrefix "."; \
  190. set allNames [FME_AttributeNames]; \
  191. foreach oldName $allNames { \
  192. set newName $kAttrPrefix; \
  193. append newName $oldName; \
  194. FME_RenameAttribute $newName $oldName; \
  195. }; \
  196. FME_Execute RasterProperties RASTER; \
  197. if {$doResample} { \
  198. set oldNumCols [FME_GetAttribute _num_columns]; \
  199. set oldNumRows [FME_GetAttribute _num_rows]; \
  200. set oldSpacingX [FME_GetAttribute _spacing_x]; \
  201. set oldSpacingY [FME_GetAttribute _spacing_y]; \
  202. set kMinNumCells 32; \
  203. set kMaxNumCells 512; \
  204. set comment { \
  205. We will only resample if both dimensions are greater than the \
  206. minimum num cells, and at least one is greater than the maximum. \
  207. }; \
  208. if {$oldNumRows > $kMinNumCells && $oldNumCols > $kMinNumCells && ($oldNumRows > $kMaxNumCells || $oldNumCols > $kMaxNumCells)} { \
  209. set newSpacingX 1.0; \
  210. set newSpacingY 1.0; \
  211. if {$oldNumRows > $oldNumCols} { \
  212. set comment { \
  213. If we have more rows than columns, we need to choose a spacing \
  214. that reduces the number of rows to the maximum we've chosen. \
  215. }; \
  216. set newSpacingY [expr 1.0 * $oldNumRows * $oldSpacingY / $kMaxNumCells]; \
  217. set newSpacingX [expr 1.0 * $newSpacingY / $oldSpacingY * $oldSpacingX]; \
  218. set comment { \
  219. Now we need to check if doing this will result in the columns \
  220. going below the minimum. If so, choose the spacing such that \
  221. we only go down to the minimum (and not past). \
  222. }; \
  223. set newNumCols [expr $oldNumCols * $oldSpacingX / $newSpacingX]; \
  224. if {$newNumCols < $kMinNumCells} \
  225. { \
  226. set newSpacingX [expr 1.0 * $oldNumCols * $oldSpacingX / $kMinNumCells]; \
  227. set newSpacingY [expr 1.0 * $newSpacingX / $oldSpacingX * $oldSpacingY]; \
  228. }; \
  229. } \
  230. else { \
  231. set comment { \
  232. This is identical to the above case, except the roles of \
  233. rows and cols are reversed. \
  234. }; \
  235. set newSpacingX [expr 1.0 * $oldNumCols * $oldSpacingX / $kMaxNumCells]; \
  236. set newSpacingY [expr 1.0 * $newSpacingX / $oldSpacingX * $oldSpacingY]; \
  237. set newNumRows [expr $oldNumRows * $oldSpacingY / $newSpacingY]; \
  238. if {$newNumRows < $kMinNumCells} \
  239. { \
  240. set newSpacingY [expr 1.0 * $oldNumRows * $oldSpacingY / $kMinNumCells]; \
  241. set newSpacingX [expr 1.0 * $newSpacingY / $oldSpacingY * $oldSpacingX]; \
  242. }; \
  243. }; \
  244. FME_Execute ResampleRaster CELL_SIZE $newSpacingX $newSpacingY NearestNeighbor; \
  245. }; \
  246. } \
  247. elseif {$doSubset} { \
  248. set comment { \
  249. Get the value of some strings that may be attributes or constants. \
  250. Note that we pass in the attribute prefix we're using, because if \
  251. one does turn out to be an attribute, it won't actually be the exact \
  252. name in the string (since we renamed all our attributes above). \
  253. }; \
  254. set rasterNumRows [FME_GetAttribute _num_rows]; \
  255. set rasterNumCols [FME_GetAttribute _num_columns]; \
  256. set comment { \
  257. Only do subsetting if the specified start position is actually \
  258. within the raster. \
  259. }; \
  260. if {$subsetStartRow < $rasterNumRows && $subsetStartCol < $rasterNumCols} \
  261. { \
  262. set comment { \
  263. Now bound the subset to the size of the raster, so that \
  264. we don't create padding. \
  265. }; \
  266. if {[expr $subsetStartRow + $subsetNumRows] > $rasterNumRows} \
  267. { \
  268. set subsetNumRows [expr $rasterNumRows - $subsetStartRow]; \
  269. }; \
  270. if {[expr $subsetStartCol + $subsetNumCols] > $rasterNumCols} \
  271. { \
  272. set subsetNumCols [expr $rasterNumCols - $subsetStartCol]; \
  273. }; \
  274. FME_Execute SubsetRaster $subsetStartRow $subsetNumRows $subsetStartCol $subsetNumCols; \
  275. }; \
  276. }; \
  277. set comment { \
  278. Remove all the attributes added by @RasterProperties and remove the \
  279. prefix from the real attributes. We assume they all start with an \
  280. underscore. \
  281. }; \
  282. FME_Execute RemoveAttributes fme_regexp_match {^_}; \
  283. foreach oldName $allNames { \
  284. set newName $kAttrPrefix; \
  285. append newName $oldName; \
  286. FME_RenameAttribute $oldName $newName; \
  287. }; \
  288. }; \
  289. }
  290.  
  291. FACTORY_DEF * TeeFactory \
  292. FACTORY_NAME AttributeCreator_OUTPUT_RasterSetterUpper \
  293. INPUT FEATURE_TYPE AttributeCreator_OUTPUT___RasterFeatures___ \
  294. OUTPUT FEATURE_TYPE __viewme__ \
  295. @Tcl2("AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_prepareRaster {<Unused>} {<Unused>} {<Unused>} {<Unused>}")
  296.  
  297. # Now route all the features into the recorder, changing their
  298.  
  299. # feature type to the transformer name so that they view nicely
  300.  
  301. # AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE changes the feature types
  302.  
  303. # of the features being visualized.
  304.  
  305.  
  306. DEFAULT_MACRO AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE AttributeCreator_OUTPUT$(CATMAC)
  307.  
  308. DEFAULT_MACRO VISUALIZER_FEATURE_FILE $(WORKSPACE_TEMP_DIR)/$(SAFE_FFS_NAME).ffs
  309.  
  310. DEFAULT_MACRO VISUALIZER_CREATE_SPATIAL_INDEX NO
  311.  
  312. FACTORY_DEF * RecorderFactory \
  313. FACTORY_NAME AttributeCreator_OUTPUT_Recorder \
  314. INPUT FEATURE_TYPE __viewme__ _wb_termination_feature Yes @FeatureType(TERMINATOR_@Value(_wb_termination_xformer)) \
  315. INPUT FEATURE_TYPE __viewme__ @FeatureType($(AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE)) \
  316. FEATURE_FILE "$(VISUALIZER_FEATURE_FILE)" \
  317. CREATE_SPATIAL_INDEX "$(VISUALIZER_CREATE_SPATIAL_INDEX)" \
  318. INSPECTOR "$(VISUALIZER_CREATE_SPATIAL_INDEX)" \
  319. MODE RECORD_PASS_THROUGH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement