Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DEFAULT_MACRO WB_CURRENT_CONTEXT
- # -------------------------------------------------------------------------
- Tcl2 proc Creator_CoordSysRemover {} { \
- global FME_CoordSys; \
- set FME_CoordSys {}; \
- }
- MACRO Creator_XML NOT_ACTIVATED
- MACRO Creator_CLASSIC NOT_ACTIVATED
- MACRO Creator_2D3D 2D_GEOMETRY
- MACRO Creator_COORDS <Unused>
- INCLUDE [ if { {Geometry Object} == {Geometry Object} } { \
- puts {MACRO Creator_XML *} } ]
- INCLUDE [ if { {Geometry Object} == {2D Coordinate List} } { \
- puts {MACRO Creator_2D3D 2D_GEOMETRY}; \
- puts {MACRO Creator_CLASSIC *} } ]
- INCLUDE [ if { {Geometry Object} == {3D Coordinate List} } { \
- puts {MACRO Creator_2D3D 3D_GEOMETRY}; \
- puts {MACRO Creator_CLASSIC *} } ]
- INCLUDE [ if { {Geometry Object} == {2D Min/Max Box} } { \
- set comment { \
- We need to turn the COORDS which are \
- minX minY maxX maxY \
- into a full polygon list of coordinates \
- }; \
- set splitCoords [split [string trim {<Unused>}]]; \
- if { [llength $splitCoords] != 4 } { \
- error {Creator: Coordinate List MUST have four numbers - `<Unused>' is invalid}; \
- }; \
- set minX [lindex $splitCoords 0]; \
- set minY [lindex $splitCoords 1]; \
- set maxX [lindex $splitCoords 2]; \
- set maxY [lindex $splitCoords 3]; \
- puts "MACRO Creator_COORDS $minX $minY $minX $maxY $maxX $maxY $maxX $minY $minX $minY"; \
- puts {MACRO Creator_2D3D 2D_GEOMETRY}; \
- puts {MACRO Creator_CLASSIC *} } ]
- FACTORY_DEF $(Creator_XML) CreationFactory \
- FACTORY_NAME Creator_XML_Creator \
- CREATE_AT_END no \
- OUTPUT FEATURE_TYPE _____CREATED______ \
- @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>)
- FACTORY_DEF $(Creator_CLASSIC) CreationFactory \
- FACTORY_NAME Creator_CLASSIC_Creator \
- $(Creator_2D3D) $(Creator_COORDS) \
- CREATE_AT_END no \
- OUTPUT FEATURE_TYPE _____CREATED______
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME Creator_Cloner \
- INPUT FEATURE_TYPE _____CREATED______ \
- NUMBER_OF_COPIES 1 \
- COPY_NUMBER_ATTRIBUTE "_creation_instance" \
- OUTPUT FEATURE_TYPE Creator_CREATED \
- @Tcl2(Creator_CoordSysRemover) \
- @CoordSys()
- # -------------------------------------------------------------------------
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME AttributeRenamer \
- INPUT FEATURE_TYPE Creator_CREATED \
- OUTPUT FEATURE_TYPE AttributeRenamer_OUTPUT \
- @RenameAttributes(ATTR_LIST_DEF_VAL, "",$(Date__FMEENCODED__),$(Date__FMEENCODED__))
- # -------------------------------------------------------------------------
- # Set the directive to add all the meta-attributes to the features.
- # We do this so users see all possible information in the viewed
- # features.
- READER_META_ATTRIBUTES fme_feature_type fme_dataset fme_basename
- # Assumption is that the workspace temp dir has been already set and created. See controldefs.cpp - ControlDefs::writeVisualizerTempDir
- DEFAULT_MACRO WORKSPACE_TEMP_DIR
- INCLUDE [ \
- if { [string length {}] > 0 } { \
- set catter "" ; \
- set comma "" ; \
- foreach attr {} { \
- set catter "$catter$comma@Value(\"$attr\")" ; \
- set comma ",_," ; \
- } ; \
- puts "MACRO CATMAC _@Concatenate($catter)" ; \
- } \
- else { \
- puts "MACRO CATMAC " ; \
- }; \
- set safeName "[regsub -all {[^a-zA-Z0-9]} {AttributeCreator_OUTPUT} _]_[expr round(rand() * 1000000)]_[clock clicks -milliseconds]"; \
- puts "MACRO SAFE_FFS_NAME $safeName"; \
- ]
- # Make the temporary directory that the FFS files will live in.
- FACTORY_DEF * CreationFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_DirCreator \
- OUTPUT FEATURE_TYPE __nukeme__ \
- @Tcl2("catch {file mkdir {$(WORKSPACE_TEMP_DIR)}}")
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_DirCreatorCleanerUpper \
- INPUT FEATURE_TYPE __nukeme__
- # Send raster, point cloud and vector features down different paths to prepare
- # them for viewing
- FACTORY_DEF * TestFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_FeatureDirector \
- INPUT FEATURE_TYPE AttributeRenamer_OUTPUT \
- TEST &fme_type == "fme_raster" \
- OUTPUT FAILED FEATURE_TYPE AttributeCreator_OUTPUT___NotRasterFeatures___ \
- OUTPUT PASSED FEATURE_TYPE AttributeCreator_OUTPUT___RasterFeatures___
- FACTORY_DEF * TestFactory \
- FACTORY_NAME AttributeCreator_OUTPUT___FeatureDirector1 \
- INPUT FEATURE_TYPE AttributeCreator_OUTPUT___NotRasterFeatures___ \
- TEST &fme_type == "fme_point_cloud" \
- OUTPUT FAILED FEATURE_TYPE AttributeCreator_OUTPUT___VectorFeatures___ \
- OUTPUT PASSED FEATURE_TYPE AttributeCreator_OUTPUT___PointCloudFeatures___
- # Vector features simply may get their colors overridden
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_VectorSetterUpper \
- INPUT FEATURE_TYPE AttributeCreator_OUTPUT___VectorFeatures___ \
- OUTPUT FEATURE_TYPE __viewme__
- # Point Cloud Features Might Need to be thinned
- # Note that we don't call the ThinPointCloud function directly, but rather
- # do it through TCL. This should allow this transformer to be used with a
- # Desktop license, even though ThinPointCloud requires Professional.
- Tcl2 proc AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_thinPointCloud {} { \
- FME_Execute ThinPointCloud NO_THINNING 1; \
- }
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME AttributeCreator_OUTPUT___PointCloudThinner \
- INPUT FEATURE_TYPE AttributeCreator_OUTPUT___PointCloudFeatures___ \
- OUTPUT FEATURE_TYPE __viewme__ \
- @Tcl2("AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_thinPointCloud")
- Tcl2 proc AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_prepareRaster {subsetStartRow subsetNumRows subsetStartCol subsetNumCols} { \
- set useDI [string equal -nocase {$(FME_VIEWER_APP)} {fmedatainspector}]; \
- if {!$useDI} { \
- FME_Execute ApplyRasterRotation BILINEAR; \
- }; \
- set doResample [string equal {NoReduction} {Resample}]; \
- set doSubset [string equal {NoReduction} {Subset}]; \
- set doBounds [string equal {NoReduction} {BoundingBoxOnly}]; \
- if {$doBounds} { \
- FME_Execute GeometryType fme_polygon; \
- } \
- elseif {$doResample || $doSubset} { \
- set comment { \
- First, we need to prefix all the attributes. This is done because \
- we are going to call @RasterProperties, and we want to make sure \
- it doesn't overwrite any existing attributes. \
- }; \
- set kAttrPrefix "."; \
- set allNames [FME_AttributeNames]; \
- foreach oldName $allNames { \
- set newName $kAttrPrefix; \
- append newName $oldName; \
- FME_RenameAttribute $newName $oldName; \
- }; \
- FME_Execute RasterProperties RASTER; \
- if {$doResample} { \
- set oldNumCols [FME_GetAttribute _num_columns]; \
- set oldNumRows [FME_GetAttribute _num_rows]; \
- set oldSpacingX [FME_GetAttribute _spacing_x]; \
- set oldSpacingY [FME_GetAttribute _spacing_y]; \
- set kMinNumCells 32; \
- set kMaxNumCells 512; \
- set comment { \
- We will only resample if both dimensions are greater than the \
- minimum num cells, and at least one is greater than the maximum. \
- }; \
- if {$oldNumRows > $kMinNumCells && $oldNumCols > $kMinNumCells && ($oldNumRows > $kMaxNumCells || $oldNumCols > $kMaxNumCells)} { \
- set newSpacingX 1.0; \
- set newSpacingY 1.0; \
- if {$oldNumRows > $oldNumCols} { \
- set comment { \
- If we have more rows than columns, we need to choose a spacing \
- that reduces the number of rows to the maximum we've chosen. \
- }; \
- set newSpacingY [expr 1.0 * $oldNumRows * $oldSpacingY / $kMaxNumCells]; \
- set newSpacingX [expr 1.0 * $newSpacingY / $oldSpacingY * $oldSpacingX]; \
- set comment { \
- Now we need to check if doing this will result in the columns \
- going below the minimum. If so, choose the spacing such that \
- we only go down to the minimum (and not past). \
- }; \
- set newNumCols [expr $oldNumCols * $oldSpacingX / $newSpacingX]; \
- if {$newNumCols < $kMinNumCells} \
- { \
- set newSpacingX [expr 1.0 * $oldNumCols * $oldSpacingX / $kMinNumCells]; \
- set newSpacingY [expr 1.0 * $newSpacingX / $oldSpacingX * $oldSpacingY]; \
- }; \
- } \
- else { \
- set comment { \
- This is identical to the above case, except the roles of \
- rows and cols are reversed. \
- }; \
- set newSpacingX [expr 1.0 * $oldNumCols * $oldSpacingX / $kMaxNumCells]; \
- set newSpacingY [expr 1.0 * $newSpacingX / $oldSpacingX * $oldSpacingY]; \
- set newNumRows [expr $oldNumRows * $oldSpacingY / $newSpacingY]; \
- if {$newNumRows < $kMinNumCells} \
- { \
- set newSpacingY [expr 1.0 * $oldNumRows * $oldSpacingY / $kMinNumCells]; \
- set newSpacingX [expr 1.0 * $newSpacingY / $oldSpacingY * $oldSpacingX]; \
- }; \
- }; \
- FME_Execute ResampleRaster CELL_SIZE $newSpacingX $newSpacingY NearestNeighbor; \
- }; \
- } \
- elseif {$doSubset} { \
- set comment { \
- Get the value of some strings that may be attributes or constants. \
- Note that we pass in the attribute prefix we're using, because if \
- one does turn out to be an attribute, it won't actually be the exact \
- name in the string (since we renamed all our attributes above). \
- }; \
- set rasterNumRows [FME_GetAttribute _num_rows]; \
- set rasterNumCols [FME_GetAttribute _num_columns]; \
- set comment { \
- Only do subsetting if the specified start position is actually \
- within the raster. \
- }; \
- if {$subsetStartRow < $rasterNumRows && $subsetStartCol < $rasterNumCols} \
- { \
- set comment { \
- Now bound the subset to the size of the raster, so that \
- we don't create padding. \
- }; \
- if {[expr $subsetStartRow + $subsetNumRows] > $rasterNumRows} \
- { \
- set subsetNumRows [expr $rasterNumRows - $subsetStartRow]; \
- }; \
- if {[expr $subsetStartCol + $subsetNumCols] > $rasterNumCols} \
- { \
- set subsetNumCols [expr $rasterNumCols - $subsetStartCol]; \
- }; \
- FME_Execute SubsetRaster $subsetStartRow $subsetNumRows $subsetStartCol $subsetNumCols; \
- }; \
- }; \
- set comment { \
- Remove all the attributes added by @RasterProperties and remove the \
- prefix from the real attributes. We assume they all start with an \
- underscore. \
- }; \
- FME_Execute RemoveAttributes fme_regexp_match {^_}; \
- foreach oldName $allNames { \
- set newName $kAttrPrefix; \
- append newName $oldName; \
- FME_RenameAttribute $oldName $newName; \
- }; \
- }; \
- }
- FACTORY_DEF * TeeFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_RasterSetterUpper \
- INPUT FEATURE_TYPE AttributeCreator_OUTPUT___RasterFeatures___ \
- OUTPUT FEATURE_TYPE __viewme__ \
- @Tcl2("AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_prepareRaster {<Unused>} {<Unused>} {<Unused>} {<Unused>}")
- # Now route all the features into the recorder, changing their
- # feature type to the transformer name so that they view nicely
- # AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE changes the feature types
- # of the features being visualized.
- DEFAULT_MACRO AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE AttributeCreator_OUTPUT$(CATMAC)
- DEFAULT_MACRO VISUALIZER_FEATURE_FILE $(WORKSPACE_TEMP_DIR)/$(SAFE_FFS_NAME).ffs
- DEFAULT_MACRO VISUALIZER_CREATE_SPATIAL_INDEX NO
- FACTORY_DEF * RecorderFactory \
- FACTORY_NAME AttributeCreator_OUTPUT_Recorder \
- INPUT FEATURE_TYPE __viewme__ _wb_termination_feature Yes @FeatureType(TERMINATOR_@Value(_wb_termination_xformer)) \
- INPUT FEATURE_TYPE __viewme__ @FeatureType($(AttributeCreator_OUTPUT_abce2f4b_10a3_4c40_8f1b_a06c47cc1de812_VIS_FEAT_TYPE)) \
- FEATURE_FILE "$(VISUALIZER_FEATURE_FILE)" \
- CREATE_SPATIAL_INDEX "$(VISUALIZER_CREATE_SPATIAL_INDEX)" \
- INSPECTOR "$(VISUALIZER_CREATE_SPATIAL_INDEX)" \
- MODE RECORD_PASS_THROUGH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement