#!#! #! #!#! #!#! #!#! #!#! #!#!#! #!#!#!#!#!#!#! #!#! #!#!#!#!#! #! #!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#! #!#! #!#! #!#!#!DEFAULT_MACRO VAL 500 GUI可选STRING_ENCODED VAL搜索半径:#!START_HEADER # !START_WB_HEADER READER_TYPE NULL READER_KEYWORD NULL_SOURCE NULL_SOURCE_DATASET NULL WRITER_TYPE NULL WRITER_KEYWORD NULL_DEST NULL_DEST_DATASET NULL #!END_WB_HEADER # !END_HEADER LOG_FILENAME " $ (FME_MF_DIR) spatialQueryExample.log“LOG_APPEND没有LOG_MAX_FEATURES 200 LOG_MAX_RECORDED_FEATURES 200 FME FME_GEOMETRY_HANDLING增强FME_STROKE_MAX_DEVIATION 0 LOG_TIMINGS FME_REPROJECTION_ENGINE:是的 # ------------------------------------------------------------------------- MULTI_READER_CONTINUE_ON_READER_FAILURE没有#------------------------------------------------------------------------- MACRO WORKSPACE_NAME spatialQueryExample DEFAULT_MACRO WB_CURRENT_CONTEXT # ------------------------------------------------------------------------- Tcl2 proc Creator_2_CoordSysRemover {} { global FME_CoordSys; set FME_CoordSys {}; } MACRO Creator_2_XML NOT_ACTIVATED MACRO Creator_2_CLASSIC NOT_ACTIVATED MACRO Creator_2_2D3D 2D_GEOMETRY MACRO Creator_2_COORDS -122.857726 49.14066 INCLUDE [ if { {2D Coordinate List} == {XML Geometry} } { puts {MACRO Creator_2_XML *} } ] INCLUDE [ if { {2D Coordinate List} == {2D Coordinate List} } { puts {MACRO Creator_2_2D3D 2D_GEOMETRY}; puts {MACRO Creator_2_CLASSIC *} } ] INCLUDE [ if { {2D Coordinate List} == {3D Coordinate List} } { puts {MACRO Creator_2_2D3D 3D_GEOMETRY}; puts {MACRO Creator_2_CLASSIC *} } ] INCLUDE [ if { {2D Coordinate List} == {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 {-122.857726 49.14066}]]; if { [llength $splitCoords] != 4 } { error {Creator_2: Coordinate List MUST have four numbers - `-122.857726 49.14066' 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_2_COORDS $minX $minY $minX $maxY $maxX $maxY $maxX $minY $minX $minY"; puts {MACRO Creator_2_2D3D 2D_GEOMETRY}; puts {MACRO Creator_2_CLASSIC *} } ] FACTORY_DEF $(Creator_2_XML) CreationFactory FACTORY_NAME Creator_2_XML_Creator CREATE_AT_END no OUTPUT FEATURE_TYPE _____CREATED______ @Geometry(FROM_ENCODED_STRING, ) FACTORY_DEF $(Creator_2_CLASSIC) CreationFactory FACTORY_NAME Creator_2_CLASSIC_Creator $(Creator_2_2D3D) $(Creator_2_COORDS) CREATE_AT_END no OUTPUT FEATURE_TYPE _____CREATED______ FACTORY_DEF * TeeFactory FACTORY_NAME Creator_2_Cloner INPUT FEATURE_TYPE _____CREATED______ NUMBER_OF_COPIES 1 COPY_NUMBER_ATTRIBUTE _creation_instance OUTPUTFEATURE_TYPE Creator_2_CREATED @Tcl2(Creator_2_CoordSysRemover) @CoordSys(LL84) # ------------------------------------------------------------------------- FACTORY_DEF * TeeFactory FACTORY_NAME AttributeCreator_2 INPUT FEATURE_TYPE Creator_2_CREATED OUTPUT FEATURE_TYPE AttributeCreator_2_OUTPUT @SupplyAttributes(ENCODED,name,亚搏在线Safe 软件、category_id添加0 ) # ------------------------------------------------------------------------- Tcl2 proc Creator_CoordSysRemover{}{全球FME_CoordSys;设置FME_CoordSys {};2}宏观Creator_XML NOT_ACTIVATED宏观Creator_CLASSIC NOT_ACTIVATED宏观Creator_2D3D d_geometry宏观Creator_COORDS -123.177681 - 49.195503包括(如果{{2 d坐标列表}= = {XML几何}}{把{宏Creator_XML *}})包括(如果{{2 d坐标列表}= = {2 d坐标列表}}{{宏Creator_2D3D 2 d_geometry};[if {{2D坐标列表}== {3D坐标列表}}{puts {MACRO Creator_2D3D 3D_GEOMETRY};我们需要将坐标minX minY maxX maxY转换为一个完整的多边形坐标列表};set splitCoords [split [string trim {-123.177681 49.195503}]];如果{[llength $ splitcoordinates] != 4} {error {Creator: Coordinate List MUST have four numbers - ' -123.177681 49.195503' is invalid};};设置minX [lindex $splitCoords 0];set minY [lindex $splitCoords 1]; / /设置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, ) 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_clone INPUT FEATURE_TYPE _____CREATED______ NUMBER_OF_COPIES 1 COPY_NUMBER_ATTRIBUTE _creation_instance OUTPUT FEATURE_TYPEcreate_created @Tcl2(create_coordsysremover) @CoordSys(LL84) # ------------------------------------------------------------------------- FACTORY_DEF * TeeFactory FACTORY_NAME AttributeCreator INPUT FEATURE_TYPE create_created OUTPUT FEATURE_TYPE AttributeCreator_OUTPUT @SupplyAttributes(ENCODED,name,Vancouver . 机场,CATEGORY_ID,2)#-------------------------------------------------------------------------#首先确定哪个函数,我们将要使用 - 我们可以静态地做到这#解析时间效率起见MACRO GeometryExtractor_Function INCLUDE [如果{{WKT} == {fmebinary}} {{放MACRO GeometryExtractor_Function @Geometry(TO_ATTRIBUTE_BINARY,_geometryAsText)}} elseif的{{WKT} == {fmehex}} {{放MACRO GeometryExtractor_Function@Geometry(TO_ATTRIBUTE_BINARY_HEX,_geometryAsText)}} elseif的{{WKT} == {fmexml}} {{放MACRO GeometryExtractor_Function @Geometry(TO_ATTRIBUTE,_geometryAsText)}} elseif的{{WKT} == {} WKT ||{WKT} == {} WKB ||{} WKT == {wkbhex}} {{放MACRO GeometryExtractor_Function @OGCGeometry(to_attribute,高铁总站,_geometryAsText,1.1)}}] FACTORY_DEF * TeeFactory FACTORY_NAME GeometryExtractor INPUT FEATURE_TYPE AttributeCreator_2_OUTPUT输入FEATURE_TYPE AttributeCreator_OUTPUT输出FEATURE_TYPE GeometryExtractor_OUTPUT $(GeometryExtractor_Function)#------------------------------------------------------------------------- FACTORY_DEF * TeeFactory FACTORY_NAME AttributeCreator_4 INPUT FEATURE_TYPE GeometryExtractor_OUTPUT OUTPUT FEATURE_TYPE AttributeCreator_4_OUTPUT @SupplyAttributes(编码_search_radius,0)#------------------------------------------------------------------------- TCL2 PROC AttributeSetter_doSetAttr {} {如果{[字符串范围{&_search_radius} 0 0] == {&}} {FME_SetAttribute [FME_DecodeText [字符串范围{&_search_radius} 1个端]] [FME_DecodeTextOrAttr {$(VAL)}]}否则{FME_SetAttribute [FME_DecodeText {&_search_radius}] [FME_DecodeTextOrAttr {$(VAL)}]}} FACTORY_DEF * TeeFactoryFACTORY_NAME AttributeSetter INPUT FEATURE_TYPE AttributeCreator_4_OUTPUT输出FEATURE_TYPE AttributeSetter_OUTPUT @ TCL2(AttributeSetter_doSetAttr)#------------------------------------------------------------------------- SQL SQLExecutor_2_Conn SERVER_TYPE POSTGIS SERVER_NAME “127.0.0.1” USER_NAME“的Postgres“PASSWORD ”postgres的“ DB_NAME ”POSTGIS“ PORT 5432 MACRO SQLExecutor_2_QUERY SELECT名称,距离(变换(the_geom,32610),变换(GeometryFromText( '@值(_geometryAsText)',(SELECT SRID(the_geom)FROM public.fme LIMIT 1)),32610)),AsText(the_geom)FROM public.fme WHERE ST_DWithin(变换(the_geom,32610),变换(GeometryFromText( '@值(_geometryAsText)',(SELECT SRID(the_geom)FROM public.fme LIMIT 1)),32610),@值(_search_radius))MACRO SQLExecutor_2_LIST_ARG INCLUDE [如果{{_matched_geoms} = {}!} {{放MACRO SQLExecutor_2_LIST_ARG “_matched_geoms {}”}; } ] FACTORY_DEF * TeeFactory FACTORY_NAME SQLExecutor_2 INPUT FEATURE_TYPE AttributeSetter_OUTPUT OUTPUT FEATURE_TYPE SQLExecutor_2_OUTPUT @SQL("SQLExecutor_2_Conn","$(SQLExecutor_2_QUERY)"$(SQLExecutor_2_LIST_ARG)) # ------------------------------------------------------------------------- FACTORY_DEF * TeeFactory FACTORY_NAME ListElementCounter INPUT FEATURE_TYPE SQLExecutor_2_OUTPUT OUTPUT FEATURE_TYPE ListElementCounter_OUTPUT _element_count @NumElements(_matched_geoms{}) # ------------------------------------------------------------------------- FACTORY_DEF * TestFactory FACTORY_NAME Tester INPUT FEATURE_TYPE ListElementCounter_OUTPUT TEST @Value(_element_count) = 0 BOOLEAN_OPERATOR OR OUTPUT PASSED FEATURE_TYPE Tester_PASSED OUTPUT FAILED FEATURE_TYPE Tester_FAILED # ------------------------------------------------------------------------- FACTORY_DEF * ElementFactory FACTORY_NAME ListExploder INPUT FEATURE_TYPE Tester_FAILED LIST_NAME _matched_geoms{} ELEMENT_NUMBER_FIELD _element_index CLONE_GEOMETRY MODE LEAN OUTPUT ELEMENT FEATURE_TYPE ListExploder_OUTPUT # ------------------------------------------------------------------------- # Expose all attributes. This ensures that if you expose fme_dataset, you will get it. READER_META_ATTRIBUTES fme_feature_type fme_dataset fme_basename FACTORY_DEF * TeeFactory FACTORY_NAME AttributeExposer INPUT FEATURE_TYPE ListExploder_OUTPUT OUTPUT FEATURE_TYPE AttributeExposer_OUTPUT FACTORY_DEF * TeeFactory FACTORY_NAME "AttributeExposer OUTPUT Splitter" INPUT FEATURE_TYPE AttributeExposer_OUTPUT OUTPUT FEATURE_TYPE AttributeExposer_OUTPUT_0 OUTPUT FEATURE_TYPE AttributeExposer_OUTPUT_1 # ------------------------------------------------------------------------- # 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 # First, set up the temporary directory that will be used for # the recordings we will be viewing (these three lines do this) # They assume that the WORKSPACE_NAME macro has already been set DEFAULT_MACRO WORKSPACE_TEMP_DIR INCLUDE [ if {[string length {$(WORKSPACE_TEMP_DIR)}] < 2} { if {[info exists env(TEMP)]} {set gVisualizerTemp $env(TEMP)} elseif { $tcl_platform(platform) == "unix" } {set gVisualizerTemp "/tmp"} else {set gVisualizerTemp c:}; regsub -all {[ ,]} {$(WORKSPACE_NAME)} {_} wsname; set gVisualizerTemp $gVisualizerTemp/${wsname}_[clock format [clock seconds] -format %H%M%S] ; puts "MACRO WORKSPACE_TEMP_DIR $gVisualizerTemp"; } else { set gVisualizerTemp {$(WORKSPACE_TEMP_DIR)}; }; if { [string length {}] > 0 } { set catter "" ; set comma "" ; foreach attr "" { set catter "$catter$comma&$attr" ; set comma ",_," ; } ; puts "MACRO CATMAC _@Concatenate($catter)" ; } else { puts "MACRO CATMAC " ; }; set safeName "[regsub -all {[^a-zA-Z0-9]} {Original_FME_Feature} _]_[expr round(rand() * 1000000)]_[clock clicks]"; puts "MACRO SAFE_FFS_NAME $safeName"; if {[string length {}] != 0 } { set outputLine {FME_END_TCL file copy -force "}; append outputLine [regsub -all {\\} "$gVisualizerTemp/$safeName" /]; append outputLine {.ffs" "{}"}; puts $outputLine; }; ] # Make the temporary directory that the FFS files will live in. FACTORY_DEF * CreationFactory FACTORY_NAME Original_FME_Feature_DirCreator OUTPUT FEATURE_TYPE __nukeme__ @Tcl2("catch {file mkdir {$(WORKSPACE_TEMP_DIR)}}") FACTORY_DEF * TeeFactory FACTORY_NAME Original_FME_Feature_DirCreatorCleanerUpper INPUT FEATURE_TYPE __nukeme__ # Send raster and vector features down different paths to prepare # them for viewing FACTORY_DEF * TestFactory FACTORY_NAME Original_FME_Feature_FeatureDirector INPUT FEATURE_TYPE AttributeExposer_OUTPUT_1 TEST &fme_type == "fme_raster" OUTPUT FAILED FEATURE_TYPE Original_FME_Feature___VectorFeatures___ OUTPUT PASSED FEATURE_TYPE Original_FME_Feature___RasterFeatures___ # Vector features simply may get their colors overridden FACTORY_DEF * TeeFactory FACTORY_NAME Original_FME_Feature_VectorSetterUpper INPUT FEATURE_TYPE Original_FME_Feature___VectorFeatures___ OUTPUT FEATURE_TYPE __viewme__ # Raster features require some more work to set up Tcl2 proc Original_FME_Feature_getIntOrAttrValue {value attrPrefix} { if {[string compare [string range $value 0 6] "@Value("] == 0} { set oldName [string range $value 7 [expr [string length $value] - 2]]; set newName $attrPrefix; append newName $oldName; set value [FME_GetAttribute $newName]; }; return $value; } Tcl2 proc Original_FME_Feature_prepareRaster {} { set doResample [string equal {No Reduction} {Resample}]; set doSubset [string equal {No Reduction} {Subset}]; if {$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 subsetStartRow [Original_FME_Feature_getIntOrAttrValue {" ”}$ kAttrPrefix];set subsetNumRows [Original_FME_Feature_getIntOrAttrValue] {" ”}$ kAttrPrefix];set subsetStartCol [Original_FME_Feature_getIntOrAttrValue {" ”}$ kAttrPrefix];设置subsetNumCols [Original_FME_Feature_getIntOrAttrValue {" “} $ kAttrPrefix];组rasterNumRows [FME_GetAttribute _num_rows];组rasterNumCols [FME_GetAttribute _num_columns];组注释{只有做到子集划分如果指定的开始位置实际上是光栅内};如果{$ subsetStartRow <$ rasterNumRows && $ subsetStartCol <$ rasterNumCols} {集评论{现在绑定的子集光栅的大小,因此我们不创建填充。};如果{[EXPR $ subsetStartRow + $ subsetNumRows]> $ rasterNumRows} {集subsetNumRows [EXPR $ rasterNumRows- $ subsetStartRow];};如果{[EXPR $ subsetStartCol + $ subsetNumCols]> $ rasterNumCols} {集subsetNumCols [EXPR $ rasterNumCols - $ subsetStartCol];}; FME_Execute SubsetRaster $ subsetStartRow $ subsetNumRows $ subsetStartCol $ subsetNumCols;};};集评论{删除所有由@RasterProperties添加的属性和真实属性,去掉前缀,我们假设他们都开始用下划线。}; FME_Execute RemoveAttributes fme_regexp_match {^ _};的foreach使用oldName $ {allNames设置了newName $ kAttrPre使固定;添加新名称oldName美元;FME_RenameAttribute oldName美元新名称;};};} FACTORY_DEF * TeeFactory FACTORY_NAME Original_FME_Feature_RasterSetterUpper INPUT FEATURE_TYPE Original_FME_Feature___RasterFeatures___输出FEATURE_TYPE __viewme__ @ TCL2( “Original_FME_Feature_prepareRaster”)#现在将所有功能集成在录像机,改变他们#功能类型变压器的名字,让他们查看很好FACTORY_DEF * RecorderFactory FACTORY_NAME Original_FME_Feature_Recorder INPUT FEATURE_TYPE__viewme__ @FeatureType(Original_FME_Feature $(CATMAC))FEATURE_FILE “$(WORKSPACE_TEMP_DIR)/ $亚搏在线(SAFE_FFS_NAME).ffs” MODE RECORD_PASS_THROUGH FACTORY_DEF * CreationFactory FACTORY_NAME Original_FME_Feature_Trigger CREATE_AT_END输出FEATURE_TYPE __nukeme__ @TCL( “lappend gVisualizerFilesToView $(SAFE_FFS_NAME)”)FACTORY_DEF * TeeFactory FACTORY_NAME Original_FME_Feature_CleanerUpper INPUT FEATURE_TYPE __nukeme__ # ------------------------------------------------------------------------- # First determine which function we are going to be using -- we can do # this statically at parse time for efficiency sake MACRO GeometryReplacer_Function INCLUDE [ if {{wkt} == {fmebinary} } { puts {MACRO GeometryReplacer_Function @Geometry(FROM_ATTRIBUTE_BINARY,asText) } } elseif {{wkt} == {fmehex} } { puts {MACRO GeometryReplacer_Function @Geometry(FROM_ATTRIBUTE_BINARY_HEX,asText) } } elseif {{wkt} == {fmexml} } { puts {MACRO GeometryReplacer_Function @Geometry(FROM_ATTRIBUTE,asText) } } elseif {{wkt} == {fmexmlencoded} } { puts {MACRO GeometryReplacer_Function @Geometry(FROM_ENCODED_STRING,&asText) } } elseif {{wkt} == {wkt} || {wkt} == {wkb} || {wkt} == {wkbhex} } { puts {MACRO GeometryReplacer_Function @OGCGeometry(from_attribute,wkt,asText) } } ] FACTORY_DEF * TeeFactory FACTORY_NAME GeometryReplacer INPUT FEATURE_TYPE AttributeExposer_OUTPUT_0 OUTPUT FEATURE_TYPE GeometryReplacer_OUTPUT $(GeometryReplacer_Function) # ------------------------------------------------------------------------- # 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 # First, set up the temporary directory that will be used for # the recordings we will be viewing (these three lines do this) # They assume that the WORKSPACE_NAME macro has already been set DEFAULT_MACRO WORKSPACE_TEMP_DIR INCLUDE [ if {[string length {$(WORKSPACE_TEMP_DIR)}] < 2} { if {[info exists env(TEMP)]} {set gVisualizerTemp $env(TEMP)} elseif { $tcl_platform(platform) == "unix" } {set gVisualizerTemp "/tmp"} else {set gVisualizerTemp c:}; regsub -all {[ ,]} {$(WORKSPACE_NAME)} {_} wsname; set gVisualizerTemp $gVisualizerTemp/${wsname}_[clock format [clock seconds] -format %H%M%S] ; puts "MACRO WORKSPACE_TEMP_DIR $gVisualizerTemp"; } else { set gVisualizerTemp {$(WORKSPACE_TEMP_DIR)}; }; if { [string length {}] > 0 } { set catter "" ; set comma "" ; foreach attr "" { set catter "$catter$comma&$attr" ; set comma ",_," ; } ; puts "MACRO CATMAC _@Concatenate($catter)" ; } else { puts "MACRO CATMAC " ; }; set safeName "[regsub -all {[^a-zA-Z0-9]} {All_Geoms_within_search_radius_of_input_feature} _]_[expr round(rand() * 1000000)]_[clock clicks]"; puts "MACRO SAFE_FFS_NAME $safeName"; if {[string length {}] != 0 } { set outputLine {FME_END_TCL file copy -force "}; append outputLine [regsub -all {\\} "$gVisualizerTemp/$safeName" /]; append outputLine {.ffs" "{}"}; puts $outputLine; }; ] # Make the temporary directory that the FFS files will live in. FACTORY_DEF * CreationFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_DirCreator OUTPUT FEATURE_TYPE __nukeme__ @Tcl2("catch {file mkdir {$(WORKSPACE_TEMP_DIR)}}") FACTORY_DEF * TeeFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_DirCreatorCleanerUpper INPUT FEATURE_TYPE __nukeme__ # Send raster and vector features down different paths to prepare # them for viewing FACTORY_DEF * TestFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_FeatureDirector INPUT FEATURE_TYPE GeometryReplacer_OUTPUT TEST &fme_type == "fme_raster" OUTPUT FAILED FEATURE_TYPE All_Geoms_within_search_radius_of_input_feature___VectorFeatures___ OUTPUT PASSED FEATURE_TYPE All_Geoms_within_search_radius_of_input_feature___RasterFeatures___ # Vector features simply may get their colors overridden FACTORY_DEF * TeeFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_VectorSetterUpper INPUT FEATURE_TYPE All_Geoms_within_search_radius_of_input_feature___VectorFeatures___ OUTPUT FEATURE_TYPE __viewme__ # Raster features require some more work to set up Tcl2 proc All_Geoms_within_search_radius_of_input_feature_getIntOrAttrValue {value attrPrefix} { if {[string compare [string range $value 0 6] "@Value("] == 0} { set oldName [string range $value 7 [expr [string length $value] - 2]]; set newName $attrPrefix; append newName $oldName; set value [FME_GetAttribute $newName]; }; return $value; } Tcl2 proc All_Geoms_within_search_radius_of_input_feature_prepareRaster {} { set doResample [string equal {No Reduction} {Resample}]; set doSubset [string equal {No Reduction} {Subset}]; if {$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 subsetStartRow [All_Geoms_within_search_radius_of_input_feature_getIntOrAttrValue {" ”}$ kAttrPrefix];设置subsetNumRows [All_Geoms_within_search_radius_of_input_feature_getIntOrAttrValue {" ”}$ kAttrPrefix];设置subsetStartCol [All_Geoms_within_search_radius_of_input_feature_getIntOrAttrValue {" ”}$ kAttrPrefix];设置subsetNumCols [All_Geoms_within_search_radius_of_input_feature_getIntOrAttrValue {" “} $ kAttrPrefix];组rasterNumRows [FME_GetAttribute _num_rows];组rasterNumCols [FME_GetAttribute _num_columns];组注释{只有做到子集划分如果指定的开始位置实际上是光栅内};如果{$ subsetStartRow <$ rasterNumRows && $ subsetStartCol <$ rasterNumCols} {集评论{现在绑定的子集光栅的大小,因此我们不创建填充。};如果{[EXPR $ subsetStartRow + $ subsetNumRows]> $ rasterNumRows} {集subsetNumRows [EXPR $ rasterNumRows- $ subsetStartRow];};如果{[EXPR $ subsetStartCol + $ subsetNumCols]> $ rasterNumCols} {集subsetNumCols [EXPR $ rasterNumCols - $ subsetStartCol];}; FME_Execute SubsetRaster $ subsetStartRow $ subsetNumRows $ subsetStartCol $ subsetNumCols;};};集评论{删除所有由@RasterProperties添加的属性和真实属性,去掉前缀,我们假设他们都开始用下划线。}; FME_Execute RemoveAttributes fme_regexp_match {^ _};的foreach使用oldName $ {allNames设置了newName $ kAttrPre使固定;添加新名称oldName美元;FME_RenameAttribute oldName美元新名称;};};} FACTORY_DEF * TeeFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_RasterSetterUpper INPUT FEATURE_TYPE All_Geoms_within_search_radius_of_input_feature___RasterFeatures___输出FEATURE_TYPE __viewme__ @ TCL2( “All_Geoms_within_search_radius_of_input_feature_prepareRaster”)#现在将所有功能集成在录像机,改变他们#功能类型变压器的名字,让他们查看很好FACTORY_DEF * RecorderFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_Recorder INPUT FEATURE_TYPE__viewme__ @FeatureType(All_Geoms_within_search_radius_of_input_feature $(CATMAC))FEATURE_FILE “$(WORKSPACE_TEMP_DIR)/ $亚搏在线(SAFE_FFS_NAME).ffs” MODE RECORD_PASS_THROUGH FACTORY_DEF * CreationFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_Trigger CREATE_AT_END输出FEATURE_TYPE __nukeme__ @TCL( “lappend gVisualizerFilesToView $(SAFE_FFS_NAME)”)FACTORY_DEF * TeeFactory FACTORY_NAME All_Geoms_within_search_radius_of_input_feature_CleanerUpper INPUT FEATURE_TYPE __nukeme__ # ------------------------------------------------------------------------- # 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 # First, set up the temporary directory that will be used for # the recordings we will be viewing (these three lines do this) # They assume that the WORKSPACE_NAME macro has already been set DEFAULT_MACRO WORKSPACE_TEMP_DIR INCLUDE [ if {[string length {$(WORKSPACE_TEMP_DIR)}] < 2} { if {[info exists env(TEMP)]} {set gVisualizerTemp $env(TEMP)} elseif { $tcl_platform(platform) == "unix" } {set gVisualizerTemp "/tmp"} else {set gVisualizerTemp c:}; regsub -all {[ ,]} {$(WORKSPACE_NAME)} {_} wsname; set gVisualizerTemp $gVisualizerTemp/${wsname}_[clock format [clock seconds] -format %H%M%S] ; puts "MACRO WORKSPACE_TEMP_DIR $gVisualizerTemp"; } else { set gVisualizerTemp {$(WORKSPACE_TEMP_DIR)}; }; if { [string length {}] > 0 } { set catter "" ; set comma "" ; foreach attr "" { set catter "$catter$comma&$attr" ; set comma ",_," ; } ; puts "MACRO CATMAC _@Concatenate($catter)" ; } else { puts "MACRO CATMAC " ; }; set safeName "[regsub -all {[^a-zA-Z0-9]} {No_Matches} _]_[expr round(rand() * 1000000)]_[clock clicks]"; puts "MACRO SAFE_FFS_NAME $safeName"; if {[string length {}] != 0 } { set outputLine {FME_END_TCL file copy -force "}; append outputLine [regsub -all {\\} "$gVisualizerTemp/$safeName" /]; append outputLine {.ffs" "{}"}; puts $outputLine; }; ] # Make the temporary directory that the FFS files will live in. FACTORY_DEF * CreationFactory FACTORY_NAME No_Matches_DirCreator OUTPUT FEATURE_TYPE __nukeme__ @Tcl2("catch {file mkdir {$(WORKSPACE_TEMP_DIR)}}") FACTORY_DEF * TeeFactory FACTORY_NAME No_Matches_DirCreatorCleanerUpper INPUT FEATURE_TYPE __nukeme__ # Send raster and vector features down different paths to prepare # them for viewing FACTORY_DEF * TestFactory FACTORY_NAME No_Matches_FeatureDirector INPUT FEATURE_TYPE Tester_PASSED TEST &fme_type == "fme_raster" OUTPUT FAILED FEATURE_TYPE No_Matches___VectorFeatures___ OUTPUT PASSED FEATURE_TYPE No_Matches___RasterFeatures___ # Vector features simply may get their colors overridden FACTORY_DEF * TeeFactory FACTORY_NAME No_Matches_VectorSetterUpper INPUT FEATURE_TYPE No_Matches___VectorFeatures___ OUTPUT FEATURE_TYPE __viewme__ # Raster features require some more work to set up Tcl2 proc No_Matches_getIntOrAttrValue {value attrPrefix} { if {[string compare [string range $value 0 6] "@Value("] == 0} { set oldName [string range $value 7 [expr [string length $value] - 2]]; set newName $attrPrefix; append newName $oldName; set value [FME_GetAttribute $newName]; }; return $value; } Tcl2 proc No_Matches_prepareRaster {} { set doResample [string equal {No Reduction} {Resample}]; set doSubset [string equal {No Reduction} {Subset}]; if {$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 subsetStartRow [No_Matches_getIntOrAttrValue {" ”}$ kAttrPrefix];设置subsetNumRows [No_Matches_getIntOrAttrValue {"] ”}$ kAttrPrefix];设置subsetStartCol [No_Matches_getIntOrAttrValue {" "] ”}$ kAttrPrefix];设置subsetNumCols [No_Matches_getIntOrAttrValue {"] “} $ kAttrPrefix];组rasterNumRows [FME_GetAttribute _num_rows];组rasterNumCols [FME_GetAttribute _num_columns];组注释{只有做到子集划分如果指定的开始位置实际上是光栅内};如果{$ subsetStartRow <$ rasterNumRows && $ subsetStartCol <$ rasterNumCols} {集评论{现在绑定的子集光栅的大小,因此我们不创建填充。};如果{[EXPR $ subsetStartRow + $ subsetNumRows]> $ rasterNumRows} {集subsetNumRows [EXPR $ rasterNumRows- $ subsetStartRow];};如果{[EXPR $ subsetStartCol + $ subsetNumCols]> $ rasterNumCols} {集subsetNumCols [EXPR $ rasterNumCols - $ subsetStartCol];}; FME_Execute SubsetRaster $ subsetStartRow $ subsetNumRows $ subsetStartCol $ subsetNumCols;};};集评论{删除所有由@RasterProperties添加的属性和真实属性,去掉前缀,我们假设他们都开始用下划线。}; FME_Execute RemoveAttributes fme_regexp_match {^ _};的foreach使用oldName $ {allNames设置了newName $ kAttrPre使固定;添加新名称oldName美元;FME_RenameAttribute oldName美元新名称;};};} FACTORY_DEF * TeeFactory FACTORY_NAME No_Matches_RasterSetterUpper INPUT FEATURE_TYPE no_matches__rasterfeatures___ OUTPUT FEATURE_TYPE __viewme__ @Tcl2(" no_matches_prepareeraster ") #现在路由所有的功能到记录,将他们的# feature类型更改为转换器名称,这样他们就可以很好地查看FACTORY_DEF * RecorderFactory FACTORY_NAME No_Matches_Recorder INPUT FEATURE_TYPE __viewme__ @FeatureType(No_Matches$(CATMAC)) FEATURE_FILE "$(WORKSPACE_TEMP_DIR)/$(SAFE_FFS_NAME)。亚搏在线ffs" MODE RECORD_PASS_THROUGH FACTORY_DEF * CreationFactory FACTORY_NAME No_Matches_Trigger CREATE_AT_END OUTPUT FEATURE_TYPE __nukeme__ @TCL("lappend gVisualizerFilesToView $(SAFE_FFS_NAME)") FACTORY_DEF * TeeFactory FACTORY_NAME No_Matches_CleanerUpper INPUT FEATURE_TYPE __nukeme__ # ------------------------------------------------------------------------- FACTORY_DEF * TestFactory FACTORY_NAME "Final Output Feature Type Router" INPUT FEATURE_TYPE * TEST @Value(__wb_out_feat_type__) != "" OUTPUT PASSED FEATURE_TYPE * @FeatureType(@Value(__wb_out_feat_type__)) # ------------------------------------------------------------------------- DEFAULT_MACRO WORKSPACE_TEMP_DIR INCLUDE [ if {{$(WORKSPACE_TEMP_DIR)} == {}} { puts {MACRO __WB_ENABLE_VISUALIZER__ no} } else { puts {MACRO __WB_ENABLE_VISUALIZER__ *} } ] FACTORY_DEF $(__WB_ENABLE_VISUALIZER__) CreationFactory CREATE_AT_END OUTPUT FEATURE_TYPE __NUKEME__ @TCL("eval FME_Execute System \173fmeview /ownffs {$(WORKSPACE_TEMP_DIR)} $gVisualizerFilesToView & }") FACTORY_DEF * TeeFactory INPUT FEATURE_TYPE __NUKEME__